diff --git a/sddm-theme/Login.qml b/sddm-theme/Login.qml --- a/sddm-theme/Login.qml +++ b/sddm-theme/Login.qml @@ -12,6 +12,10 @@ property string lastUserName + //the y position that should be ensured visible when the on screen keyboard is visible + property int visibleBoundary: mapFromItem(loginButton, 0, 0).y + onHeightChanged: visibleBoundary = mapFromItem(loginButton, 0, 0).y + loginButton.height + units.smallSpacing + signal loginRequest(string username, string password) onShowUsernamePromptChanged: { diff --git a/sddm-theme/Main.qml b/sddm-theme/Main.qml --- a/sddm-theme/Main.qml +++ b/sddm-theme/Main.qml @@ -64,119 +64,211 @@ } - ColumnLayout { + StackView { + id: mainStack anchors { - top: parent.top - bottom: footer.top left: parent.left right: parent.right - topMargin: footer.height // effectively centre align within the view } - StackView { - id: mainStack - Layout.fillWidth: true - Layout.fillHeight: true - 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() - } + 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 true + 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 + if ( userListModel.count == 0 ) return false - return userListModel.count <= userListModel.disableAvatarsThreshold - } + 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 } + 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","Shutdown") - onClicked: sddm.powerOff() - enabled: sddm.canPowerOff - visible: !inputPanel.keyboardActive - }, - ActionButton { - iconSource: "system-search" - 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) + 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","Shutdown") + onClicked: sddm.powerOff() + enabled: sddm.canPowerOff + visible: !inputPanel.keyboardActive + }, + ActionButton { + iconSource: "system-search" + 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) } + } - Behavior on opacity { - OpacityAnimator { - duration: units.longDuration - } + Behavior on opacity { + OpacityAnimator { + duration: units.longDuration } } + } - Loader { - id: inputPanel - property bool keyboardActive: item ? item.active : false - source: "components/VirtualKeyboard.qml" - Layout.fillWidth: true - Layout.preferredHeight: (item && item.active) ? item.implicitHeight : 0 - function showHide() { - if (Qt.inputMethod.visible) { - Qt.inputMethod.hide(); - } else { - item.activated = true; - Qt.inputMethod.show(); - } + 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"; + } + + 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(); + } + } + 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 + } + } + } + }, + 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 + } + } + ScriptAction { + script: { + Qt.inputMethod.hide(); + } + } + } + } + ] } + Component { id: userPromptComponent Login {