Commit a72b95f1 authored by spiiroin's avatar spiiroin

Merge pull request #40 from spiiroin/jb32093_als_settings

Fixes to ALS related display settings
parents a1a4870b 0bf8f08e
......@@ -43,8 +43,10 @@ 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";
static const char *MceLidSensorFilteringEnabled = "/system/osso/dsm/locks/filter_lid_with_als";
DisplaySettings::DisplaySettings(QObject *parent)
: QObject(parent)
......@@ -81,6 +83,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();
......@@ -89,6 +95,10 @@ DisplaySettings::DisplaySettings(QObject *parent)
result.waitForFinished();
m_lidSensorEnabled = result.value().variant().toBool();
result = m_mceIface->get_config(QDBusObjectPath(MceLidSensorFilteringEnabled));
result.waitForFinished();
m_lidSensorFilteringEnabled = result.value().variant().toBool();
m_mceSignalIface = new ComNokiaMceSignalInterface(MCE_SERVICE, MCE_SIGNAL_PATH, QDBusConnection::systemBus(), this);
connect(m_mceSignalIface, SIGNAL(config_change_ind(QString,QDBusVariant)), this, SLOT(configChange(QString,QDBusVariant)));
}
......@@ -199,6 +209,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;
......@@ -237,6 +261,20 @@ void DisplaySettings::setLidSensorEnabled(bool enabled)
}
}
bool DisplaySettings::lidSensorFilteringEnabled() const
{
return m_lidSensorFilteringEnabled;
}
void DisplaySettings::setLidSensorFilteringEnabled(bool enabled)
{
if (m_lidSensorFilteringEnabled != enabled) {
m_lidSensorFilteringEnabled = enabled;
m_mceIface->set_config(QDBusObjectPath(MceLidSensorFilteringEnabled), QDBusVariant(enabled));
emit lidSensorFilteringEnabledChanged();
}
}
void DisplaySettings::configChange(const QString &key, const QDBusVariant &value)
{
if (key == MceDisplayBrightness) {
......@@ -281,6 +319,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) {
......@@ -293,5 +337,11 @@ void DisplaySettings::configChange(const QString &key, const QDBusVariant &value
m_lidSensorEnabled = val;
emit lidSensorEnabledChanged();
}
} else if (key == MceLidSensorFilteringEnabled) {
bool val = value.variant().toBool();
if (val != m_lidSensorFilteringEnabled) {
m_lidSensorFilteringEnabled = val;
emit lidSensorFilteringEnabledChanged();
}
}
}
......@@ -53,9 +53,11 @@ 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)
Q_PROPERTY(bool lidSensorFilteringEnabled READ lidSensorFilteringEnabled WRITE setLidSensorFilteringEnabled NOTIFY lidSensorFilteringEnabledChanged)
public:
enum DoubleTapMode {
......@@ -103,6 +105,9 @@ public:
bool ambientLightSensorEnabled() const;
void setAmbientLightSensorEnabled(bool);
bool autoBrightnessEnabled() const;
void setAutoBrightnessEnabled(bool);
int doubleTapMode() const;
void setDoubleTapMode(int);
......@@ -112,6 +117,9 @@ public:
bool lidSensorEnabled() const;
void setLidSensorEnabled(bool);
bool lidSensorFilteringEnabled() const;
void setLidSensorFilteringEnabled(bool);
signals:
void brightnessChanged();
void dimTimeoutChanged();
......@@ -120,9 +128,11 @@ signals:
void adaptiveDimmingEnabledChanged();
void lowPowerModeEnabledChanged();
void ambientLightSensorEnabledChanged();
void autoBrightnessEnabledChanged();
void doubleTapModeChanged();
void orientationLockChanged();
void lidSensorEnabledChanged();
void lidSensorFilteringEnabledChanged();
private slots:
void configChange(const QString &key, const QDBusVariant &value);
......@@ -138,8 +148,10 @@ private:
bool m_adaptiveDimmingEnabled;
bool m_lowPowerModeEnabled;
bool m_ambientLightSensorEnabled;
bool m_autoBrightnessEnabled;
bool m_doubleTapMode;
bool m_lidSensorEnabled;
bool m_lidSensorFilteringEnabled;
};
QML_DECLARE_TYPE(DisplaySettings)
......
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