From bcaf3886d92da5b5cc6f2ab6a6b43dbc096d7c60 Mon Sep 17 00:00:00 2001 From: Nate Graham Date: Wed, 12 Aug 2020 13:04:03 -0600 Subject: [PATCH] Fix all errors and warnings on login, lock, and logout screens There were three principal sources of errors and warnings: 1. Un-ported `onFooChanged` statements 2. `config.fontSize` being unconditionally referenced from components without access to it (it comes from the SDDM config) 3. Accessing units from the context property rather than the singleton All are fixed now. Tested with: 1. `sddm-greeter --test-mode --theme ~/kde/usr/share/sddm/themes/breeze/` 2. `~/kde/usr/lib64/libexec/kscreenlocker_greet --testing --theme ~/kde/src/plasma-workspace/lookandfeel` 3. `/kde/usr/lib64/libexec/ksmserver-logout-greeter --fakearg` No regressions found. BUG: 425349 FIXED-IN: 5.20 --- components/workspace/BatteryIcon.qml | 2 +- .../contents/components/ActionButton.qml | 4 ++-- lookandfeel/contents/components/Battery.qml | 8 +++++-- .../components/KeyboardLayoutButton.qml | 4 ---- .../components/SessionManagementScreen.qml | 5 +++-- .../contents/components/UserDelegate.qml | 5 ++--- lookandfeel/contents/components/UserList.qml | 3 +++ .../contents/lockscreen/LockScreen.qml | 2 +- .../contents/lockscreen/LockScreenUi.qml | 10 ++++----- lookandfeel/contents/lockscreen/MainBlock.qml | 2 +- lookandfeel/contents/logout/Logout.qml | 1 - sddm-theme/KeyboardButton.qml | 1 - sddm-theme/Login.qml | 2 +- sddm-theme/Main.qml | 22 +++++++++++++++++-- sddm-theme/SessionButton.qml | 2 -- 15 files changed, 45 insertions(+), 28 deletions(-) diff --git a/components/workspace/BatteryIcon.qml b/components/workspace/BatteryIcon.qml index 1ddbdcb7c..3c40ab827 100644 --- a/components/workspace/BatteryIcon.qml +++ b/components/workspace/BatteryIcon.qml @@ -39,7 +39,7 @@ Item { PlasmaCore.SvgItem { id: batterySvg anchors.centerIn: parent - width: units.roundToIconSize(Math.min(parent.width, parent.height)) + width: PlasmaCore.Units.roundToIconSize(Math.min(parent.width, parent.height)) height: width svg: svg elementId: "Battery" diff --git a/lookandfeel/contents/components/ActionButton.qml b/lookandfeel/contents/components/ActionButton.qml index 87e5c72fe..342e0f939 100644 --- a/lookandfeel/contents/components/ActionButton.qml +++ b/lookandfeel/contents/components/ActionButton.qml @@ -30,7 +30,7 @@ Item { property alias labelRendering: label.renderType property alias circleOpacity: iconCircle.opacity property alias circleVisiblity: iconCircle.visible - property int fontSize: config.fontSize + property int fontSize: PlasmaCore.Theme.defaultFont.pointSize + 1 readonly property bool softwareRendering: GraphicsInfo.api === GraphicsInfo.Software signal clicked @@ -96,7 +96,7 @@ Item { PlasmaComponents3.Label { id: label - font.pointSize: Math.max(fontSize + 1,theme.defaultFont.pointSize + 1) + font.pointSize: root.fontSize anchors { top: icon.bottom topMargin: (softwareRendering ? 1.5 : 1) * units.smallSpacing diff --git a/lookandfeel/contents/components/Battery.qml b/lookandfeel/contents/components/Battery.qml index b7ab644f1..93796c6ff 100644 --- a/lookandfeel/contents/components/Battery.qml +++ b/lookandfeel/contents/components/Battery.qml @@ -24,7 +24,11 @@ import org.kde.plasma.components 3.0 as PlasmaComponents3 import org.kde.plasma.workspace.components 2.0 as PW Row { - spacing: units.smallSpacing + id: row + + property int fontSize: PlasmaCore.Theme.defaultFont.pointSize + + spacing: PlasmaCore.Units.smallSpacing visible: pmSource.data["Battery"]["Has Cumulative"] PlasmaCore.DataSource { @@ -45,7 +49,7 @@ Row { PlasmaComponents3.Label { id: batteryLabel - font.pointSize: config.fontSize + font.pointSize: row.fontSize text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","%1%", battery.percent) Accessible.name: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Battery at %1%", battery.percent) } diff --git a/lookandfeel/contents/components/KeyboardLayoutButton.qml b/lookandfeel/contents/components/KeyboardLayoutButton.qml index f3be4c951..483ca25f6 100644 --- a/lookandfeel/contents/components/KeyboardLayoutButton.qml +++ b/lookandfeel/contents/components/KeyboardLayoutButton.qml @@ -25,14 +25,10 @@ import org.kde.plasma.components 3.0 as PlasmaComponents3 import org.kde.plasma.workspace.keyboardlayout 1.0 PlasmaComponents3.ToolButton { - - property int fontSize: config.fontSize - id: kbLayoutButton icon.name: "input-keyboard" text: layout.currentLayoutDisplayName - font.pointSize: Math.max(fontSize,theme.defaultFont.pointSize) Accessible.name: i18ndc("plasma_lookandfeel_org.kde.lookandfeel", "Button to change keyboard layout", "Switch layout") diff --git a/lookandfeel/contents/components/SessionManagementScreen.qml b/lookandfeel/contents/components/SessionManagementScreen.qml index e222017ed..58110c5fb 100644 --- a/lookandfeel/contents/components/SessionManagementScreen.qml +++ b/lookandfeel/contents/components/SessionManagementScreen.qml @@ -61,7 +61,7 @@ Item { property alias userList: userListView - property int fontSize: config.fontSize + property int fontSize: PlasmaCore.Theme.defaultFont.pointSize + 2 default property alias _children: innerLayout.children @@ -73,6 +73,7 @@ Item { left: parent.left right: parent.right } + fontSize: root.fontSize } //goal is to show the prompts, in ~16 grid units high, then the action buttons @@ -87,7 +88,7 @@ Item { anchors.bottom: parent.bottom PlasmaComponents3.Label { id: notificationsLabel - font.pointSize: Math.max(fontSize + 1,theme.defaultFont.pointSize + 1) + font.pointSize: root.fontSize Layout.maximumWidth: units.gridUnit * 16 Layout.alignment: Qt.AlignHCenter Layout.fillWidth: true diff --git a/lookandfeel/contents/components/UserDelegate.qml b/lookandfeel/contents/components/UserDelegate.qml index fb06b1d3b..b24e1d6f6 100644 --- a/lookandfeel/contents/components/UserDelegate.qml +++ b/lookandfeel/contents/components/UserDelegate.qml @@ -31,14 +31,13 @@ Item { 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 property alias nameFontSize: usernameDelegate.font.pointSize - property int fontSize: config.fontSize + property int fontSize: PlasmaCore.Theme.defaultFont.pointSize + 2 signal clicked() property real faceSize: units.gridUnit * 7 @@ -161,7 +160,7 @@ Item { PlasmaComponents3.Label { id: usernameDelegate - font.pointSize: Math.max(fontSize + 2,theme.defaultFont.pointSize + 2) + font.pointSize: wrapper.fontSize anchors { bottom: parent.bottom horizontalCenter: parent.horizontalCenter diff --git a/lookandfeel/contents/components/UserList.qml b/lookandfeel/contents/components/UserList.qml index 9e8ca4cc6..dbac102cb 100644 --- a/lookandfeel/contents/components/UserList.qml +++ b/lookandfeel/contents/components/UserList.qml @@ -18,12 +18,14 @@ */ import QtQuick 2.2 +import org.kde.plasma.core 2.0 as PlasmaCore ListView { id: view readonly property string selectedUser: currentItem ? currentItem.userName : "" readonly property int userItemWidth: units.gridUnit * 8 readonly property int userItemHeight: units.gridUnit * 8 + property int fontSize: PlasmaCore.Theme.defaultFont.pointSize + 2 implicitHeight: userItemHeight @@ -47,6 +49,7 @@ ListView { delegate: UserDelegate { avatarPath: model.icon || "" iconSource: model.iconName || "user-identity" + fontSize: view.fontSize name: { var displayName = model.realName || model.name diff --git a/lookandfeel/contents/lockscreen/LockScreen.qml b/lookandfeel/contents/lockscreen/LockScreen.qml index c0bc939e4..7c0d814f3 100644 --- a/lookandfeel/contents/lockscreen/LockScreen.qml +++ b/lookandfeel/contents/lockscreen/LockScreen.qml @@ -52,7 +52,7 @@ Item { Connections { id:loaderConnection target: org_kde_plasma_screenlocker_greeter_view - onFrameSwapped: { + function onFrameSwapped() { mainLoader.source = "LockScreenUi.qml"; loaderConnection.target = null; } diff --git a/lookandfeel/contents/lockscreen/LockScreenUi.qml b/lookandfeel/contents/lockscreen/LockScreenUi.qml index 19bff3ea2..5a82f9bca 100644 --- a/lookandfeel/contents/lockscreen/LockScreenUi.qml +++ b/lookandfeel/contents/lockscreen/LockScreenUi.qml @@ -40,19 +40,19 @@ PlasmaCore.ColorScope { Connections { target: authenticator - onFailed: { + function onFailed() { root.notification = i18nd("plasma_lookandfeel_org.kde.lookandfeel","Unlocking failed"); } - onGraceLockedChanged: { + function onGraceLockedChanged() { if (!authenticator.graceLocked) { root.notification = ""; root.clearPassword(); } } - onMessage: { + function onMessage() { root.notification = msg; } - onError: { + function onError() { root.notification = err; } } @@ -63,7 +63,7 @@ PlasmaCore.ColorScope { Connections { target: sessionManagement - onAboutToSuspend: { + function onAboutToSuspend() { root.clearPassword(); } } diff --git a/lookandfeel/contents/lockscreen/MainBlock.qml b/lookandfeel/contents/lockscreen/MainBlock.qml index ea8bf3d6b..628ae9043 100644 --- a/lookandfeel/contents/lockscreen/MainBlock.qml +++ b/lookandfeel/contents/lockscreen/MainBlock.qml @@ -87,7 +87,7 @@ SessionManagementScreen { Connections { target: root - onClearPassword: { + function onClearPassword() { passwordBox.forceActiveFocus() passwordBox.text = ""; } diff --git a/lookandfeel/contents/logout/Logout.qml b/lookandfeel/contents/logout/Logout.qml index 99f9bb99e..d715cdb34 100644 --- a/lookandfeel/contents/logout/Logout.qml +++ b/lookandfeel/contents/logout/Logout.qml @@ -119,7 +119,6 @@ PlasmaCore.ColorScope { UserDelegate { width: units.gridUnit * 7 height: width - nameFontSize: theme.defaultFont.pointSize + 2 anchors { horizontalCenter: parent.horizontalCenter bottom: parent.verticalCenter diff --git a/sddm-theme/KeyboardButton.qml b/sddm-theme/KeyboardButton.qml index 1ff71d4d9..d5d5a446c 100644 --- a/sddm-theme/KeyboardButton.qml +++ b/sddm-theme/KeyboardButton.qml @@ -12,7 +12,6 @@ PlasmaComponents.ToolButton { text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Keyboard Layout: %1", instantiator.objectAt(currentIndex).shortName) implicitWidth: minimumWidth - font.pointSize: config.fontSize visible: menu.items.length > 1 diff --git a/sddm-theme/Login.qml b/sddm-theme/Login.qml index 7a65cc505..e60ad704f 100644 --- a/sddm-theme/Login.qml +++ b/sddm-theme/Login.qml @@ -19,7 +19,7 @@ SessionManagementScreen { property int visibleBoundary: mapFromItem(loginButton, 0, 0).y onHeightChanged: visibleBoundary = mapFromItem(loginButton, 0, 0).y + loginButton.height + units.smallSpacing - property int fontSize: config.fontSize + property int fontSize: parseInt(config.fontSize) signal loginRequest(string username, string password) diff --git a/sddm-theme/Main.qml b/sddm-theme/Main.qml index 6c9b7c03e..43e444eb8 100644 --- a/sddm-theme/Main.qml +++ b/sddm-theme/Main.qml @@ -29,6 +29,11 @@ import org.kde.plasma.extras 2.0 as PlasmaExtras import "components" +// TODO: Once SDDM 0.19 is released and we are setting the font size using the +// SDDM KCM's syncing feature, remove the `config.fontSize` overrides here and +// the fontSize properties in various components, because the theme's default +// font size will be correctly propagated to the login screen + PlasmaCore.ColorScope { id: root @@ -203,6 +208,7 @@ PlasmaCore.ColorScope { ActionButton { iconSource: "system-suspend" text: i18ndc("plasma_lookandfeel_org.kde.lookandfeel","Suspend to RAM","Sleep") + fontSize: parseInt(config.fontSize) + 1 onClicked: sddm.suspend() enabled: sddm.canSuspend visible: !inputPanel.keyboardActive @@ -210,6 +216,7 @@ PlasmaCore.ColorScope { ActionButton { iconSource: "system-reboot" text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Restart") + fontSize: parseInt(config.fontSize) + 1 onClicked: sddm.reboot() enabled: sddm.canReboot visible: !inputPanel.keyboardActive @@ -217,6 +224,7 @@ PlasmaCore.ColorScope { ActionButton { iconSource: "system-shutdown" text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Shut Down") + fontSize: parseInt(config.fontSize) + 1 onClicked: sddm.powerOff() enabled: sddm.canPowerOff visible: !inputPanel.keyboardActive @@ -224,6 +232,7 @@ PlasmaCore.ColorScope { ActionButton { iconSource: "system-user-prompt" text: i18ndc("plasma_lookandfeel_org.kde.lookandfeel", "For switching to a username and password prompt", "Other...") + fontSize: parseInt(config.fontSize) + 1 onClicked: mainStack.push(userPromptComponent) enabled: true visible: !userListComponent.showUsernamePrompt && !inputPanel.keyboardActive @@ -361,6 +370,7 @@ PlasmaCore.ColorScope { showUsernamePrompt: true notificationMessage: root.notificationMessage loginScreenUiVisible: loginScreenRoot.uiVisible + fontSize: parseInt(config.fontSize) + 2 // using a model rather than a QObject list to avoid QTBUG-75900 userListModel: ListModel { @@ -383,6 +393,7 @@ PlasmaCore.ColorScope { ActionButton { iconSource: "system-suspend" text: i18ndc("plasma_lookandfeel_org.kde.lookandfeel","Suspend to RAM","Sleep") + fontSize: parseInt(config.fontSize) + 1 onClicked: sddm.suspend() enabled: sddm.canSuspend visible: !inputPanel.keyboardActive @@ -390,6 +401,7 @@ PlasmaCore.ColorScope { ActionButton { iconSource: "system-reboot" text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Restart") + fontSize: parseInt(config.fontSize) + 1 onClicked: sddm.reboot() enabled: sddm.canReboot visible: !inputPanel.keyboardActive @@ -397,6 +409,7 @@ PlasmaCore.ColorScope { ActionButton { iconSource: "system-shutdown" text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","Shut Down") + fontSize: parseInt(config.fontSize) + 1 onClicked: sddm.powerOff() enabled: sddm.canPowerOff visible: !inputPanel.keyboardActive @@ -404,6 +417,7 @@ PlasmaCore.ColorScope { ActionButton { iconSource: "system-user-list" text: i18nd("plasma_lookandfeel_org.kde.lookandfeel","List Users") + fontSize: parseInt(config.fontSize) + 1 onClicked: mainStack.pop() visible: !inputPanel.keyboardActive } @@ -460,7 +474,7 @@ PlasmaCore.ColorScope { bottom: parent.bottom left: parent.left right: parent.right - margins: units.smallSpacing + margins: PlasmaCore.Units.smallSpacing } Behavior on opacity { @@ -478,17 +492,21 @@ PlasmaCore.ColorScope { } KeyboardButton { + font.pointSize: config.fontSize } SessionButton { id: sessionButton + font.pointSize: config.fontSize } Item { Layout.fillWidth: true } - Battery { } + Battery { + fontSize: config.fontSize + } } } diff --git a/sddm-theme/SessionButton.qml b/sddm-theme/SessionButton.qml index 6bfd73ff5..cdd730a0a 100644 --- a/sddm-theme/SessionButton.qml +++ b/sddm-theme/SessionButton.qml @@ -34,8 +34,6 @@ PlasmaComponents.ToolButton { text: i18nd("plasma_lookandfeel_org.kde.lookandfeel", "Desktop Session: %1", instantiator.objectAt(currentIndex).text || "") - font.pointSize: config.fontSize - Component.onCompleted: { currentIndex = sessionModel.lastIndex }