Location/Clock: Moved use12hourformat and reverseDaymonth from the clock widget settings to the main settings, location tab

- Fix #303
This commit is contained in:
LemmyCook
2025-09-17 21:10:51 -04:00
parent 85d7dc2506
commit 47f72d9498
9 changed files with 77 additions and 87 deletions
+5 -5
View File
@@ -30,10 +30,10 @@ Rectangle {
readonly property string barPosition: Settings.data.bar.position
readonly property bool compact: (Settings.data.bar.density === "compact")
readonly property bool use12h: Settings.data.location.use12hourFormat
readonly property bool monthBeforeDay: Settings.data.location.monthBeforeDay
// Resolve settings: try user settings or defaults from BarWidgetRegistry
readonly property bool use12h: widgetSettings.use12HourClock !== undefined ? widgetSettings.use12HourClock : widgetMetadata.use12HourClock
readonly property bool reverseDayMonth: widgetSettings.reverseDayMonth !== undefined ? widgetSettings.reverseDayMonth : widgetMetadata.reverseDayMonth
readonly property string displayFormat: widgetSettings.displayFormat !== undefined ? widgetSettings.displayFormat : widgetMetadata.displayFormat
// Use compact mode for vertical bars
@@ -119,7 +119,7 @@ Rectangle {
dayName = dayName.charAt(0).toUpperCase() + dayName.slice(1)
const day = now.getDate().toString().padStart(2, '0')
let month = now.toLocaleDateString(Qt.locale(), "MMM")
timeStr += " - " + (reverseDayMonth ? `${dayName}, ${month} ${day}` : `${dayName}, ${day} ${month}`)
timeStr += " - " + (monthBeforeDay ? `${dayName}, ${month} ${day}` : `${dayName}, ${day} ${month}`)
}
return timeStr
@@ -184,7 +184,7 @@ Rectangle {
const now = Time.date
const day = now.getDate().toString().padStart(2, '0')
const month = (now.getMonth() + 1).toString().padStart(2, '0')
return reverseDayMonth ? `${month}/${day}` : `${day}/${month}`
return monthBeforeDay ? `${month}/${day}` : `${day}/${month}`
}
// Enable fixed-width font for consistent spacing
@@ -199,7 +199,7 @@ Rectangle {
NTooltip {
id: tooltip
text: `${Time.formatDate(reverseDayMonth)}.`
text: `${Time.formatDate(monthBeforeDay)}.`
target: clockContainer
positionAbove: Settings.data.bar.position === "bottom"
}
+15 -5
View File
@@ -26,6 +26,15 @@ Loader {
}
}
function formatTime() {
return Settings.data.location.use12hourFormat ? Qt.formatDateTime(new Date(), "h:mm A") : Qt.formatDateTime(new Date(), "HH:mm")
}
function formatDate() {
// For full text date, day is always before month, so we use this format for everybody: Wednesday, September 17.
return Qt.formatDateTime(new Date(), "dddd, MMMM d")
}
function scheduleUnloadAfterUnlock() {
unloadAfterUnlockTimer.start()
}
@@ -137,9 +146,10 @@ Loader {
NText {
id: timeText
text: Qt.formatDateTime(new Date(), "HH:mm")
text: formatTime()
font.family: Settings.data.ui.fontBillboard
font.pointSize: Style.fontSizeXXXL * 6 * scaling
// Smaller time display when using longer 12 hour format
font.pointSize: Settings.data.location.use12hourFormat ? Style.fontSizeXXXL * 4 * scaling : Style.fontSizeXXXL * 5 * scaling
font.weight: Style.fontWeightBold
font.letterSpacing: -2 * scaling
color: Color.mOnSurface
@@ -163,7 +173,7 @@ Loader {
NText {
id: dateText
text: Qt.formatDateTime(new Date(), "dddd, MMMM d")
text: formatDate()
font.family: Settings.data.ui.fontBillboard
font.pointSize: Style.fontSizeXXL * scaling
font.weight: Font.Light
@@ -877,8 +887,8 @@ Loader {
running: true
repeat: true
onTriggered: {
timeText.text = Qt.formatDateTime(new Date(), "HH:mm")
dateText.text = Qt.formatDateTime(new Date(), "dddd, MMMM d")
timeText.text = formatTime()
dateText.text = formatDate()
}
}
}
@@ -15,14 +15,10 @@ ColumnLayout {
// Local state
property string valueDisplayFormat: widgetData.displayFormat !== undefined ? widgetData.displayFormat : widgetMetadata.displayFormat
property bool valueUse12h: widgetData.use12HourClock !== undefined ? widgetData.use12HourClock : widgetMetadata.use12HourClock
property bool valueReverseDayMonth: widgetData.reverseDayMonth !== undefined ? widgetData.reverseDayMonth : widgetMetadata.reverseDayMonth
function saveSettings() {
var settings = Object.assign({}, widgetData || {})
settings.displayFormat = valueDisplayFormat
settings.use12HourClock = valueUse12h
settings.reverseDayMonth = valueReverseDayMonth
return settings
}
@@ -50,16 +46,4 @@ ColumnLayout {
onSelected: key => valueDisplayFormat = key
minimumWidth: 230 * scaling
}
NToggle {
label: "Use 12-hour clock"
checked: valueUse12h
onToggled: checked => valueUse12h = checked
}
NToggle {
label: "Reverse day and month"
checked: valueReverseDayMonth
onToggled: checked => valueReverseDayMonth = checked
}
}
+10 -10
View File
@@ -26,16 +26,16 @@ NPanel {
About,
Audio,
Bar,
Dock,
Hooks,
Launcher,
ColorScheme,
Display,
Dock,
General,
Hooks,
Launcher,
Location,
Network,
Notification,
ScreenRecorder,
Weather,
Wallpaper,
WallpaperSelector
}
@@ -81,8 +81,8 @@ NPanel {
Tabs.NetworkTab {}
}
Component {
id: weatherTab
Tabs.WeatherTab {}
id: locationTab
Tabs.LocationTab {}
}
Component {
id: colorSchemeTab
@@ -160,10 +160,10 @@ NPanel {
"icon": "settings-network",
"source": networkTab
}, {
"id": SettingsPanel.Tab.Weather,
"label": "Weather",
"icon": "settings-weather",
"source": weatherTab
"id": SettingsPanel.Tab.Location,
"label": "Location",
"icon": "settings-location",
"source": locationTab
}, {
"id": SettingsPanel.Tab.ColorScheme,
"label": "Color Scheme",
@@ -65,7 +65,7 @@ ColumnLayout {
NHeader {
label: "Weather"
description: "Configure weather display preferences and temperature units."
description: "Configure temperature units."
}
NToggle {
@@ -81,4 +81,35 @@ ColumnLayout {
Layout.topMargin: Style.marginXL * scaling
Layout.bottomMargin: Style.marginXL * scaling
}
// Weather section
ColumnLayout {
spacing: Style.marginM * scaling
Layout.fillWidth: true
NHeader {
label: "Time & Date"
description: "Configure time and date formats."
}
NToggle {
label: "Use 12-hour time format"
description: "Classic AM/PM or modern 24-hour."
checked: Settings.data.location.use12hourFormat
onToggled: checked => Settings.data.location.use12hourFormat = checked
}
NToggle {
label: "Show Month Before Day"
description: "Organize your dates. On for 09/17/2025, off for 17/09/2025."
checked: Settings.data.location.monthBeforeDay
onToggled: checked => Settings.data.location.monthBeforeDay = checked
}
}
NDivider {
Layout.fillWidth: true
Layout.topMargin: Style.marginXL * scaling
Layout.bottomMargin: Style.marginXL * scaling
}
}