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.Window 2.2 | ||||
broulik: I think that's unused now | |||||
21 | import QtQuick.Layouts 1.2 | 22 | import QtQuick.Layouts 1.2 | ||
22 | import QtQuick.Controls 1.1 as Controls | 23 | import QtQuick.Controls 1.1 as Controls | ||
23 | 24 | | |||
24 | import org.kde.plasma.core 2.0 as PlasmaCore | 25 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
25 | import org.kde.plasma.components 2.0 as PlasmaComponents | 26 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
26 | import org.kde.kcoreaddons 1.0 as KCoreAddons | 27 | import org.kde.kcoreaddons 1.0 as KCoreAddons | ||
27 | 28 | | |||
28 | import "../components" | 29 | import "../components" | ||
29 | 30 | | |||
30 | PlasmaCore.ColorScope { | 31 | PlasmaCore.ColorScope { | ||
31 | id: root | 32 | id: root | ||
32 | colorGroup: PlasmaCore.Theme.ComplementaryColorGroup | 33 | colorGroup: PlasmaCore.Theme.ComplementaryColorGroup | ||
33 | height: screenGeometry.height | 34 | height: screenGeometry.height | ||
34 | width: screenGeometry.width | 35 | width: screenGeometry.width | ||
35 | 36 | | |||
36 | signal logoutRequested() | 37 | signal logoutRequested() | ||
37 | signal haltRequested() | 38 | signal haltRequested() | ||
38 | signal suspendRequested(int spdMethod) | 39 | signal suspendRequested(int spdMethod) | ||
39 | signal rebootRequested() | 40 | signal rebootRequested() | ||
40 | signal rebootRequested2(int opt) | 41 | signal rebootRequested2(int opt) | ||
41 | signal cancelRequested() | 42 | signal cancelRequested() | ||
42 | signal lockScreenRequested() | 43 | signal lockScreenRequested() | ||
43 | 44 | | |||
45 | property alias backgroundColor: backgroundRect.color | ||||
46 | | ||||
44 | function sleepRequested() { | 47 | function sleepRequested() { | ||
45 | root.suspendRequested(2); | 48 | root.suspendRequested(2); | ||
46 | } | 49 | } | ||
47 | 50 | | |||
48 | property real timeout: 30 | 51 | property real timeout: 30 | ||
49 | property real remainingTime: root.timeout | 52 | property real remainingTime: root.timeout | ||
50 | property var currentAction: { | 53 | property var currentAction: { | ||
51 | switch (sdtype) { | 54 | 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: | 55 | case ShutdownType.ShutdownTypeReboot: | ||
53 | return root.rebootRequested; | 56 | return root.rebootRequested; | ||
54 | case ShutdownType.ShutdownTypeHalt: | 57 | case ShutdownType.ShutdownTypeHalt: | ||
55 | return root.haltRequested; | 58 | return root.haltRequested; | ||
56 | default: | 59 | default: | ||
57 | return root.logoutRequested; | 60 | return root.logoutRequested; | ||
58 | } | 61 | } | ||
59 | } | 62 | } | ||
Show All 9 Lines | |||||
69 | 72 | | |||
70 | onRemainingTimeChanged: { | 73 | onRemainingTimeChanged: { | ||
71 | if (remainingTime <= 0) { | 74 | if (remainingTime <= 0) { | ||
72 | root.currentAction(); | 75 | root.currentAction(); | ||
73 | } | 76 | } | ||
74 | } | 77 | } | ||
75 | 78 | | |||
76 | Timer { | 79 | Timer { | ||
80 | id: countDownTimer | ||||
77 | running: true | 81 | running: true | ||
78 | repeat: true | 82 | repeat: true | ||
79 | interval: 1000 | 83 | interval: 1000 | ||
80 | onTriggered: remainingTime-- | 84 | onTriggered: remainingTime-- | ||
81 | } | 85 | } | ||
82 | 86 | | |||
87 | function rgbToHsv(color) { | ||||
broulik: Urgh. Can you add a TODO for Qt 5.8 :) | |||||
88 | var max = Math.max(color.r, color.g, color.b); | ||||
89 | var min = Math.min(color.r, color.g, color.b); | ||||
90 | var d = max - min; | ||||
91 | var h; | ||||
92 | var s = (max === 0 ? 0 : d / max); | ||||
93 | var v = max / 255; | ||||
94 | | ||||
95 | switch (max) { | ||||
96 | case min: | ||||
97 | h = 0; | ||||
98 | break; | ||||
99 | case color.r: | ||||
100 | h = (color.g - color.b) + d * (color.g < color.b ? 6: 0); | ||||
101 | h /= 6 * d; | ||||
102 | break; | ||||
103 | case color.g: | ||||
104 | h = (color.b - color.r) + d * 2; h /= 6 * d; | ||||
105 | break; | ||||
106 | case color.b: | ||||
107 | h = (color.r - color.g) + d * 4; h /= 6 * d; | ||||
108 | break; | ||||
109 | } | ||||
110 | | ||||
111 | return { | ||||
112 | h: h, | ||||
113 | s: s, | ||||
114 | v: v | ||||
115 | }; | ||||
116 | } | ||||
117 | | ||||
83 | Rectangle { | 118 | Rectangle { | ||
119 | id: backgroundRect | ||||
84 | anchors.fill: parent | 120 | anchors.fill: parent | ||
85 | color: PlasmaCore.ColorScope.backgroundColor | 121 | //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" | ||
122 | color: root.rgbToHsv(PlasmaCore.ColorScope.backgroundColor).v > 128 ? PlasmaCore.ColorScope.backgroundColor : "black" | ||||
86 | opacity: 0.5 | 123 | opacity: 0.5 | ||
87 | } | 124 | } | ||
88 | MouseArea { | 125 | MouseArea { | ||
89 | anchors.fill: parent | 126 | anchors.fill: parent | ||
90 | onClicked: root.cancelRequested() | 127 | onClicked: root.cancelRequested() | ||
91 | } | 128 | } | ||
92 | UserDelegate { | 129 | UserDelegate { | ||
93 | width: units.iconSizes.enormous | 130 | width: units.iconSizes.enormous | ||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | 181 | LogoutButton { | |||
149 | KeyNavigation.left: shutdownButton | 186 | KeyNavigation.left: shutdownButton | ||
150 | KeyNavigation.right: suspendButton | 187 | KeyNavigation.right: suspendButton | ||
151 | focus: sdtype == ShutdownType.ShutdownTypeNone | 188 | focus: sdtype == ShutdownType.ShutdownTypeNone | ||
152 | } | 189 | } | ||
153 | } | 190 | } | ||
154 | 191 | | |||
155 | PlasmaComponents.Label { | 192 | PlasmaComponents.Label { | ||
156 | 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 | } | ||||
157 | text: { | 202 | text: { | ||
158 | switch (sdtype) { | 203 | switch (sdtype) { | ||
159 | case ShutdownType.ShutdownTypeReboot: | 204 | case ShutdownType.ShutdownTypeReboot: | ||
160 | 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); | ||
161 | case ShutdownType.ShutdownTypeHalt: | 206 | case ShutdownType.ShutdownTypeHalt: | ||
162 | 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); | ||
163 | default: | 208 | default: | ||
164 | 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); | ||
165 | } | 210 | } | ||
166 | } | 211 | } | ||
167 | } | 212 | } | ||
168 | 213 | | |||
169 | PlasmaComponents.Button { | 214 | RowLayout { | ||
170 | 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 { | ||||
171 | text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Cancel") | 222 | text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Cancel") | ||
172 | onClicked: root.cancelRequested() | 223 | onClicked: root.cancelRequested() | ||
173 | } | 224 | } | ||
174 | } | 225 | } | ||
175 | } | 226 | } | ||
227 | } |
I think that's unused now