Commit 8b787d26 authored by kananoja's avatar kananoja

[displaysettings] Added a property to DisplaySettings for controlling the lid...

[displaysettings] Added a property to DisplaySettings for controlling the lid sensor. Contributes to JB#29182
parent c931ef38
......@@ -44,6 +44,7 @@ static const char *MceDisplayUseAdaptiveDimming = "/system/osso/dsm/display/use_
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";
static const char *MceLidSensorEnabled = "/system/osso/dsm/locks/lid_sensor_enabled";
DisplaySettings::DisplaySettings(QObject *parent)
: QObject(parent)
......@@ -84,6 +85,10 @@ DisplaySettings::DisplaySettings(QObject *parent)
result.waitForFinished();
m_doubleTapMode = result.value().variant().toInt();
result = m_mceIface->get_config(QDBusObjectPath(MceLidSensorEnabled));
result.waitForFinished();
m_lidSensorEnabled = 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)));
}
......@@ -218,6 +223,20 @@ void DisplaySettings::setOrientationLock(const QVariant &orientationLock)
m_orientationLock->set(orientationLock);
}
bool DisplaySettings::lidSensorEnabled() const
{
return m_lidSensorEnabled;
}
void DisplaySettings::setLidSensorEnabled(bool enabled)
{
if (m_lidSensorEnabled != enabled) {
m_lidSensorEnabled = enabled;
m_mceIface->set_config(QDBusObjectPath(MceLidSensorEnabled), QDBusVariant(enabled));
emit lidSensorEnabledChanged();
}
}
void DisplaySettings::configChange(const QString &key, const QDBusVariant &value)
{
if (key == MceDisplayBrightness) {
......@@ -268,5 +287,11 @@ void DisplaySettings::configChange(const QString &key, const QDBusVariant &value
m_doubleTapMode = val;
emit doubleTapModeChanged();
}
} else if (key == MceLidSensorEnabled) {
bool val = value.variant().toBool();
if (val != m_lidSensorEnabled) {
m_lidSensorEnabled = val;
emit lidSensorEnabledChanged();
}
}
}
......@@ -55,6 +55,7 @@ class DisplaySettings: public QObject
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)
Q_PROPERTY(bool lidSensorEnabled READ lidSensorEnabled WRITE setLidSensorEnabled NOTIFY lidSensorEnabledChanged)
public:
enum DoubleTapMode {
......@@ -108,6 +109,9 @@ public:
QVariant orientationLock() const;
void setOrientationLock(const QVariant &);
bool lidSensorEnabled() const;
void setLidSensorEnabled(bool);
signals:
void brightnessChanged();
void dimTimeoutChanged();
......@@ -118,6 +122,7 @@ signals:
void ambientLightSensorEnabledChanged();
void doubleTapModeChanged();
void orientationLockChanged();
void lidSensorEnabledChanged();
private slots:
void configChange(const QString &key, const QDBusVariant &value);
......@@ -134,6 +139,7 @@ private:
bool m_lowPowerModeEnabled;
bool m_ambientLightSensorEnabled;
bool m_doubleTapMode;
bool m_lidSensorEnabled;
};
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