Initialise the orientation sensor at start
Summary: We want to set the right orientation as the system starts. Reviewers: #plasma, #kwin, zzag, davidedmundson Reviewed By: #plasma, #kwin, zzag, davidedmundson Subscribers: zzag, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D20622
This commit is contained in:
parent
3323857a64
commit
bf6f05bf3c
2 changed files with 32 additions and 29 deletions
|
@ -34,8 +34,12 @@ OrientationSensor::OrientationSensor(QObject *parent)
|
|||
: QObject(parent)
|
||||
, m_sensor(new QOrientationSensor(this))
|
||||
{
|
||||
connect(m_sensor, &QOrientationSensor::readingChanged, this,
|
||||
[this] {
|
||||
connect(m_sensor, &QOrientationSensor::readingChanged, this, &OrientationSensor::updateState);
|
||||
connect(m_sensor, &QOrientationSensor::activeChanged, this, &OrientationSensor::refresh);
|
||||
}
|
||||
|
||||
void OrientationSensor::updateState()
|
||||
{
|
||||
auto toOrientation = [] (auto reading) {
|
||||
switch (reading->orientation()) {
|
||||
case QOrientationReading::Undefined:
|
||||
|
@ -61,9 +65,6 @@ OrientationSensor::OrientationSensor(QObject *parent)
|
|||
m_orientation = orientation;
|
||||
emit orientationChanged();
|
||||
}
|
||||
}
|
||||
);
|
||||
connect(m_sensor, &QOrientationSensor::activeChanged, this, &OrientationSensor::refresh);
|
||||
}
|
||||
|
||||
void OrientationSensor::activate()
|
||||
|
@ -96,6 +97,7 @@ void OrientationSensor::refresh()
|
|||
if (m_sensor->isActive()) {
|
||||
m_sni->setTitle(i18n("Allow Rotation"));
|
||||
m_sni->setToolTipTitle(i18n("Automatic screen rotation is enabled"));
|
||||
updateState();
|
||||
} else {
|
||||
QString text;
|
||||
switch(m_orientation) {
|
||||
|
|
|
@ -80,6 +80,7 @@ private:
|
|||
void loadConfig();
|
||||
void refresh();
|
||||
void activate();
|
||||
void updateState();
|
||||
|
||||
QOrientationSensor *m_sensor;
|
||||
bool m_enabled = false;
|
||||
|
|
Loading…
Reference in a new issue