lockscreen: Use bold text for clock to improve contrast

This commit is contained in:
Devin Lin 2022-10-27 19:48:05 -04:00
parent 7eaf640926
commit be5acaf8a9
3 changed files with 59 additions and 49 deletions

View file

@ -1,67 +1,75 @@
/*
* SPDX-FileCopyrightText: 2019 Nicolas Fella <nicolas.fella@gmx.de>
* SPDX-FileCopyrightText: 2020-2022 Devin Lin <devin@kde.org>
* 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
}
}
}

View file

@ -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
}

View file

@ -40,6 +40,7 @@ Loader {
Clock {
layoutAlignment: Qt.AlignLeft
Layout.alignment: Qt.AlignLeft
Layout.fillWidth: true
Layout.minimumWidth: PlasmaCore.Units.gridUnit * 20
}