File indexing completed on 2024-10-27 04:24:10
0001 #pragma once 0002 0003 #include <QObject> 0004 #include <QString> 0005 0006 #include "mauiman_export.h" 0007 0008 class QDBusInterface; 0009 namespace MauiMan 0010 { 0011 class SettingsStore; 0012 0013 /** 0014 * The ScreenManager class exposes all the system screen properties. 0015 */ 0016 class MAUIMAN_EXPORT ScreenManager : public QObject 0017 { 0018 Q_OBJECT 0019 /** 0020 * The preferred scale factor for the main screen. 0021 */ 0022 Q_PROPERTY(double scaleFactor READ scaleFactor WRITE setScaleFactor NOTIFY scaleFactorChanged) 0023 0024 /** 0025 * The preferred orientation of the main screen. 0026 * Possible values are: 0027 * - 0 Horizontal - Landscape 0028 * - 1 Vertical - Portrait 0029 */ 0030 Q_PROPERTY(uint orientation READ orientation WRITE setOrientation NOTIFY orientationChanged) 0031 0032 public: 0033 0034 /** 0035 * @brief The Screen module default values. 0036 */ 0037 struct DefaultValues 0038 { 0039 static inline const double scaleFactor = 1; 0040 static inline const double orientation = 0; 0041 } ; 0042 0043 explicit ScreenManager(QObject * parent = nullptr); 0044 0045 double scaleFactor() const; 0046 void setScaleFactor(double scaleFactor); 0047 0048 uint orientation() const; 0049 void setOrientation(uint orientation); 0050 0051 private Q_SLOTS: 0052 void onScaleFactorChanged(double scale); 0053 void onOrientationChanged(uint orientation); 0054 0055 Q_SIGNALS: 0056 void scaleFactorChanged(double scaleFactor); 0057 void orientationChanged(uint orientation); 0058 0059 private: 0060 #if !defined Q_OS_ANDROID 0061 QDBusInterface *m_interface = nullptr; 0062 #endif 0063 MauiMan::SettingsStore *m_settings; 0064 0065 void sync(const QString &key, const QVariant &value); 0066 void setConnections(); 0067 void loadSettings(); 0068 0069 double m_scaleFactor = ScreenManager::DefaultValues::scaleFactor; 0070 uint m_orientation = ScreenManager::DefaultValues::orientation; 0071 }; 0072 }