Commit 93301c90 authored by martinjones's avatar martinjones

Merge pull request #24 from martinjones/inhibit_mode

[nemo-qml-plugin-systemsettings] Expose display inhibit mode.
parents 4722c745 372a0822
......@@ -38,6 +38,7 @@
static const char *MceDisplayBrightness = "/system/osso/dsm/display/display_brightness";
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 *MceDisplayInhibitMode = "/system/osso/dsm/display/inhibit_blank_mode";
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";
......@@ -60,6 +61,10 @@ DisplaySettings::DisplaySettings(QObject *parent)
result.waitForFinished();
m_blankTimeout = result.value().variant().toInt();
result = m_mceIface->get_config(QDBusObjectPath(MceDisplayInhibitMode));
result.waitForFinished();
m_inhibitMode = static_cast<InhibitMode>(result.value().variant().toInt());
result = m_mceIface->get_config(QDBusObjectPath(MceDisplayUseAdaptiveDimming));
result.waitForFinished();
m_adaptiveDimmingEnabled = result.value().variant().toBool();
......@@ -130,6 +135,20 @@ void DisplaySettings::setBlankTimeout(int value)
}
}
DisplaySettings::InhibitMode DisplaySettings::inhibitMode() const
{
return m_inhibitMode;
}
void DisplaySettings::setInhibitMode(InhibitMode mode)
{
if (m_inhibitMode != mode) {
m_inhibitMode = mode;
m_mceIface->set_config(QDBusObjectPath(MceDisplayInhibitMode), QDBusVariant(static_cast<int>(mode)));
emit inhibitModeChanged();
}
}
bool DisplaySettings::adaptiveDimmingEnabled() const
{
return m_adaptiveDimmingEnabled;
......@@ -216,6 +235,12 @@ void DisplaySettings::configChange(const QString &key, const QDBusVariant &value
m_blankTimeout = val;
emit blankTimeoutChanged();
}
} else if (key == MceDisplayInhibitMode) {
InhibitMode val = static_cast<InhibitMode>(value.variant().toInt());
if (val != m_inhibitMode) {
m_inhibitMode = val;
emit inhibitModeChanged();
}
} else if (key == MceDisplayUseAdaptiveDimming) {
bool val = value.variant().toBool();
if (val != m_adaptiveDimmingEnabled) {
......
......@@ -44,11 +44,12 @@ class DisplaySettings: public QObject
{
Q_OBJECT
Q_ENUMS(DoubleTapMode)
Q_ENUMS(DoubleTapMode InhibitMode)
Q_PROPERTY(int brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged)
Q_PROPERTY(int maximumBrightness READ maximumBrightness CONSTANT)
Q_PROPERTY(int dimTimeout READ dimTimeout WRITE setDimTimeout NOTIFY dimTimeoutChanged)
Q_PROPERTY(int blankTimeout READ blankTimeout WRITE setBlankTimeout NOTIFY blankTimeoutChanged)
Q_PROPERTY(InhibitMode inhibitMode READ inhibitMode WRITE setInhibitMode NOTIFY inhibitModeChanged)
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)
......@@ -62,6 +63,20 @@ public:
DoubleTapWakeupNoProximity
};
enum InhibitMode {
InhibitInvalid = -1,
// No inhibit
InhibitOff = 0,
// Inhibit blanking; always keep on if charger connected
InhibitStayOnWithCharger = 1,
// Inhibit blanking; always keep on or dimmed if charger connected
InhibitStayDimWithCharger = 2,
// Inhibit blanking; always keep on
InhibitStayOn = 3,
// Inhibit blanking; always keep on or dimmed
InhibitStayDim = 4,
};
explicit DisplaySettings(QObject *parent = 0);
int brightness() const;
......@@ -75,6 +90,9 @@ public:
int blankTimeout() const;
void setBlankTimeout(int t);
InhibitMode inhibitMode() const;
void setInhibitMode(InhibitMode mode);
bool adaptiveDimmingEnabled() const;
void setAdaptiveDimmingEnabled(bool);
......@@ -94,6 +112,7 @@ signals:
void brightnessChanged();
void dimTimeoutChanged();
void blankTimeoutChanged();
void inhibitModeChanged();
void adaptiveDimmingEnabledChanged();
void lowPowerModeEnabledChanged();
void ambientLightSensorEnabledChanged();
......@@ -110,6 +129,7 @@ private:
int m_brightness;
int m_dimTimeout;
int m_blankTimeout;
InhibitMode m_inhibitMode;
bool m_adaptiveDimmingEnabled;
bool m_lowPowerModeEnabled;
bool m_ambientLightSensorEnabled;
......
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