Settings: new json model structure
This commit is contained in:
parent
0c044c7b81
commit
2d47c2ed1b
10 changed files with 149 additions and 100 deletions
|
|
@ -9,7 +9,7 @@ function getCountryCode(callback) {
|
|||
return;
|
||||
}
|
||||
var xhr = new XMLHttpRequest();
|
||||
xhr.open("GET", "https://nominatim.openstreetmap.org/search?city="+ Settings.settings.weatherCity+"&country=&format=json&addressdetails=1&extratags=1", true);
|
||||
xhr.open("GET", "https://nominatim.openstreetmap.org/search?city="+ Settings.data.location.name+"&country=&format=json&addressdetails=1&extratags=1", true);
|
||||
xhr.onreadystatechange = function() {
|
||||
if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
|
||||
var response = JSON.parse(xhr.responseText);
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ PanelWindow {
|
|||
screen: modelData
|
||||
implicitHeight: Style.barHeight * scaling
|
||||
color: "transparent"
|
||||
visible: Settings.settings.barMonitors.includes(modelData.name)
|
||||
|| (Settings.settings.barMonitors.length === 0)
|
||||
visible: Settings.data.bar.monitors.includes(modelData.name)
|
||||
|| (Settings.data.bar.monitors.length === 0)
|
||||
|
||||
anchors {
|
||||
top: true
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ Singleton {
|
|||
|
||||
// // 1) Per-monitor override wins
|
||||
// try {
|
||||
// const overrides = Settings.settings.monitorScaleOverrides || {};
|
||||
// const overrides = Settings.data.ui.monitorsScale || {};
|
||||
// if (currentScreen && currentScreen.name && overrides[currentScreen.name] !== undefined) {
|
||||
// const overrideValue = overrides[currentScreen.name]
|
||||
// if (isFinite(overrideValue)) return overrideValue
|
||||
|
|
|
|||
|
|
@ -1,22 +1,20 @@
|
|||
pragma Singleton
|
||||
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import qs.Services
|
||||
pragma Singleton
|
||||
|
||||
Singleton {
|
||||
|
||||
property string shellName: "Noctalia"
|
||||
property string shellName: "noctalia"
|
||||
property string settingsDir: Quickshell.env("NOCTALIA_SETTINGS_DIR")
|
||||
|| (Quickshell.env("XDG_CONFIG_HOME")
|
||||
|| Quickshell.env(
|
||||
"HOME") + "/.config") + "/" + shellName + "/"
|
||||
property string settingsFile: Quickshell.env("NOCTALIA_SETTINGS_FILE")
|
||||
|| (settingsDir + "Settings.json")
|
||||
|| (settingsDir + "settings.json")
|
||||
property string colorsFile: Quickshell.env("NOCTALIA_COLORS_FILE")
|
||||
|| (settingsDir + "Colors.json")
|
||||
property var settings: settingAdapter
|
||||
|| (settingsDir + "colors.json")
|
||||
property var data: settingAdapter
|
||||
|
||||
Item {
|
||||
Component.onCompleted: {
|
||||
|
|
@ -26,7 +24,14 @@ Singleton {
|
|||
}
|
||||
|
||||
FileView {
|
||||
|
||||
// TBC ? needed for SWWW only ?
|
||||
// Qt.callLater(function () {
|
||||
// WallpaperManager.setCurrentWallpaper(settings.currentWallpaper, true);
|
||||
// })
|
||||
|
||||
id: settingFileView
|
||||
|
||||
path: settingsFile
|
||||
watchChanges: true
|
||||
onFileChanged: reload()
|
||||
|
|
@ -34,80 +39,127 @@ Singleton {
|
|||
Component.onCompleted: function () {
|
||||
reload()
|
||||
}
|
||||
onLoaded: function () {// Qt.callLater(function () {
|
||||
// WallpaperManager.setCurrentWallpaper(settings.currentWallpaper, true);
|
||||
// })
|
||||
}
|
||||
onLoaded: function () {}
|
||||
onLoadFailed: function (error) {
|
||||
if (error.toString().includes("No such file") || error === 2) {
|
||||
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/"
|
||||
|
||||
// bar
|
||||
property JsonObject bar
|
||||
|
||||
bar: JsonObject {
|
||||
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 bool showSystemInfo: false
|
||||
property bool showMedia: false
|
||||
property list<string> monitors: []
|
||||
}
|
||||
|
||||
// general
|
||||
property JsonObject general
|
||||
|
||||
general: JsonObject {
|
||||
property string avatarImage: Quickshell.env("HOME") + "/.face"
|
||||
property bool dimDesktop: true
|
||||
property bool showScreenCorners: false
|
||||
}
|
||||
|
||||
// location
|
||||
property JsonObject location
|
||||
|
||||
location: JsonObject {
|
||||
property bool name: true
|
||||
property bool useFahrenheit: false
|
||||
property bool reverseDayMonth: false
|
||||
property bool use12HourClock: false
|
||||
}
|
||||
|
||||
// screen recorder
|
||||
property JsonObject screenRecorder
|
||||
|
||||
screenRecorder: JsonObject {
|
||||
property string directory: "~/Videos"
|
||||
property int frameRate: 60
|
||||
property string audioCodec: "opus"
|
||||
property string videoCodec: "h264"
|
||||
property string quality: "very_high"
|
||||
property string colorRange: "limited"
|
||||
property bool showCursor: true
|
||||
}
|
||||
|
||||
// wallpaper
|
||||
property JsonObject wallpaper
|
||||
|
||||
wallpaper: JsonObject {
|
||||
property string directory: "/usr/share/wallpapers"
|
||||
property string current: ""
|
||||
property bool isRandom: false
|
||||
property int randomInterval: 300
|
||||
property bool generateTheme: false
|
||||
property JsonObject swww
|
||||
|
||||
onDirectoryChanged: WallpaperManager.loadWallpapers()
|
||||
onIsRandomChanged: WallpaperManager.toggleRandomWallpaper()
|
||||
onRandomIntervalChanged: WallpaperManager.restartRandomWallpaperTimer()
|
||||
|
||||
swww: JsonObject {
|
||||
property bool enabled: false
|
||||
property string resizeMethod: "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"
|
||||
// applauncher
|
||||
property JsonObject appLauncher
|
||||
|
||||
// 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: {
|
||||
appLauncher: JsonObject {
|
||||
property list<string> pinnedExecs: []
|
||||
}
|
||||
|
||||
} // Map of monitor name -> scale override (e.g., 0.8..2.0). When set, Colors.scale() returns this value
|
||||
// dock
|
||||
property JsonObject dock
|
||||
|
||||
dock: JsonObject {
|
||||
property bool exclusive: false
|
||||
property list<string> monitors: []
|
||||
}
|
||||
|
||||
// network
|
||||
property JsonObject network
|
||||
|
||||
network: JsonObject {
|
||||
property bool wifiEnabled: true
|
||||
property bool bluetoothEnabled: true
|
||||
}
|
||||
|
||||
// notifications
|
||||
property JsonObject notifications
|
||||
|
||||
notifications: JsonObject {
|
||||
property list<string> monitors: []
|
||||
}
|
||||
|
||||
// audioVisualizer
|
||||
property JsonObject audioVisualizer
|
||||
|
||||
audioVisualizer: JsonObject {
|
||||
property string type: "radial"
|
||||
}
|
||||
|
||||
// ui
|
||||
property JsonObject ui
|
||||
|
||||
ui: JsonObject {
|
||||
property string fontFamily: "Roboto" // Family for all text
|
||||
property list<string> monitorsScale: []
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: settingAdapter
|
||||
function onRandomWallpaperChanged() {
|
||||
WallpaperManager.toggleRandomWallpaper()
|
||||
}
|
||||
function onWallpaperIntervalChanged() {
|
||||
WallpaperManager.restartRandomWallpaperTimer()
|
||||
}
|
||||
function onWallpaperFolderChanged() {
|
||||
WallpaperManager.loadWallpapers()
|
||||
}
|
||||
function onNotificationMonitorsChanged() {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ Singleton {
|
|||
id: root
|
||||
|
||||
property var date: new Date()
|
||||
property string time: Settings.settings.use12HourClock ? Qt.formatDateTime(
|
||||
property string time: Settings.data.location.use12HourClock ? Qt.formatDateTime(
|
||||
date,
|
||||
"h:mm AP") : Qt.formatDateTime(
|
||||
date, "HH:mm")
|
||||
|
|
@ -36,7 +36,7 @@ Singleton {
|
|||
}
|
||||
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}`)
|
||||
return `${dayName}, ` + (Settings.data.location.reverseDayMonth ? `${month} ${day}${suffix} ${year}` : `${day}${suffix} ${month} ${year}`)
|
||||
}
|
||||
|
||||
Timer {
|
||||
|
|
|
|||
|
|
@ -17,17 +17,17 @@ Singleton {
|
|||
}
|
||||
|
||||
property var wallpaperList: []
|
||||
property string currentWallpaper: Settings.settings.currentWallpaper
|
||||
property string currentWallpaper: Settings.data.wallpaper.current
|
||||
property bool scanning: false
|
||||
property string transitionType: Settings.settings.transitionType
|
||||
property string transitionType: Settings.data.wallpaper.swww.transitionType
|
||||
property var randomChoices: ["fade", "left", "right", "top", "bottom", "wipe", "wave", "grow", "center", "any", "outer"]
|
||||
|
||||
function loadWallpapers() {
|
||||
scanning = true
|
||||
wallpaperList = []
|
||||
folderModel.folder = ""
|
||||
folderModel.folder = "file://" + (Settings.settings.wallpaperFolder
|
||||
!== undefined ? Settings.settings.wallpaperFolder : "")
|
||||
folderModel.folder = "file://" + (Settings.data.wallpaper.directory
|
||||
!== undefined ? Settings.data.wallpaper.directory : "")
|
||||
}
|
||||
|
||||
function changeWallpaper(path) {
|
||||
|
|
@ -37,14 +37,14 @@ Singleton {
|
|||
function setCurrentWallpaper(path, isInitial) {
|
||||
currentWallpaper = path
|
||||
if (!isInitial) {
|
||||
Settings.settings.currentWallpaper = path
|
||||
Settings.data.wallpaper.current = path
|
||||
}
|
||||
if (Settings.settings.useSWWW) {
|
||||
if (Settings.settings.transitionType === "random") {
|
||||
if (Settings.data.swww.enabled) {
|
||||
if (Settings.data.swww.transitionType === "random") {
|
||||
transitionType = randomChoices[Math.floor(Math.random(
|
||||
) * randomChoices.length)]
|
||||
} else {
|
||||
transitionType = Settings.settings.transitionType
|
||||
transitionType = Settings.data.swww.transitionType
|
||||
}
|
||||
changeWallpaperProcess.running = true
|
||||
}
|
||||
|
|
@ -66,31 +66,31 @@ Singleton {
|
|||
}
|
||||
|
||||
function toggleRandomWallpaper() {
|
||||
if (Settings.settings.randomWallpaper && !randomWallpaperTimer.running) {
|
||||
if (Settings.data.wallpaper.isRandom && !randomWallpaperTimer.running) {
|
||||
randomWallpaperTimer.start()
|
||||
setRandomWallpaper()
|
||||
} else if (!Settings.settings.randomWallpaper
|
||||
} else if (!Settings.data.randomWallpaper
|
||||
&& randomWallpaperTimer.running) {
|
||||
randomWallpaperTimer.stop()
|
||||
}
|
||||
}
|
||||
|
||||
function restartRandomWallpaperTimer() {
|
||||
if (Settings.settings.randomWallpaper) {
|
||||
if (Settings.data.wallpaper.isRandom) {
|
||||
randomWallpaperTimer.stop()
|
||||
randomWallpaperTimer.start()
|
||||
}
|
||||
}
|
||||
|
||||
function generateTheme() {
|
||||
if (Settings.settings.useWallpaperTheme) {
|
||||
if (Settings.data.wallpaper.generateTheme) {
|
||||
generateThemeProcess.running = true
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: randomWallpaperTimer
|
||||
interval: Settings.settings.wallpaperInterval * 1000
|
||||
interval: Settings.data.wallpaper.randomInterval * 1000
|
||||
running: false
|
||||
repeat: true
|
||||
onTriggered: setRandomWallpaper()
|
||||
|
|
@ -108,8 +108,8 @@ Singleton {
|
|||
var files = []
|
||||
var filesSwww = []
|
||||
for (var i = 0; i < count; i++) {
|
||||
var filepath = (Settings.settings.wallpaperFolder
|
||||
!== undefined ? Settings.settings.wallpaperFolder : "") + "/" + get(
|
||||
var filepath = (Settings.data.wallpaper.folder
|
||||
!== undefined ? Settings.data.wallpaper.folder : "") + "/" + get(
|
||||
i, "fileName")
|
||||
files.push(filepath)
|
||||
}
|
||||
|
|
@ -121,8 +121,8 @@ Singleton {
|
|||
|
||||
Process {
|
||||
id: changeWallpaperProcess
|
||||
command: ["swww", "img", "--resize", Settings.settings.wallpaperResize, "--transition-fps", Settings.settings.transitionFps.toString(
|
||||
), "--transition-type", transitionType, "--transition-duration", Settings.settings.transitionDuration.toString(
|
||||
command: ["swww", "img", "--resize", Settings.data.wallpaper.swww.resizeMethod, "--transition-fps", Settings.data.wallpaper.swww.transitionFps.toString(
|
||||
), "--transition-type", transitionType, "--transition-duration", Settings.data.wallpaper.transitionDuration.toString(
|
||||
), currentWallpaper]
|
||||
running: false
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ PanelWindow {
|
|||
id: outerPanel
|
||||
|
||||
readonly property real scaling: Scaling.scale(screen)
|
||||
property bool showOverlay: Settings.settings.dimPanels
|
||||
property bool showOverlay: Settings.data.general.dimDesktop
|
||||
property int topMargin: Style.barHeight * scaling
|
||||
property color overlayColor: showOverlay ? Colors.overlay : "transparent"
|
||||
signal dismissed
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ Text {
|
|||
|
||||
readonly property real scaling: Scaling.scale(screen)
|
||||
|
||||
font.family: Settings.settings.fontFamily
|
||||
font.family: Settings.data.ui.fontFamily
|
||||
font.pointSize: Style.fontSizeMedium * scaling
|
||||
font.weight: Font.Bold
|
||||
color: Colors.textPrimary
|
||||
|
|
|
|||
|
|
@ -111,12 +111,10 @@ Window {
|
|||
z: 1
|
||||
}
|
||||
|
||||
Text {
|
||||
NText {
|
||||
id: tooltipText
|
||||
anchors.centerIn: parent
|
||||
text: root.text
|
||||
color: Colors.textPrimary
|
||||
font.family: Settings.settings.fontFamily
|
||||
font.pointSize: Style.fontSizeMedium * scaling
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
// Disable reload popup
|
||||
//@ pragma Env QS_NO_RELOAD_POPUP=1
|
||||
import QtQuick
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue