displaysettings.h 7.47 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
/*
 * Copyright (C) 2013 Jolla Ltd. <pekka.vuorela@jollamobile.com>
 *
 * You may use this file under the terms of the BSD license as follows:
 *
 * "Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *   * Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above copyright
 *     notice, this list of conditions and the following disclaimer in
 *     the documentation and/or other materials provided with the
 *     distribution.
 *   * Neither the name of Nemo Mobile nor the names of its contributors
 *     may be used to endorse or promote products derived from this
 *     software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
 */

#ifndef DISPLAYSETTINGS_H
#define DISPLAYSETTINGS_H

#include <QObject>
36
#include <QtQml>
37
#include <QDBusPendingCallWatcher>
38 39

class ComNokiaMceRequestInterface;
40 41
class ComNokiaMceSignalInterface;
class QDBusVariant;
42
class MGConfItem;
43

44 45 46
#include <systemsettingsglobal.h>

class SYSTEMSETTINGS_EXPORT DisplaySettings: public QObject
47 48 49
{
    Q_OBJECT

50
    Q_ENUMS(DoubleTapMode InhibitMode)
51 52
    Q_PROPERTY(int brightness READ brightness WRITE setBrightness NOTIFY brightnessChanged)
    Q_PROPERTY(int maximumBrightness READ maximumBrightness CONSTANT)
53 54
    Q_PROPERTY(int dimTimeout READ dimTimeout WRITE setDimTimeout NOTIFY dimTimeoutChanged)
    Q_PROPERTY(int blankTimeout READ blankTimeout WRITE setBlankTimeout NOTIFY blankTimeoutChanged)
55
    Q_PROPERTY(InhibitMode inhibitMode READ inhibitMode WRITE setInhibitMode NOTIFY inhibitModeChanged)
56
    Q_PROPERTY(bool adaptiveDimmingEnabled READ adaptiveDimmingEnabled WRITE setAdaptiveDimmingEnabled NOTIFY adaptiveDimmingEnabledChanged)
57
    Q_PROPERTY(bool lowPowerModeEnabled READ lowPowerModeEnabled WRITE setLowPowerModeEnabled NOTIFY lowPowerModeEnabledChanged)
58
    Q_PROPERTY(bool ambientLightSensorEnabled READ ambientLightSensorEnabled WRITE setAmbientLightSensorEnabled NOTIFY ambientLightSensorEnabledChanged)
59
    Q_PROPERTY(bool autoBrightnessEnabled READ autoBrightnessEnabled WRITE setAutoBrightnessEnabled NOTIFY autoBrightnessEnabledChanged)
60
    Q_PROPERTY(int doubleTapMode READ doubleTapMode WRITE setDoubleTapMode NOTIFY doubleTapModeChanged)
61
    Q_PROPERTY(QVariant orientationLock READ orientationLock WRITE setOrientationLock NOTIFY orientationLockChanged)
62
    Q_PROPERTY(bool lidSensorEnabled READ lidSensorEnabled WRITE setLidSensorEnabled NOTIFY lidSensorEnabledChanged)
63
    Q_PROPERTY(bool lidSensorFilteringEnabled READ lidSensorFilteringEnabled WRITE setLidSensorFilteringEnabled NOTIFY lidSensorFilteringEnabledChanged)
64
    Q_PROPERTY(bool flipoverGestureEnabled READ flipoverGestureEnabled WRITE setFlipoverGestureEnabled NOTIFY flipoverGestureEnabledChanged)
65 66 67
    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)
68
    Q_PROPERTY(bool populated READ populated NOTIFY populatedChanged)
69 70

public:
71 72 73 74 75 76
    enum DoubleTapMode {
        DoubleTapWakeupNever,
        DoubleTapWakeupAlways,
        DoubleTapWakeupNoProximity
    };

77 78 79 80 81 82 83 84 85 86 87 88 89 90
    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,
    };

91 92
    explicit DisplaySettings(QObject *parent = 0);

93
    int brightness() const;
94 95 96 97
    void setBrightness(int);

    int maximumBrightness();

98 99 100 101 102 103
    int dimTimeout() const;
    void setDimTimeout(int t);

    int blankTimeout() const;
    void setBlankTimeout(int t);

104 105 106
    InhibitMode inhibitMode() const;
    void setInhibitMode(InhibitMode mode);

107 108 109
    bool adaptiveDimmingEnabled() const;
    void setAdaptiveDimmingEnabled(bool);

110 111 112
    bool lowPowerModeEnabled() const;
    void setLowPowerModeEnabled(bool);

113 114
    bool ambientLightSensorEnabled() const;
    void setAmbientLightSensorEnabled(bool);
115

116 117 118
    bool autoBrightnessEnabled() const;
    void setAutoBrightnessEnabled(bool);

119 120 121
    int doubleTapMode() const;
    void setDoubleTapMode(int);

122 123 124
    QVariant orientationLock() const;
    void setOrientationLock(const QVariant &);

125 126 127
    bool lidSensorEnabled() const;
    void setLidSensorEnabled(bool);

128 129 130
    bool lidSensorFilteringEnabled() const;
    void setLidSensorFilteringEnabled(bool);

131 132 133
    bool flipoverGestureEnabled() const;
    void setFlipoverGestureEnabled(bool);

134 135 136 137 138 139 140 141 142
    bool powerSaveModeForced() const;
    void setPowerSaveModeForced(bool);

    bool powerSaveModeEnabled() const;
    void setPowerSaveModeEnabled(bool);

    int powerSaveModeThreshold() const;
    void setPowerSaveModeThreshold(int);

143 144
    bool populated() const;

145 146
signals:
    void brightnessChanged();
147 148
    void dimTimeoutChanged();
    void blankTimeoutChanged();
149
    void inhibitModeChanged();
150
    void adaptiveDimmingEnabledChanged();
151
    void lowPowerModeEnabledChanged();
152
    void ambientLightSensorEnabledChanged();
153
    void autoBrightnessEnabledChanged();
154
    void doubleTapModeChanged();
155
    void orientationLockChanged();
156
    void lidSensorEnabledChanged();
157
    void lidSensorFilteringEnabledChanged();
158
    void flipoverGestureEnabledChanged();
159 160 161
    void powerSaveModeForcedChanged();
    void powerSaveModeEnabledChanged();
    void powerSaveModeThresholdChanged();
162
    void populatedChanged();
163 164 165

private slots:
    void configChange(const QString &key, const QDBusVariant &value);
166 167
    void configReply(QDBusPendingCallWatcher *watcher);

168
private:
169
    void updateConfig(const QString &key, const QVariant &value);
170
    ComNokiaMceRequestInterface *m_mceIface;
171
    ComNokiaMceSignalInterface *m_mceSignalIface;
172
    MGConfItem *m_orientationLock;
173
    int m_brightness;
174 175
    int m_dimTimeout;
    int m_blankTimeout;
176
    InhibitMode m_inhibitMode;
177
    bool m_adaptiveDimmingEnabled;
178
    bool m_lowPowerModeEnabled;
179
    bool m_ambientLightSensorEnabled;
180
    bool m_autoBrightnessEnabled;
181
    bool m_doubleTapMode;
182
    bool m_lidSensorEnabled;
183
    bool m_lidSensorFilteringEnabled;
184
    bool m_flipoverGestureEnabled;
185 186 187
    bool m_powerSaveModeForced;
    bool m_powerSaveModeEnabled;
    int m_powerSaveModeThreshold;
188
    bool m_populated;
189 190 191 192 193
};

QML_DECLARE_TYPE(DisplaySettings)

#endif