Changeset View
Changeset View
Standalone View
Standalone View
lookandfeel/contents/logout/Logout.qml
Show First 20 Lines • Show All 77 Lines • ▼ Show 20 Line(s) | 30 | PlasmaCore.ColorScope { | |||
---|---|---|---|---|---|
78 | Timer { | 78 | Timer { | ||
79 | id: countDownTimer | 79 | id: countDownTimer | ||
80 | running: true | 80 | running: true | ||
81 | repeat: true | 81 | repeat: true | ||
82 | interval: 1000 | 82 | interval: 1000 | ||
83 | onTriggered: remainingTime-- | 83 | onTriggered: remainingTime-- | ||
84 | } | 84 | } | ||
85 | 85 | | |||
86 | function rgbToHsv(color) { | 86 | function isLightColor(color) { | ||
87 | var max = Math.max(color.r, color.g, color.b); | 87 | return Math.max(color.r, color.g, color.b) > 0.5 | ||
mart: the method lattes is using 0.2126*r + 0.7152*g + 0.0722*b is more correct
(a simple one would… | |||||
qGray() uses an integer approximation that is only correct for CRT monitors. fredrik: qGray() uses an integer approximation that is only correct for CRT monitors. | |||||
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 | } | 88 | } | ||
116 | 89 | | |||
117 | Rectangle { | 90 | Rectangle { | ||
118 | id: backgroundRect | 91 | id: backgroundRect | ||
119 | anchors.fill: parent | 92 | anchors.fill: parent | ||
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" | 93 | //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" | 94 | color: root.isLightColor(PlasmaCore.ColorScope.backgroundColor) ? PlasmaCore.ColorScope.backgroundColor : "black" | ||
122 | opacity: 0.5 | 95 | opacity: 0.5 | ||
123 | } | 96 | } | ||
124 | MouseArea { | 97 | MouseArea { | ||
125 | anchors.fill: parent | 98 | anchors.fill: parent | ||
126 | onClicked: root.cancelRequested() | 99 | onClicked: root.cancelRequested() | ||
127 | } | 100 | } | ||
128 | UserDelegate { | 101 | UserDelegate { | ||
129 | width: units.iconSizes.enormous | 102 | width: units.iconSizes.enormous | ||
▲ Show 20 Lines • Show All 102 Lines • Show Last 20 Lines |
the method lattes is using 0.2126*r + 0.7152*g + 0.0722*b is more correct
(a simple one would be convertin to gray scale with qGray, but unfortunately is C++ only)