Commit bd1c1d77 authored by spiiroin's avatar spiiroin

[displaysettings] Add autoBrightnessEnabled property. Contributes to JB#32093

MCE will adjust display brightness automatically when use of ambient
light sensor is allowed (ambientLightSensorEnabled property) and
autoBrightnessEnabled property is set to true.
parent a1a4870b
......@@ -43,6 +43,7 @@ static const char *MceDisplayInhibitMode = "/system/osso/dsm/display/inhibit_bla
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 *MceDisplayAutoBrightnessEnabled = "/system/osso/dsm/display/als_autobrightness";
static const char *MceDoubleTapMode = "/system/osso/dsm/doubletap/mode";
static const char *MceLidSensorEnabled = "/system/osso/dsm/locks/lid_sensor_enabled";
......@@ -81,6 +82,10 @@ DisplaySettings::DisplaySettings(QObject *parent)
result.waitForFinished();
m_ambientLightSensorEnabled = result.value().variant().toBool();
result = m_mceIface->get_config(QDBusObjectPath(MceDisplayAutoBrightnessEnabled));
result.waitForFinished();
m_autoBrightnessEnabled = result.value().variant().toBool();
result = m_mceIface->get_config(QDBusObjectPath(MceDoubleTapMode));
result.waitForFinished();
m_doubleTapMode = result.value().variant().toInt();
......@@ -199,6 +204,20 @@ void DisplaySettings::setAmbientLightSensorEnabled(bool enabled)
}
}
bool DisplaySettings::autoBrightnessEnabled() const
{
return m_autoBrightnessEnabled;
}
void DisplaySettings::setAutoBrightnessEnabled(bool enabled)
{
if (m_autoBrightnessEnabled != enabled) {
m_autoBrightnessEnabled = enabled;
m_mceIface->set_config(QDBusObjectPath(MceDisplayAutoBrightnessEnabled), QDBusVariant(enabled));
emit autoBrightnessEnabledChanged();
}
}
int DisplaySettings::doubleTapMode() const
{
return m_doubleTapMode;
......@@ -281,6 +300,12 @@ void DisplaySettings::configChange(const QString &key, const QDBusVariant &value
m_ambientLightSensorEnabled = val;
emit ambientLightSensorEnabledChanged();
}
} else if (key == MceDisplayAutoBrightnessEnabled) {
bool val = value.variant().toBool();
if (val != m_autoBrightnessEnabled) {
m_autoBrightnessEnabled = val;
emit autoBrightnessEnabledChanged();
}
} else if (key == MceDoubleTapMode) {
int val = value.variant().toInt();
if (val != m_doubleTapMode) {
......
......@@ -53,6 +53,7 @@ class DisplaySettings: public QObject
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(bool autoBrightnessEnabled READ autoBrightnessEnabled WRITE setAutoBrightnessEnabled NOTIFY autoBrightnessEnabledChanged)
Q_PROPERTY(int doubleTapMode READ doubleTapMode WRITE setDoubleTapMode NOTIFY doubleTapModeChanged)
Q_PROPERTY(QVariant orientationLock READ orientationLock WRITE setOrientationLock NOTIFY orientationLockChanged)
Q_PROPERTY(bool lidSensorEnabled READ lidSensorEnabled WRITE setLidSensorEnabled NOTIFY lidSensorEnabledChanged)
......@@ -103,6 +104,9 @@ public:
bool ambientLightSensorEnabled() const;
void setAmbientLightSensorEnabled(bool);
bool autoBrightnessEnabled() const;
void setAutoBrightnessEnabled(bool);
int doubleTapMode() const;
void setDoubleTapMode(int);
......@@ -120,6 +124,7 @@ signals:
void adaptiveDimmingEnabledChanged();
void lowPowerModeEnabledChanged();
void ambientLightSensorEnabledChanged();
void autoBrightnessEnabledChanged();
void doubleTapModeChanged();
void orientationLockChanged();
void lidSensorEnabledChanged();
......@@ -138,6 +143,7 @@ private:
bool m_adaptiveDimmingEnabled;
bool m_lowPowerModeEnabled;
bool m_ambientLightSensorEnabled;
bool m_autoBrightnessEnabled;
bool m_doubleTapMode;
bool m_lidSensorEnabled;
};
......
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