diff --git a/lookandfeel/contents/components/ActionButton.qml b/lookandfeel/contents/components/ActionButton.qml index e786f2a2b..626cb6fa7 100644 --- a/lookandfeel/contents/components/ActionButton.qml +++ b/lookandfeel/contents/components/ActionButton.qml @@ -1,81 +1,81 @@ /* * 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 org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents Item { id: root property alias text: label.text property alias iconSource: icon.source property alias containsMouse: mouseArea.containsMouse property alias font: label.font signal clicked activeFocusOnTab: true property int iconSize: units.gridUnit * 3 implicitWidth: Math.max(iconSize + units.largeSpacing * 2, label.contentWidth) implicitHeight: iconSize + units.smallSpacing + label.implicitHeight PlasmaCore.IconItem { id: icon anchors { top: parent.top horizontalCenter: parent.horizontalCenter } width: iconSize height: iconSize colorGroup: PlasmaCore.ColorScope.colorGroup active: mouseArea.containsMouse || root.activeFocus } - + PlasmaComponents.Label { id: label - font.pointSize: 11 + font.pointSize: theme.defaultFont.pointSize + 1 anchors { top: icon.bottom topMargin: units.smallSpacing left: parent.left right: parent.right } horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignTop wrapMode: Text.WordWrap font.underline: root.activeFocus } MouseArea { id: mouseArea hoverEnabled: true onClicked: root.clicked() anchors.fill: parent } Keys.onEnterPressed: clicked() Keys.onReturnPressed: clicked() Keys.onSpacePressed: clicked() Accessible.onPressAction: clicked() Accessible.role: Accessible.Button Accessible.name: label.text } diff --git a/lookandfeel/contents/components/UserDelegate.qml b/lookandfeel/contents/components/UserDelegate.qml index 2166d42ba..9e563323b 100644 --- a/lookandfeel/contents/components/UserDelegate.qml +++ b/lookandfeel/contents/components/UserDelegate.qml @@ -1,204 +1,204 @@ /* * Copyright 2014 David Edmundson * Copyright 2014 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.8 import QtGraphicalEffects 1.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents Item { id: wrapper // If we're using software rendering, draw outlines instead of shadows // See https://bugs.kde.org/show_bug.cgi?id=398317 readonly property bool softwareRendering: GraphicsInfo.api === GraphicsInfo.Software property bool isCurrent: true readonly property var m: model property string name property string userName property string avatarPath property string iconSource property bool constrainText: true signal clicked() property real faceSize: Math.min(width, height - usernameDelegate.height - units.smallSpacing) opacity: isCurrent ? 1.0 : 0.5 Behavior on opacity { OpacityAnimator { duration: units.longDuration } } // Draw a translucent background circle under the user picture Rectangle { anchors.centerIn: imageSource width: imageSource.width + 2 height: width radius: width / 2 color: PlasmaCore.ColorScope.backgroundColor opacity: 0.9 } Item { id: imageSource anchors { bottom: usernameDelegate.top bottomMargin: units.largeSpacing horizontalCenter: parent.horizontalCenter } Behavior on width { PropertyAnimation { from: faceSize duration: units.longDuration * 2; } } width: isCurrent ? faceSize : faceSize - units.largeSpacing height: width //Image takes priority, taking a full path to a file, if that doesn't exist we show an icon Image { id: face source: wrapper.avatarPath sourceSize: Qt.size(faceSize, faceSize) fillMode: Image.PreserveAspectCrop anchors.fill: parent } PlasmaCore.IconItem { id: faceIcon source: iconSource visible: (face.status == Image.Error || face.status == Image.Null) anchors.fill: parent anchors.margins: units.gridUnit * 0.5 // because mockup says so... colorGroup: PlasmaCore.ColorScope.colorGroup } } ShaderEffect { anchors { bottom: usernameDelegate.top bottomMargin: units.largeSpacing horizontalCenter: parent.horizontalCenter } width: imageSource.width height: imageSource.height supportsAtlasTextures: true property var source: ShaderEffectSource { sourceItem: imageSource // software rendering is just a fallback so we can accept not having a rounded avatar here hideSource: wrapper.GraphicsInfo.api !== GraphicsInfo.Software live: true // otherwise the user in focus will show a blurred avatar } property var colorBorder: PlasmaCore.ColorScope.textColor //draw a circle with an antialised border //innerRadius = size of the inner circle with contents //outerRadius = size of the border //blend = area to blend between two colours //all sizes are normalised so 0.5 == half the width of the texture //if copying into another project don't forget to connect themeChanged to update() //but in SDDM that's a bit pointless fragmentShader: " varying highp vec2 qt_TexCoord0; uniform highp float qt_Opacity; uniform lowp sampler2D source; uniform lowp vec4 colorBorder; highp float blend = 0.01; highp float innerRadius = 0.47; highp float outerRadius = 0.49; lowp vec4 colorEmpty = vec4(0.0, 0.0, 0.0, 0.0); void main() { lowp vec4 colorSource = texture2D(source, qt_TexCoord0.st); highp vec2 m = qt_TexCoord0 - vec2(0.5, 0.5); highp float dist = sqrt(m.x * m.x + m.y * m.y); if (dist < innerRadius) gl_FragColor = colorSource; else if (dist < innerRadius + blend) gl_FragColor = mix(colorSource, colorBorder, ((dist - innerRadius) / blend)); else if (dist < outerRadius) gl_FragColor = colorBorder; else if (dist < outerRadius + blend) gl_FragColor = mix(colorBorder, colorEmpty, ((dist - outerRadius) / blend)); else gl_FragColor = colorEmpty ; gl_FragColor = gl_FragColor * qt_Opacity; } " } DropShadow { id: usernameShadow visible: !softwareRendering anchors.fill: usernameDelegate source: usernameDelegate horizontalOffset: 1 verticalOffset: 1 radius: 4 samples: 9 spread: 0.35 color: "black" // matches Breeze window decoration and desktopcontainment } PlasmaComponents.Label { id: usernameDelegate - font.pointSize: 12 + font.pointSize: theme.defaultFont.pointSize + 2 anchors { bottom: parent.bottom horizontalCenter: parent.horizontalCenter } height: implicitHeight // work around stupid bug in Plasma Components that sets the height width: constrainText ? parent.width : implicitWidth text: wrapper.name style: softwareRendering ? Text.Outline : undefined styleColor: softwareRendering ? ColorScope.backgroundColor : undefined elide: Text.ElideRight horizontalAlignment: Text.AlignHCenter //make an indication that this has active focus, this only happens when reached with keyboard navigation font.underline: wrapper.activeFocus } MouseArea { anchors.fill: parent hoverEnabled: true onClicked: wrapper.clicked(); } Accessible.name: name Accessible.role: Accessible.Button function accessiblePressAction() { wrapper.clicked() } } diff --git a/lookandfeel/contents/lockscreen/MainBlock.qml b/lookandfeel/contents/lockscreen/MainBlock.qml index 17910ff95..3d7b644d0 100644 --- a/lookandfeel/contents/lockscreen/MainBlock.qml +++ b/lookandfeel/contents/lockscreen/MainBlock.qml @@ -1,102 +1,102 @@ /* * 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 import "../components" SessionManagementScreen { property Item mainPasswordBox: passwordBox property bool lockScreenUiVisible: false //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 /* * 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 */ signal loginRequest(string password) function startLogin() { 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 focused //See https://bugreports.qt.io/browse/QTBUG-55460 loginButton.forceActiveFocus(); loginRequest(password); } PlasmaComponents.TextField { id: passwordBox - font.pointSize: 11 + font.pointSize: theme.defaultFont.pointSize + 1 Layout.fillWidth: true placeholderText: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Password") focus: true echoMode: TextInput.Password inputMethodHints: Qt.ImhHiddenText | Qt.ImhSensitiveData | Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText enabled: !authenticator.graceLocked revealPasswordButtonShown: true onAccepted: { if (lockScreenUiVisible) { startLogin(); } } //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: root onClearPassword: { passwordBox.forceActiveFocus() passwordBox.selectAll() } } } PlasmaComponents.Button { id: loginButton - font.pointSize: 11 + font.pointSize: theme.defaultFont.pointSize + 1 Layout.fillWidth: true text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Unlock") onClicked: startLogin() } } diff --git a/lookandfeel/contents/logout/Logout.qml b/lookandfeel/contents/logout/Logout.qml index ee28fd4b2..954d6eb8c 100644 --- a/lookandfeel/contents/logout/Logout.qml +++ b/lookandfeel/contents/logout/Logout.qml @@ -1,249 +1,249 @@ /*************************************************************************** * 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 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, 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.2 import QtQuick.Controls 1.1 as Controls import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.kcoreaddons 1.0 as KCoreAddons import "../components" import "timer.js" as AutoTriggerTimer import org.kde.plasma.private.sessions 2.0 PlasmaCore.ColorScope { id: root colorGroup: PlasmaCore.Theme.ComplementaryColorGroup height: screenGeometry.height width: screenGeometry.width signal logoutRequested() signal haltRequested() signal suspendRequested(int spdMethod) signal rebootRequested() signal rebootRequested2(int opt) signal cancelRequested() signal lockScreenRequested() property alias backgroundColor: backgroundRect.color function sleepRequested() { root.suspendRequested(2); } function hibernateRequested() { root.suspendRequested(4); } property real timeout: 30 property real remainingTime: root.timeout property var currentAction: { switch (sdtype) { case ShutdownType.ShutdownTypeReboot: return root.rebootRequested; case ShutdownType.ShutdownTypeHalt: return root.haltRequested; default: return root.logoutRequested; } } KCoreAddons.KUser { id: kuser } // For showing a "other users are logged in" hint SessionsModel { id: sessionsModel includeUnusedSessions: false } Controls.Action { onTriggered: root.cancelRequested() shortcut: "Escape" } onRemainingTimeChanged: { if (remainingTime <= 0) { root.currentAction(); } } Timer { id: countDownTimer running: true repeat: true interval: 1000 onTriggered: remainingTime-- Component.onCompleted: { AutoTriggerTimer.addCancelAutoTriggerCallback(function() { countDownTimer.running = false; }); } } function isLightColor(color) { return Math.max(color.r, color.g, color.b) > 0.5 } Rectangle { id: backgroundRect anchors.fill: parent //use "black" because this is intended to look like a general darkening of the scene. a dark gray as normal background would just look too "washed out" color: root.isLightColor(PlasmaCore.ColorScope.backgroundColor) ? PlasmaCore.ColorScope.backgroundColor : "black" opacity: 0.5 } MouseArea { anchors.fill: parent onClicked: root.cancelRequested() } UserDelegate { width: units.iconSizes.enormous height: width anchors { horizontalCenter: parent.horizontalCenter bottom: parent.verticalCenter } constrainText: false avatarPath: kuser.faceIconUrl iconSource: "user-identity" isCurrent: true name: kuser.fullName } ColumnLayout { anchors { top: parent.verticalCenter topMargin: units.gridUnit * 2 horizontalCenter: parent.horizontalCenter } spacing: units.largeSpacing height: Math.max(implicitHeight, units.gridUnit * 10) width: Math.max(implicitWidth, units.gridUnit * 16) PlasmaComponents.Label { - font.pointSize: 11 + font.pointSize: theme.defaultFont.pointSize + 1 Layout.maximumWidth: units.gridUnit * 16 Layout.alignment: Qt.AlignHCenter Layout.fillWidth: true horizontalAlignment: Text.AlignHCenter wrapMode: Text.WordWrap font.italic: true text: i18ndp("plasma_lookandfeel_org.kde.lookandfeel", "One other user is currently logged in. If the computer is shut down or restarted, that user may lose work.", "%1 other users are currently logged in. If the computer is shut down or restarted, those users may lose work.", sessionsModel.count) visible: sessionsModel.count > 1 } RowLayout { spacing: units.largeSpacing * 2 Layout.alignment: Qt.AlignHCenter LogoutButton { id: suspendButton iconSource: "system-suspend" text: i18ndc("plasma_lookandfeel_org.kde.lookandfeel", "Suspend to RAM", "Sleep") action: root.sleepRequested KeyNavigation.left: logoutButton KeyNavigation.right: hibernateButton visible: spdMethods.SuspendState } LogoutButton { id: hibernateButton iconSource: "system-suspend-hibernate" text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Hibernate") action: root.hibernateRequested KeyNavigation.left: suspendButton KeyNavigation.right: rebootButton visible: spdMethods.HibernateState } LogoutButton { id: rebootButton iconSource: "system-reboot" text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Restart") action: root.rebootRequested KeyNavigation.left: hibernateButton KeyNavigation.right: shutdownButton focus: sdtype == ShutdownType.ShutdownTypeReboot visible: maysd } LogoutButton { id: shutdownButton iconSource: "system-shutdown" text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Shut Down") action: root.haltRequested KeyNavigation.left: rebootButton KeyNavigation.right: logoutButton focus: sdtype == ShutdownType.ShutdownTypeHalt visible: maysd } LogoutButton { id: logoutButton iconSource: "system-log-out" text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Log Out") action: root.logoutRequested KeyNavigation.left: shutdownButton KeyNavigation.right: suspendButton focus: sdtype == ShutdownType.ShutdownTypeNone visible: canLogout } } PlasmaComponents.Label { - font.pointSize: 11 + font.pointSize: theme.defaultFont.pointSize + 1 Layout.alignment: Qt.AlignHCenter //opacity, as visible would re-layout opacity: countDownTimer.running ? 1 : 0 Behavior on opacity { OpacityAnimator { duration: units.longDuration easing.type: Easing.InOutQuad } } text: { switch (sdtype) { case ShutdownType.ShutdownTypeReboot: return i18ndp("plasma_lookandfeel_org.kde.lookandfeel", "Restarting in 1 second", "Restarting in %1 seconds", root.remainingTime); case ShutdownType.ShutdownTypeHalt: return i18ndp("plasma_lookandfeel_org.kde.lookandfeel", "Shutting down in 1 second", "Shutting down in %1 seconds", root.remainingTime); default: return i18ndp("plasma_lookandfeel_org.kde.lookandfeel", "Logging out in 1 second", "Logging out in %1 seconds", root.remainingTime); } } } RowLayout { Layout.alignment: Qt.AlignHCenter PlasmaComponents.Button { - font.pointSize: 11 + font.pointSize: theme.defaultFont.pointSize + 1 enabled: root.currentAction != null text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "OK") onClicked: root.currentAction() } PlasmaComponents.Button { - font.pointSize: 11 + font.pointSize: theme.defaultFont.pointSize + 1 text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Cancel") onClicked: root.cancelRequested() } } } } diff --git a/sddm-theme/Login.qml b/sddm-theme/Login.qml index c710b6a2f..ff3990f9c 100644 --- a/sddm-theme/Login.qml +++ b/sddm-theme/Login.qml @@ -1,111 +1,111 @@ 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 { id: root property Item mainPasswordBox: passwordBox property bool showUsernamePrompt: !showUserList property string lastUserName property bool loginScreenUiVisible: false //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 focused //DAVE REPORT THE FRICKING THING AND PUT A LINK loginButton.forceActiveFocus(); loginRequest(username, password); } PlasmaComponents.TextField { id: userNameInput - font.pointSize: 11 + font.pointSize: theme.defaultFont.pointSize + 1 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") onAccepted: if (root.loginScreenUiVisible) { passwordBox.forceActiveFocus() } } PlasmaComponents.TextField { id: passwordBox - font.pointSize: 11 + font.pointSize: theme.defaultFont.pointSize + 1 Layout.fillWidth: true placeholderText: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Password") focus: !showUsernamePrompt || lastUserName echoMode: TextInput.Password revealPasswordButtonShown: true onAccepted: { if (root.loginScreenUiVisible) { 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 - font.pointSize: 11 + font.pointSize: theme.defaultFont.pointSize + 1 Layout.fillWidth: true text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Log In") onClicked: startLogin(); } }