Skip to content

Commit

Permalink
[systemsettings] Expose display low power mode state
Browse files Browse the repository at this point in the history
Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>
  • Loading branch information
spiiroin committed May 15, 2014
1 parent e5f6497 commit 7daf75c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/displaysettings.cpp
Expand Up @@ -39,6 +39,7 @@ static const char *MceDisplayBrightness = "/system/osso/dsm/display/display_brig
static const char *MceDisplayDimTimeout = "/system/osso/dsm/display/display_dim_timeout";
static const char *MceDisplayBlankTimeout = "/system/osso/dsm/display/display_blank_timeout";
static const char *MceDisplayUseAdaptiveDimming = "/system/osso/dsm/display/use_adaptive_display_dimming";
static const char *MceDisplayUseLowPowerMode = "/system/osso/dsm/display/use_low_power_mode";
static const char *MceDisplayUseAmbientLightSensor = "/system/osso/dsm/display/als_enabled";
static const char *MceDoubleTapMode = "/system/osso/dsm/doubletap/mode";

Expand All @@ -63,6 +64,10 @@ DisplaySettings::DisplaySettings(QObject *parent)
result.waitForFinished();
m_adaptiveDimmingEnabled = result.value().variant().toBool();

result = m_mceIface->get_config(QDBusObjectPath(MceDisplayUseLowPowerMode));
result.waitForFinished();
m_lowPowerModeEnabled = result.value().variant().toBool();

result = m_mceIface->get_config(QDBusObjectPath(MceDisplayUseAmbientLightSensor));
result.waitForFinished();
m_ambientLightSensorEnabled = result.value().variant().toBool();
Expand Down Expand Up @@ -139,6 +144,20 @@ void DisplaySettings::setAdaptiveDimmingEnabled(bool enabled)
}
}

bool DisplaySettings::lowPowerModeEnabled() const
{
return m_lowPowerModeEnabled;
}

void DisplaySettings::setLowPowerModeEnabled(bool enabled)
{
if (m_lowPowerModeEnabled != enabled) {
m_lowPowerModeEnabled = enabled;
m_mceIface->set_config(QDBusObjectPath(MceDisplayUseLowPowerMode), QDBusVariant(enabled));
emit lowPowerModeEnabledChanged();
}
}

bool DisplaySettings::ambientLightSensorEnabled() const
{
return m_ambientLightSensorEnabled;
Expand Down Expand Up @@ -203,6 +222,12 @@ void DisplaySettings::configChange(const QString &key, const QDBusVariant &value
m_adaptiveDimmingEnabled = val;
emit adaptiveDimmingEnabledChanged();
}
} else if (key == MceDisplayUseLowPowerMode) {
bool val = value.variant().toBool();
if (val != m_lowPowerModeEnabled) {
m_lowPowerModeEnabled = val;
emit lowPowerModeEnabledChanged();
}
} else if (key == MceDisplayUseAmbientLightSensor) {
bool val = value.variant().toBool();
if (val != m_ambientLightSensorEnabled) {
Expand Down
6 changes: 6 additions & 0 deletions src/displaysettings.h
Expand Up @@ -50,6 +50,7 @@ class DisplaySettings: public QObject
Q_PROPERTY(int dimTimeout READ dimTimeout WRITE setDimTimeout NOTIFY dimTimeoutChanged)
Q_PROPERTY(int blankTimeout READ blankTimeout WRITE setBlankTimeout NOTIFY blankTimeoutChanged)
Q_PROPERTY(bool adaptiveDimmingEnabled READ adaptiveDimmingEnabled WRITE setAdaptiveDimmingEnabled NOTIFY adaptiveDimmingEnabledChanged)
Q_PROPERTY(bool lowPowerModeEnabled READ lowPowerModeEnabled WRITE setLowPowerModeEnabled NOTIFY lowPowerModeEnabledChanged)
Q_PROPERTY(bool ambientLightSensorEnabled READ ambientLightSensorEnabled WRITE setAmbientLightSensorEnabled NOTIFY ambientLightSensorEnabledChanged)
Q_PROPERTY(int doubleTapMode READ doubleTapMode WRITE setDoubleTapMode NOTIFY doubleTapModeChanged)
Q_PROPERTY(QVariant orientationLock READ orientationLock WRITE setOrientationLock NOTIFY orientationLockChanged)
Expand Down Expand Up @@ -77,6 +78,9 @@ class DisplaySettings: public QObject
bool adaptiveDimmingEnabled() const;
void setAdaptiveDimmingEnabled(bool);

bool lowPowerModeEnabled() const;
void setLowPowerModeEnabled(bool);

bool ambientLightSensorEnabled() const;
void setAmbientLightSensorEnabled(bool);

Expand All @@ -91,6 +95,7 @@ class DisplaySettings: public QObject
void dimTimeoutChanged();
void blankTimeoutChanged();
void adaptiveDimmingEnabledChanged();
void lowPowerModeEnabledChanged();
void ambientLightSensorEnabledChanged();
void doubleTapModeChanged();
void orientationLockChanged();
Expand All @@ -106,6 +111,7 @@ private slots:
int m_dimTimeout;
int m_blankTimeout;
bool m_adaptiveDimmingEnabled;
bool m_lowPowerModeEnabled;
bool m_ambientLightSensorEnabled;
bool m_doubleTapMode;
};
Expand Down

0 comments on commit 7daf75c

Please sign in to comment.