Changeset View
Changeset View
Standalone View
Standalone View
orientation_sensor.h
Show First 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 50 | enum class Orientation { | |||
---|---|---|---|---|---|
51 | Undefined, | 51 | Undefined, | ||
52 | TopUp, | 52 | TopUp, | ||
53 | TopDown, | 53 | TopDown, | ||
54 | LeftUp, | 54 | LeftUp, | ||
55 | RightUp, | 55 | RightUp, | ||
56 | FaceUp, | 56 | FaceUp, | ||
57 | FaceDown | 57 | FaceDown | ||
58 | }; | 58 | }; | ||
59 | Q_ENUM(Orientation) | ||||
59 | 60 | | |||
60 | Orientation orientation() const { | 61 | Orientation orientation() const { | ||
61 | return m_orientation; | 62 | return m_orientation; | ||
62 | } | 63 | } | ||
63 | 64 | | |||
64 | void setConfig(KSharedConfig::Ptr config) { | 65 | void setConfig(KSharedConfig::Ptr config) { | ||
65 | m_config = config; | 66 | m_config = config; | ||
66 | } | 67 | } | ||
67 | 68 | | |||
68 | bool isUserEnabled() const { | 69 | bool isUserEnabled() const { | ||
69 | return m_userEnabled; | 70 | return m_userEnabled; | ||
70 | } | 71 | } | ||
71 | void setUserEnabled(bool enabled); | 72 | void setUserEnabled(bool enabled); | ||
72 | 73 | | |||
73 | Q_SIGNALS: | 74 | Q_SIGNALS: | ||
74 | void orientationChanged(); | 75 | void orientationChanged(); | ||
75 | void userEnabledChanged(bool); | 76 | void userEnabledChanged(bool); | ||
76 | 77 | | |||
77 | private: | 78 | private: | ||
78 | void setupStatusNotifier(); | 79 | void setupStatusNotifier(); | ||
79 | void startStopSensor(); | 80 | void startStopSensor(); | ||
80 | void loadConfig(); | 81 | void loadConfig(); | ||
82 | void refresh(); | ||||
83 | | ||||
81 | QOrientationSensor *m_sensor; | 84 | QOrientationSensor *m_sensor; | ||
82 | bool m_enabled = false; | 85 | bool m_enabled = false; | ||
83 | bool m_userEnabled = true; | 86 | bool m_userEnabled = true; | ||
84 | Orientation m_orientation = Orientation::Undefined; | 87 | Orientation m_orientation = Orientation::Undefined; | ||
85 | KStatusNotifierItem *m_sni = nullptr; | 88 | KStatusNotifierItem *m_sni = nullptr; | ||
86 | KSharedConfig::Ptr m_config; | 89 | KSharedConfig::Ptr m_config; | ||
87 | OrientationSensorAdaptor *m_adaptor = nullptr; | 90 | OrientationSensorAdaptor *m_adaptor = nullptr; | ||
88 | 91 | | |||
89 | }; | 92 | }; | ||
90 | 93 | | |||
91 | } | 94 | } |