diff --git a/lookandfeel/contents/components/Clock.qml b/lookandfeel/contents/components/Clock.qml index 395f2bd47..fc7cf94a9 100644 --- a/lookandfeel/contents/components/Clock.qml +++ b/lookandfeel/contents/components/Clock.qml @@ -1,44 +1,46 @@ /* * Copyright 2016 David Edmundson * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.0 import QtQuick.Layouts 1.1 import org.kde.plasma.core 2.0 import org.kde.plasma.components 2.0 ColumnLayout { Label { text: Qt.formatTime(timeSource.data["Local"]["DateTime"]) - font.pointSize: 32 //Mockup says this, I'm not sure what to do? + font.pointSize: 48 //Mockup says this, I'm not sure what to do? + font.weight: Font.Light Layout.alignment: Qt.AlignHCenter renderType: Text.QtRendering } Label { text: Qt.formatDate(timeSource.data["Local"]["DateTime"], Qt.DefaultLocaleLongDate) - font.pointSize: 18 + font.pointSize: 24 + font.weight: Font.Light Layout.alignment: Qt.AlignHCenter } DataSource { id: timeSource engine: "time" connectedSources: ["Local"] interval: 1000 } } diff --git a/lookandfeel/contents/components/SessionManagementScreen.qml b/lookandfeel/contents/components/SessionManagementScreen.qml index 45b8315db..e078140b4 100644 --- a/lookandfeel/contents/components/SessionManagementScreen.qml +++ b/lookandfeel/contents/components/SessionManagementScreen.qml @@ -1,119 +1,118 @@ /* * Copyright 2016 David Edmundson * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.2 import QtQuick.Layouts 1.1 import QtQuick.Controls 1.1 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents Item { id: root /* * Any message to be displayed to the user, visible above the text fields */ property alias notificationMessage: notificationsLabel.text /* * A list of Items (typically ActionButtons) to be shown in a Row beneath the prompts */ property alias actionItems: actionItemsLayout.children /* * A model with a list of users to show in the view * The following roles should exist: * - name * - iconSource * * The following are also handled: * - vtNumber * - displayNumber * - session * - isTty */ property alias userListModel: userListView.model /* * Self explanatory */ property alias userListCurrentIndex: userListView.currentIndex property var userListCurrentModelData: userListView.currentItem === null ? [] : userListView.currentItem.m property bool showUserList: true property alias userList: userListView default property alias _children: innerLayout.children - UserList { id: userListView visible: showUserList && y > 0 anchors { bottom: parent.verticalCenter left: parent.left right: parent.right } } //goal is to show the prompts, in ~16 grid units high, then the action buttons //but collapse the space between the prompts and actions if there's no room //ui is constrained to 16 grid units wide, or the screen ColumnLayout { id: prompts anchors.top: parent.verticalCenter anchors.topMargin: units.gridUnit * 0.5 anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom PlasmaComponents.Label { id: notificationsLabel Layout.maximumWidth: units.gridUnit * 16 Layout.alignment: Qt.AlignHCenter Layout.fillWidth: true horizontalAlignment: Text.AlignHCenter wrapMode: Text.WordWrap font.italic: true } ColumnLayout { Layout.minimumHeight: implicitHeight Layout.maximumHeight: units.gridUnit * 10 Layout.maximumWidth: units.gridUnit * 16 Layout.alignment: Qt.AlignHCenter ColumnLayout { id: innerLayout Layout.alignment: Qt.AlignHCenter Layout.fillWidth: true } Item { Layout.fillHeight: true } } Row { //deliberately not rowlayout as I'm not trying to resize child items id: actionItemsLayout spacing: units.smallSpacing Layout.alignment: Qt.AlignHCenter } Item { Layout.fillHeight: true } } } diff --git a/lookandfeel/contents/components/WallpaperFader.qml b/lookandfeel/contents/components/WallpaperFader.qml new file mode 100644 index 000000000..5b8ece576 --- /dev/null +++ b/lookandfeel/contents/components/WallpaperFader.qml @@ -0,0 +1,182 @@ +/******************************************************************** + This file is part of the KDE project. + +Copyright (C) 2014 Aleix Pol Gonzalez + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . +*********************************************************************/ + +import QtQuick 2.6 +import QtQuick.Controls 1.1 +import QtQuick.Layouts 1.1 +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.private.sessions 2.0 +import "../components" + +Item { + id: wallpaperFader + property Item clock + property Item mainStack + property Item footer + property alias source: wallpaperBlur.source + state: lockScreenRoot.uiVisible ? "on" : "off" + property real factor: 0 + readonly property bool lightBackground: Math.max(PlasmaCore.ColorScope.backgroundColor.r, PlasmaCore.ColorScope.backgroundColor.g, PlasmaCore.ColorScope.backgroundColor.b) > 0.5 + + Behavior on factor { + NumberAnimation { + target: wallpaperFader + property: "factor" + duration: 1000 + easing.type: Easing.InOutQuad + } + } + FastBlur { + id: wallpaperBlur + anchors.fill: parent + radius: 100 * wallpaperFader.factor + } + ShaderEffect { + id: wallpaperShader + anchors.fill: parent + supportsAtlasTextures: true + property var source: ShaderEffectSource { + sourceItem: wallpaperBlur + live: true + hideSource: true + textureMirroring: ShaderEffectSource.NoMirroring + } + + readonly property real contrast: 0.45 * wallpaperFader.factor + (1 - wallpaperFader.factor) + readonly property real saturation: 1.7 * wallpaperFader.factor + (1 - wallpaperFader.factor) + readonly property real intensity: (wallpaperFader.lightBackground ? 1.7 : 0.45) * wallpaperFader.factor + (1 - wallpaperFader.factor) + + readonly property real transl: (1.0 - contrast) / 2.0; + readonly property real rval: (1.0 - saturation) * 0.2126; + readonly property real gval: (1.0 - saturation) * 0.7152; + readonly property real bval: (1.0 - saturation) * 0.0722; + + property var colorMatrix: Qt.matrix4x4( + contrast, 0, 0, 0.0, + 0, contrast, 0, 0.0, + 0, 0, contrast, 0.0, + transl, transl, transl, 1.0).times(Qt.matrix4x4( + rval + saturation, rval, rval, 0.0, + gval, gval + saturation, gval, 0.0, + bval, bval, bval + saturation, 0.0, + 0, 0, 0, 1.0)).times(Qt.matrix4x4( + intensity, 0, 0, 0, + 0, intensity, 0, 0, + 0, 0, intensity, 0, + 0, 0, 0, 1 + )); + + + fragmentShader: " + uniform mediump mat4 colorMatrix; + uniform mediump sampler2D source; + varying mediump vec2 qt_TexCoord0; + uniform lowp float qt_Opacity; + + void main(void) + { + mediump vec4 tex = texture2D(source, qt_TexCoord0); + gl_FragColor = tex * colorMatrix * qt_Opacity; + }" + } + + states: [ + State { + name: "on" + PropertyChanges { + target: mainStack + opacity: 1 + } + PropertyChanges { + target: footer + opacity: 1 + } + PropertyChanges { + target: wallpaperFader + factor: 1 + } + PropertyChanges { + target: clock.shadow + opacity: 0 + } + }, + State { + name: "off" + PropertyChanges { + target: mainStack + opacity: 0 + } + PropertyChanges { + target: footer + opacity: 0 + } + PropertyChanges { + target: wallpaperFader + factor: 0 + } + PropertyChanges { + target: clock.shadow + opacity: 1 + } + } + ] + transitions: [ + Transition { + from: "off" + to: "on" + //Note: can't use animators as they don't play well with parallelanimations + ParallelAnimation { + NumberAnimation { + target: mainStack + property: "opacity" + duration: units.longDuration + easing.type: Easing.InOutQuad + } + NumberAnimation { + target: footer + property: "opacity" + duration: units.longDuration + easing.type: Easing.InOutQuad + } + } + }, + Transition { + from: "on" + to: "off" + ParallelAnimation { + NumberAnimation { + target: mainStack + property: "opacity" + duration: 500 + easing.type: Easing.InOutQuad + } + NumberAnimation { + target: footer + property: "opacity" + duration: 500 + easing.type: Easing.InOutQuad + } + } + } + ] +} diff --git a/lookandfeel/contents/lockscreen/LockScreenUi.qml b/lookandfeel/contents/lockscreen/LockScreenUi.qml index 72d0d2a33..39df7077e 100644 --- a/lookandfeel/contents/lockscreen/LockScreenUi.qml +++ b/lookandfeel/contents/lockscreen/LockScreenUi.qml @@ -1,393 +1,461 @@ /******************************************************************** This file is part of the KDE project. Copyright (C) 2014 Aleix Pol Gonzalez This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . *********************************************************************/ -import QtQuick 2.5 +import QtQuick 2.6 import QtQuick.Controls 1.1 import QtQuick.Layouts 1.1 +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.private.sessions 2.0 import "../components" PlasmaCore.ColorScope { colorGroup: PlasmaCore.Theme.ComplementaryColorGroup Connections { target: authenticator onFailed: { root.notification = i18nd("plasma_lookandfeel_org.kde.lookandfeel","Unlocking failed"); } onGraceLockedChanged: { if (!authenticator.graceLocked) { root.notification = ""; root.clearPassword(); } } onMessage: { root.notification = msg; } onError: { root.notification = err; } } SessionsModel { id: sessionsModel showNewSessionEntry: true } PlasmaCore.DataSource { id: keystateSource engine: "keystate" connectedSources: "Caps Lock" } Loader { id: changeSessionComponent active: false source: "ChangeSession.qml" visible: false } - Item { + MouseArea { id: lockScreenRoot + property bool uiVisible: false + property bool blockUI: mainStack.depth > 1 || mainBlock.mainPasswordBox.text.length > 0 || inputPanel.keyboardActive + x: parent.x y: parent.y width: parent.width height: parent.height + 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(); + } + } + Keys.onEscapePressed: { + uiVisible = !uiVisible; + if (inputPanel.keyboardActive) { + inputPanel.showHide(); + } + if (!uiVisible) { + mainBlock.mainPasswordBox.text = ""; + } + } + Timer { + id: fadeoutTimer + interval: 10000 + onTriggered: { + if (!lockScreenRoot.blockUI) { + lockScreenRoot.uiVisible = false; + } + } + } Component.onCompleted: PropertyAnimation { id: launchAnimation; target: lockScreenRoot; property: "opacity"; from: 0; to: 1; duration: 1000 } states: [ State { name: "onOtherSession" // for slide out animation PropertyChanges { target: lockScreenRoot; y: lockScreenRoot.height } // we also change the opacity just to be sure it's not visible even on unexpected screen dimension changes with possible race conditions PropertyChanges { target: lockScreenRoot; opacity: 0 } } ] transitions: Transition { // we only animate switchting to another session, because kscreenlocker doesn't get notified when // coming from another session back and so we wouldn't know when to trigger the animation exactly - from: "" - to: "onOtherSession" + from: "" + to: "onOtherSession" - PropertyAnimation { id: stateChangeAnimation; properties: "y"; duration: 300; easing.type: Easing.InQuad} - PropertyAnimation { properties: "opacity"; duration: 300} + PropertyAnimation { id: stateChangeAnimation; properties: "y"; duration: 300; easing.type: Easing.InQuad} + PropertyAnimation { properties: "opacity"; duration: 300} - onRunningChanged: { - // after the animation has finished switch session: since we only animate the transition TO state "onOtherSession" - // and not the other way around, we don't have to check the state we transitioned into - if (/* lockScreenRoot.state == "onOtherSession" && */ !running) { - mainStack.currentItem.switchSession() - } + onRunningChanged: { + // after the animation has finished switch session: since we only animate the transition TO state "onOtherSession" + // and not the other way around, we don't have to check the state we transitioned into + if (/* lockScreenRoot.state == "onOtherSession" && */ !running) { + mainStack.currentItem.switchSession() + } + } + } + + WallpaperFader { + anchors.fill: parent + state: lockScreenRoot.uiVisible ? "on" : "off" + source: wallpaper + mainStack: mainStack + footer: footer + clock: clock + } + + DropShadow { + id: clockShadow + anchors.fill: clock + source: clock + horizontalOffset: 0 + verticalOffset: 1 + radius: 12 + samples: 32 + spread: 0.2 + color: Qt.rgba(0, 0, 0, 1) + Behavior on opacity { + OpacityAnimator { + duration: 1000 + easing.type: Easing.InOutQuad } } + } Clock { id: clock + property Item shadow: clockShadow anchors.horizontalCenter: parent.horizontalCenter y: (mainBlock.userList.y + mainStack.y)/2 - height/2 visible: y > 0 Layout.alignment: Qt.AlignBaseline } ListModel { id: users Component.onCompleted: { users.append({name: kscreenlocker_userName, realName: kscreenlocker_userName, icon: kscreenlocker_userImage, }) } } - StackView { id: mainStack anchors { left: parent.left right: parent.right } height: lockScreenRoot.height focus: true //StackView is an implicit focus scope, so we need to give this focus so the item inside will have it initialItem: MainBlock { id: mainBlock showUserList: userList.y + mainStack.y > 0 Stack.onStatusChanged: { // prepare for presenting again to the user if (Stack.status == Stack.Activating) { mainPasswordBox.remove(0, mainPasswordBox.length) mainPasswordBox.focus = true } } userListModel: users notificationMessage: { var text = "" if (keystateSource.data["Caps Lock"]["Locked"]) { text += i18nd("plasma_lookandfeel_org.kde.lookandfeel","Caps Lock is on") if (root.notification) { text += " • " } } text += root.notification return text } onLoginRequest: { root.notification = "" authenticator.tryUnlock(password) } actionItems: [ ActionButton { text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Switch User") iconSource: "system-switch-user" onClicked: mainStack.push(switchSessionPage) // the current session isn't listed in the model, hence a check for greater than zero, not one visible: (sessionsModel.count > 0 || sessionsModel.canStartNewSession) && sessionsModel.canSwitchUser } ] Loader { Layout.fillWidth: true Layout.preferredHeight: item ? item.implicitHeight : 0 active: config.showMediaControls source: "MediaControls.qml" } } } Loader { id: inputPanel state: "hidden" readonly property bool keyboardActive: item ? item.active : false anchors { left: parent.left right: parent.right } function showHide() { state = state == "hidden" ? "visible" : "hidden"; } Component.onCompleted: inputPanel.source = "../components/VirtualKeyboard.qml" onKeyboardActiveChanged: { if (keyboardActive) { state = "visible"; } else { state = "hidden"; } } states: [ State { name: "visible" PropertyChanges { target: mainStack y: Math.min(0, lockScreenRoot.height - inputPanel.height - mainBlock.visibleBoundary) } PropertyChanges { target: inputPanel y: lockScreenRoot.height - inputPanel.height opacity: 1 } }, State { name: "hidden" PropertyChanges { target: mainStack y: 0 } PropertyChanges { target: inputPanel y: lockScreenRoot.height - lockScreenRoot.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: switchSessionPage SessionManagementScreen { property var switchSession: finalSwitchSession Stack.onStatusChanged: { if (Stack.status == Stack.Activating) { focus = true } } userListModel: sessionsModel // initiating animation of lockscreen for session switch function initSwitchSession() { lockScreenRoot.state = 'onOtherSession' } // initiating session switch and preparing lockscreen for possible return of user function finalSwitchSession() { mainStack.pop({immediate:true}) sessionsModel.switchUser(userListCurrentModelData.vtNumber) lockScreenRoot.state = '' } Keys.onLeftPressed: userList.decrementCurrentIndex() Keys.onRightPressed: userList.incrementCurrentIndex() Keys.onEnterPressed: initSwitchSession() Keys.onReturnPressed: initSwitchSession() Keys.onEscapePressed: mainStack.pop() PlasmaComponents.Button { Layout.fillWidth: true // the magic "-1" vtNumber indicates the "New Session" entry text: userListCurrentModelData.vtNumber === -1 ? i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Start New Session") : i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Switch Session") onClicked: initSwitchSession() } actionItems: [ ActionButton { iconSource: "go-previous" text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Back") onClicked: mainStack.pop() } ] } } Loader { active: root.viewVisible source: "LockOsd.qml" anchors { horizontalCenter: parent.horizontalCenter bottom: parent.bottom } } RowLayout { id: footer anchors { bottom: parent.bottom left: parent.left right: parent.right margins: units.smallSpacing } 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" onClicked: inputPanel.showHide() visible: inputPanel.status == Loader.Ready } KeyboardLayoutButton { } Item { Layout.fillWidth: true } Battery {} } } Component.onCompleted: { // version support checks if (root.interfaceVersion < 1) { // ksmserver of 5.4, with greeter of 5.5 root.viewVisible = true; } } } diff --git a/sddm-theme/Login.qml b/sddm-theme/Login.qml index 5ea0711d1..12ef79bf6 100644 --- a/sddm-theme/Login.qml +++ b/sddm-theme/Login.qml @@ -1,96 +1,98 @@ import "components" import QtQuick 2.0 import QtQuick.Layouts 1.2 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents SessionManagementScreen { + property Item mainPasswordBox: passwordBox + property bool showUsernamePrompt: !showUserList 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: { if (!showUsernamePrompt) { lastUserName = "" } } /* * Login has been requested with the following username and password * If username field is visible, it will be taken from that, otherwise from the "name" property of the currentIndex */ function startLogin() { var username = showUsernamePrompt ? userNameInput.text : userList.selectedUser var password = passwordBox.text //this is partly because it looks nicer //but more importantly it works round a Qt bug that can trigger if the app is closed with a TextField focussed //DAVE REPORT THE FRICKING THING AND PUT A LINK loginButton.forceActiveFocus(); loginRequest(username, password); } PlasmaComponents.TextField { id: userNameInput Layout.fillWidth: true text: lastUserName visible: showUsernamePrompt focus: showUsernamePrompt && !lastUserName //if there's a username prompt it gets focus first, otherwise password does placeholderText: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Username") } PlasmaComponents.TextField { id: passwordBox Layout.fillWidth: true placeholderText: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Password") focus: !showUsernamePrompt || lastUserName echoMode: TextInput.Password revealPasswordButtonShown: true onAccepted: startLogin() Keys.onEscapePressed: { mainStack.currentItem.forceActiveFocus(); } //if empty and left or right is pressed change selection in user switch //this cannot be in keys.onLeftPressed as then it doesn't reach the password box Keys.onPressed: { if (event.key == Qt.Key_Left && !text) { userList.decrementCurrentIndex(); event.accepted = true } if (event.key == Qt.Key_Right && !text) { userList.incrementCurrentIndex(); event.accepted = true } } Connections { target: sddm onLoginFailed: { passwordBox.selectAll() passwordBox.forceActiveFocus() } } } PlasmaComponents.Button { id: loginButton Layout.fillWidth: true text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Login") onClicked: startLogin(); } } diff --git a/sddm-theme/Main.qml b/sddm-theme/Main.qml index a00a9a330..3ef30117d 100644 --- a/sddm-theme/Main.qml +++ b/sddm-theme/Main.qml @@ -1,361 +1,433 @@ /* * Copyright 2016 David Edmundson * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2 or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.2 import QtQuick.Layouts 1.1 import QtQuick.Controls 1.1 +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 import "components" PlasmaCore.ColorScope { id: root colorGroup: PlasmaCore.Theme.ComplementaryColorGroup width: 1600 height: 900 property string notificationMessage LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft LayoutMirroring.childrenInherit: true PlasmaCore.DataSource { id: keystateSource engine: "keystate" connectedSources: "Caps Lock" } - Repeater { - model: screenModel - - Background { - x: geometry.x; y: geometry.y; width: geometry.width; height: geometry.height - sceneBackgroundType: config.type - sceneBackgroundColor: config.color - sceneBackgroundImage: config.background + Item { + id: wallpaper + anchors.fill: parent + Repeater { + model: screenModel + + Background { + x: geometry.x; y: geometry.y; width: geometry.width; height: geometry.height + sceneBackgroundType: config.type + sceneBackgroundColor: config.color + sceneBackgroundImage: config.background + } } } - Clock { - visible: y > 0 - y: (userListComponent.userList.y + mainStack.y)/2 - height/2 - anchors.horizontalCenter: parent.horizontalCenter - } - - - StackView { - id: mainStack - anchors { - left: parent.left - right: parent.right + MouseArea { + id: loginScreenRoot + anchors.fill: parent + + 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(); + } } - 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 { - //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 + id: fadeoutTimer running: true - repeat: false - interval: 200 - onTriggered: mainStack.forceActiveFocus() + 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 + } + + DropShadow { + id: clockShadow + anchors.fill: clock + source: clock + horizontalOffset: 0 + verticalOffset: 1 + radius: 12 + samples: 32 + spread: 0.2 + color: Qt.rgba(0, 0, 0, 1) + Behavior on opacity { + OpacityAnimator { + duration: 1000 + easing.type: Easing.InOutQuad + } + } } - 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 + Clock { + id: clock + visible: y > 0 + property Item shadow: clockShadow + y: (userListComponent.userList.y + mainStack.y)/2 - height/2 + anchors.horizontalCenter: parent.horizontalCenter + } - if ( userListModel.count == 0 ) return false - return userListModel.count <= userListModel.disableAvatarsThreshold && (userList.y + mainStack.y) > 0 + 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 + + 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() } - notificationMessage: { - var text = "" - if (keystateSource.data["Caps Lock"]["Locked"]) { - text += i18nd("plasma_lookandfeel_org.kde.lookandfeel","Caps Lock is on") - if (root.notificationMessage) { - text += " • " - } + 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 } - 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-switch-user" - text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Different User") - onClicked: mainStack.push(userPromptComponent) - enabled: true - visible: !userListComponent.showUsernamePrompt && !inputPanel.keyboardActive + 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 } - ] - 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-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) + } } - } - Behavior on opacity { - OpacityAnimator { - duration: units.longDuration + Behavior on opacity { + OpacityAnimator { + duration: units.longDuration + } } } - } - Loader { - id: inputPanel - state: "hidden" - property bool keyboardActive: item ? item.active : false - onKeyboardActiveChanged: { - if (keyboardActive) { - state = "visible" - } else { - state = "hidden"; + 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 } - } - 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 - } + function showHide() { + state = state == "hidden" ? "visible" : "hidden"; } - ] - transitions: [ - Transition { - from: "hidden" - to: "visible" - SequentialAnimation { - ScriptAction { - script: { - inputPanel.item.activated = true; - Qt.inputMethod.show(); - } + + states: [ + State { + name: "visible" + PropertyChanges { + target: mainStack + y: Math.min(0, root.height - inputPanel.height - userListComponent.visibleBoundary) } - 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 - } + 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 } } - }, - 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 + ] + transitions: [ + Transition { + from: "hidden" + to: "visible" + SequentialAnimation { + ScriptAction { + script: { + inputPanel.item.activated = true; + Qt.inputMethod.show(); + } } - OpacityAnimator { - target: inputPanel - duration: units.longDuration - easing.type: Easing.InQuad + 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 + } } } - ScriptAction { - script: { - Qt.inputMethod.hide(); + }, + 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 { + 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", "Login as different user") + property string iconSource: "" + } + + onLoginRequest: { + root.notificationMessage = "" + sddm.login(username, password, sessionButton.currentIndex) + } - userListModel: QtObject { - property string name: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Login as different user") - property string iconSource: "" + actionItems: [ + ActionButton { + iconSource: "go-previous" + text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Back") + onClicked: mainStack.pop() + } + ] } + } - onLoginRequest: { - root.notificationMessage = "" - sddm.login(username, password, sessionButton.currentIndex) + //Footer + RowLayout { + id: footer + anchors { + bottom: parent.bottom + left: parent.left + right: parent.right + margins: units.smallSpacing } - actionItems: [ - ActionButton { - iconSource: "go-previous" - text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Back") - onClicked: mainStack.pop() + Behavior on opacity { + OpacityAnimator { + duration: units.longDuration } - ] - } - } - - //Footer - RowLayout { - id: footer - anchors { - bottom: parent.bottom - left: parent.left - right: parent.right - 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" + onClicked: inputPanel.showHide() + visible: inputPanel.status == Loader.Ready } - } - 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" - onClicked: inputPanel.showHide() - visible: inputPanel.status == Loader.Ready - } + KeyboardButton { + } - KeyboardButton { - } + SessionButton { + id: sessionButton + } - SessionButton { - id: sessionButton - } + Item { + Layout.fillWidth: true + } - Item { - Layout.fillWidth: true + Battery { } } - - Battery { } } Connections { target: sddm onLoginFailed: { notificationMessage = i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Login Failed") } onLoginSucceeded: { //note SDDM will kill the greeter at some random point after this //there is no certainty any transition will finish, it depends on the time it //takes to complete the init mainStack.opacity = 0 footer.opacity = 0 } } onNotificationMessageChanged: { if (notificationMessage) { notificationResetTimer.start(); } } Timer { id: notificationResetTimer interval: 3000 onTriggered: notificationMessage = "" } - }