From be5acaf8a9b15551855da38e2283717ec4935f70 Mon Sep 17 00:00:00 2001 From: Devin Lin Date: Thu, 27 Oct 2022 19:48:05 -0400 Subject: [PATCH] lockscreen: Use bold text for clock to improve contrast --- look-and-feel/contents/lockscreen/Clock.qml | 106 ++++++++++-------- .../lockscreen/LockScreenNarrowContent.qml | 1 + .../LockScreenWideScreenContent.qml | 1 + 3 files changed, 59 insertions(+), 49 deletions(-) diff --git a/look-and-feel/contents/lockscreen/Clock.qml b/look-and-feel/contents/lockscreen/Clock.qml index 40eaef7a..0ba4c04c 100644 --- a/look-and-feel/contents/lockscreen/Clock.qml +++ b/look-and-feel/contents/lockscreen/Clock.qml @@ -1,67 +1,75 @@ /* * SPDX-FileCopyrightText: 2019 Nicolas Fella + * SPDX-FileCopyrightText: 2020-2022 Devin Lin * SPDX-License-Identifier: GPL-2.0-or-later */ -import QtQuick 2.8 -import QtQuick.Layouts 1.1 -import QtQuick.Controls 2.5 +import QtQuick 2.15 +import QtQuick.Layouts 1.15 +import QtQuick.Controls 2.15 import QtGraphicalEffects 1.12 -import org.kde.plasma.core 2.0 - +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 3.0 as PC3 import org.kde.plasma.private.mobileshell 1.0 as MobileShell -ColumnLayout { +import org.kde.kirigami 2.20 as Kirigami + +Item { id: root + implicitHeight: clockColumn.implicitHeight + implicitWidth: clockColumn.implicitWidth + property int layoutAlignment - readonly property bool softwareRendering: GraphicsInfo.api === GraphicsInfo.Software - readonly property bool is24HourTime: MobileShell.ShellUtil.isSystem24HourFormat - - Layout.alignment: layoutAlignment - spacing: Units.gridUnit - - Label { - text: Qt.formatTime(timeSource.data["Local"]["DateTime"], root.is24HourTime ? "h:mm" : "h:mm ap") - color: ColorScope.textColor - style: softwareRendering ? Text.Outline : Text.Normal - styleColor: softwareRendering ? ColorScope.backgroundColor : "transparent" // no outline, doesn't matter - - Layout.alignment: root.layoutAlignment - font.weight: Font.Light // this font weight may switch to regular on distros that don't have a light variant - font.pointSize: 36 - layer.enabled: true - layer.effect: DropShadow { - verticalOffset: 1 - radius: 4 - samples: 6 - color: "#757575" - } - } - - Label { - text: Qt.formatDate(timeSource.data["Local"]["DateTime"], "ddd, MMM d") - color: ColorScope.textColor - style: softwareRendering ? Text.Outline : Text.Normal - styleColor: softwareRendering ? ColorScope.backgroundColor : "transparent" // no outline, doesn't matter - - Layout.alignment: root.layoutAlignment - font.pointSize: 10 - layer.enabled: true - layer.effect: DropShadow { - verticalOffset: 1 - radius: 4 - samples: 6 - color: "#757575" - } - } - - DataSource { + PlasmaCore.DataSource { id: timeSource engine: "time" connectedSources: ["Local"] interval: 60000 - intervalAlignment: Types.AlignToMinute + intervalAlignment: PlasmaCore.Types.AlignToMinute + } + + Kirigami.ImageColors { + id: imageColors + source: wallpaper + } + + DropShadow { + anchors.fill: parent + source: clockColumn + cached: true + verticalOffset: 1 + radius: 4 + samples: 6 + color: Qt.rgba(0, 0, 0, 0.4) + } + + ColumnLayout { + id: clockColumn + opacity: 0.8 + spacing: PlasmaCore.Units.gridUnit + + anchors.top: parent.top + anchors.left: parent.left + anchors.right: parent.right + + PC3.Label { + text: Qt.formatTime(timeSource.data["Local"]["DateTime"], MobileShell.ShellUtil.isSystem24HourFormat ? "h:mm" : "h:mm ap") + color: "white" + + Layout.alignment: root.layoutAlignment + font.weight: Font.Bold + font.pointSize: 36 + } + + PC3.Label { + text: Qt.formatDate(timeSource.data["Local"]["DateTime"], "ddd, MMM d") + color: "white" + + Layout.alignment: root.layoutAlignment + font.weight: Font.Bold + font.pointSize: 10 + } } } diff --git a/look-and-feel/contents/lockscreen/LockScreenNarrowContent.qml b/look-and-feel/contents/lockscreen/LockScreenNarrowContent.qml index 50418631..dc79a6a0 100644 --- a/look-and-feel/contents/lockscreen/LockScreenNarrowContent.qml +++ b/look-and-feel/contents/lockscreen/LockScreenNarrowContent.qml @@ -54,6 +54,7 @@ Loader { Clock { layoutAlignment: Qt.AlignHCenter + Layout.alignment: Qt.AlignHCenter Layout.bottomMargin: PlasmaCore.Units.gridUnit * 2 // keep spacing even if media controls are gone } diff --git a/look-and-feel/contents/lockscreen/LockScreenWideScreenContent.qml b/look-and-feel/contents/lockscreen/LockScreenWideScreenContent.qml index b0077502..f2eb4a1c 100644 --- a/look-and-feel/contents/lockscreen/LockScreenWideScreenContent.qml +++ b/look-and-feel/contents/lockscreen/LockScreenWideScreenContent.qml @@ -40,6 +40,7 @@ Loader { Clock { layoutAlignment: Qt.AlignLeft + Layout.alignment: Qt.AlignLeft Layout.fillWidth: true Layout.minimumWidth: PlasmaCore.Units.gridUnit * 20 }