Commit b75ecd89 authored by spiiroin's avatar spiiroin

[displaysettings] Add PowerSaveMode properties. JB#43843

powerSaveModeEnabled: boolean toggle for PSM feature enable/disable
powerSaveModeThreshold: battery percentage threshold for triggering PSM
Signed-off-by: spiiroin's avatarSimo Piiroinen <simo.piiroinen@jollamobile.com>
parent 38267ea2
......@@ -48,6 +48,9 @@ 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";
static const char *MceFlipOverGestureEnabled = "/system/osso/dsm/display/flipover_gesture_enabled";
static const char *McePowerSaveModeForced = "/system/osso/dsm/energymanagement/force_power_saving";
static const char *McePowerSaveModeEnabled = "/system/osso/dsm/energymanagement/enable_power_saving";
static const char *McePowerSaveModeThreshold = "/system/osso/dsm/energymanagement/psm_threshold";
DisplaySettings::DisplaySettings(QObject *parent)
: QObject(parent)
......@@ -68,6 +71,9 @@ DisplaySettings::DisplaySettings(QObject *parent)
m_doubleTapMode = true;
m_lidSensorFilteringEnabled = true;
m_lidSensorEnabled = true;
m_powerSaveModeForced = false;
m_powerSaveModeEnabled = false;
m_powerSaveModeThreshold = 20;
m_populated = false;
/* Setup change listener & get current values via async query */
......@@ -287,6 +293,48 @@ void DisplaySettings::setFlipoverGestureEnabled(bool enabled)
}
}
bool DisplaySettings::powerSaveModeForced() const
{
return m_powerSaveModeForced;
}
void DisplaySettings::setPowerSaveModeForced(bool force)
{
if (m_powerSaveModeForced != force) {
m_powerSaveModeForced = force;
m_mceIface->set_config(QDBusObjectPath(McePowerSaveModeForced), QDBusVariant(force));
emit powerSaveModeForcedChanged();
}
}
bool DisplaySettings::powerSaveModeEnabled() const
{
return m_powerSaveModeEnabled;
}
void DisplaySettings::setPowerSaveModeEnabled(bool enabled)
{
if (m_powerSaveModeEnabled != enabled) {
m_powerSaveModeEnabled = enabled;
m_mceIface->set_config(QDBusObjectPath(McePowerSaveModeEnabled), QDBusVariant(enabled));
emit powerSaveModeEnabledChanged();
}
}
int DisplaySettings::powerSaveModeThreshold() const
{
return m_powerSaveModeThreshold;
}
void DisplaySettings::setPowerSaveModeThreshold(int value)
{
if (m_powerSaveModeThreshold != value) {
m_powerSaveModeThreshold = value;
m_mceIface->set_config(QDBusObjectPath(McePowerSaveModeThreshold), QDBusVariant(value));
emit powerSaveModeThresholdChanged();
}
}
bool DisplaySettings::populated() const
{
return m_populated;
......@@ -371,5 +419,23 @@ void DisplaySettings::updateConfig(const QString &key, const QVariant &value)
m_flipoverGestureEnabled = val;
emit flipoverGestureEnabledChanged();
}
} else if (key == McePowerSaveModeForced) {
bool val = value.toBool();
if (val != m_powerSaveModeForced) {
m_powerSaveModeForced = val;
emit powerSaveModeForcedChanged();
}
} else if (key == McePowerSaveModeEnabled) {
bool val = value.toBool();
if (val != m_powerSaveModeEnabled) {
m_powerSaveModeEnabled = val;
emit powerSaveModeEnabledChanged();
}
} else if (key == McePowerSaveModeThreshold) {
int val = value.toInt();
if (val != m_powerSaveModeThreshold) {
m_powerSaveModeThreshold = val;
emit powerSaveModeThresholdChanged();
}
}
}
......@@ -62,6 +62,9 @@ class SYSTEMSETTINGS_EXPORT DisplaySettings: public QObject
Q_PROPERTY(bool lidSensorEnabled READ lidSensorEnabled WRITE setLidSensorEnabled NOTIFY lidSensorEnabledChanged)
Q_PROPERTY(bool lidSensorFilteringEnabled READ lidSensorFilteringEnabled WRITE setLidSensorFilteringEnabled NOTIFY lidSensorFilteringEnabledChanged)
Q_PROPERTY(bool flipoverGestureEnabled READ flipoverGestureEnabled WRITE setFlipoverGestureEnabled NOTIFY flipoverGestureEnabledChanged)
Q_PROPERTY(bool powerSaveModeForced READ powerSaveModeForced WRITE setPowerSaveModeForced NOTIFY powerSaveModeForcedChanged)
Q_PROPERTY(bool powerSaveModeEnabled READ powerSaveModeEnabled WRITE setPowerSaveModeEnabled NOTIFY powerSaveModeEnabledChanged)
Q_PROPERTY(int powerSaveModeThreshold READ powerSaveModeThreshold WRITE setPowerSaveModeThreshold NOTIFY powerSaveModeThresholdChanged)
Q_PROPERTY(bool populated READ populated NOTIFY populatedChanged)
public:
......@@ -128,6 +131,15 @@ public:
bool flipoverGestureEnabled() const;
void setFlipoverGestureEnabled(bool);
bool powerSaveModeForced() const;
void setPowerSaveModeForced(bool);
bool powerSaveModeEnabled() const;
void setPowerSaveModeEnabled(bool);
int powerSaveModeThreshold() const;
void setPowerSaveModeThreshold(int);
bool populated() const;
signals:
......@@ -144,6 +156,9 @@ signals:
void lidSensorEnabledChanged();
void lidSensorFilteringEnabledChanged();
void flipoverGestureEnabledChanged();
void powerSaveModeForcedChanged();
void powerSaveModeEnabledChanged();
void powerSaveModeThresholdChanged();
void populatedChanged();
private slots:
......@@ -167,6 +182,9 @@ private:
bool m_lidSensorEnabled;
bool m_lidSensorFilteringEnabled;
bool m_flipoverGestureEnabled;
bool m_powerSaveModeForced;
bool m_powerSaveModeEnabled;
int m_powerSaveModeThreshold;
bool m_populated;
};
......
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