diff --git a/look-and-feel/contents/components/InfoPane.qml b/look-and-feel/contents/lockscreen/InfoPane.qml similarity index 94% rename from look-and-feel/contents/components/InfoPane.qml rename to look-and-feel/contents/lockscreen/InfoPane.qml index 2045fc5..59a53a6 100644 --- a/look-and-feel/contents/components/InfoPane.qml +++ b/look-and-feel/contents/lockscreen/InfoPane.qml @@ -1,91 +1,91 @@ /* * Copyright 2014 David Edmundson * Copyright (C) 2014 by Aleix Pol Gonzalez * * 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 org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.plasma.workspace.components 2.0 as PW ColumnLayout { PlasmaComponents.Label { //should be a heading but we want it _loads_ bigger text: Qt.formatTime(timeSource.data["Local"]["DateTime"]) //we fill the width then align the text so that we can make the text shrink to fit Layout.fillWidth: true - horizontalAlignment: Text.AlignRight + horizontalAlignment: Text.AlignHCenter font.weight: Font.DemiBold fontSizeMode: Text.HorizontalFit font.pointSize: 36 } PlasmaComponents.Label { text: Qt.formatDate(timeSource.data["Local"]["DateTime"], Qt.DefaultLocaleLongDate); - Layout.alignment: Qt.AlignRight + Layout.alignment: Qt.AlignHCenter } RowLayout { - Layout.alignment: Qt.AlignRight + Layout.alignment: Qt.AlignHCenter visible: pmSource.data["Battery"]["Has Cumulative"] PW.BatteryIcon { id: battery hasBattery: true percent: pmSource.data["Battery"]["Percent"] pluggedIn: pmSource.data["AC Adapter"] ? pmSource.data["AC Adapter"]["Plugged in"] : false height: batteryLabel.height width: batteryLabel.height } PlasmaComponents.Label { id: batteryLabel text: { var state = pmSource.data["Battery"] ? pmSource.data["Battery"]["State"] : ""; switch(state) { case "Charging": return i18nd("plasma_lookandfeel_org.kde.lookandfeel","%1%. Charging", battery.percent) case "FullyCharged": return i18nd("plasma_lookandfeel_org.kde.lookandfeel","Fully charged") default: return i18nd("plasma_lookandfeel_org.kde.lookandfeel","%1% battery remaining", battery.percent) } } - Layout.alignment: Qt.AlignRight + Layout.alignment: Qt.AlignHCenter wrapMode: Text.Wrap } } PlasmaCore.DataSource { id: pmSource engine: "powermanagement" connectedSources: ["Battery", "AC Adapter"] } PlasmaCore.DataSource { id: timeSource engine: "time" connectedSources: ["Local"] interval: 1000 } } diff --git a/look-and-feel/contents/lockscreen/LockScreen.qml b/look-and-feel/contents/lockscreen/LockScreen.qml index 79d66be..d60ad20 100644 --- a/look-and-feel/contents/lockscreen/LockScreen.qml +++ b/look-and-feel/contents/lockscreen/LockScreen.qml @@ -1,94 +1,125 @@ /******************************************************************** 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.0 import QtQuick.Controls 1.1 +import QtQuick.Layouts 1.1 +import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.plasma.private.sessions 2.0 +import org.kde.plasma.workspace.keyboardlayout 1.0 import "../components" -Image { - id: root - property bool viewVisible: false - property bool debug: false - property string notification - property Item userSelect: null - property int interfaceVersion: org_kde_plasma_screenlocker_greeter_interfaceVersion ? org_kde_plasma_screenlocker_greeter_interfaceVersion : 0 - signal clearPassword() +PlasmaCore.ColorScope { + id: block + colorGroup: PlasmaCore.Theme.ComplementaryColorGroup + anchors.fill: parent - source: backgroundPath || "../components/artwork/background.png" - fillMode: Image.PreserveAspectCrop - asynchronous: true + Rectangle { + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + color: PlasmaCore.ColorScope.backgroundColor + opacity: 0.8 + height: infoPane.height + units.largeSpacing * 2 + } - onStatusChanged: { - if (status == Image.Error) { - source = "../components/artwork/background.png"; - } + InfoPane { + id: infoPane + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + anchors.topMargin: units.largeSpacing } - LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft - LayoutMirroring.childrenInherit: true + Rectangle { + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + color: PlasmaCore.ColorScope.backgroundColor + opacity: 0.8 + height: mainLayout.height + units.largeSpacing * 2 + } - 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; + ColumnLayout { + id: mainLayout + anchors { + left: parent.left + right: parent.right + bottom: parent.bottom + bottomMargin: units.largeSpacing } - onError: { - root.notification = err; - } - } + spacing: units.largeSpacing + RowLayout { + Layout.alignment: Qt.AlignHCenter - SessionsModel { - id: sessionsModel - } + PlasmaComponents.TextField { + id: passwordInput + placeholderText: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Password") + echoMode: TextInput.Password + enabled: !authenticator.graceLocked + onAccepted: actionButton.clicked(null) + focus: false - PlasmaCore.DataSource { - id: keystateSource - engine: "keystate" - connectedSources: "Caps Lock" - } + onVisibleChanged: { + if (visible) { + forceActiveFocus(); + } + text = ""; + } + onTextChanged: { + if (text == "") { + clearTimer.stop(); + } else { + clearTimer.restart(); + } + } - StackView { - id: stackView - anchors.fill: parent + Timer { + id: clearTimer + interval: 30000 + repeat: false + onTriggered: { + passwordInput.text = ""; + } + } + } - initialItem: Loader { - active: root.viewVisible - source: "MainBlock.qml" + DialerIconButton { + source: "edit-clear" + callback: function() { + if (passwordInput.text.length > 0) { + passwordInput.text = passwordInput.text.substr(0, passwordInput.text.length - 1); + } + } + } } - } - - Component.onCompleted: { - // version support checks - if (root.interfaceVersion < 1) { - // ksmserver of 5.4, with greeter of 5.5 - root.viewVisible = true; + Dialer { + id: dialer + Layout.fillWidth: true + } + PlasmaComponents.Button { + id: actionButton + Layout.alignment: Qt.AlignHCenter + Layout.minimumWidth: passwordInput.width + text: i18n("Unlock") + enabled: !authenticator.graceLocked + onClicked: authenticator.tryUnlock(passwordInput.text); } } } diff --git a/look-and-feel/contents/lockscreen/MainBlock.qml b/look-and-feel/contents/lockscreen/MainBlock.qml deleted file mode 100644 index d95f548..0000000 --- a/look-and-feel/contents/lockscreen/MainBlock.qml +++ /dev/null @@ -1,173 +0,0 @@ -/******************************************************************** - 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.Layouts 1.1 -import QtQuick.Controls 1.1 -import org.kde.plasma.components 2.0 as PlasmaComponents -import org.kde.plasma.core 2.0 as PlasmaCore -import org.kde.plasma.workspace.keyboardlayout 1.0 -import "../components" - -PlasmaCore.ColorScope { - id: block - colorGroup: PlasmaCore.Theme.ComplementaryColorGroup - anchors.fill: parent - - Component.onCompleted: appearAnimation.running = true; - - SequentialAnimation { - id: appearAnimation - ParallelAnimation { - YAnimator { - target: topPanel - from: -topPanel.height - to: 0 - duration: units.longDuration - } - YAnimator { - target: bottomPanel - from: block.height - to: block.height - bottomPanel.height - duration: units.longDuration - } - } - ScriptAction { - script: { - topPanel.anchors.top = block.top; - bottomPanel.anchors.bottom = block.bottom; - } - } - } - Item { - id: topPanel - y: -height - anchors { - left: parent.left - right: parent.right - } - - height: infoPane.height + units.largeSpacing * 2 - - Rectangle { - anchors.fill: parent - color: PlasmaCore.ColorScope.backgroundColor - opacity: 0.8 - } - InfoPane { - id: infoPane - anchors.centerIn: parent - } - } - - Item { - id: bottomPanel - height: mainLayout.height + units.largeSpacing * 2 - anchors { - left: parent.left - right: parent.right - } - y: parent.height - Rectangle { - anchors.fill: parent - color: PlasmaCore.ColorScope.backgroundColor - opacity: 0.8 - } - function unlockFunction() { - authenticator.tryUnlock(passwordInput.text); - } - - ColumnLayout { - id: mainLayout - anchors { - left: parent.left - right: parent.right - verticalCenter: parent.verticalCenter - } - spacing: units.largeSpacing - RowLayout { - anchors.horizontalCenter: parent.horizontalCenter - - - PlasmaComponents.TextField { - id: passwordInput - placeholderText: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Password") - echoMode: TextInput.Password - enabled: !authenticator.graceLocked - onAccepted: actionButton.clicked(null) - focus: false - - onVisibleChanged: { - if (visible) { - forceActiveFocus(); - } - text = ""; - } - onTextChanged: { - if (text == "") { - clearTimer.stop(); - } else { - clearTimer.restart(); - } - } - - Timer { - id: clearTimer - interval: 30000 - repeat: false - onTriggered: { - passwordInput.text = ""; - } - } - } - - DialerIconButton { - source: "edit-clear" - callback: function() { - if (passwordInput.text.length > 0) { - passwordInput.text = passwordInput.text.substr(0, passwordInput.text.length - 1); - } - } - } - - Connections { - target: root - onClearPassword: { - passwordInput.selectAll(); - passwordInput.forceActiveFocus(); - } - } - } - Dialer { - id: dialer - Layout.fillWidth: true - } - PlasmaComponents.Button { - id: actionButton - Layout.alignment: Qt.AlignHCenter - Layout.minimumWidth: passwordInput.width - text: i18n("Unlock") - enabled: !authenticator.graceLocked - onClicked: { - bottomPanel.unlockFunction(); - } - } - } - } -}