Changeset View
Changeset View
Standalone View
Standalone View
applets/batterymonitor/package/contents/ui/PopupDialog.qml
Show All 12 Lines | |||||
13 | * GNU General Public License for more details | 13 | * GNU General Public License for more details | ||
14 | * | 14 | * | ||
15 | * You should have received a copy of the GNU Library General Public | 15 | * You should have received a copy of the GNU Library General Public | ||
16 | * License along with this program; if not, write to the | 16 | * License along with this program; if not, write to the | ||
17 | * Free Software Foundation, Inc., | 17 | * Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
19 | */ | 19 | */ | ||
20 | 20 | | |||
21 | import QtQuick 2.0 | 21 | import QtQuick 2.2 | ||
22 | import QtQuick.Layouts 1.0 | ||||
23 | | ||||
22 | import org.kde.plasma.core 2.0 as PlasmaCore | 24 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
23 | import org.kde.plasma.components 2.0 as Components | 25 | import org.kde.plasma.components 2.0 as Components | ||
26 | import org.kde.plasma.components 3.0 as Components3 | ||||
24 | import org.kde.plasma.extras 2.0 as PlasmaExtras | 27 | import org.kde.plasma.extras 2.0 as PlasmaExtras | ||
25 | import org.kde.kquickcontrolsaddons 2.0 | 28 | import org.kde.kquickcontrolsaddons 2.0 | ||
26 | 29 | | |||
27 | FocusScope { | 30 | FocusScope { | ||
28 | id: dialog | 31 | id: dialog | ||
29 | focus: true | 32 | focus: true | ||
30 | 33 | | |||
31 | property alias model: batteryList.model | 34 | property alias model: batteryList.model | ||
32 | property bool pluggedIn | 35 | property bool pluggedIn | ||
33 | 36 | | |||
34 | property int remainingTime | 37 | property int remainingTime | ||
35 | 38 | | |||
36 | property bool isBrightnessAvailable | 39 | property bool isBrightnessAvailable | ||
37 | property bool isKeyboardBrightnessAvailable | 40 | property bool isKeyboardBrightnessAvailable | ||
38 | 41 | | |||
39 | signal powermanagementChanged(bool checked) | 42 | signal powermanagementChanged(bool checked) | ||
40 | 43 | | |||
41 | Column { | 44 | PlasmaCore.Svg { | ||
45 | id: lineSvg | ||||
46 | imagePath: "widgets/line" | ||||
47 | } | ||||
48 | | ||||
49 | ColumnLayout { | ||||
42 | id: settingsColumn | 50 | id: settingsColumn | ||
43 | anchors.horizontalCenter: parent.horizontalCenter | 51 | anchors.horizontalCenter: parent.horizontalCenter | ||
44 | width: parent.width - units.gridUnit | 52 | width: parent.width - units.smallSpacing * 2 | ||
45 | spacing: Math.round(units.gridUnit / 2) | 53 | height: parent.height | ||
54 | spacing: units.smallSpacing | ||||
46 | 55 | | |||
47 | Components.Label { | 56 | PlasmaExtras.ScrollArea { | ||
48 | // this is just for metrics, TODO use TextMetrics in 5.4 instead | 57 | id: scrollView | ||
49 | id: percentageMeasurementLabel | 58 | Layout.fillWidth: true | ||
50 | text: i18nc("Used for measurement", "100%") | 59 | Layout.fillHeight: true | ||
51 | visible: false | 60 | flickableItem.boundsBehavior: Flickable.StopAtBounds; | ||
61 | activeFocusOnTab: false | ||||
62 | | ||||
63 | ColumnLayout { | ||||
64 | width: scrollView.viewport.width | ||||
65 | | ||||
66 | InhibitionHint { | ||||
67 | id: lidHint | ||||
68 | visible: pmSource.data["PowerDevil"] && pmSource.data["PowerDevil"]["Is Lid Present"] && !pmSource.data["PowerDevil"]["Triggers Lid Action"] ? true : false | ||||
69 | iconSource: "computer-laptop" | ||||
70 | text: i18n("Your notebook is configured not to suspend when closing the lid while an external monitor is connected.") | ||||
71 | } | ||||
72 | | ||||
73 | InhibitionHint { | ||||
74 | id: suppressHint | ||||
75 | visible: inhibitions.length > 0 | ||||
76 | iconSource: inhibitions.length > 0 ? inhibitions[0].Icon || "" : "" | ||||
ngraham: The icon is a bit small: {F7923036, size=full} | |||||
77 | text: { | ||||
78 | if (inhibitions.length > 1) { | ||||
79 | return i18ncp("Some Application and n others are currently suppressing PM", | ||||
80 | "%2 and %1 other application are currently suppressing power management.", | ||||
81 | "%2 and %1 other applications are currently suppressing power management.", | ||||
82 | inhibitions.length - 1, inhibitions[0].Name) // plural only works on %1 | ||||
83 | } else if (inhibitions.length === 1) { | ||||
84 | if (!inhibitions[0].Reason) { | ||||
85 | return i18nc("Some Application is suppressing PM", | ||||
86 | "%1 is currently suppressing power management.", inhibitions[0].Name) | ||||
87 | } else { | ||||
88 | return i18nc("Some Application is suppressing PM: Reason provided by the app", | ||||
89 | "%1 is currently suppressing power management: %2", inhibitions[0].Name, inhibitions[0].Reason) | ||||
90 | } | ||||
91 | } else { | ||||
92 | return "" | ||||
93 | } | ||||
94 | } | ||||
52 | } | 95 | } | ||
53 | 96 | | |||
54 | PowerManagementItem { | 97 | PlasmaCore.SvgItem { | ||
55 | id: pmSwitch | 98 | elementId: "horizontal-line" | ||
56 | width: parent.width | 99 | Layout.fillWidth: true | ||
57 | onEnabledChanged: powermanagementChanged(enabled) | 100 | visible: lidHint.visible || suppressHint.visible | ||
58 | KeyNavigation.tab: batteryList | 101 | svg: lineSvg | ||
59 | KeyNavigation.backtab: keyboardBrightnessSlider | | |||
60 | } | 102 | } | ||
61 | 103 | | |||
62 | BrightnessItem { | 104 | BrightnessItem { | ||
63 | id: brightnessSlider | 105 | id: brightnessSlider | ||
64 | width: parent.width | | |||
65 | 106 | | |||
66 | icon: "video-display-brightness" | 107 | icon: "video-display-brightness" | ||
67 | label: i18n("Display Brightness") | 108 | label: i18n("Display Brightness") | ||
68 | visible: isBrightnessAvailable | 109 | visible: isBrightnessAvailable | ||
69 | value: batterymonitor.screenBrightness | 110 | value: batterymonitor.screenBrightness | ||
70 | maximumValue: batterymonitor.maximumScreenBrightness | 111 | maximumValue: batterymonitor.maximumScreenBrightness | ||
71 | KeyNavigation.tab: keyboardBrightnessSlider | 112 | KeyNavigation.tab: keyboardBrightnessSlider | ||
72 | KeyNavigation.backtab: batteryList | 113 | KeyNavigation.backtab: pmSwitch | ||
73 | stepSize: batterymonitor.maximumScreenBrightness/100 | 114 | stepSize: batterymonitor.maximumScreenBrightness/100 | ||
74 | 115 | | |||
75 | onMoved: batterymonitor.screenBrightness = value | 116 | onMoved: batterymonitor.screenBrightness = value | ||
76 | 117 | | |||
77 | // Manually dragging the slider around breaks the binding | 118 | // Manually dragging the slider around breaks the binding | ||
78 | Connections { | 119 | Connections { | ||
79 | target: batterymonitor | 120 | target: batterymonitor | ||
80 | onScreenBrightnessChanged: brightnessSlider.value = batterymonitor.screenBrightness | 121 | onScreenBrightnessChanged: brightnessSlider.value = batterymonitor.screenBrightness | ||
81 | } | 122 | } | ||
82 | } | 123 | } | ||
83 | 124 | | |||
84 | BrightnessItem { | 125 | BrightnessItem { | ||
85 | id: keyboardBrightnessSlider | 126 | id: keyboardBrightnessSlider | ||
86 | width: parent.width | | |||
87 | 127 | | |||
88 | icon: "input-keyboard-brightness" | 128 | icon: "input-keyboard-brightness" | ||
89 | label: i18n("Keyboard Brightness") | 129 | label: i18n("Keyboard Brightness") | ||
90 | value: batterymonitor.keyboardBrightness | 130 | value: batterymonitor.keyboardBrightness | ||
91 | maximumValue: batterymonitor.maximumKeyboardBrightness | 131 | maximumValue: batterymonitor.maximumKeyboardBrightness | ||
92 | visible: isKeyboardBrightnessAvailable | 132 | visible: isKeyboardBrightnessAvailable | ||
93 | KeyNavigation.tab: pmSwitch | 133 | KeyNavigation.tab: batteryList | ||
94 | KeyNavigation.backtab: brightnessSlider | 134 | KeyNavigation.backtab: brightnessSlider | ||
95 | 135 | | |||
96 | onMoved: batterymonitor.keyboardBrightness = value | 136 | onMoved: batterymonitor.keyboardBrightness = value | ||
97 | 137 | | |||
98 | // Manually dragging the slider around breaks the binding | 138 | // Manually dragging the slider around breaks the binding | ||
99 | Connections { | 139 | Connections { | ||
100 | target: batterymonitor | 140 | target: batterymonitor | ||
101 | onKeyboardBrightnessChanged: keyboardBrightnessSlider.value = batterymonitor.keyboardBrightness | 141 | onKeyboardBrightnessChanged: keyboardBrightnessSlider.value = batterymonitor.keyboardBrightness | ||
102 | } | 142 | } | ||
103 | } | 143 | } | ||
104 | } | | |||
105 | | ||||
106 | PlasmaExtras.ScrollArea { | | |||
107 | anchors { | | |||
108 | horizontalCenter: parent.horizontalCenter | | |||
109 | top: settingsColumn.bottom | | |||
110 | topMargin: units.gridUnit // not divided by 2 for unified looks | | |||
111 | bottom: dialog.bottom | | |||
112 | } | | |||
113 | width: parent.width - units.gridUnit | | |||
114 | 144 | | |||
115 | ListView { | 145 | ListView { | ||
116 | id: batteryList | 146 | id: batteryList | ||
147 | height: childrenRect.height | ||||
davidedmundson: and here | |||||
148 | implicitHeight: height | ||||
117 | 149 | | |||
118 | boundsBehavior: Flickable.StopAtBounds | 150 | boundsBehavior: Flickable.StopAtBounds | ||
119 | spacing: Math.round(units.gridUnit / 2) | 151 | spacing: Math.round(units.gridUnit / 2) | ||
120 | 152 | | |||
121 | KeyNavigation.tab: brightnessSlider | 153 | KeyNavigation.tab: pmSwitch | ||
122 | KeyNavigation.backtab: pmSwitch | 154 | KeyNavigation.backtab: keyboardBrightnessSlider | ||
123 | 155 | | |||
124 | delegate: BatteryItem { | 156 | delegate: BatteryItem { | ||
125 | width: parent.width | 157 | width: scrollView.viewport.width | ||
126 | battery: model | 158 | battery: model | ||
127 | } | 159 | } | ||
128 | } | 160 | } | ||
129 | } | 161 | } | ||
162 | } | ||||
130 | 163 | | |||
164 | PlasmaCore.SvgItem { | ||||
165 | elementId: "horizontal-line" | ||||
166 | Layout.fillWidth: true | ||||
167 | Layout.leftMargin: -units.smallSpacing * 2.5 | ||||
168 | Layout.rightMargin: Layout.leftMargin | ||||
169 | svg: lineSvg | ||||
170 | } | ||||
171 | | ||||
172 | PowerManagementItem { | ||||
173 | id: pmSwitch | ||||
174 | Layout.fillWidth: true | ||||
175 | onEnabledChanged: powermanagementChanged(enabled) | ||||
176 | KeyNavigation.tab: brightnessSlider | ||||
177 | KeyNavigation.backtab: batteryList | ||||
178 | } | ||||
179 | } | ||||
131 | } | 180 | } |
The icon is a bit small: