Clock and calendar

This commit is contained in:
quadbyte 2025-08-09 18:00:57 -04:00
parent 0e037561f3
commit bce57c101a
12 changed files with 530 additions and 4 deletions

View file

View file

@ -41,6 +41,6 @@ Singleton {
}
// 3) Safe default
return 1.0
return 2.0
}
}

View file

@ -6,7 +6,6 @@ import Quickshell.Io
import qs.Services
Singleton {
id: root
property string shellName: "Noctalia"
property string settingsDir: Quickshell.env("NOCTALIA_SETTINGS_DIR")
@ -17,6 +16,7 @@ Singleton {
|| (settingsDir + "Settings.json")
property string themeFile: Quickshell.env("NOCTALIA_THEME_FILE")
|| (settingsDir + "Theme.json")
property var settings: settingAdapter
Item {
Component.onCompleted: {
@ -24,4 +24,88 @@ Singleton {
Quickshell.execDetached(["mkdir", "-p", settingsDir])
}
}
FileView {
id: settingFileView
path: settingsFile
watchChanges: true
onFileChanged: reload()
onAdapterUpdated: writeAdapter()
Component.onCompleted: function () {
reload()
}
onLoaded: function () {// Qt.callLater(function () {
// WallpaperManager.setCurrentWallpaper(settings.currentWallpaper, true);
// })
}
onLoadFailed: function (error) {
if (error.toString().includes("No such file") || error === 2) {
// File doesn't exist, create it with default values
writeAdapter()
}
}
JsonAdapter {
id: settingAdapter
property string weatherCity: "Dinslaken"
property string profileImage: Quickshell.env("HOME") + "/.face"
property bool useFahrenheit: false
property string wallpaperFolder: "/usr/share/wallpapers"
property string currentWallpaper: ""
property string videoPath: "~/Videos/"
property bool showActiveWindow: true
property bool showActiveWindowIcon: false
property bool showSystemInfoInBar: false
property bool showCorners: false
property bool showTaskbar: true
property bool showMediaInBar: false
property bool useSWWW: false
property bool randomWallpaper: false
property bool useWallpaperTheme: false
property int wallpaperInterval: 300
property string wallpaperResize: "crop"
property int transitionFps: 60
property string transitionType: "random"
property real transitionDuration: 1.1
property string visualizerType: "radial"
property bool reverseDayMonth: false
property bool use12HourClock: false
property bool dimPanels: true
property real fontSizeMultiplier: 1.0 // Font size multiplier (1.0 = normal, 1.2 = 20% larger, 0.8 = 20% smaller)
property int taskbarIconSize: 24 // Taskbar icon button size in pixels (default: 32, smaller: 24, larger: 40)
property var pinnedExecs: [] // Added for AppLauncher pinned apps
property bool showDock: true
property bool dockExclusive: false
property bool wifiEnabled: false
property bool bluetoothEnabled: false
property int recordingFrameRate: 60
property string recordingQuality: "very_high"
property string recordingCodec: "h264"
property string audioCodec: "opus"
property bool showCursor: true
property string colorRange: "limited"
// Monitor/Display Settings
property var barMonitors: [] // Array of monitor names to show the bar on
property var dockMonitors: [] // Array of monitor names to show the dock on
property var notificationMonitors: [] // Array of monitor names to show notifications on, "*" means all monitors
property var monitorScaleOverrides: {
} // Map of monitor name -> scale override (e.g., 0.8..2.0). When set, Theme.scale() returns this value
}
}
Connections {
target: settingAdapter
function onRandomWallpaperChanged() {
WallpaperManager.toggleRandomWallpaper()
}
function onWallpaperIntervalChanged() {
WallpaperManager.restartRandomWallpaperTimer()
}
function onWallpaperFolderChanged() {
WallpaperManager.loadWallpapers()
}
function onNotificationMonitorsChanged() {}
}
}

49
Services/Time.qml Normal file
View file

@ -0,0 +1,49 @@
pragma Singleton
import Quickshell
import QtQuick
import qs.Services
Singleton {
id: root
property var date: new Date()
property string time: Settings.settings.use12HourClock ? Qt.formatDateTime(
date,
"h:mm AP") : Qt.formatDateTime(
date, "HH:mm")
property string dateString: {
let now = date
let dayName = now.toLocaleDateString(Qt.locale(), "ddd")
dayName = dayName.charAt(0).toUpperCase() + dayName.slice(1)
let day = now.getDate()
let suffix
if (day > 3 && day < 21)
suffix = 'th'
else
switch (day % 10) {
case 1:
suffix = "st"
break
case 2:
suffix = "nd"
break
case 3:
suffix = "rd"
break
default:
suffix = "th"
}
let month = now.toLocaleDateString(Qt.locale(), "MMMM")
let year = now.toLocaleDateString(Qt.locale(), "yyyy")
return `${dayName}, ` + (Settings.settings.reverseDayMonth ? `${month} ${day}${suffix} ${year}` : `${day}${suffix} ${month} ${year}`)
}
Timer {
interval: 1000
repeat: true
running: true
onTriggered: root.date = new Date()
}
}