Changeset View
Changeset View
Standalone View
Standalone View
orientation_sensor.cpp
Show First 20 Lines • Show All 57 Lines • ▼ Show 20 Line(s) | 38 | [this] { | |||
---|---|---|---|---|---|
58 | }; | 58 | }; | ||
59 | const auto orientation = toOrientation(m_sensor->reading()); | 59 | const auto orientation = toOrientation(m_sensor->reading()); | ||
60 | if (m_orientation != orientation) { | 60 | if (m_orientation != orientation) { | ||
61 | m_orientation = orientation; | 61 | m_orientation = orientation; | ||
62 | emit orientationChanged(); | 62 | emit orientationChanged(); | ||
63 | } | 63 | } | ||
64 | } | 64 | } | ||
65 | ); | 65 | ); | ||
66 | connect(m_sensor, &QOrientationSensor::activeChanged, this, | 66 | connect(m_sensor, &QOrientationSensor::activeChanged, this, &OrientationSensor::refresh); | ||
ngraham: "Allow Automatic Rotation" ? | |||||
apol: Rotating automatically?
On Android it says "Auto-rotate". | |||||
apol: "Allow Rotation" | |||||
67 | [this] { | 67 | } | ||
68 | | ||||
69 | void OrientationSensor::refresh() | ||||
70 | { | ||||
Can we just not show any text in this state? "Undefined" is not really a useful user-facing string. ngraham: Can we just not show any text in this state? "Undefined" is not really a useful user-facing… | |||||
apol: I wouldn't worry too much, this should never appear. | |||||
68 | if (!m_sni) { | 71 | if (!m_sni) { | ||
69 | return; | 72 | return; | ||
70 | } | 73 | } | ||
71 | if (m_sensor->isActive()) { | 74 | if (m_sensor->isActive()) { | ||
How about: "Locked: Portrait View", and the other is "Locked: Landscape View" ? ngraham: How about: "Locked: Portrait View", and the other is "Locked: Landscape View"
? | |||||
I'm not convinced about the "View" bit, maybe Display would be a bit better? apol: I'm not convinced about the "View" bit, maybe Display would be a bit better? | |||||
apol: I also wonder if we need to say Locked at all. | |||||
75 | m_sni->setTitle(i18n("Allow Rotation")); | ||||
72 | m_sni->setToolTipTitle(i18n("Automatic screen rotation is enabled")); | 76 | m_sni->setToolTipTitle(i18n("Automatic screen rotation is enabled")); | ||
73 | } else { | 77 | } else { | ||
74 | m_sni->setToolTipTitle(i18n("Automatic screen rotation is disabled")); | 78 | QString text; | ||
79 | switch(m_orientation) { | ||||
80 | case FaceUp: | ||||
81 | case FaceDown: | ||||
82 | case Undefined: | ||||
83 | text = i18n("Undefined"); | ||||
84 | break; | ||||
85 | case TopUp: | ||||
86 | case TopDown: | ||||
87 | text = i18n("Vertical"); | ||||
88 | break; | ||||
89 | case LeftUp: | ||||
90 | case RightUp: | ||||
91 | text = i18n("Horizontal"); | ||||
92 | break; | ||||
75 | } | 93 | } | ||
94 | m_sni->setTitle(text); | ||||
95 | m_sni->setToolTipTitle(i18n("Automatic screen rotation is disabled")); | ||||
76 | } | 96 | } | ||
77 | ); | | |||
78 | } | 97 | } | ||
79 | 98 | | |||
80 | OrientationSensor::~OrientationSensor() = default; | 99 | OrientationSensor::~OrientationSensor() = default; | ||
81 | 100 | | |||
82 | void OrientationSensor::setEnabled(bool enabled) | 101 | void OrientationSensor::setEnabled(bool enabled) | ||
83 | { | 102 | { | ||
84 | if (m_enabled == enabled) { | 103 | if (m_enabled == enabled) { | ||
85 | return; | 104 | return; | ||
Show All 24 Lines | |||||
110 | { | 129 | { | ||
111 | if (m_sni) { | 130 | if (m_sni) { | ||
112 | return; | 131 | return; | ||
113 | } | 132 | } | ||
114 | m_sni = new KStatusNotifierItem(QStringLiteral("kwin-automatic-rotation"), this); | 133 | m_sni = new KStatusNotifierItem(QStringLiteral("kwin-automatic-rotation"), this); | ||
115 | m_sni->setStandardActionsEnabled(false); | 134 | m_sni->setStandardActionsEnabled(false); | ||
116 | m_sni->setCategory(KStatusNotifierItem::Hardware); | 135 | m_sni->setCategory(KStatusNotifierItem::Hardware); | ||
117 | m_sni->setStatus(KStatusNotifierItem::Passive); | 136 | m_sni->setStatus(KStatusNotifierItem::Passive); | ||
118 | m_sni->setTitle(i18n("Automatic Screen Rotation")); | | |||
119 | // TODO: proper icon with state | 137 | // TODO: proper icon with state | ||
zzag: Can't we address this todo item instead? | |||||
apol: I don't think that's sufficient. I'll improve the texts. | |||||
120 | m_sni->setIconByName(QStringLiteral("preferences-desktop-display")); | 138 | m_sni->setIconByName(QStringLiteral("preferences-desktop-display")); | ||
121 | // we start disabled, it gets updated when the sensor becomes active | 139 | // we start disabled, it gets updated when the sensor becomes active | ||
122 | m_sni->setToolTipTitle(i18n("Automatic screen rotation is disabled")); | 140 | | ||
141 | refresh(); | ||||
123 | connect(m_sni, &KStatusNotifierItem::activateRequested, this, | 142 | connect(m_sni, &KStatusNotifierItem::activateRequested, this, | ||
124 | [this] { | 143 | [this] { | ||
125 | m_userEnabled = !m_userEnabled; | 144 | m_userEnabled = !m_userEnabled; | ||
126 | startStopSensor(); | 145 | startStopSensor(); | ||
127 | emit userEnabledChanged(m_userEnabled); | 146 | emit userEnabledChanged(m_userEnabled); | ||
128 | } | 147 | } | ||
129 | ); | 148 | ); | ||
130 | } | 149 | } | ||
Show All 23 Lines |
"Allow Automatic Rotation" ?