diff --git a/lookandfeel/contents/components/ActionButton.qml b/lookandfeel/contents/components/ActionButton.qml --- a/lookandfeel/contents/components/ActionButton.qml +++ b/lookandfeel/contents/components/ActionButton.qml @@ -18,15 +18,18 @@ */ import QtQuick 2.2 +import QtGraphicalEffects 1.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.plasma.extras 2.0 as PlasmaExtras Item { id: root property alias text: label.text property alias iconSource: icon.source property alias containsMouse: mouseArea.containsMouse property alias font: label.font + property alias labelShadow: labelShadow.visible signal clicked activeFocusOnTab: true @@ -48,6 +51,19 @@ colorGroup: PlasmaCore.ColorScope.colorGroup active: mouseArea.containsMouse || root.activeFocus } + + DropShadow { + id: labelShadow + visible: false + anchors.fill: label + source: label + horizontalOffset: 0 + verticalOffset: 1 + radius: 12 + samples: 32 + spread: 0.35 + color: PlasmaCore.ColorScope.backgroundColor + } PlasmaComponents.Label { id: label anchors { diff --git a/sddm-theme/Main.qml b/sddm-theme/Main.qml --- a/sddm-theme/Main.qml +++ b/sddm-theme/Main.qml @@ -62,308 +62,268 @@ } } - MouseArea { - id: loginScreenRoot - anchors.fill: parent + Clock { + id: clock + visible: y > 0 + y: (userListComponent.userList.y + mainStack.y)/2 - height/2 + anchors.horizontalCenter: parent.horizontalCenter + } - property bool uiVisible: true - property bool blockUI: mainStack.depth > 1 || userListComponent.mainPasswordBox.text.length > 0 || inputPanel.keyboardActive || config.type != "image" - - hoverEnabled: true - drag.filterChildren: true - onPressed: uiVisible = true; - onPositionChanged: uiVisible = true; - onUiVisibleChanged: { - if (blockUI) { - fadeoutTimer.running = false; - } else if (uiVisible) { - fadeoutTimer.restart(); - } - } - onBlockUIChanged: { - if (blockUI) { - fadeoutTimer.running = false; - uiVisible = true; - } else { - fadeoutTimer.restart(); - } + + StackView { + id: mainStack + anchors { + left: parent.left + right: parent.right } + height: root.height + + focus: true //StackView is an implicit focus scope, so we need to give this focus so the item inside will have it - //takes one full minute for the ui to disappear Timer { - id: fadeoutTimer + //SDDM has a bug in 0.13 where even though we set the focus on the right item within the window, the window doesn't have focus + //it is fixed in 6d5b36b28907b16280ff78995fef764bb0c573db which will be 0.14 + //we need to call "window->activate()" *After* it's been shown. We can't control that in QML so we use a shoddy timer + //it's been this way for all Plasma 5.x without a huge problem running: true - interval: 60000 - onTriggered: { - if (!loginScreenRoot.blockUI) { - loginScreenRoot.uiVisible = false; - } - } - } - WallpaperFader { - visible: config.type == "image" - anchors.fill: parent - state: loginScreenRoot.uiVisible ? "on" : "off" - source: wallpaper - mainStack: mainStack - footer: footer - clock: clock + repeat: false + interval: 200 + onTriggered: mainStack.forceActiveFocus() } - Clock { - id: clock - visible: y > 0 - y: (userListComponent.userList.y + mainStack.y)/2 - height/2 - anchors.horizontalCenter: parent.horizontalCenter - } + initialItem: Login { + id: userListComponent + userListModel: userModel + userListCurrentIndex: userModel.lastIndex >= 0 ? userModel.lastIndex : 0 + lastUserName: userModel.lastUser + showUserList: { + if ( !userListModel.hasOwnProperty("count") + || !userListModel.hasOwnProperty("disableAvatarsThreshold")) + return (userList.y + mainStack.y) > 0 + if ( userListModel.count == 0 ) return false - StackView { - id: mainStack - anchors { - left: parent.left - right: parent.right + return userListModel.count <= userListModel.disableAvatarsThreshold && (userList.y + mainStack.y) > 0 } - height: root.height - - focus: true //StackView is an implicit focus scope, so we need to give this focus so the item inside will have it - - Timer { - //SDDM has a bug in 0.13 where even though we set the focus on the right item within the window, the window doesn't have focus - //it is fixed in 6d5b36b28907b16280ff78995fef764bb0c573db which will be 0.14 - //we need to call "window->activate()" *After* it's been shown. We can't control that in QML so we use a shoddy timer - //it's been this way for all Plasma 5.x without a huge problem - running: true - repeat: false - interval: 200 - onTriggered: mainStack.forceActiveFocus() - } - - initialItem: Login { - id: userListComponent - userListModel: userModel - userListCurrentIndex: userModel.lastIndex >= 0 ? userModel.lastIndex : 0 - lastUserName: userModel.lastUser - showUserList: { - if ( !userListModel.hasOwnProperty("count") - || !userListModel.hasOwnProperty("disableAvatarsThreshold")) - return (userList.y + mainStack.y) > 0 - - if ( userListModel.count == 0 ) return false - - return userListModel.count <= userListModel.disableAvatarsThreshold && (userList.y + mainStack.y) > 0 - } - notificationMessage: { - var text = "" - if (keystateSource.data["Caps Lock"]["Locked"]) { - text += i18nd("plasma_lookandfeel_org.kde.lookandfeel","Caps Lock is on") - if (root.notificationMessage) { - text += " • " - } + notificationMessage: { + var text = "" + if (keystateSource.data["Caps Lock"]["Locked"]) { + text += i18nd("plasma_lookandfeel_org.kde.lookandfeel","Caps Lock is on") + if (root.notificationMessage) { + text += " • " } - text += root.notificationMessage - return text - } - - actionItems: [ - ActionButton { - iconSource: "system-suspend" - text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Suspend") - onClicked: sddm.suspend() - enabled: sddm.canSuspend - visible: !inputPanel.keyboardActive - }, - ActionButton { - iconSource: "system-reboot" - text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Restart") - onClicked: sddm.reboot() - enabled: sddm.canReboot - visible: !inputPanel.keyboardActive - }, - ActionButton { - iconSource: "system-shutdown" - text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Shut Down") - onClicked: sddm.powerOff() - enabled: sddm.canPowerOff - visible: !inputPanel.keyboardActive - }, - ActionButton { - iconSource: "system-switch-user" - text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Different User") - onClicked: mainStack.push(userPromptComponent) - enabled: true - visible: !userListComponent.showUsernamePrompt && !inputPanel.keyboardActive - }] - - onLoginRequest: { - root.notificationMessage = "" - sddm.login(username, password, sessionButton.currentIndex) } + text += root.notificationMessage + return text } - Behavior on opacity { - OpacityAnimator { - duration: units.longDuration - } + actionItems: [ + ActionButton { + iconSource: "system-suspend-translucent" + text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Suspend") + labelShadow: true + onClicked: sddm.suspend() + enabled: sddm.canSuspend + visible: !inputPanel.keyboardActive + }, + ActionButton { + iconSource: "system-reboot-translucent" + text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Restart") + labelShadow: true + onClicked: sddm.reboot() + enabled: sddm.canReboot + visible: !inputPanel.keyboardActive + }, + ActionButton { + iconSource: "system-shutdown-translucent" + text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Shut Down") + labelShadow: true + onClicked: sddm.powerOff() + enabled: sddm.canPowerOff + visible: !inputPanel.keyboardActive + }, + ActionButton { + iconSource: "system-switch-user-translucent" + text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Different User") + labelShadow: true + onClicked: mainStack.push(userPromptComponent) + enabled: true + visible: !userListComponent.showUsernamePrompt && !inputPanel.keyboardActive + }] + + onLoginRequest: { + root.notificationMessage = "" + sddm.login(username, password, sessionButton.currentIndex) } } + } - Loader { - id: inputPanel - state: "hidden" - property bool keyboardActive: item ? item.active : false - onKeyboardActiveChanged: { - if (keyboardActive) { - state = "visible" - } else { - state = "hidden"; - } - } - source: "components/VirtualKeyboard.qml" - anchors { - left: parent.left - right: parent.right + Loader { + id: inputPanel + state: "hidden" + property bool keyboardActive: item ? item.active : false + onKeyboardActiveChanged: { + if (keyboardActive) { + state = "visible" + } else { + state = "hidden"; } + } + source: "components/VirtualKeyboard.qml" + anchors { + left: parent.left + right: parent.right + } - function showHide() { - state = state == "hidden" ? "visible" : "hidden"; - } + function showHide() { + state = state == "hidden" ? "visible" : "hidden"; + } - states: [ - State { - name: "visible" - PropertyChanges { - target: mainStack - y: Math.min(0, root.height - inputPanel.height - userListComponent.visibleBoundary) - } - PropertyChanges { - target: inputPanel - y: root.height - inputPanel.height - opacity: 1 - } - }, - State { - name: "hidden" - PropertyChanges { - target: mainStack - y: 0 + states: [ + State { + name: "visible" + PropertyChanges { + target: mainStack + y: Math.min(0, root.height - inputPanel.height - userListComponent.visibleBoundary) + } + PropertyChanges { + target: inputPanel + y: root.height - inputPanel.height + opacity: 1 + } + }, + State { + name: "hidden" + PropertyChanges { + target: mainStack + y: 0 + } + PropertyChanges { + target: inputPanel + y: root.height - root.height/4 + opacity: 0 + } + } + ] + transitions: [ + Transition { + from: "hidden" + to: "visible" + SequentialAnimation { + ScriptAction { + script: { + inputPanel.item.activated = true; + Qt.inputMethod.show(); + } } - PropertyChanges { - target: inputPanel - y: root.height - root.height/4 - opacity: 0 + ParallelAnimation { + NumberAnimation { + target: mainStack + property: "y" + duration: units.longDuration + easing.type: Easing.InOutQuad + } + NumberAnimation { + target: inputPanel + property: "y" + duration: units.longDuration + easing.type: Easing.OutQuad + } + OpacityAnimator { + target: inputPanel + duration: units.longDuration + easing.type: Easing.OutQuad + } } } - ] - transitions: [ - Transition { - from: "hidden" - to: "visible" - SequentialAnimation { - ScriptAction { - script: { - inputPanel.item.activated = true; - Qt.inputMethod.show(); - } + }, + Transition { + from: "visible" + to: "hidden" + SequentialAnimation { + ParallelAnimation { + NumberAnimation { + target: mainStack + property: "y" + duration: units.longDuration + easing.type: Easing.InOutQuad } - ParallelAnimation { - NumberAnimation { - target: mainStack - property: "y" - duration: units.longDuration - easing.type: Easing.InOutQuad - } - NumberAnimation { - target: inputPanel - property: "y" - duration: units.longDuration - easing.type: Easing.OutQuad - } - OpacityAnimator { - target: inputPanel - duration: units.longDuration - easing.type: Easing.OutQuad - } + NumberAnimation { + target: inputPanel + property: "y" + duration: units.longDuration + easing.type: Easing.InQuad } - } - }, - Transition { - from: "visible" - to: "hidden" - SequentialAnimation { - ParallelAnimation { - NumberAnimation { - target: mainStack - property: "y" - duration: units.longDuration - easing.type: Easing.InOutQuad - } - NumberAnimation { - target: inputPanel - property: "y" - duration: units.longDuration - easing.type: Easing.InQuad - } - OpacityAnimator { - target: inputPanel - duration: units.longDuration - easing.type: Easing.InQuad - } + OpacityAnimator { + target: inputPanel + duration: units.longDuration + easing.type: Easing.InQuad } - ScriptAction { - script: { - Qt.inputMethod.hide(); - } + } + ScriptAction { + script: { + Qt.inputMethod.hide(); } } } - ] - } + } + ] + } + Component { + id: userPromptComponent + Login { + showUsernamePrompt: true + notificationMessage: root.notificationMessage - Component { - id: userPromptComponent - Login { - showUsernamePrompt: true - notificationMessage: root.notificationMessage + userListModel: QtObject { + property string name: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Log in as a different user") + property string iconSource: "" + } - userListModel: QtObject { - property string name: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Log in as a different user") - property string iconSource: "" - } + onLoginRequest: { + root.notificationMessage = "" + sddm.login(username, password, sessionButton.currentIndex) + } - onLoginRequest: { - root.notificationMessage = "" - sddm.login(username, password, sessionButton.currentIndex) + actionItems: [ + ActionButton { + iconSource: "go-previous-translucent" + text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Back") + onClicked: mainStack.pop() + labelShadow: true } + ] + } + } - actionItems: [ - ActionButton { - iconSource: "go-previous" - text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Back") - onClicked: mainStack.pop() - } - ] + //Footer + Rectangle { + id: footer + anchors { + bottom: parent.bottom + left: parent.left + right: parent.right + } + height: footerLayout.implicitHeight + (units.smallSpacing * 2) + + color: PlasmaCore.ColorScope.backgroundColor + opacity: 0.9 + + Behavior on opacity { + OpacityAnimator { + duration: units.longDuration } } - //Footer RowLayout { - id: footer + id: footerLayout anchors { - bottom: parent.bottom - left: parent.left - right: parent.right + fill: parent margins: units.smallSpacing } - Behavior on opacity { - OpacityAnimator { - duration: units.longDuration - } - } - PlasmaComponents.ToolButton { text: i18ndc("plasma_lookandfeel_org.kde.lookandfeel", "Button to show/hide virtual keyboard", "Virtual Keyboard") iconName: inputPanel.keyboardActive ? "input-keyboard-virtual-on" : "input-keyboard-virtual-off"