1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 13:32:50 -05:00

lockscreen/greetd: add 0 in front of single digit hours for 12 hour format. greetd: add option to hide profile image (#1247)

* greetd: add lockScreenShowProfileImage option

* lockscreen/greetd: for non 24 hour formats, add 0 in front of single digit hours to ensure that everything is always centered properly - previously, it would only appear centered if on a double digit hour. also add getEffectiveTimeFormat function to GreetdSettings.

* clock: made pad 12 hour formats optional

---------

Co-authored-by: bbedward <bbedward@gmail.com>
This commit is contained in:
Ethan Todd
2026-01-23 14:47:59 -05:00
committed by GitHub
parent b4ba2dac37
commit 11e23feb0e
6 changed files with 43 additions and 17 deletions

View File

@@ -146,6 +146,7 @@ Singleton {
property bool use24HourClock: true property bool use24HourClock: true
property bool showSeconds: false property bool showSeconds: false
property bool padHours12Hour: false
property bool useFahrenheit: false property bool useFahrenheit: false
property string windSpeedUnit: "kmh" property string windSpeedUnit: "kmh"
property bool nightModeEnabled: false property bool nightModeEnabled: false
@@ -1252,11 +1253,11 @@ Singleton {
} }
function getEffectiveTimeFormat() { function getEffectiveTimeFormat() {
if (use24HourClock) { if (use24HourClock)
return showSeconds ? "hh:mm:ss" : "hh:mm"; return showSeconds ? "hh:mm:ss" : "hh:mm";
} else { if (padHours12Hour)
return showSeconds ? "h:mm:ss AP" : "h:mm AP"; return showSeconds ? "hh:mm:ss AP" : "hh:mm AP";
} return showSeconds ? "h:mm:ss AP" : "h:mm AP";
} }
function getEffectiveClockDateFormat() { function getEffectiveClockDateFormat() {

View File

@@ -32,6 +32,7 @@ var SPEC = {
use24HourClock: { def: true }, use24HourClock: { def: true },
showSeconds: { def: false }, showSeconds: { def: false },
padHours12Hour: { def: false },
useFahrenheit: { def: false }, useFahrenheit: { def: false },
windSpeedUnit: { def: "kmh" }, windSpeedUnit: { def: "kmh" },
nightModeEnabled: { def: false }, nightModeEnabled: { def: false },

View File

@@ -30,13 +30,13 @@ BasePill {
StyledText { StyledText {
text: { text: {
if (SettingsData.use24HourClock) { const hours = systemClock?.date?.getHours();
return String(systemClock?.date?.getHours()).padStart(2, '0').charAt(0); if (SettingsData.use24HourClock)
} else { return String(hours).padStart(2, '0').charAt(0);
const hours = systemClock?.date?.getHours(); const display = hours === 0 ? 12 : hours > 12 ? hours - 12 : hours;
const display = hours === 0 ? 12 : hours > 12 ? hours - 12 : hours; if (SettingsData.padHours12Hour)
return String(display).padStart(2, '0').charAt(0); return String(display).padStart(2, '0').charAt(0);
} return display >= 10 ? String(display).charAt(0) : "";
} }
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale) font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
color: Theme.widgetTextColor color: Theme.widgetTextColor
@@ -47,13 +47,13 @@ BasePill {
StyledText { StyledText {
text: { text: {
if (SettingsData.use24HourClock) { const hours = systemClock?.date?.getHours();
return String(systemClock?.date?.getHours()).padStart(2, '0').charAt(1); if (SettingsData.use24HourClock)
} else { return String(hours).padStart(2, '0').charAt(1);
const hours = systemClock?.date?.getHours(); const display = hours === 0 ? 12 : hours > 12 ? hours - 12 : hours;
const display = hours === 0 ? 12 : hours > 12 ? hours - 12 : hours; if (SettingsData.padHours12Hour)
return String(display).padStart(2, '0').charAt(1); return String(display).padStart(2, '0').charAt(1);
} return display >= 10 ? String(display).charAt(1) : String(display);
} }
font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale) font.pixelSize: Theme.barTextSize(root.barThickness, root.barConfig?.fontScale)
color: Theme.widgetTextColor color: Theme.widgetTextColor

View File

@@ -20,6 +20,7 @@ Singleton {
property string matugenScheme: "scheme-tonal-spot" property string matugenScheme: "scheme-tonal-spot"
property bool use24HourClock: true property bool use24HourClock: true
property bool showSeconds: false property bool showSeconds: false
property bool padHours12Hour: false
property bool useFahrenheit: false property bool useFahrenheit: false
property bool nightModeEnabled: false property bool nightModeEnabled: false
property string weatherLocation: "New York, NY" property string weatherLocation: "New York, NY"
@@ -39,6 +40,7 @@ Singleton {
property string widgetBackgroundColor: "sch" property string widgetBackgroundColor: "sch"
property string lockDateFormat: "" property string lockDateFormat: ""
property bool lockScreenShowPowerActions: true property bool lockScreenShowPowerActions: true
property bool lockScreenShowProfileImage: true
property var screenPreferences: ({}) property var screenPreferences: ({})
property int animationSpeed: 2 property int animationSpeed: 2
property string wallpaperFillMode: "Fill" property string wallpaperFillMode: "Fill"
@@ -52,6 +54,7 @@ Singleton {
matugenScheme = settings.matugenScheme !== undefined ? settings.matugenScheme : "scheme-tonal-spot"; matugenScheme = settings.matugenScheme !== undefined ? settings.matugenScheme : "scheme-tonal-spot";
use24HourClock = settings.use24HourClock !== undefined ? settings.use24HourClock : true; use24HourClock = settings.use24HourClock !== undefined ? settings.use24HourClock : true;
showSeconds = settings.showSeconds !== undefined ? settings.showSeconds : false; showSeconds = settings.showSeconds !== undefined ? settings.showSeconds : false;
padHours12Hour = settings.padHours12Hour !== undefined ? settings.padHours12Hour : false;
useFahrenheit = settings.useFahrenheit !== undefined ? settings.useFahrenheit : false; useFahrenheit = settings.useFahrenheit !== undefined ? settings.useFahrenheit : false;
nightModeEnabled = settings.nightModeEnabled !== undefined ? settings.nightModeEnabled : false; nightModeEnabled = settings.nightModeEnabled !== undefined ? settings.nightModeEnabled : false;
weatherLocation = settings.weatherLocation !== undefined ? settings.weatherLocation : "New York, NY"; weatherLocation = settings.weatherLocation !== undefined ? settings.weatherLocation : "New York, NY";
@@ -71,6 +74,7 @@ Singleton {
widgetBackgroundColor = settings.widgetBackgroundColor !== undefined ? settings.widgetBackgroundColor : "sch"; widgetBackgroundColor = settings.widgetBackgroundColor !== undefined ? settings.widgetBackgroundColor : "sch";
lockDateFormat = settings.lockDateFormat !== undefined ? settings.lockDateFormat : ""; lockDateFormat = settings.lockDateFormat !== undefined ? settings.lockDateFormat : "";
lockScreenShowPowerActions = settings.lockScreenShowPowerActions !== undefined ? settings.lockScreenShowPowerActions : true; lockScreenShowPowerActions = settings.lockScreenShowPowerActions !== undefined ? settings.lockScreenShowPowerActions : true;
lockScreenShowProfileImage = settings.lockScreenShowProfileImage !== undefined ? settings.lockScreenShowProfileImage : true;
screenPreferences = settings.screenPreferences !== undefined ? settings.screenPreferences : ({}); screenPreferences = settings.screenPreferences !== undefined ? settings.screenPreferences : ({});
animationSpeed = settings.animationSpeed !== undefined ? settings.animationSpeed : 2; animationSpeed = settings.animationSpeed !== undefined ? settings.animationSpeed : 2;
wallpaperFillMode = settings.wallpaperFillMode !== undefined ? settings.wallpaperFillMode : "Fill"; wallpaperFillMode = settings.wallpaperFillMode !== undefined ? settings.wallpaperFillMode : "Fill";
@@ -88,6 +92,14 @@ Singleton {
} }
} }
function getEffectiveTimeFormat() {
if (use24HourClock)
return showSeconds ? "hh:mm:ss" : "hh:mm";
if (padHours12Hour)
return showSeconds ? "hh:mm:ss AP" : "hh:mm AP";
return showSeconds ? "h:mm:ss AP" : "h:mm AP";
}
function getEffectiveLockDateFormat() { function getEffectiveLockDateFormat() {
return lockDateFormat && lockDateFormat.length > 0 ? lockDateFormat : Locale.LongFormat; return lockDateFormat && lockDateFormat.length > 0 ? lockDateFormat : Locale.LongFormat;
} }

View File

@@ -217,7 +217,7 @@ Item {
spacing: 0 spacing: 0
property string fullTimeStr: { property string fullTimeStr: {
const format = GreetdSettings.use24HourClock ? (GreetdSettings.showSeconds ? "HH:mm:ss" : "HH:mm") : (GreetdSettings.showSeconds ? "h:mm:ss AP" : "h:mm AP"); const format = GreetdSettings.getEffectiveTimeFormat();
return systemClock.date.toLocaleTimeString(Qt.locale(), format); return systemClock.date.toLocaleTimeString(Qt.locale(), format);
} }
property var timeParts: fullTimeStr.split(':') property var timeParts: fullTimeStr.split(':')
@@ -363,6 +363,7 @@ Item {
return PortalService.profileImage; return PortalService.profileImage;
} }
fallbackIcon: "person" fallbackIcon: "person"
visible: GreetdSettings.lockScreenShowProfileImage
} }
Rectangle { Rectangle {

View File

@@ -49,6 +49,17 @@ Item {
checked: SettingsData.showSeconds checked: SettingsData.showSeconds
onToggled: checked => SettingsData.set("showSeconds", checked) onToggled: checked => SettingsData.set("showSeconds", checked)
} }
SettingsToggleRow {
tab: "time"
tags: ["time", "12hour", "format", "padding", "leading", "zero"]
settingKey: "padHours12Hour"
text: I18n.tr("Pad Hours")
description: "02:31 PM vs 2:31 PM"
checked: SettingsData.padHours12Hour
onToggled: checked => SettingsData.set("padHours12Hour", checked)
visible: !SettingsData.use24HourClock
}
} }
SettingsCard { SettingsCard {