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
This commit is contained in:
parent
9e42ff2f48
commit
c192d35192
2 changed files with 35 additions and 13 deletions
|
@ -63,18 +63,37 @@ OrientationSensor::OrientationSensor(QObject *parent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
connect(m_sensor, &QOrientationSensor::activeChanged, this,
|
connect(m_sensor, &QOrientationSensor::activeChanged, this, &OrientationSensor::refresh);
|
||||||
[this] {
|
}
|
||||||
if (!m_sni) {
|
|
||||||
return;
|
void OrientationSensor::refresh()
|
||||||
}
|
{
|
||||||
if (m_sensor->isActive()) {
|
if (!m_sni) {
|
||||||
m_sni->setToolTipTitle(i18n("Automatic screen rotation is enabled"));
|
return;
|
||||||
} else {
|
}
|
||||||
m_sni->setToolTipTitle(i18n("Automatic screen rotation is disabled"));
|
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;
|
OrientationSensor::~OrientationSensor() = default;
|
||||||
|
@ -115,11 +134,11 @@ void OrientationSensor::setupStatusNotifier()
|
||||||
m_sni->setStandardActionsEnabled(false);
|
m_sni->setStandardActionsEnabled(false);
|
||||||
m_sni->setCategory(KStatusNotifierItem::Hardware);
|
m_sni->setCategory(KStatusNotifierItem::Hardware);
|
||||||
m_sni->setStatus(KStatusNotifierItem::Passive);
|
m_sni->setStatus(KStatusNotifierItem::Passive);
|
||||||
m_sni->setTitle(i18n("Automatic Screen Rotation"));
|
|
||||||
// TODO: proper icon with state
|
// TODO: proper icon with state
|
||||||
m_sni->setIconByName(QStringLiteral("preferences-desktop-display"));
|
m_sni->setIconByName(QStringLiteral("preferences-desktop-display"));
|
||||||
// we start disabled, it gets updated when the sensor becomes active
|
// 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,
|
connect(m_sni, &KStatusNotifierItem::activateRequested, this,
|
||||||
[this] {
|
[this] {
|
||||||
m_userEnabled = !m_userEnabled;
|
m_userEnabled = !m_userEnabled;
|
||||||
|
|
|
@ -56,6 +56,7 @@ public:
|
||||||
FaceUp,
|
FaceUp,
|
||||||
FaceDown
|
FaceDown
|
||||||
};
|
};
|
||||||
|
Q_ENUM(Orientation)
|
||||||
|
|
||||||
Orientation orientation() const {
|
Orientation orientation() const {
|
||||||
return m_orientation;
|
return m_orientation;
|
||||||
|
@ -78,6 +79,8 @@ private:
|
||||||
void setupStatusNotifier();
|
void setupStatusNotifier();
|
||||||
void startStopSensor();
|
void startStopSensor();
|
||||||
void loadConfig();
|
void loadConfig();
|
||||||
|
void refresh();
|
||||||
|
|
||||||
QOrientationSensor *m_sensor;
|
QOrientationSensor *m_sensor;
|
||||||
bool m_enabled = false;
|
bool m_enabled = false;
|
||||||
bool m_userEnabled = true;
|
bool m_userEnabled = true;
|
||||||
|
|
Loading…
Reference in a new issue