mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-01 19:18:28 -04:00
time: add follow-locale option and squash separate greeter time options
port 1.5
(cherry picked from commit f4f47c0bc5)
This commit is contained in:
@@ -190,7 +190,12 @@ Singleton {
|
||||
property int firstDayOfWeek: -1
|
||||
property bool showWeekNumber: false
|
||||
property string calendarBackend: "auto"
|
||||
property bool use24HourClock: true
|
||||
property string clockFormat: "auto"
|
||||
readonly property bool localeUses24Hour: {
|
||||
const fmt = Qt.locale().timeFormat(Locale.ShortFormat).replace(/'[^']*'/g, "");
|
||||
return !/[aA]/.test(fmt);
|
||||
}
|
||||
readonly property bool use24HourClock: clockFormat === "24h" ? true : (clockFormat === "12h" ? false : localeUses24Hour)
|
||||
property bool showSeconds: false
|
||||
property bool padHours12Hour: false
|
||||
property bool useFahrenheit: false
|
||||
@@ -492,9 +497,6 @@ Singleton {
|
||||
property bool greeterEnableFprint: false
|
||||
property bool greeterEnableU2f: false
|
||||
property string greeterWallpaperPath: ""
|
||||
property bool greeterUse24HourClock: true
|
||||
property bool greeterShowSeconds: false
|
||||
property bool greeterPadHours12Hour: false
|
||||
property string greeterLockDateFormat: ""
|
||||
property string greeterFontFamily: ""
|
||||
property string greeterWallpaperFillMode: ""
|
||||
@@ -1752,6 +1754,11 @@ Singleton {
|
||||
delete obj.lockScreenActiveMonitor;
|
||||
}
|
||||
|
||||
if (obj?.use24HourClock !== undefined && obj?.clockFormat === undefined) {
|
||||
obj.clockFormat = obj.use24HourClock ? "24h" : "12h";
|
||||
delete obj.use24HourClock;
|
||||
}
|
||||
|
||||
Store.parse(root, obj);
|
||||
|
||||
if (obj?.directionalAnimationMode === 3 && frameMode !== "connected")
|
||||
|
||||
@@ -42,9 +42,9 @@ var SPEC = {
|
||||
firstDayOfWeek: { def: -1 },
|
||||
showWeekNumber: { def: false },
|
||||
calendarBackend: { def: "auto" },
|
||||
use24HourClock: { def: true },
|
||||
showSeconds: { def: false },
|
||||
padHours12Hour: { def: false },
|
||||
clockFormat: { def: "auto", onChange: "markGreeterSyncPending" },
|
||||
showSeconds: { def: false, onChange: "markGreeterSyncPending" },
|
||||
padHours12Hour: { def: false, onChange: "markGreeterSyncPending" },
|
||||
useFahrenheit: { def: false },
|
||||
windSpeedUnit: { def: "kmh" },
|
||||
nightModeEnabled: { def: false },
|
||||
@@ -230,9 +230,6 @@ var SPEC = {
|
||||
greeterEnableFprint: { def: false, onChange: "scheduleAuthApply" },
|
||||
greeterEnableU2f: { def: false, onChange: "scheduleAuthApply" },
|
||||
greeterWallpaperPath: { def: "", onChange: "markGreeterSyncPending" },
|
||||
greeterUse24HourClock: { def: true, onChange: "markGreeterSyncPending" },
|
||||
greeterShowSeconds: { def: false, onChange: "markGreeterSyncPending" },
|
||||
greeterPadHours12Hour: { def: false, onChange: "markGreeterSyncPending" },
|
||||
greeterLockDateFormat: { def: "", onChange: "markGreeterSyncPending" },
|
||||
greeterFontFamily: { def: "", onChange: "markGreeterSyncPending" },
|
||||
greeterWallpaperFillMode: { def: "", onChange: "markGreeterSyncPending" },
|
||||
|
||||
@@ -36,12 +36,14 @@ Singleton {
|
||||
property string customThemeFile: ""
|
||||
property var registryThemeVariants: ({})
|
||||
property string matugenScheme: "scheme-tonal-spot"
|
||||
property bool use24HourClock: true
|
||||
property string clockFormat: "auto"
|
||||
readonly property bool localeUses24Hour: {
|
||||
const fmt = Qt.locale().timeFormat(Locale.ShortFormat).replace(/'[^']*'/g, "");
|
||||
return !/[aA]/.test(fmt);
|
||||
}
|
||||
readonly property bool use24HourClock: clockFormat === "24h" ? true : (clockFormat === "12h" ? false : localeUses24Hour)
|
||||
property bool showSeconds: false
|
||||
property bool padHours12Hour: false
|
||||
property bool greeterUse24HourClock: true
|
||||
property bool greeterShowSeconds: false
|
||||
property bool greeterPadHours12Hour: false
|
||||
property string greeterLockDateFormat: ""
|
||||
property string greeterFontFamily: ""
|
||||
property string greeterWallpaperFillMode: ""
|
||||
@@ -112,12 +114,9 @@ Singleton {
|
||||
customThemeFile = settings.customThemeFile !== undefined ? settings.customThemeFile : "";
|
||||
registryThemeVariants = settings.registryThemeVariants !== undefined ? settings.registryThemeVariants : ({});
|
||||
matugenScheme = settings.matugenScheme !== undefined ? settings.matugenScheme : "scheme-tonal-spot";
|
||||
use24HourClock = settings.use24HourClock !== undefined ? settings.use24HourClock : true;
|
||||
clockFormat = settings.clockFormat !== undefined ? settings.clockFormat : (settings.use24HourClock !== undefined ? (settings.use24HourClock ? "24h" : "12h") : "auto");
|
||||
showSeconds = settings.showSeconds !== undefined ? settings.showSeconds : false;
|
||||
padHours12Hour = settings.padHours12Hour !== undefined ? settings.padHours12Hour : false;
|
||||
greeterUse24HourClock = settings.greeterUse24HourClock !== undefined ? settings.greeterUse24HourClock : use24HourClock;
|
||||
greeterShowSeconds = settings.greeterShowSeconds !== undefined ? settings.greeterShowSeconds : showSeconds;
|
||||
greeterPadHours12Hour = settings.greeterPadHours12Hour !== undefined ? settings.greeterPadHours12Hour : padHours12Hour;
|
||||
greeterLockDateFormat = settings.greeterLockDateFormat !== undefined ? settings.greeterLockDateFormat : "";
|
||||
greeterFontFamily = settings.greeterFontFamily !== undefined ? settings.greeterFontFamily : "";
|
||||
greeterWallpaperFillMode = settings.greeterWallpaperFillMode !== undefined ? settings.greeterWallpaperFillMode : "";
|
||||
@@ -182,9 +181,9 @@ Singleton {
|
||||
}
|
||||
|
||||
function getEffectiveTimeFormat() {
|
||||
const use24 = greeterUse24HourClock;
|
||||
const secs = greeterShowSeconds;
|
||||
const pad = greeterPadHours12Hour;
|
||||
const use24 = use24HourClock;
|
||||
const secs = showSeconds;
|
||||
const pad = padHours12Hour;
|
||||
if (use24)
|
||||
return secs ? "hh:mm:ss" : "hh:mm";
|
||||
if (pad)
|
||||
|
||||
@@ -547,42 +547,6 @@ Item {
|
||||
onFontSelected: family => SettingsData.set("greeterFontFamily", family)
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("Time Format")
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
font.weight: Font.Medium
|
||||
color: Theme.surfaceText
|
||||
topPadding: Theme.spacingM
|
||||
width: parent.width
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
}
|
||||
|
||||
SettingsToggleRow {
|
||||
settingKey: "greeterUse24Hour"
|
||||
tags: ["greeter", "time", "24hour"]
|
||||
text: I18n.tr("24-hour clock")
|
||||
description: I18n.tr("Greeter only — does not affect main clock")
|
||||
checked: SettingsData.greeterUse24HourClock
|
||||
onToggled: checked => SettingsData.set("greeterUse24HourClock", checked)
|
||||
}
|
||||
|
||||
SettingsToggleRow {
|
||||
settingKey: "greeterShowSeconds"
|
||||
tags: ["greeter", "time", "seconds"]
|
||||
text: I18n.tr("Show Seconds")
|
||||
checked: SettingsData.greeterShowSeconds
|
||||
onToggled: checked => SettingsData.set("greeterShowSeconds", checked)
|
||||
}
|
||||
|
||||
SettingsToggleRow {
|
||||
settingKey: "greeterPadHours"
|
||||
tags: ["greeter", "time", "12hour"]
|
||||
text: I18n.tr("Pad hours (02:00 vs 2:00)")
|
||||
visible: !SettingsData.greeterUse24HourClock
|
||||
checked: SettingsData.greeterPadHours12Hour
|
||||
onToggled: checked => SettingsData.set("greeterPadHours12Hour", checked)
|
||||
}
|
||||
|
||||
StyledText {
|
||||
text: I18n.tr("Date format on greeter")
|
||||
font.pixelSize: Theme.fontSizeMedium
|
||||
|
||||
@@ -46,14 +46,37 @@ Item {
|
||||
settingKey: "timeFormat"
|
||||
iconName: "schedule"
|
||||
|
||||
SettingsToggleRow {
|
||||
SettingsDropdownRow {
|
||||
tab: "time"
|
||||
tags: ["time", "24hour", "format"]
|
||||
settingKey: "use24HourClock"
|
||||
text: I18n.tr("24-Hour Format")
|
||||
tags: ["time", "24hour", "12hour", "format", "locale"]
|
||||
settingKey: "clockFormat"
|
||||
text: I18n.tr("Time Format")
|
||||
description: I18n.tr("Use 24-hour time format instead of 12-hour AM/PM")
|
||||
checked: SettingsData.use24HourClock
|
||||
onToggled: checked => SettingsData.set("use24HourClock", checked)
|
||||
readonly property var _sample: new Date(2000, 0, 1, 13, 0, 0)
|
||||
readonly property string _twelve: Qt.formatTime(_sample, "h:mm AP")
|
||||
readonly property string _twentyFour: Qt.formatTime(_sample, "HH:mm")
|
||||
options: [I18n.tr("System Default"), _twelve, _twentyFour]
|
||||
currentValue: {
|
||||
switch (SettingsData.clockFormat) {
|
||||
case "12h":
|
||||
return _twelve;
|
||||
case "24h":
|
||||
return _twentyFour;
|
||||
default:
|
||||
return I18n.tr("System Default");
|
||||
}
|
||||
}
|
||||
onValueChanged: value => {
|
||||
if (value === _twelve) {
|
||||
SettingsData.set("clockFormat", "12h");
|
||||
return;
|
||||
}
|
||||
if (value === _twentyFour) {
|
||||
SettingsData.set("clockFormat", "24h");
|
||||
return;
|
||||
}
|
||||
SettingsData.set("clockFormat", "auto");
|
||||
}
|
||||
}
|
||||
|
||||
SettingsToggleRow {
|
||||
|
||||
@@ -412,23 +412,6 @@
|
||||
],
|
||||
"description": "Select monitor to configure wallpaper"
|
||||
},
|
||||
{
|
||||
"section": "use24HourClock",
|
||||
"label": "24-Hour Format",
|
||||
"tabIndex": 1,
|
||||
"category": "Time & Weather",
|
||||
"keywords": [
|
||||
"24hour",
|
||||
"clock",
|
||||
"date",
|
||||
"forecast",
|
||||
"format",
|
||||
"hour",
|
||||
"time",
|
||||
"weather"
|
||||
],
|
||||
"description": "Use 24-hour time format instead of 12-hour AM/PM"
|
||||
},
|
||||
{
|
||||
"section": "useAutoLocation",
|
||||
"label": "Auto Location",
|
||||
@@ -634,6 +617,25 @@
|
||||
],
|
||||
"icon": "schedule"
|
||||
},
|
||||
{
|
||||
"section": "clockFormat",
|
||||
"label": "Time Format",
|
||||
"tabIndex": 1,
|
||||
"category": "Time & Weather",
|
||||
"keywords": [
|
||||
"12hour",
|
||||
"24hour",
|
||||
"clock",
|
||||
"date",
|
||||
"forecast",
|
||||
"format",
|
||||
"hour",
|
||||
"locale",
|
||||
"time",
|
||||
"weather"
|
||||
],
|
||||
"description": "Use 24-hour time format instead of 12-hour AM/PM"
|
||||
},
|
||||
{
|
||||
"section": "timeFormat",
|
||||
"label": "Time Format",
|
||||
@@ -7676,27 +7678,6 @@
|
||||
],
|
||||
"description": "Change the locale used for date and time formatting, independent of the interface language."
|
||||
},
|
||||
{
|
||||
"section": "greeterUse24Hour",
|
||||
"label": "24-hour clock",
|
||||
"tabIndex": 31,
|
||||
"category": "Greeter",
|
||||
"keywords": [
|
||||
"24hour",
|
||||
"affect",
|
||||
"clock",
|
||||
"display manager",
|
||||
"does",
|
||||
"greetd",
|
||||
"greeter",
|
||||
"hour",
|
||||
"login",
|
||||
"main",
|
||||
"time",
|
||||
"watch"
|
||||
],
|
||||
"description": "Greeter only — does not affect main clock"
|
||||
},
|
||||
{
|
||||
"section": "greeterAutoLogin",
|
||||
"label": "Auto-login on startup",
|
||||
@@ -7875,24 +7856,6 @@
|
||||
],
|
||||
"icon": "fingerprint"
|
||||
},
|
||||
{
|
||||
"section": "greeterPadHours",
|
||||
"label": "Pad hours (02:00 vs 2:00)",
|
||||
"tabIndex": 31,
|
||||
"category": "Greeter",
|
||||
"keywords": [
|
||||
"(02:00",
|
||||
"12hour",
|
||||
"2:00)",
|
||||
"display manager",
|
||||
"greetd",
|
||||
"greeter",
|
||||
"hours",
|
||||
"login",
|
||||
"pad",
|
||||
"time"
|
||||
]
|
||||
},
|
||||
{
|
||||
"section": "greeterRememberLastSession",
|
||||
"label": "Remember last session",
|
||||
@@ -7929,21 +7892,6 @@
|
||||
],
|
||||
"description": "Pre-fill the last successful username on the greeter"
|
||||
},
|
||||
{
|
||||
"section": "greeterShowSeconds",
|
||||
"label": "Show Seconds",
|
||||
"tabIndex": 31,
|
||||
"category": "Greeter",
|
||||
"keywords": [
|
||||
"display manager",
|
||||
"greetd",
|
||||
"greeter",
|
||||
"login",
|
||||
"seconds",
|
||||
"show",
|
||||
"time"
|
||||
]
|
||||
},
|
||||
{
|
||||
"section": "muxType",
|
||||
"label": "Multiplexer",
|
||||
|
||||
Reference in New Issue
Block a user