Changeset View
Changeset View
Standalone View
Standalone View
lookandfeel/contents/logout/Logout.qml
Show All 12 Lines | |||||
13 | * * | 13 | * * | ||
14 | * You should have received a copy of the GNU General Public License * | 14 | * You should have received a copy of the GNU General Public License * | ||
15 | * along with this program; if not, write to the * | 15 | * along with this program; if not, write to the * | ||
16 | * Free Software Foundation, Inc., * | 16 | * Free Software Foundation, Inc., * | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA . * | ||
18 | ***************************************************************************/ | 18 | ***************************************************************************/ | ||
19 | 19 | | |||
20 | import QtQuick 2.2 | 20 | import QtQuick 2.2 | ||
21 | import QtQuick.Layouts 1.2 | 21 | import QtQuick.Layouts 1.2 | ||
broulik: I think that's unused now | |||||
22 | import QtQuick.Controls 1.1 as Controls | 22 | import QtQuick.Controls 1.1 as Controls | ||
23 | 23 | | |||
24 | import org.kde.plasma.core 2.0 as PlasmaCore | 24 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
25 | import org.kde.plasma.components 2.0 as PlasmaComponents | 25 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
26 | import org.kde.kcoreaddons 1.0 as KCoreAddons | 26 | import org.kde.kcoreaddons 1.0 as KCoreAddons | ||
27 | 27 | | |||
28 | import "../components" | 28 | import "../components" | ||
29 | 29 | | |||
30 | PlasmaCore.ColorScope { | 30 | PlasmaCore.ColorScope { | ||
31 | id: root | 31 | id: root | ||
32 | colorGroup: PlasmaCore.Theme.ComplementaryColorGroup | 32 | colorGroup: PlasmaCore.Theme.ComplementaryColorGroup | ||
33 | height: screenGeometry.height | 33 | height: screenGeometry.height | ||
34 | width: screenGeometry.width | 34 | width: screenGeometry.width | ||
35 | 35 | | |||
36 | signal logoutRequested() | 36 | signal logoutRequested() | ||
37 | signal haltRequested() | 37 | signal haltRequested() | ||
38 | signal suspendRequested(int spdMethod) | 38 | signal suspendRequested(int spdMethod) | ||
39 | signal rebootRequested() | 39 | signal rebootRequested() | ||
40 | signal rebootRequested2(int opt) | 40 | signal rebootRequested2(int opt) | ||
41 | signal cancelRequested() | 41 | signal cancelRequested() | ||
42 | signal lockScreenRequested() | 42 | signal lockScreenRequested() | ||
43 | 43 | | |||
44 | property alias backgroundColor: backgroundRect.color | ||||
45 | | ||||
44 | function sleepRequested() { | 46 | function sleepRequested() { | ||
45 | root.suspendRequested(2); | 47 | root.suspendRequested(2); | ||
46 | } | 48 | } | ||
47 | 49 | | |||
48 | property real timeout: 30 | 50 | property real timeout: 30 | ||
49 | property real remainingTime: root.timeout | 51 | property real remainingTime: root.timeout | ||
50 | property var currentAction: { | 52 | property var currentAction: { | ||
51 | switch (sdtype) { | 53 | switch (sdtype) { | ||
broulik: Don't let Martin see that you animate a window opacity manually | |||||
;-) But yes for a good, flicker free experience it needs to be animated by KWin. We can re add the logout effect to do the fading. graesslin: ;-)
But yes for a good, flicker free experience it needs to be animated by KWin. We can re add… | |||||
ok, i'll remove it and then will do a separate review for a logout effect in kwin (that would just be fading that window) mart: ok, i'll remove it and then will do a separate review for a logout effect in kwin (that would… | |||||
52 | case ShutdownType.ShutdownTypeReboot: | 54 | case ShutdownType.ShutdownTypeReboot: | ||
53 | return root.rebootRequested; | 55 | return root.rebootRequested; | ||
54 | case ShutdownType.ShutdownTypeHalt: | 56 | case ShutdownType.ShutdownTypeHalt: | ||
55 | return root.haltRequested; | 57 | return root.haltRequested; | ||
56 | default: | 58 | default: | ||
57 | return root.logoutRequested; | 59 | return root.logoutRequested; | ||
58 | } | 60 | } | ||
59 | } | 61 | } | ||
Show All 9 Lines | |||||
69 | 71 | | |||
70 | onRemainingTimeChanged: { | 72 | onRemainingTimeChanged: { | ||
71 | if (remainingTime <= 0) { | 73 | if (remainingTime <= 0) { | ||
72 | root.currentAction(); | 74 | root.currentAction(); | ||
73 | } | 75 | } | ||
74 | } | 76 | } | ||
75 | 77 | | |||
76 | Timer { | 78 | Timer { | ||
79 | id: countDownTimer | ||||
77 | running: true | 80 | running: true | ||
78 | repeat: true | 81 | repeat: true | ||
79 | interval: 1000 | 82 | interval: 1000 | ||
80 | onTriggered: remainingTime-- | 83 | onTriggered: remainingTime-- | ||
81 | } | 84 | } | ||
82 | 85 | | |||
86 | function rgbToHsv(color) { | ||||
broulik: Urgh. Can you add a TODO for Qt 5.8 :) | |||||
87 | var max = Math.max(color.r, color.g, color.b); | ||||
88 | var min = Math.min(color.r, color.g, color.b); | ||||
89 | var d = max - min; | ||||
90 | var h; | ||||
91 | var s = (max === 0 ? 0 : d / max); | ||||
92 | var v = max / 255; | ||||
93 | | ||||
94 | switch (max) { | ||||
95 | case min: | ||||
96 | h = 0; | ||||
97 | break; | ||||
98 | case color.r: | ||||
99 | h = (color.g - color.b) + d * (color.g < color.b ? 6: 0); | ||||
100 | h /= 6 * d; | ||||
101 | break; | ||||
102 | case color.g: | ||||
103 | h = (color.b - color.r) + d * 2; h /= 6 * d; | ||||
104 | break; | ||||
105 | case color.b: | ||||
106 | h = (color.r - color.g) + d * 4; h /= 6 * d; | ||||
107 | break; | ||||
108 | } | ||||
109 | | ||||
110 | return { | ||||
111 | h: h, | ||||
112 | s: s, | ||||
113 | v: v | ||||
114 | }; | ||||
115 | } | ||||
116 | | ||||
83 | Rectangle { | 117 | Rectangle { | ||
118 | id: backgroundRect | ||||
84 | anchors.fill: parent | 119 | anchors.fill: parent | ||
85 | color: PlasmaCore.ColorScope.backgroundColor | 120 | //use "black" because this is intended to look like a general darkening of the scene. a dark gray as normal background would just look too "washed out" | ||
121 | color: root.rgbToHsv(PlasmaCore.ColorScope.backgroundColor).v > 128 ? PlasmaCore.ColorScope.backgroundColor : "black" | ||||
86 | opacity: 0.5 | 122 | opacity: 0.5 | ||
87 | } | 123 | } | ||
88 | MouseArea { | 124 | MouseArea { | ||
89 | anchors.fill: parent | 125 | anchors.fill: parent | ||
90 | onClicked: root.cancelRequested() | 126 | onClicked: root.cancelRequested() | ||
91 | } | 127 | } | ||
92 | UserDelegate { | 128 | UserDelegate { | ||
93 | width: units.iconSizes.enormous | 129 | width: units.iconSizes.enormous | ||
▲ Show 20 Lines • Show All 56 Lines • ▼ Show 20 Line(s) | 181 | LogoutButton { | |||
150 | KeyNavigation.left: shutdownButton | 186 | KeyNavigation.left: shutdownButton | ||
151 | KeyNavigation.right: suspendButton | 187 | KeyNavigation.right: suspendButton | ||
152 | focus: sdtype == ShutdownType.ShutdownTypeNone | 188 | focus: sdtype == ShutdownType.ShutdownTypeNone | ||
153 | } | 189 | } | ||
154 | } | 190 | } | ||
155 | 191 | | |||
156 | PlasmaComponents.Label { | 192 | PlasmaComponents.Label { | ||
157 | Layout.alignment: Qt.AlignHCenter | 193 | Layout.alignment: Qt.AlignHCenter | ||
194 | //opacity, as visible would re-layout | ||||
195 | opacity: countDownTimer.running ? 1 : 0 | ||||
196 | Behavior on opacity { | ||||
197 | OpacityAnimator { | ||||
198 | duration: units.longDuration | ||||
199 | easing.type: Easing.InOutQuad | ||||
200 | } | ||||
201 | } | ||||
158 | text: { | 202 | text: { | ||
159 | switch (sdtype) { | 203 | switch (sdtype) { | ||
160 | case ShutdownType.ShutdownTypeReboot: | 204 | case ShutdownType.ShutdownTypeReboot: | ||
161 | return i18ndp("plasma_lookandfeel_org.kde.lookandfeel", "Reboot in 1 second", "Reboot in %1 seconds", root.remainingTime); | 205 | return i18ndp("plasma_lookandfeel_org.kde.lookandfeel", "Reboot in 1 second", "Reboot in %1 seconds", root.remainingTime); | ||
162 | case ShutdownType.ShutdownTypeHalt: | 206 | case ShutdownType.ShutdownTypeHalt: | ||
163 | return i18ndp("plasma_lookandfeel_org.kde.lookandfeel", "Shutting down in 1 second", "Shutting down in %1 seconds", root.remainingTime); | 207 | return i18ndp("plasma_lookandfeel_org.kde.lookandfeel", "Shutting down in 1 second", "Shutting down in %1 seconds", root.remainingTime); | ||
164 | default: | 208 | default: | ||
165 | return i18ndp("plasma_lookandfeel_org.kde.lookandfeel", "Logging out in 1 second", "Logging out in %1 seconds", root.remainingTime); | 209 | return i18ndp("plasma_lookandfeel_org.kde.lookandfeel", "Logging out in 1 second", "Logging out in %1 seconds", root.remainingTime); | ||
166 | } | 210 | } | ||
167 | } | 211 | } | ||
168 | } | 212 | } | ||
169 | 213 | | |||
170 | PlasmaComponents.Button { | 214 | RowLayout { | ||
171 | Layout.alignment: Qt.AlignHCenter | 215 | Layout.alignment: Qt.AlignHCenter | ||
216 | PlasmaComponents.Button { | ||||
217 | enabled: root.currentAction != null | ||||
218 | text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "OK") | ||||
broulik: Isn't it "OK"? | |||||
219 | onClicked: root.currentAction() | ||||
220 | } | ||||
221 | PlasmaComponents.Button { | ||||
172 | text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Cancel") | 222 | text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Cancel") | ||
173 | onClicked: root.cancelRequested() | 223 | onClicked: root.cancelRequested() | ||
174 | } | 224 | } | ||
175 | } | 225 | } | ||
176 | } | 226 | } | ||
227 | } |
I think that's unused now