make config use json instead of shitty qt implementation

This commit is contained in:
lucy 2026-08-27 18:10:37 +02:00
commit 31965a0dba
40 changed files with 272 additions and 745 deletions

View file

@ -2,33 +2,43 @@ pragma Singleton
import QtCore
import QtQuick
import Quickshell
import Quickshell.Io
Singleton {
id: root
property string font: "Maple Mono"
property int fontSize: 12
property int iconSize: 14
property int barHeight: 30
property int rounding: 16
property url wallpaper: "file:///home/lucy/.walls/frierensuff.png"
property bool floating: false
property double opacity: 1.0
property string primaryMon: "eDP-1"
property string wallDir: "file://" + Quickshell.env("HOME") + "/.walls"
property bool showCorners: true
property real moduleHeight: barHeight - 8
Settings {
location: Qt.resolvedUrl("file:///home/lucy/.config/quickshell/settings/settings.ini")
property alias font: root.font
property alias fontSize: root.fontSize
property alias barHeight: root.barHeight
property alias rounding: root.rounding
property alias wallpaper: root.wallpaper
property alias opacity: root.opacity
property alias primaryMon: root.primaryMon
property alias floating: root.floating
property alias wallDir: root.wallDir
property alias showCorners: root.showCorners
property alias iconSize: root.iconSize
property alias cfg: cfg
function save() {
if (cfgView.loaded)
cfgView.writeAdapter();
}
FileView {
id: cfgView
path: Qt.resolvedUrl(Quickshell.shellDir + "/settings/settings.json")
watchChanges: true
onFileChanged: {
this.reload();
}
onLoadFailed: error => {
if (error === FileViewError.FileNotFound)
writeAdapter();
}
adapter: JsonAdapter {
id: cfg
property JsonObject appearance: JsonObject {
property string font: "Iosevka"
property int fontSize: 14
property int iconSize: 16
property int rounding: 16
}
property JsonObject bar: JsonObject {
property bool floating: true
property int height: 40
property real opacity: 1.0
}
property JsonObject wallpaper: JsonObject {
property string wallDir: Quickshell.env("HOME") + "/.walls/"
property string wallpaper: ""
}
}
}
}

View file

@ -1,12 +1,12 @@
[General]
barHeight=30
floating=true
floating=false
font=Iosevka
fontSize=16
iconSize=18
fontSize=14
iconSize=16
opacity=1
primaryMon=eDP-1
rounding=16
showCorners=true
wallDir=file:///home/lucy/.walls
wallpaper=@Variant(\0\0\0\x11\0\0\0\x1f/home/lucy/.walls/lain_blue.png)
wallDir=/home/lucy/.walls/
wallpaper=/home/lucy/.walls/walkingcastle.png

17
settings/settings.json Normal file
View file

@ -0,0 +1,17 @@
{
"appearance": {
"font": "Iosevka",
"fontSize": 14,
"iconSize": 16,
"rounding": 16
},
"bar": {
"floating": true,
"height": 40,
"opacity": 1
},
"wallpaper": {
"wallDir": "/home/lucy/.walls/",
"wallpaper": "/home/lucy/.walls/frierensuff.png"
}
}

18
settings/settings.json~ Normal file
View file

@ -0,0 +1,18 @@
{
"appearance": {
"font": "Iosevka",
"fontSize": 14,
"iconSize": 16,
"rounding": 16
},
"bar": {
"floating": true,
"height": 38,
"moduleHeight": 30,
"opacity": 1
},
"wallpaper": {
"wallDir": "/home/lucy/.walls/",
"wallpaper": "/home/lucy/.walls/frierensuff.png"
}
}