Commit c192d351 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Improve SNI text

Summary:
Allow the user to see if rotation lock is enabled by reading the text.
Alternatively one has to hover it and wait for the tooltip.

Reviewers: #plasma, #kwin, ngraham

Reviewed By: ngraham

Subscribers: ngraham, arvidhansson, bruns, niccolove, ndavis, zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D19690
parent 9e42ff2f
......@@ -63,18 +63,37 @@ OrientationSensor::OrientationSensor(QObject *parent)
}
}
);
connect(m_sensor, &QOrientationSensor::activeChanged, this,
[this] {
if (!m_sni) {
return;
}
if (m_sensor->isActive()) {
m_sni->setToolTipTitle(i18n("Automatic screen rotation is enabled"));
} else {
m_sni->setToolTipTitle(i18n("Automatic screen rotation is disabled"));
}
connect(m_sensor, &QOrientationSensor::activeChanged, this, &OrientationSensor::refresh);
}
void OrientationSensor::refresh()
{
if (!m_sni) {
return;
}
if (m_sensor->isActive()) {
m_sni->setTitle(i18n("Allow Rotation"));
m_sni->setToolTipTitle(i18n("Automatic screen rotation is enabled"));
} else {
QString text;
switch(m_orientation) {
case FaceUp:
case FaceDown:
case Undefined:
text = i18n("Undefined");
break;
case TopUp:
case TopDown:
text = i18n("Vertical");
break;
case LeftUp:
case RightUp:
text = i18n("Horizontal");
break;
}
);
m_sni->setTitle(text);
m_sni->setToolTipTitle(i18n("Automatic screen rotation is disabled"));
}
}
OrientationSensor::~OrientationSensor() = default;
......@@ -115,11 +134,11 @@ void OrientationSensor::setupStatusNotifier()
m_sni->setStandardActionsEnabled(false);
m_sni->setCategory(KStatusNotifierItem::Hardware);
m_sni->setStatus(KStatusNotifierItem::Passive);
m_sni->setTitle(i18n("Automatic Screen Rotation"));
// TODO: proper icon with state
m_sni->setIconByName(QStringLiteral("preferences-desktop-display"));
// we start disabled, it gets updated when the sensor becomes active
m_sni->setToolTipTitle(i18n("Automatic screen rotation is disabled"));
refresh();
connect(m_sni, &KStatusNotifierItem::activateRequested, this,
[this] {
m_userEnabled = !m_userEnabled;
......
......@@ -56,6 +56,7 @@ public:
FaceUp,
FaceDown
};
Q_ENUM(Orientation)
Orientation orientation() const {
return m_orientation;
......@@ -78,6 +79,8 @@ private:
void setupStatusNotifier();
void startStopSensor();
void loadConfig();
void refresh();
QOrientationSensor *m_sensor;
bool m_enabled = false;
bool m_userEnabled = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment