123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473 |
-
- import QtQuick 2.8
- 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
- readonly property bool softwareRendering: GraphicsInfo.api === GraphicsInfo.Software
- 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"
- }
- Image {
- id: wallpaper
- height: parent.height
- width: parent.width
- source: config.background || config.Background
- asynchronous: true
- cache: true
- clip: true
- }
- 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();
- }
- }
- Keys.onPressed: {
- uiVisible = true;
- event.accepted = false;
- }
-
- Timer {
- id: fadeoutTimer
- running: true
- interval: 60000
- onTriggered: {
- if (!loginScreenRoot.blockUI) {
- loginScreenRoot.uiVisible = false;
- }
- }
- }
- StackView {
- id: mainStack
- anchors.centerIn: parent
- height: root.height / 2
- width: parent.width / 3
- focus: true
- Timer {
-
-
-
-
- running: true
- repeat: false
- interval: 200
- onTriggered: mainStack.forceActiveFocus()
- }
- initialItem: Login {
- id: userListComponent
- userListModel: userModel
- loginScreenUiVisible: loginScreenRoot.uiVisible
- 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 += " • "
- }
- }
- text += root.notificationMessage
- return text
- }
- actionItems: [
- ActionButton {
- iconSource: Qt.resolvedUrl("assets/suspend.svg")
- text: i18ndc("plasma_lookandfeel_org.kde.lookandfeel","Suspend to RAM","Sleep")
- onClicked: sddm.suspend()
- enabled: sddm.canSuspend
- visible: !inputPanel.keyboardActive
- },
- ActionButton {
- iconSource: Qt.resolvedUrl("assets/restart.svg")
- text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Restart")
- onClicked: sddm.reboot()
- enabled: sddm.canReboot
- visible: !inputPanel.keyboardActive
- },
- ActionButton {
- iconSource: Qt.resolvedUrl("assets/shutdown.svg")
- text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Shut Down")
- onClicked: sddm.powerOff()
- enabled: sddm.canPowerOff
- visible: !inputPanel.keyboardActive
- },
- ActionButton {
- iconSource: Qt.resolvedUrl("assets/change_user.svg")
- 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
- }
- }
- }
- 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 {
- showUsernamePrompt: true
- notificationMessage: root.notificationMessage
- loginScreenUiVisible: loginScreenRoot.uiVisible
-
- userListModel: ListModel {
- ListElement {
- name: ""
- iconSource: ""
- }
- Component.onCompleted: {
-
- setProperty(0, "name", i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Type in Username and Password"));
- }
- }
- onLoginRequest: {
- root.notificationMessage = ""
- sddm.login(username, password, sessionButton.currentIndex)
- }
- actionItems: [
- ActionButton {
- iconSource: "system-suspend"
- text: i18ndc("plasma_lookandfeel_org.kde.lookandfeel","Suspend to RAM","Sleep")
- 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: "go-previous"
- text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","List Users")
- onClicked: mainStack.pop()
- visible: !inputPanel.keyboardActive
- }
- ]
- }
- }
- Rectangle {
- id: formBg
- width: mainStack.width
- height: mainStack.height + footerBg.height
- x: root.width / 2 - width / 2
- y: root.height / 2 - height / 2 + footerBg.height
- radius: 14
- color: "#21232D"
- opacity: 1
- z:-1
- }
- Rectangle {
- id: footerBg
- width: parent.width
- height: footer.height + 10
- anchors.left: parent.left
- anchors.top: parent.top
- radius: 7
- color: "#21232D"
- opacity: 1
- z:-1
- }
-
- RowLayout {
- id: footer
- anchors {
- top: parent.top
- left: parent.left
- 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: true
- }
- KeyboardButton {
- }
- SessionButton {
- id: sessionButton
- }
- }
- RowLayout {
- id: footerRight
- spacing: 10
- anchors {
- top: parent.top
- right: parent.right
- margins: 10
- }
- Behavior on opacity {
- OpacityAnimator {
- duration: units.longDuration
- }
- }
- Battery {}
- Clock {
- id: clock
- visible: true
- }
- }
- }
- Connections {
- target: sddm
- onLoginFailed: {
- notificationMessage = i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Login Failed")
- }
- onLoginSucceeded: {
-
-
-
- mainStack.opacity = 0
- footer.opacity = 0
- footerRight.opacity = 0
- }
- }
- onNotificationMessageChanged: {
- if (notificationMessage) {
- notificationResetTimer.start();
- }
- }
- Timer {
- id: notificationResetTimer
- interval: 3000
- onTriggered: notificationMessage = ""
- }
- }
|