qs: should have been fixed...
This commit is contained in:
@@ -2,6 +2,7 @@ import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import qs.Constants
|
||||
import qs.Services
|
||||
import qs.Utils
|
||||
pragma Singleton
|
||||
|
||||
@@ -75,20 +76,37 @@ Singleton {
|
||||
}
|
||||
|
||||
function setColor(name, value) {
|
||||
if (!adapter.colors)
|
||||
adapter.colors = {
|
||||
};
|
||||
|
||||
adapter.colors[name] = value;
|
||||
colorFile.writeAdapter();
|
||||
let state = ShellState.colorState;
|
||||
state[name] = value;
|
||||
ShellState.colorState = state;
|
||||
}
|
||||
|
||||
function unsetColor(name) {
|
||||
if (!adapter.colors || !(name in adapter.colors))
|
||||
return ;
|
||||
let state = ShellState.colorState;
|
||||
delete state[name];
|
||||
ShellState.colorState = state;
|
||||
}
|
||||
|
||||
delete adapter.colors[name];
|
||||
colorFile.writeAdapter();
|
||||
Component.onCompleted: {
|
||||
reloadColors(ShellState.colorState);
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: ShellState
|
||||
onColorStateChanged: {
|
||||
reloadTimer.restart();
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: reloadTimer
|
||||
|
||||
interval: 500
|
||||
running: false
|
||||
repeat: false
|
||||
onTriggered: {
|
||||
reloadColors(ShellState.colorState);
|
||||
}
|
||||
}
|
||||
|
||||
QtObject {
|
||||
@@ -118,38 +136,4 @@ Singleton {
|
||||
readonly property color mLavender: "#b4befe"
|
||||
}
|
||||
|
||||
FileView {
|
||||
id: colorFile
|
||||
|
||||
path: Paths.configDir + "colors.json"
|
||||
printErrors: false
|
||||
watchChanges: true
|
||||
onFileChanged: reload()
|
||||
|
||||
JsonAdapter {
|
||||
id: adapter
|
||||
|
||||
property var colors: ({
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Connections {
|
||||
function onColorsChanged() {
|
||||
colorReloadTimer.restart();
|
||||
}
|
||||
|
||||
target: adapter
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: colorReloadTimer
|
||||
|
||||
interval: 50
|
||||
running: true
|
||||
repeat: false
|
||||
onTriggered: reloadColors(adapter.colors)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ Singleton {
|
||||
return ;
|
||||
|
||||
previewPath = ""; // clear preview path
|
||||
cachedPath = ""; // clear cached path
|
||||
ImageCacheService.checkFileExists(path, function(exists) {
|
||||
if (!exists)
|
||||
return ;
|
||||
|
||||
@@ -16,6 +16,7 @@ Singleton {
|
||||
property alias leftSiderbarTab: adapter.leftSiderbarTab
|
||||
property alias rightSiderbarTab: adapter.rightSiderbarTab
|
||||
property alias wifiEnabled: adapter.wifiEnabled
|
||||
property alias colorState: adapter.colorState
|
||||
|
||||
function save() {
|
||||
saveTimer.restart();
|
||||
@@ -27,6 +28,7 @@ Singleton {
|
||||
onLeftSiderbarTabChanged: save()
|
||||
onRightSiderbarTabChanged: save()
|
||||
onWifiEnabledChanged: save()
|
||||
onColorStateChanged: save()
|
||||
Component.onCompleted: {
|
||||
stateFileView.path = stateFile;
|
||||
}
|
||||
@@ -58,6 +60,8 @@ Singleton {
|
||||
property string leftSiderbarTab: "bluetooth"
|
||||
property string rightSiderbarTab: "notes"
|
||||
property bool wifiEnabled: true
|
||||
property var colorState: ({
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ Singleton {
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: checkStart()
|
||||
|
||||
Connections {
|
||||
function onIsEnabledChanged() {
|
||||
if (root.isEnabled)
|
||||
|
||||
Reference in New Issue
Block a user