Changeset View
Standalone View
kcms/launch/package/contents/ui/main.qml
Show All 15 Lines | 1 | /* | |||
---|---|---|---|---|---|
16 | Boston, MA 02110-1301, USA. | 16 | Boston, MA 02110-1301, USA. | ||
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | import QtQuick 2.1 | 19 | import QtQuick 2.1 | ||
20 | import QtQuick.Layouts 1.1 | 20 | import QtQuick.Layouts 1.1 | ||
21 | import QtQuick.Controls 2.2 as QtControls | 21 | import QtQuick.Controls 2.2 as QtControls | ||
22 | import org.kde.kirigami 2.3 as Kirigami | 22 | import org.kde.kirigami 2.3 as Kirigami | ||
23 | import org.kde.kcm 1.1 | 23 | import org.kde.kcm 1.1 | ||
24 | import org.kde.private.kcms.launchfeedback 1.0 as Private | ||||
24 | 25 | | |||
25 | SimpleKCM { | 26 | SimpleKCM { | ||
26 | id: root | 27 | id: root | ||
27 | 28 | | |||
28 | ConfigModule.quickHelp: i18n("Launch Feedback") | 29 | ConfigModule.quickHelp: i18n("Launch Feedback") | ||
29 | ConfigModule.buttons: ConfigModule.Help | ConfigModule.Defaults | ConfigModule.Apply | | |||
30 | | ||||
31 | function applyBusyCursorCurrentIndex() { | | |||
32 | if (kcm.busyCursorCurrentIndex === 0) { | | |||
33 | busyCursorDisabled.checked = true; | | |||
34 | } else if (kcm.busyCursorCurrentIndex === 1) { | | |||
35 | busyCursorStatic.checked = true; | | |||
36 | } else if (kcm.busyCursorCurrentIndex === 2) { | | |||
37 | busyCursorBlinking.checked = true; | | |||
38 | } else if (kcm.busyCursorCurrentIndex === 3) { | | |||
39 | busyCursorBouncing.checked = true; | | |||
40 | } | | |||
41 | } | | |||
42 | 30 | | |||
43 | Kirigami.FormLayout { | 31 | Kirigami.FormLayout { | ||
44 | id: formLayout | 32 | id: formLayout | ||
45 | 33 | | |||
46 | Connections { | 34 | function setCursorSettings(feedback) { | ||
47 | target: kcm | 35 | kcm.launchFeedbackSettings.busyCursor = feedback !== Private.KCM.None | ||
48 | 36 | kcm.launchFeedbackSettings.blinking = feedback === Private.KCM.Blinking | |||
49 | onBusyCursorCurrentIndexChanged: applyBusyCursorCurrentIndex() | 37 | kcm.launchFeedbackSettings.bouncing = feedback === Private.KCM.Bouncing | ||
davidedmundson: This is a bit of a boolean trap.
We could declare an enum in QML
setCursorSettings(Busy |… | |||||
Yes, I would prefer all of this to be abstracted away from the QML, the checked bindings area also quite messy broulik: Yes, I would prefer all of this to be abstracted away from the QML, the `checked` bindings area… | |||||
I agree it's a bit tricky, we have a kind of enum choice written as a binary representation in the config file. Will try to work it with a QML enum to make it less confusing. crossi: I agree it's a bit tricky, we have a kind of enum choice written as a binary representation in… | |||||
Or... but that's more work and I'd say it should come in another patch on top of that one. We migrate the config file to use an enum all the way. This boolean trap exists in the config after all. ervin: Or... but that's more work and I'd say it should come in another patch on top of that one. We… | |||||
Added enum to remove the triple boolean parameter. To solve the boolean trap, it means to change the config to an enum instead of 3 booleans. This patch is intended to port Launch Feedback to KConfig XT, we could fix the configuration issue in another patch. crossi: Added enum to remove the triple boolean parameter.
To solve the boolean trap, it means to… | |||||
50 | | ||||
51 | onTaskManagerNotificationChanged: taskManagerNotification.checked = kcm.taskManagerNotification | | |||
52 | | ||||
53 | onNotificationTimeoutChanged: notificationTimeout.value = kcm.notificationTimeout | | |||
54 | } | 38 | } | ||
55 | 39 | | |||
56 | | ||||
57 | QtControls.RadioButton { | 40 | QtControls.RadioButton { | ||
58 | id: busyCursorDisabled | 41 | id: busyCursorDisabled | ||
59 | 42 | | |||
60 | Kirigami.FormData.label: i18n("Cursor:") | 43 | Kirigami.FormData.label: i18n("Cursor:") | ||
61 | text: i18n("No Feedback") | 44 | text: i18n("No Feedback") | ||
62 | 45 | checked: !kcm.launchFeedbackSettings.busyCursor && !kcm.launchFeedbackSettings.blinking && !kcm.launchFeedbackSettings.bouncing | |||
63 | onToggled: kcm.busyCursorCurrentIndex = 0; | 46 | onToggled: formLayout.setCursorSettings(Private.KCM.None) | ||
onToggled is called both when it is checked, and presumably when it is unchecked (or another button is checked) I assume we want something more like: onToggled: {if (!checked) return; formLayout.setCursorSettings(false,...} davidedmundson: onToggled is called both when it is checked, and presumably when it is unchecked (or another… | |||||
onToggled fires when user explicitly toggles it by clicking it. Given you can't "untoggle" a radio button should be fine-ish? broulik: `onToggled` fires when user explicitly toggles it by clicking it. Given you can't "untoggle" a… | |||||
According to Qt documentation :
Since it's a radio button, you can't uncheck it, so the signal is emitted only when checked. I've tested both as I first tought like david said. crossi: According to Qt documentation :
> This signal is emitted when a checkable button is… | |||||
64 | } | 47 | } | ||
65 | 48 | | |||
66 | QtControls.RadioButton { | 49 | QtControls.RadioButton { | ||
67 | id: busyCursorStatic | 50 | id: busyCursorStatic | ||
68 | 51 | | |||
69 | text: i18n("Static") | 52 | text: i18n("Static") | ||
70 | 53 | checked: kcm.launchFeedbackSettings.busyCursor && !kcm.launchFeedbackSettings.blinking && !kcm.launchFeedbackSettings.bouncing | |||
71 | onToggled: kcm.busyCursorCurrentIndex = 1; | 54 | onToggled: formLayout.setCursorSettings(Private.KCM.Static) | ||
72 | } | 55 | } | ||
73 | 56 | | |||
74 | QtControls.RadioButton { | 57 | QtControls.RadioButton { | ||
75 | id: busyCursorBlinking | 58 | id: busyCursorBlinking | ||
76 | 59 | | |||
77 | text: i18n("Blinking") | 60 | text: i18n("Blinking") | ||
78 | 61 | checked: kcm.launchFeedbackSettings.busyCursor && kcm.launchFeedbackSettings.blinking && !kcm.launchFeedbackSettings.bouncing | |||
79 | onToggled: kcm.busyCursorCurrentIndex = 2; | 62 | onToggled: formLayout.setCursorSettings(Private.KCM.Blinking) | ||
80 | } | 63 | } | ||
81 | 64 | | |||
82 | QtControls.RadioButton { | 65 | QtControls.RadioButton { | ||
83 | id: busyCursorBouncing | 66 | id: busyCursorBouncing | ||
84 | 67 | | |||
85 | text: i18n("Bouncing") | 68 | text: i18n("Bouncing") | ||
86 | 69 | checked: kcm.launchFeedbackSettings.busyCursor && !kcm.launchFeedbackSettings.blinking && kcm.launchFeedbackSettings.bouncing | |||
87 | onToggled: kcm.busyCursorCurrentIndex = 3; | 70 | onToggled: formLayout.setCursorSettings(Private.KCM.Bouncing) | ||
88 | } | 71 | } | ||
89 | 72 | | |||
90 | QtControls.CheckBox { | 73 | QtControls.CheckBox { | ||
91 | id: taskManagerNotification | 74 | id: taskManagerNotification | ||
92 | 75 | | |||
93 | Kirigami.FormData.label: i18n("Task Manager:") | 76 | Kirigami.FormData.label: i18n("Task Manager:") | ||
94 | 77 | | |||
95 | text: i18n("Enable animation") | 78 | text: i18n("Enable animation") | ||
96 | 79 | | |||
97 | checked: kcm.taskManagerNotification | 80 | checked: kcm.launchFeedbackSettings.taskbarButton | ||
98 | onToggled: kcm.taskManagerNotification = checked | 81 | onToggled: kcm.launchFeedbackSettings.taskbarButton = checked | ||
99 | } | 82 | } | ||
100 | 83 | | |||
101 | QtControls.SpinBox { | 84 | QtControls.SpinBox { | ||
102 | id: notificationTimeout | 85 | id: notificationTimeout | ||
103 | 86 | | |||
104 | Kirigami.FormData.label: i18n("Stop animation after:") | 87 | Kirigami.FormData.label: i18n("Stop animation after:") | ||
105 | 88 | | |||
106 | stepSize: 1 | 89 | stepSize: 1 | ||
107 | editable: true | 90 | editable: true | ||
108 | 91 | | |||
109 | enabled: taskManagerNotification.checked | 92 | enabled: taskManagerNotification.checked | ||
110 | 93 | | |||
111 | value: kcm.notificationTimeout | 94 | value: kcm.launchFeedbackSettings.cursorTimeout | ||
112 | onValueChanged: kcm.notificationTimeout = value | 95 | onValueModified: { | ||
Use onValueModified which only fires when the user explicitly changes it, not because of some binding updates broulik: Use `onValueModified` which only fires when the user explicitly changes it, not because of some… | |||||
crossi: Sounds better. wiil fix. | |||||
96 | kcm.launchFeedbackSettings.cursorTimeout = value | ||||
97 | kcm.launchFeedbackSettings.taskbarTimeout = value | ||||
davidedmundson: taskar -> taskbar
| |||||
crossi: good catch, thanks. will fix. | |||||
98 | } | ||||
113 | 99 | | |||
114 | textFromValue: function(value, locale) { return i18np("%1 sec", "%1 secs", value)} | 100 | textFromValue: function(value, locale) { return i18np("%1 sec", "%1 secs", value)} | ||
115 | valueFromText: function(text, locale) { return parseInt(text) } | 101 | valueFromText: function(text, locale) { return parseInt(text) } | ||
116 | } | 102 | } | ||
117 | } | 103 | } | ||
118 | | ||||
119 | Component.onCompleted: applyBusyCursorCurrentIndex() | | |||
120 | } | 104 | } | ||
121 | |
This is a bit of a boolean trap.
We could declare an enum in QML
setCursorSettings(Busy | Blinking) would be a bit nicer maybe?
Up to you.