add support for custom date formats via config
This commit is contained in:
@@ -180,6 +180,7 @@ Singleton {
|
|||||||
logo: general.logo,
|
logo: general.logo,
|
||||||
wallpaperPath: general.wallpaperPath,
|
wallpaperPath: general.wallpaperPath,
|
||||||
desktopIcons: general.desktopIcons,
|
desktopIcons: general.desktopIcons,
|
||||||
|
dateFormat: general.dateFormat,
|
||||||
color: {
|
color: {
|
||||||
mode: general.color.mode,
|
mode: general.color.mode,
|
||||||
smart: general.color.smart,
|
smart: general.color.smart,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ JsonObject {
|
|||||||
}
|
}
|
||||||
property Color color: Color {
|
property Color color: Color {
|
||||||
}
|
}
|
||||||
|
property string dateFormat: "ddd d MMM - hh:mm:ss"
|
||||||
property bool desktopIcons: false
|
property bool desktopIcons: false
|
||||||
property Idle idle: Idle {
|
property Idle idle: Idle {
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-2
@@ -1,18 +1,23 @@
|
|||||||
pragma Singleton
|
pragma Singleton
|
||||||
|
|
||||||
import Quickshell
|
import Quickshell
|
||||||
|
import QtQuick
|
||||||
|
import qs.Config
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
readonly property string amPmStr: timeComponents[2] ?? ""
|
id: root
|
||||||
|
|
||||||
readonly property date date: clock.date
|
readonly property date date: clock.date
|
||||||
|
readonly property string dateStr: format(Config.general.dateFormat)
|
||||||
property alias enabled: clock.enabled
|
property alias enabled: clock.enabled
|
||||||
readonly property string hourStr: timeComponents[0] ?? ""
|
readonly property string hourStr: timeComponents[0] ?? ""
|
||||||
readonly property int hours: clock.hours
|
readonly property int hours: clock.hours
|
||||||
readonly property string minuteStr: timeComponents[1] ?? ""
|
readonly property string minuteStr: timeComponents[1] ?? ""
|
||||||
readonly property int minutes: clock.minutes
|
readonly property int minutes: clock.minutes
|
||||||
|
readonly property string secondStr: timeComponents[2] ?? ""
|
||||||
readonly property int seconds: clock.seconds
|
readonly property int seconds: clock.seconds
|
||||||
readonly property list<string> timeComponents: timeStr.split(":")
|
readonly property list<string> timeComponents: timeStr.split(":")
|
||||||
readonly property string timeStr: format("hh:mm")
|
readonly property string timeStr: format("hh:mm:ss")
|
||||||
|
|
||||||
function format(fmt: string): string {
|
function format(fmt: string): string {
|
||||||
return Qt.formatDateTime(clock.date, fmt);
|
return Qt.formatDateTime(clock.date, fmt);
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ import QtQuick
|
|||||||
import QtQuick.Layouts
|
import QtQuick.Layouts
|
||||||
import qs.Config
|
import qs.Config
|
||||||
import qs.Modules
|
import qs.Modules
|
||||||
import qs.Helpers as Helpers
|
import qs.Helpers
|
||||||
import qs.Components
|
import qs.Components
|
||||||
|
|
||||||
CustomRect {
|
CustomRect {
|
||||||
|
|||||||
@@ -47,6 +47,15 @@ SettingsPage {
|
|||||||
object: Config.general
|
object: Config.general
|
||||||
setting: "desktopIcons"
|
setting: "desktopIcons"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Separator {
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingInput {
|
||||||
|
name: "Date format"
|
||||||
|
object: Config.general
|
||||||
|
setting: "dateFormat"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingsSection {
|
SettingsSection {
|
||||||
|
|||||||
@@ -30,6 +30,13 @@ export const settingsIndex = [
|
|||||||
section: "General",
|
section: "General",
|
||||||
keywords: ["icons", "desktop", "show"],
|
keywords: ["icons", "desktop", "show"],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "Date format",
|
||||||
|
category: "general",
|
||||||
|
categoryName: "General",
|
||||||
|
section: "General",
|
||||||
|
keywords: ["date", "time", "format"],
|
||||||
|
},
|
||||||
// Color section
|
// Color section
|
||||||
{
|
{
|
||||||
name: "Scheme mode",
|
name: "Scheme mode",
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
pragma Singleton
|
|
||||||
|
|
||||||
import Quickshell
|
|
||||||
import QtQuick
|
|
||||||
|
|
||||||
Singleton {
|
|
||||||
id: root
|
|
||||||
|
|
||||||
readonly property date date: clock.date
|
|
||||||
readonly property string dateStr: format("ddd d MMM - hh:mm:ss")
|
|
||||||
property alias enabled: clock.enabled
|
|
||||||
readonly property string hourStr: timeComponents[0] ?? ""
|
|
||||||
readonly property int hours: clock.hours
|
|
||||||
readonly property string minuteStr: timeComponents[1] ?? ""
|
|
||||||
readonly property int minutes: clock.minutes
|
|
||||||
readonly property string secondStr: timeComponents[2] ?? ""
|
|
||||||
readonly property int seconds: clock.seconds
|
|
||||||
readonly property list<string> timeComponents: timeStr.split(":")
|
|
||||||
readonly property string timeStr: format("hh:mm:ss")
|
|
||||||
|
|
||||||
function format(fmt: string): string {
|
|
||||||
return Qt.formatDateTime(clock.date, fmt);
|
|
||||||
}
|
|
||||||
|
|
||||||
SystemClock {
|
|
||||||
id: clock
|
|
||||||
|
|
||||||
precision: SystemClock.Seconds
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user