forked from quickshell/quickshell
fix: ShellScreen signals are now connected
This commit is contained in:
parent
ea2cdf38b8
commit
1ecc943eb3
|
@ -3,8 +3,44 @@
|
||||||
#include <qdebug.h>
|
#include <qdebug.h>
|
||||||
#include <qlogging.h>
|
#include <qlogging.h>
|
||||||
#include <qnamespace.h>
|
#include <qnamespace.h>
|
||||||
|
#include <qobject.h>
|
||||||
|
#include <qscreen.h>
|
||||||
#include <qtypes.h>
|
#include <qtypes.h>
|
||||||
|
|
||||||
|
QuickShellScreenInfo::QuickShellScreenInfo(QObject* parent, QScreen* screen):
|
||||||
|
QObject(parent), screen(screen) {
|
||||||
|
QObject::connect(
|
||||||
|
this->screen,
|
||||||
|
&QScreen::geometryChanged,
|
||||||
|
this,
|
||||||
|
&QuickShellScreenInfo::geometryChanged
|
||||||
|
);
|
||||||
|
QObject::connect(
|
||||||
|
this->screen,
|
||||||
|
&QScreen::physicalDotsPerInchChanged,
|
||||||
|
this,
|
||||||
|
&QuickShellScreenInfo::physicalPixelDensityChanged
|
||||||
|
);
|
||||||
|
QObject::connect(
|
||||||
|
this->screen,
|
||||||
|
&QScreen::logicalDotsPerInchChanged,
|
||||||
|
this,
|
||||||
|
&QuickShellScreenInfo::logicalPixelDensityChanged
|
||||||
|
);
|
||||||
|
QObject::connect(
|
||||||
|
this->screen,
|
||||||
|
&QScreen::orientationChanged,
|
||||||
|
this,
|
||||||
|
&QuickShellScreenInfo::orientationChanged
|
||||||
|
);
|
||||||
|
QObject::connect(
|
||||||
|
this->screen,
|
||||||
|
&QScreen::primaryOrientationChanged,
|
||||||
|
this,
|
||||||
|
&QuickShellScreenInfo::primaryOrientationChanged
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
bool QuickShellScreenInfo::operator==(QuickShellScreenInfo& other) const {
|
bool QuickShellScreenInfo::operator==(QuickShellScreenInfo& other) const {
|
||||||
return this->screen == other.screen;
|
return this->screen == other.screen;
|
||||||
}
|
}
|
||||||
|
@ -38,7 +74,7 @@ qint32 QuickShellScreenInfo::height() const {
|
||||||
return this->screen->size().height();
|
return this->screen->size().height();
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal QuickShellScreenInfo::pixelDensity() const {
|
qreal QuickShellScreenInfo::physicalPixelDensity() const {
|
||||||
if (this->screen == nullptr) {
|
if (this->screen == nullptr) {
|
||||||
warnNull();
|
warnNull();
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
|
|
@ -28,28 +28,28 @@ class QuickShellScreenInfo: public QObject {
|
||||||
/// The name of the screen as seen by the operating system.
|
/// The name of the screen as seen by the operating system.
|
||||||
///
|
///
|
||||||
/// Usually something like `DP-1`, `HDMI-1`, `eDP-1`.
|
/// Usually something like `DP-1`, `HDMI-1`, `eDP-1`.
|
||||||
Q_PROPERTY(QString name READ name NOTIFY nameChanged);
|
Q_PROPERTY(QString name READ name);
|
||||||
Q_PROPERTY(qint32 width READ width NOTIFY widthChanged);
|
Q_PROPERTY(qint32 width READ width NOTIFY geometryChanged);
|
||||||
Q_PROPERTY(qint32 height READ height NOTIFY heightChanged);
|
Q_PROPERTY(qint32 height READ height NOTIFY geometryChanged);
|
||||||
/// The number of physical pixels per millimeter.
|
/// The number of physical pixels per millimeter.
|
||||||
Q_PROPERTY(qreal pixelDensity READ pixelDensity NOTIFY logicalPixelDensityChanged);
|
Q_PROPERTY(qreal physicalPixelDensity READ physicalPixelDensity NOTIFY physicalPixelDensityChanged);
|
||||||
/// The number of device-independent (scaled) pixels per millimeter.
|
/// The number of device-independent (scaled) pixels per millimeter.
|
||||||
Q_PROPERTY(qreal logicalPixelDensity READ logicalPixelDensity NOTIFY logicalPixelDensityChanged);
|
Q_PROPERTY(qreal logicalPixelDensity READ logicalPixelDensity NOTIFY logicalPixelDensityChanged);
|
||||||
/// The ratio between physical pixels and device-independent (scaled) pixels.
|
/// The ratio between physical pixels and device-independent (scaled) pixels.
|
||||||
Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio NOTIFY devicePixelRatioChanged);
|
Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio NOTIFY physicalPixelDensityChanged);
|
||||||
Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation NOTIFY orientationChanged);
|
Q_PROPERTY(Qt::ScreenOrientation orientation READ orientation NOTIFY orientationChanged);
|
||||||
Q_PROPERTY(Qt::ScreenOrientation primatyOrientation READ primaryOrientation NOTIFY primaryOrientationChanged);
|
Q_PROPERTY(Qt::ScreenOrientation primatyOrientation READ primaryOrientation NOTIFY primaryOrientationChanged);
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QuickShellScreenInfo(QObject* parent, QScreen* screen): QObject(parent), screen(screen) {}
|
QuickShellScreenInfo(QObject* parent, QScreen* screen); //: QObject(parent), screen(screen) {}
|
||||||
|
|
||||||
bool operator==(QuickShellScreenInfo& other) const;
|
bool operator==(QuickShellScreenInfo& other) const;
|
||||||
|
|
||||||
[[nodiscard]] QString name() const;
|
[[nodiscard]] QString name() const;
|
||||||
[[nodiscard]] qint32 width() const;
|
[[nodiscard]] qint32 width() const;
|
||||||
[[nodiscard]] qint32 height() const;
|
[[nodiscard]] qint32 height() const;
|
||||||
[[nodiscard]] qreal pixelDensity() const;
|
[[nodiscard]] qreal physicalPixelDensity() const;
|
||||||
[[nodiscard]] qreal logicalPixelDensity() const;
|
[[nodiscard]] qreal logicalPixelDensity() const;
|
||||||
[[nodiscard]] qreal devicePixelRatio() const;
|
[[nodiscard]] qreal devicePixelRatio() const;
|
||||||
[[nodiscard]] Qt::ScreenOrientation orientation() const;
|
[[nodiscard]] Qt::ScreenOrientation orientation() const;
|
||||||
|
@ -58,12 +58,9 @@ public:
|
||||||
QScreen* screen;
|
QScreen* screen;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void nameChanged();
|
void geometryChanged();
|
||||||
void widthChanged();
|
void physicalPixelDensityChanged();
|
||||||
void heightChanged();
|
|
||||||
void pixelDensityChanged();
|
|
||||||
void logicalPixelDensityChanged();
|
void logicalPixelDensityChanged();
|
||||||
void devicePixelRatioChanged();
|
|
||||||
void orientationChanged();
|
void orientationChanged();
|
||||||
void primaryOrientationChanged();
|
void primaryOrientationChanged();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue