Changeset View
Standalone View
applets/batterymonitor/package/contents/ui/PopupDialog.qml
Show All 32 Lines | 27 | FocusScope { | |||
---|---|---|---|---|---|
33 | 33 | | |||
34 | property int remainingTime | 34 | property int remainingTime | ||
35 | 35 | | |||
36 | property bool isBrightnessAvailable | 36 | property bool isBrightnessAvailable | ||
37 | property bool isKeyboardBrightnessAvailable | 37 | property bool isKeyboardBrightnessAvailable | ||
38 | 38 | | |||
39 | signal powermanagementChanged(bool checked) | 39 | signal powermanagementChanged(bool checked) | ||
40 | 40 | | |||
41 | Component.onCompleted: { | | |||
42 | // setup handler on slider value manually to avoid change on creation | | |||
43 | | ||||
44 | brightnessSlider.valueChanged.connect(function() { | | |||
45 | batterymonitor.screenBrightness = brightnessSlider.value | | |||
46 | }) | | |||
47 | | ||||
48 | keyboardBrightnessSlider.valueChanged.connect(function() { | | |||
broulik: What about this? | |||||
49 | batterymonitor.keyboardBrightness = keyboardBrightnessSlider.value | | |||
50 | }) | | |||
51 | } | | |||
52 | | ||||
53 | Column { | 41 | Column { | ||
54 | id: settingsColumn | 42 | id: settingsColumn | ||
55 | anchors.horizontalCenter: parent.horizontalCenter | 43 | anchors.horizontalCenter: parent.horizontalCenter | ||
56 | width: parent.width - units.gridUnit | 44 | width: parent.width - units.gridUnit | ||
57 | spacing: Math.round(units.gridUnit / 2) | 45 | spacing: Math.round(units.gridUnit / 2) | ||
58 | 46 | | |||
59 | Components.Label { | 47 | Components.Label { | ||
60 | // this is just for metrics, TODO use TextMetrics in 5.4 instead | 48 | // this is just for metrics, TODO use TextMetrics in 5.4 instead | ||
Show All 16 Lines | 62 | BrightnessItem { | |||
77 | 65 | | |||
78 | icon: "video-display-brightness" | 66 | icon: "video-display-brightness" | ||
79 | label: i18n("Display Brightness") | 67 | label: i18n("Display Brightness") | ||
80 | visible: isBrightnessAvailable | 68 | visible: isBrightnessAvailable | ||
81 | value: batterymonitor.screenBrightness | 69 | value: batterymonitor.screenBrightness | ||
82 | maximumValue: batterymonitor.maximumScreenBrightness | 70 | maximumValue: batterymonitor.maximumScreenBrightness | ||
83 | KeyNavigation.tab: keyboardBrightnessSlider | 71 | KeyNavigation.tab: keyboardBrightnessSlider | ||
84 | KeyNavigation.backtab: batteryList | 72 | KeyNavigation.backtab: batteryList | ||
73 | stepSize: batterymonitor.maximumScreenBrightness/100 | ||||
Because it's artificially limited to 100 positions, this change makes it impossible to set a value by clicking on a position or by dragging the slider with the pointer. It snaps to one of the 100 positions and the precision we want just isn't there. On my laptop the slider currently consists of ~582 pixels in width. (Just a quick screenshot selection-based estimate; the exact value is irrelevant other than to point out that it's very unlikely to be less than ~450 and extremely likely to be much more.) The organic limit is therefore 582 on my laptop. In the example given above, 7000/582 = 12. I assume there has to be reason for this change, so an organic limit would mean something along the lines of: stepSize: batterymonitor.maximumScreenBrightness / this.width But intuitively it seems that a slider would have to do that all by itself no matter what, which just leaves me confused as to what the purpose behind this line is. I hope it can simply be removed. frenzie: Because it's artificially limited to 100 positions, this change makes it impossible to set a… | |||||
74 | | ||||
75 | onMoved: batterymonitor.screenBrightness = value | ||||
85 | 76 | | |||
86 | // Manually dragging the slider around breaks the binding | 77 | // Manually dragging the slider around breaks the binding | ||
87 | Connections { | 78 | Connections { | ||
88 | target: batterymonitor | 79 | target: batterymonitor | ||
89 | onScreenBrightnessChanged: brightnessSlider.value = batterymonitor.screenBrightness | 80 | onScreenBrightnessChanged: brightnessSlider.value = batterymonitor.screenBrightness | ||
90 | } | 81 | } | ||
91 | } | 82 | } | ||
92 | 83 | | |||
93 | BrightnessItem { | 84 | BrightnessItem { | ||
94 | id: keyboardBrightnessSlider | 85 | id: keyboardBrightnessSlider | ||
95 | width: parent.width | 86 | width: parent.width | ||
96 | 87 | | |||
97 | icon: "input-keyboard-brightness" | 88 | icon: "input-keyboard-brightness" | ||
98 | label: i18n("Keyboard Brightness") | 89 | label: i18n("Keyboard Brightness") | ||
99 | value: batterymonitor.keyboardBrightness | 90 | value: batterymonitor.keyboardBrightness | ||
100 | maximumValue: batterymonitor.maximumKeyboardBrightness | 91 | maximumValue: batterymonitor.maximumKeyboardBrightness | ||
101 | visible: isKeyboardBrightnessAvailable | 92 | visible: isKeyboardBrightnessAvailable | ||
102 | KeyNavigation.tab: pmSwitch | 93 | KeyNavigation.tab: pmSwitch | ||
103 | KeyNavigation.backtab: brightnessSlider | 94 | KeyNavigation.backtab: brightnessSlider | ||
104 | 95 | | |||
96 | onMoved: batterymonitor.keyboardBrightness = value | ||||
97 | | ||||
105 | // Manually dragging the slider around breaks the binding | 98 | // Manually dragging the slider around breaks the binding | ||
106 | Connections { | 99 | Connections { | ||
107 | target: batterymonitor | 100 | target: batterymonitor | ||
108 | onKeyboardBrightnessChanged: keyboardBrightnessSlider.value = batterymonitor.keyboardBrightness | 101 | onKeyboardBrightnessChanged: keyboardBrightnessSlider.value = batterymonitor.keyboardBrightness | ||
109 | } | 102 | } | ||
110 | } | 103 | } | ||
111 | } | 104 | } | ||
112 | 105 | | |||
Show All 26 Lines |
What about this?