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;
|
return;
|
||||||
}
|
}
|
||||||
var xhr = new XMLHttpRequest();
|
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() {
|
xhr.onreadystatechange = function() {
|
||||||
if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
|
if (xhr.readyState === XMLHttpRequest.DONE && xhr.status === 200) {
|
||||||
var response = JSON.parse(xhr.responseText);
|
var response = JSON.parse(xhr.responseText);
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ PanelWindow {
|
||||||
screen: modelData
|
screen: modelData
|
||||||
implicitHeight: Style.barHeight * scaling
|
implicitHeight: Style.barHeight * scaling
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
visible: Settings.settings.barMonitors.includes(modelData.name)
|
visible: Settings.data.bar.monitors.includes(modelData.name)
|
||||||
|| (Settings.settings.barMonitors.length === 0)
|
|| (Settings.data.bar.monitors.length === 0)
|
||||||
|
|
||||||
anchors {
|
anchors {
|
||||||
top: true
|
top: true
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ Singleton {
|
||||||
|
|
||||||
// // 1) Per-monitor override wins
|
// // 1) Per-monitor override wins
|
||||||
// try {
|
// try {
|
||||||
// const overrides = Settings.settings.monitorScaleOverrides || {};
|
// const overrides = Settings.data.ui.monitorsScale || {};
|
||||||
// if (currentScreen && currentScreen.name && overrides[currentScreen.name] !== undefined) {
|
// if (currentScreen && currentScreen.name && overrides[currentScreen.name] !== undefined) {
|
||||||
// const overrideValue = overrides[currentScreen.name]
|
// const overrideValue = overrides[currentScreen.name]
|
||||||
// if (isFinite(overrideValue)) return overrideValue
|
// if (isFinite(overrideValue)) return overrideValue
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,20 @@
|
||||||
pragma Singleton
|
|
||||||
|
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
import qs.Services
|
import qs.Services
|
||||||
|
pragma Singleton
|
||||||
|
|
||||||
Singleton {
|
Singleton {
|
||||||
|
property string shellName: "noctalia"
|
||||||
property string shellName: "Noctalia"
|
|
||||||
property string settingsDir: Quickshell.env("NOCTALIA_SETTINGS_DIR")
|
property string settingsDir: Quickshell.env("NOCTALIA_SETTINGS_DIR")
|
||||||
|| (Quickshell.env("XDG_CONFIG_HOME")
|
|| (Quickshell.env("XDG_CONFIG_HOME")
|
||||||
|| Quickshell.env(
|
|| Quickshell.env(
|
||||||
"HOME") + "/.config") + "/" + shellName + "/"
|
"HOME") + "/.config") + "/" + shellName + "/"
|
||||||
property string settingsFile: Quickshell.env("NOCTALIA_SETTINGS_FILE")
|
property string settingsFile: Quickshell.env("NOCTALIA_SETTINGS_FILE")
|
||||||
|| (settingsDir + "Settings.json")
|
|| (settingsDir + "settings.json")
|
||||||
property string colorsFile: Quickshell.env("NOCTALIA_COLORS_FILE")
|
property string colorsFile: Quickshell.env("NOCTALIA_COLORS_FILE")
|
||||||
|| (settingsDir + "Colors.json")
|
|| (settingsDir + "colors.json")
|
||||||
property var settings: settingAdapter
|
property var data: settingAdapter
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
|
@ -26,7 +24,14 @@ Singleton {
|
||||||
}
|
}
|
||||||
|
|
||||||
FileView {
|
FileView {
|
||||||
|
|
||||||
|
// TBC ? needed for SWWW only ?
|
||||||
|
// Qt.callLater(function () {
|
||||||
|
// WallpaperManager.setCurrentWallpaper(settings.currentWallpaper, true);
|
||||||
|
// })
|
||||||
|
|
||||||
id: settingFileView
|
id: settingFileView
|
||||||
|
|
||||||
path: settingsFile
|
path: settingsFile
|
||||||
watchChanges: true
|
watchChanges: true
|
||||||
onFileChanged: reload()
|
onFileChanged: reload()
|
||||||
|
|
@ -34,80 +39,127 @@ Singleton {
|
||||||
Component.onCompleted: function () {
|
Component.onCompleted: function () {
|
||||||
reload()
|
reload()
|
||||||
}
|
}
|
||||||
onLoaded: function () {// Qt.callLater(function () {
|
onLoaded: function () {}
|
||||||
// WallpaperManager.setCurrentWallpaper(settings.currentWallpaper, true);
|
|
||||||
// })
|
|
||||||
}
|
|
||||||
onLoadFailed: function (error) {
|
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
|
// File doesn't exist, create it with default values
|
||||||
writeAdapter()
|
writeAdapter()
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonAdapter {
|
JsonAdapter {
|
||||||
id: settingAdapter
|
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
|
// bar
|
||||||
property bool dockExclusive: false
|
property JsonObject bar
|
||||||
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
|
bar: JsonObject {
|
||||||
property var barMonitors: [] // Array of monitor names to show the bar on
|
property bool showActiveWindow: true
|
||||||
property var dockMonitors: [] // Array of monitor names to show the dock on
|
property bool showActiveWindowIcon: false
|
||||||
property var notificationMonitors: [] // Array of monitor names to show notifications on, "*" means all monitors
|
property bool showSystemInfo: false
|
||||||
property var monitorScaleOverrides: {
|
property bool showMedia: false
|
||||||
|
property list<string> monitors: []
|
||||||
|
}
|
||||||
|
|
||||||
} // Map of monitor name -> scale override (e.g., 0.8..2.0). When set, Colors.scale() returns this value
|
// general
|
||||||
|
property JsonObject general
|
||||||
|
|
||||||
property string fontFamily: "Roboto" // Family for all text
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// applauncher
|
||||||
|
property JsonObject appLauncher
|
||||||
|
|
||||||
|
appLauncher: JsonObject {
|
||||||
|
property list<string> pinnedExecs: []
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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
|
id: root
|
||||||
|
|
||||||
property var date: new Date()
|
property var date: new Date()
|
||||||
property string time: Settings.settings.use12HourClock ? Qt.formatDateTime(
|
property string time: Settings.data.location.use12HourClock ? Qt.formatDateTime(
|
||||||
date,
|
date,
|
||||||
"h:mm AP") : Qt.formatDateTime(
|
"h:mm AP") : Qt.formatDateTime(
|
||||||
date, "HH:mm")
|
date, "HH:mm")
|
||||||
|
|
@ -36,7 +36,7 @@ Singleton {
|
||||||
}
|
}
|
||||||
let month = now.toLocaleDateString(Qt.locale(), "MMMM")
|
let month = now.toLocaleDateString(Qt.locale(), "MMMM")
|
||||||
let year = now.toLocaleDateString(Qt.locale(), "yyyy")
|
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 {
|
Timer {
|
||||||
|
|
|
||||||
|
|
@ -17,17 +17,17 @@ Singleton {
|
||||||
}
|
}
|
||||||
|
|
||||||
property var wallpaperList: []
|
property var wallpaperList: []
|
||||||
property string currentWallpaper: Settings.settings.currentWallpaper
|
property string currentWallpaper: Settings.data.wallpaper.current
|
||||||
property bool scanning: false
|
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"]
|
property var randomChoices: ["fade", "left", "right", "top", "bottom", "wipe", "wave", "grow", "center", "any", "outer"]
|
||||||
|
|
||||||
function loadWallpapers() {
|
function loadWallpapers() {
|
||||||
scanning = true
|
scanning = true
|
||||||
wallpaperList = []
|
wallpaperList = []
|
||||||
folderModel.folder = ""
|
folderModel.folder = ""
|
||||||
folderModel.folder = "file://" + (Settings.settings.wallpaperFolder
|
folderModel.folder = "file://" + (Settings.data.wallpaper.directory
|
||||||
!== undefined ? Settings.settings.wallpaperFolder : "")
|
!== undefined ? Settings.data.wallpaper.directory : "")
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeWallpaper(path) {
|
function changeWallpaper(path) {
|
||||||
|
|
@ -37,14 +37,14 @@ Singleton {
|
||||||
function setCurrentWallpaper(path, isInitial) {
|
function setCurrentWallpaper(path, isInitial) {
|
||||||
currentWallpaper = path
|
currentWallpaper = path
|
||||||
if (!isInitial) {
|
if (!isInitial) {
|
||||||
Settings.settings.currentWallpaper = path
|
Settings.data.wallpaper.current = path
|
||||||
}
|
}
|
||||||
if (Settings.settings.useSWWW) {
|
if (Settings.data.swww.enabled) {
|
||||||
if (Settings.settings.transitionType === "random") {
|
if (Settings.data.swww.transitionType === "random") {
|
||||||
transitionType = randomChoices[Math.floor(Math.random(
|
transitionType = randomChoices[Math.floor(Math.random(
|
||||||
) * randomChoices.length)]
|
) * randomChoices.length)]
|
||||||
} else {
|
} else {
|
||||||
transitionType = Settings.settings.transitionType
|
transitionType = Settings.data.swww.transitionType
|
||||||
}
|
}
|
||||||
changeWallpaperProcess.running = true
|
changeWallpaperProcess.running = true
|
||||||
}
|
}
|
||||||
|
|
@ -66,31 +66,31 @@ Singleton {
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleRandomWallpaper() {
|
function toggleRandomWallpaper() {
|
||||||
if (Settings.settings.randomWallpaper && !randomWallpaperTimer.running) {
|
if (Settings.data.wallpaper.isRandom && !randomWallpaperTimer.running) {
|
||||||
randomWallpaperTimer.start()
|
randomWallpaperTimer.start()
|
||||||
setRandomWallpaper()
|
setRandomWallpaper()
|
||||||
} else if (!Settings.settings.randomWallpaper
|
} else if (!Settings.data.randomWallpaper
|
||||||
&& randomWallpaperTimer.running) {
|
&& randomWallpaperTimer.running) {
|
||||||
randomWallpaperTimer.stop()
|
randomWallpaperTimer.stop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function restartRandomWallpaperTimer() {
|
function restartRandomWallpaperTimer() {
|
||||||
if (Settings.settings.randomWallpaper) {
|
if (Settings.data.wallpaper.isRandom) {
|
||||||
randomWallpaperTimer.stop()
|
randomWallpaperTimer.stop()
|
||||||
randomWallpaperTimer.start()
|
randomWallpaperTimer.start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function generateTheme() {
|
function generateTheme() {
|
||||||
if (Settings.settings.useWallpaperTheme) {
|
if (Settings.data.wallpaper.generateTheme) {
|
||||||
generateThemeProcess.running = true
|
generateThemeProcess.running = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: randomWallpaperTimer
|
id: randomWallpaperTimer
|
||||||
interval: Settings.settings.wallpaperInterval * 1000
|
interval: Settings.data.wallpaper.randomInterval * 1000
|
||||||
running: false
|
running: false
|
||||||
repeat: true
|
repeat: true
|
||||||
onTriggered: setRandomWallpaper()
|
onTriggered: setRandomWallpaper()
|
||||||
|
|
@ -108,8 +108,8 @@ Singleton {
|
||||||
var files = []
|
var files = []
|
||||||
var filesSwww = []
|
var filesSwww = []
|
||||||
for (var i = 0; i < count; i++) {
|
for (var i = 0; i < count; i++) {
|
||||||
var filepath = (Settings.settings.wallpaperFolder
|
var filepath = (Settings.data.wallpaper.folder
|
||||||
!== undefined ? Settings.settings.wallpaperFolder : "") + "/" + get(
|
!== undefined ? Settings.data.wallpaper.folder : "") + "/" + get(
|
||||||
i, "fileName")
|
i, "fileName")
|
||||||
files.push(filepath)
|
files.push(filepath)
|
||||||
}
|
}
|
||||||
|
|
@ -121,8 +121,8 @@ Singleton {
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: changeWallpaperProcess
|
id: changeWallpaperProcess
|
||||||
command: ["swww", "img", "--resize", Settings.settings.wallpaperResize, "--transition-fps", Settings.settings.transitionFps.toString(
|
command: ["swww", "img", "--resize", Settings.data.wallpaper.swww.resizeMethod, "--transition-fps", Settings.data.wallpaper.swww.transitionFps.toString(
|
||||||
), "--transition-type", transitionType, "--transition-duration", Settings.settings.transitionDuration.toString(
|
), "--transition-type", transitionType, "--transition-duration", Settings.data.wallpaper.transitionDuration.toString(
|
||||||
), currentWallpaper]
|
), currentWallpaper]
|
||||||
running: false
|
running: false
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ PanelWindow {
|
||||||
id: outerPanel
|
id: outerPanel
|
||||||
|
|
||||||
readonly property real scaling: Scaling.scale(screen)
|
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 int topMargin: Style.barHeight * scaling
|
||||||
property color overlayColor: showOverlay ? Colors.overlay : "transparent"
|
property color overlayColor: showOverlay ? Colors.overlay : "transparent"
|
||||||
signal dismissed
|
signal dismissed
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ Text {
|
||||||
|
|
||||||
readonly property real scaling: Scaling.scale(screen)
|
readonly property real scaling: Scaling.scale(screen)
|
||||||
|
|
||||||
font.family: Settings.settings.fontFamily
|
font.family: Settings.data.ui.fontFamily
|
||||||
font.pointSize: Style.fontSizeMedium * scaling
|
font.pointSize: Style.fontSizeMedium * scaling
|
||||||
font.weight: Font.Bold
|
font.weight: Font.Bold
|
||||||
color: Colors.textPrimary
|
color: Colors.textPrimary
|
||||||
|
|
|
||||||
|
|
@ -111,12 +111,10 @@ Window {
|
||||||
z: 1
|
z: 1
|
||||||
}
|
}
|
||||||
|
|
||||||
Text {
|
NText {
|
||||||
id: tooltipText
|
id: tooltipText
|
||||||
anchors.centerIn: parent
|
anchors.centerIn: parent
|
||||||
text: root.text
|
text: root.text
|
||||||
color: Colors.textPrimary
|
|
||||||
font.family: Settings.settings.fontFamily
|
|
||||||
font.pointSize: Style.fontSizeMedium * scaling
|
font.pointSize: Style.fontSizeMedium * scaling
|
||||||
horizontalAlignment: Text.AlignHCenter
|
horizontalAlignment: Text.AlignHCenter
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
// Disable reload popup
|
// Disable reload popup
|
||||||
//@ pragma Env QS_NO_RELOAD_POPUP=1
|
//@ pragma Env QS_NO_RELOAD_POPUP=1
|
||||||
import QtQuick
|
import QtQuick
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue