From 5f2f343ef6a31702af6e71f6aee6b76a94d953d3 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 22 Mar 2017 11:32:49 +0100 Subject: [PATCH] UI fixes for logout dialog Summary: * use backgroundcontrast effect, improves readability a lot * non-current actions a bit more translucent * background is actually black if the color scheme is dark, looks washed out otherwise * add an OK button, that was complained a lot * short fade animation at the beginning Test Plan: see screenshot Reviewers: #plasma, sebas, broulik Reviewed By: #plasma, broulik Subscribers: graesslin, broulik, plasma-devel Tags: #plasma Differential Revision: https://phabricator.kde.org/D5036 --- ksmserver/shutdowndlg.cpp | 8 +++ lookandfeel/contents/logout/Logout.qml | 61 ++++++++++++++++++-- lookandfeel/contents/logout/LogoutButton.qml | 3 +- 3 files changed, 66 insertions(+), 6 deletions(-) diff --git a/ksmserver/shutdowndlg.cpp b/ksmserver/shutdowndlg.cpp index c69f577af..466d1a561 100644 --- a/ksmserver/shutdowndlg.cpp +++ b/ksmserver/shutdowndlg.cpp @@ -191,6 +191,14 @@ void KSMShutdownDlg::init() setGeometry(screen()->geometry()); }); + //decide in backgroundcontrast wether doing things darker or lighter + //set backgroundcontrast here, because in QEvent::PlatformSurface + //is too early and we don't have the root object yet + const QColor backgroundColor = rootObject() ? rootObject()->property("backgroundColor").value() : QColor(); + KWindowEffects::enableBackgroundContrast(winId(), true, + 0.4, + (backgroundColor.value() > 128 ? 1.6 : 0.3), + 1.7); QQuickView::showFullScreen(); requestActivate(); diff --git a/lookandfeel/contents/logout/Logout.qml b/lookandfeel/contents/logout/Logout.qml index 839c390fb..b736e77d6 100644 --- a/lookandfeel/contents/logout/Logout.qml +++ b/lookandfeel/contents/logout/Logout.qml @@ -41,10 +41,12 @@ PlasmaCore.ColorScope { signal cancelRequested() signal lockScreenRequested() + property alias backgroundColor: backgroundRect.color + function sleepRequested() { root.suspendRequested(2); } - + property real timeout: 30 property real remainingTime: root.timeout property var currentAction: { @@ -74,15 +76,49 @@ PlasmaCore.ColorScope { } Timer { + id: countDownTimer running: true repeat: true interval: 1000 onTriggered: remainingTime-- } + function rgbToHsv(color) { + var max = Math.max(color.r, color.g, color.b); + var min = Math.min(color.r, color.g, color.b); + var d = max - min; + var h; + var s = (max === 0 ? 0 : d / max); + var v = max / 255; + + switch (max) { + case min: + h = 0; + break; + case color.r: + h = (color.g - color.b) + d * (color.g < color.b ? 6: 0); + h /= 6 * d; + break; + case color.g: + h = (color.b - color.r) + d * 2; h /= 6 * d; + break; + case color.b: + h = (color.r - color.g) + d * 4; h /= 6 * d; + break; + } + + return { + h: h, + s: s, + v: v + }; + } + Rectangle { + id: backgroundRect anchors.fill: parent - color: PlasmaCore.ColorScope.backgroundColor + //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" + color: root.rgbToHsv(PlasmaCore.ColorScope.backgroundColor).v > 128 ? PlasmaCore.ColorScope.backgroundColor : "black" opacity: 0.5 } MouseArea { @@ -155,6 +191,14 @@ PlasmaCore.ColorScope { PlasmaComponents.Label { Layout.alignment: Qt.AlignHCenter + //opacity, as visible would re-layout + opacity: countDownTimer.running ? 1 : 0 + Behavior on opacity { + OpacityAnimator { + duration: units.longDuration + easing.type: Easing.InOutQuad + } + } text: { switch (sdtype) { case ShutdownType.ShutdownTypeReboot: @@ -167,10 +211,17 @@ PlasmaCore.ColorScope { } } - PlasmaComponents.Button { + RowLayout { Layout.alignment: Qt.AlignHCenter - text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Cancel") - onClicked: root.cancelRequested() + PlasmaComponents.Button { + enabled: root.currentAction != null + text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "OK") + onClicked: root.currentAction() + } + PlasmaComponents.Button { + text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Cancel") + onClicked: root.cancelRequested() + } } } } diff --git a/lookandfeel/contents/logout/LogoutButton.qml b/lookandfeel/contents/logout/LogoutButton.qml index 4c92657e7..cd7f9c9d8 100644 --- a/lookandfeel/contents/logout/LogoutButton.qml +++ b/lookandfeel/contents/logout/LogoutButton.qml @@ -28,11 +28,12 @@ ActionButton { property var action onClicked: action() iconSize: units.iconSizes.huge - opacity: activeFocus || containsMouse ? 1 : 0.6 + opacity: activeFocus || containsMouse ? 1 : 0.5 Behavior on opacity { OpacityAnimator { duration: units.longDuration easing.type: Easing.InOutQuad } } + Keys.onPressed: countDownTimer.running = false }