PopupDialog.qml 4.53 KB
Newer Older
1
2
/*
 *   Copyright 2011 Viranch Mehta <viranch.mehta@gmail.com>
3
 *   Copyright 2013-2016 Kai Uwe Broulik <kde@privat.broulik.de>
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License as
 *   published by the Free Software Foundation; either version 2 or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the
 *   Free Software Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as Components
24
import org.kde.plasma.components 3.0 as PlasmaComponents3
25
import org.kde.plasma.extras 2.0 as PlasmaExtras
26
27
import org.kde.kquickcontrolsaddons 2.0

28
PlasmaComponents3.Page {
29
30
31
32
33
34
35
36
37
38
39
40
    id: dialog

    property alias model: batteryList.model
    property bool pluggedIn

    property int remainingTime

    property bool isBrightnessAvailable
    property bool isKeyboardBrightnessAvailable

    signal powermanagementChanged(bool checked)

41
    header: PlasmaExtras.PlasmoidHeading {
42
43
44
45
46
47
48
        PowerManagementItem {
            id: pmSwitch
            width: parent.width
            onEnabledChanged: powermanagementChanged(enabled)
            KeyNavigation.tab: batteryList
            KeyNavigation.backtab: keyboardBrightnessSlider
        }
49
    }
50

51
52
53
    FocusScope {
        anchors.fill: parent
        anchors.topMargin: units.smallSpacing * 2
54

55
        focus: true
56

57
58
59
60
61
62
63
64
65
        Column {
            id: settingsColumn
            anchors.horizontalCenter: parent.horizontalCenter
            width: parent.width - units.smallSpacing * 2
            spacing: Math.round(units.gridUnit / 2)

            BrightnessItem {
                id: brightnessSlider
                width: parent.width
66

67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
                icon: "video-display-brightness"
                label: i18n("Display Brightness")
                visible: isBrightnessAvailable
                value: batterymonitor.screenBrightness
                maximumValue: batterymonitor.maximumScreenBrightness
                KeyNavigation.tab: keyboardBrightnessSlider
                KeyNavigation.backtab: batteryList
                stepSize: batterymonitor.maximumScreenBrightness/100

                onMoved: batterymonitor.screenBrightness = value

                // Manually dragging the slider around breaks the binding
                Connections {
                    target: batterymonitor
                    onScreenBrightnessChanged: brightnessSlider.value = batterymonitor.screenBrightness
                }
            }
84

85
86
87
            BrightnessItem {
                id: keyboardBrightnessSlider
                width: parent.width
88

89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
                icon: "input-keyboard-brightness"
                label: i18n("Keyboard Brightness")
                value: batterymonitor.keyboardBrightness
                maximumValue: batterymonitor.maximumKeyboardBrightness
                visible: isKeyboardBrightnessAvailable
                KeyNavigation.tab: pmSwitch
                KeyNavigation.backtab: brightnessSlider

                onMoved: batterymonitor.keyboardBrightness = value

                // Manually dragging the slider around breaks the binding
                Connections {
                    target: batterymonitor
                    onKeyboardBrightnessChanged: keyboardBrightnessSlider.value = batterymonitor.keyboardBrightness
                }
104
            }
105
106
        }

107
108
109
110
111
112
        PlasmaExtras.ScrollArea {
            anchors {
                horizontalCenter: parent.horizontalCenter
                top: settingsColumn.bottom
                topMargin: units.gridUnit
                leftMargin: units.smallSpacing
113
                bottom: parent.bottom
114
115
            }
            width: parent.width - units.smallSpacing * 2
116

117
118
            ListView {
                id: batteryList
119

120
121
                boundsBehavior: Flickable.StopAtBounds
                spacing: Math.round(units.gridUnit / 2)
122

123
124
                KeyNavigation.tab: brightnessSlider
                KeyNavigation.backtab: pmSwitch
125

126
127
128
129
                delegate: BatteryItem {
                    width: parent.width
                    battery: model
                }
130
131
132
            }
        }
    }
133
}