controlcenter: removed FileView and now all use singleton Config
This commit is contained in:
parent
05b0660627
commit
f29f0a3805
3 changed files with 131 additions and 353 deletions
|
|
@ -12,7 +12,6 @@ import qs.config
|
|||
import qs.utils
|
||||
import Caelestia.Models
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
|
||||
|
|
@ -22,117 +21,32 @@ RowLayout {
|
|||
required property Session session
|
||||
|
||||
// Appearance settings
|
||||
property real animDurationsScale: 1
|
||||
property string fontFamilyMaterial: "Material Symbols Rounded"
|
||||
property string fontFamilyMono: "CaskaydiaCove NF"
|
||||
property string fontFamilySans: "Rubik"
|
||||
property real fontSizeScale: 1
|
||||
property real paddingScale: 1
|
||||
property real roundingScale: 1
|
||||
property real spacingScale: 1
|
||||
property bool transparencyEnabled: false
|
||||
property real transparencyBase: 0.85
|
||||
property real transparencyLayers: 0.4
|
||||
property real borderRounding: 1
|
||||
property real borderThickness: 1
|
||||
property real animDurationsScale: Config.appearance.anim.durations.scale ?? 1
|
||||
property string fontFamilyMaterial: Config.appearance.font.family.material ?? "Material Symbols Rounded"
|
||||
property string fontFamilyMono: Config.appearance.font.family.mono ?? "CaskaydiaCove NF"
|
||||
property string fontFamilySans: Config.appearance.font.family.sans ?? "Rubik"
|
||||
property real fontSizeScale: Config.appearance.font.size.scale ?? 1
|
||||
property real paddingScale: Config.appearance.padding.scale ?? 1
|
||||
property real roundingScale: Config.appearance.rounding.scale ?? 1
|
||||
property real spacingScale: Config.appearance.spacing.scale ?? 1
|
||||
property bool transparencyEnabled: Config.appearance.transparency.enabled ?? false
|
||||
property real transparencyBase: Config.appearance.transparency.base ?? 0.85
|
||||
property real transparencyLayers: Config.appearance.transparency.layers ?? 0.4
|
||||
property real borderRounding: Config.border.rounding ?? 1
|
||||
property real borderThickness: Config.border.thickness ?? 1
|
||||
|
||||
// Background settings
|
||||
property bool desktopClockEnabled: true
|
||||
property bool backgroundEnabled: true
|
||||
property bool visualiserEnabled: true
|
||||
property bool visualiserAutoHide: true
|
||||
property real visualiserRounding: 1
|
||||
property real visualiserSpacing: 1
|
||||
property bool desktopClockEnabled: Config.background.desktopClock.enabled ?? false
|
||||
property bool backgroundEnabled: Config.background.enabled ?? true
|
||||
property bool visualiserEnabled: Config.background.visualiser.enabled ?? false
|
||||
property bool visualiserAutoHide: Config.background.visualiser.autoHide ?? true
|
||||
property real visualiserRounding: Config.background.visualiser.rounding ?? 1
|
||||
property real visualiserSpacing: Config.background.visualiser.spacing ?? 1
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
spacing: 0
|
||||
|
||||
FileView {
|
||||
id: configFile
|
||||
|
||||
path: `${Paths.config}/shell.json`
|
||||
watchChanges: true
|
||||
|
||||
onLoaded: {
|
||||
try {
|
||||
const config = JSON.parse(text());
|
||||
updateFromConfig(config);
|
||||
} catch (e) {
|
||||
console.error("Failed to parse config:", e);
|
||||
}
|
||||
}
|
||||
|
||||
onSaveFailed: err => {
|
||||
console.error("Failed to save config file:", err);
|
||||
}
|
||||
}
|
||||
|
||||
function updateFromConfig(config) {
|
||||
// Update appearance settings
|
||||
if (config.appearance) {
|
||||
if (config.appearance.anim && config.appearance.anim.durations) {
|
||||
root.animDurationsScale = config.appearance.anim.durations.scale ?? 1;
|
||||
}
|
||||
if (config.appearance.font) {
|
||||
if (config.appearance.font.family) {
|
||||
root.fontFamilyMaterial = config.appearance.font.family.material ?? "Material Symbols Rounded";
|
||||
root.fontFamilyMono = config.appearance.font.family.mono ?? "CaskaydiaCove NF";
|
||||
root.fontFamilySans = config.appearance.font.family.sans ?? "Rubik";
|
||||
}
|
||||
if (config.appearance.font.size) {
|
||||
root.fontSizeScale = config.appearance.font.size.scale ?? 1;
|
||||
}
|
||||
}
|
||||
if (config.appearance.padding) {
|
||||
root.paddingScale = config.appearance.padding.scale ?? 1;
|
||||
}
|
||||
if (config.appearance.rounding) {
|
||||
root.roundingScale = config.appearance.rounding.scale ?? 1;
|
||||
}
|
||||
if (config.appearance.spacing) {
|
||||
root.spacingScale = config.appearance.spacing.scale ?? 1;
|
||||
}
|
||||
if (config.appearance.transparency) {
|
||||
root.transparencyEnabled = config.appearance.transparency.enabled ?? false;
|
||||
root.transparencyBase = config.appearance.transparency.base ?? 0.85;
|
||||
root.transparencyLayers = config.appearance.transparency.layers ?? 0.4;
|
||||
}
|
||||
}
|
||||
|
||||
// Update border settings
|
||||
if (config.border) {
|
||||
root.borderRounding = config.border.rounding ?? 1;
|
||||
root.borderThickness = config.border.thickness ?? 1;
|
||||
}
|
||||
|
||||
// Update background settings
|
||||
if (config.background) {
|
||||
root.desktopClockEnabled = config.background.desktopClock?.enabled !== undefined ? config.background.desktopClock.enabled : false;
|
||||
root.backgroundEnabled = config.background.enabled !== undefined ? config.background.enabled : true;
|
||||
if (config.background.visualiser) {
|
||||
root.visualiserEnabled = config.background.visualiser.enabled !== undefined ? config.background.visualiser.enabled : false;
|
||||
root.visualiserAutoHide = config.background.visualiser.autoHide !== undefined ? config.background.visualiser.autoHide : true;
|
||||
root.visualiserRounding = config.background.visualiser.rounding !== undefined ? config.background.visualiser.rounding : 1;
|
||||
root.visualiserSpacing = config.background.visualiser.spacing !== undefined ? config.background.visualiser.spacing : 1;
|
||||
} else {
|
||||
// Set defaults if visualiser object doesn't exist (matching BackgroundConfig defaults)
|
||||
root.visualiserEnabled = false;
|
||||
root.visualiserAutoHide = true;
|
||||
root.visualiserRounding = 1;
|
||||
root.visualiserSpacing = 1;
|
||||
}
|
||||
} else {
|
||||
// Set defaults if background object doesn't exist (matching BackgroundConfig defaults)
|
||||
root.desktopClockEnabled = false;
|
||||
root.backgroundEnabled = true;
|
||||
root.visualiserEnabled = false;
|
||||
root.visualiserAutoHide = true;
|
||||
root.visualiserRounding = 1;
|
||||
root.visualiserSpacing = 1;
|
||||
}
|
||||
}
|
||||
|
||||
function collapseAllSections(exceptSection) {
|
||||
if (exceptSection !== themeModeSection) themeModeSection.expanded = false;
|
||||
if (exceptSection !== colorVariantSection) colorVariantSection.expanded = false;
|
||||
|
|
@ -146,73 +60,40 @@ RowLayout {
|
|||
}
|
||||
|
||||
function saveConfig() {
|
||||
if (!configFile.loaded) {
|
||||
console.error("Config file not loaded yet");
|
||||
return;
|
||||
}
|
||||
// Update animations
|
||||
Config.appearance.anim.durations.scale = root.animDurationsScale;
|
||||
|
||||
try {
|
||||
const config = JSON.parse(configFile.text());
|
||||
// Update fonts
|
||||
Config.appearance.font.family.material = root.fontFamilyMaterial;
|
||||
Config.appearance.font.family.mono = root.fontFamilyMono;
|
||||
Config.appearance.font.family.sans = root.fontFamilySans;
|
||||
Config.appearance.font.size.scale = root.fontSizeScale;
|
||||
|
||||
// Ensure appearance object exists
|
||||
if (!config.appearance) config.appearance = {};
|
||||
// Update scales
|
||||
Config.appearance.padding.scale = root.paddingScale;
|
||||
Config.appearance.rounding.scale = root.roundingScale;
|
||||
Config.appearance.spacing.scale = root.spacingScale;
|
||||
|
||||
// Update animations
|
||||
if (!config.appearance.anim) config.appearance.anim = {};
|
||||
if (!config.appearance.anim.durations) config.appearance.anim.durations = {};
|
||||
config.appearance.anim.durations.scale = root.animDurationsScale;
|
||||
// Update transparency
|
||||
Config.appearance.transparency.enabled = root.transparencyEnabled;
|
||||
Config.appearance.transparency.base = root.transparencyBase;
|
||||
Config.appearance.transparency.layers = root.transparencyLayers;
|
||||
|
||||
// Update fonts
|
||||
if (!config.appearance.font) config.appearance.font = {};
|
||||
if (!config.appearance.font.family) config.appearance.font.family = {};
|
||||
config.appearance.font.family.material = root.fontFamilyMaterial;
|
||||
config.appearance.font.family.mono = root.fontFamilyMono;
|
||||
config.appearance.font.family.sans = root.fontFamilySans;
|
||||
if (!config.appearance.font.size) config.appearance.font.size = {};
|
||||
config.appearance.font.size.scale = root.fontSizeScale;
|
||||
// Update desktop clock
|
||||
Config.background.desktopClock.enabled = root.desktopClockEnabled;
|
||||
|
||||
// Update scales
|
||||
if (!config.appearance.padding) config.appearance.padding = {};
|
||||
config.appearance.padding.scale = root.paddingScale;
|
||||
if (!config.appearance.rounding) config.appearance.rounding = {};
|
||||
config.appearance.rounding.scale = root.roundingScale;
|
||||
if (!config.appearance.spacing) config.appearance.spacing = {};
|
||||
config.appearance.spacing.scale = root.spacingScale;
|
||||
// Update background enabled
|
||||
Config.background.enabled = root.backgroundEnabled;
|
||||
|
||||
// Update transparency
|
||||
if (!config.appearance.transparency) config.appearance.transparency = {};
|
||||
config.appearance.transparency.enabled = root.transparencyEnabled;
|
||||
config.appearance.transparency.base = root.transparencyBase;
|
||||
config.appearance.transparency.layers = root.transparencyLayers;
|
||||
// Update visualiser
|
||||
Config.background.visualiser.enabled = root.visualiserEnabled;
|
||||
Config.background.visualiser.autoHide = root.visualiserAutoHide;
|
||||
Config.background.visualiser.rounding = root.visualiserRounding;
|
||||
Config.background.visualiser.spacing = root.visualiserSpacing;
|
||||
|
||||
// Ensure background object exists
|
||||
if (!config.background) config.background = {};
|
||||
|
||||
// Update desktop clock
|
||||
if (!config.background.desktopClock) config.background.desktopClock = {};
|
||||
config.background.desktopClock.enabled = root.desktopClockEnabled;
|
||||
|
||||
// Update background enabled
|
||||
config.background.enabled = root.backgroundEnabled;
|
||||
|
||||
// Update visualiser
|
||||
if (!config.background.visualiser) config.background.visualiser = {};
|
||||
config.background.visualiser.enabled = root.visualiserEnabled;
|
||||
config.background.visualiser.autoHide = root.visualiserAutoHide;
|
||||
config.background.visualiser.rounding = root.visualiserRounding;
|
||||
config.background.visualiser.spacing = root.visualiserSpacing;
|
||||
|
||||
// Update border
|
||||
if (!config.border) config.border = {};
|
||||
config.border.rounding = root.borderRounding;
|
||||
config.border.thickness = root.borderThickness;
|
||||
|
||||
// Write back to file using setText (same simple approach that worked for taskbar)
|
||||
const jsonString = JSON.stringify(config, null, 4);
|
||||
configFile.setText(jsonString);
|
||||
} catch (e) {
|
||||
console.error("Failed to save config:", e);
|
||||
}
|
||||
// Update border
|
||||
Config.border.rounding = root.borderRounding;
|
||||
Config.border.thickness = root.borderThickness;
|
||||
}
|
||||
|
||||
Item {
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import qs.config
|
|||
import qs.utils
|
||||
import Caelestia
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Widgets
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
|
|
@ -29,74 +28,46 @@ RowLayout {
|
|||
|
||||
spacing: 0
|
||||
|
||||
FileView {
|
||||
id: configFile
|
||||
|
||||
path: `${Paths.config}/shell.json`
|
||||
watchChanges: true
|
||||
|
||||
onLoaded: {
|
||||
try {
|
||||
const config = JSON.parse(text());
|
||||
updateToggleState();
|
||||
} catch (e) {
|
||||
console.error("Failed to parse config:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateToggleState() {
|
||||
if (!root.selectedApp || !configFile.loaded) {
|
||||
if (!root.selectedApp) {
|
||||
root.hideFromLauncherChecked = false;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const config = JSON.parse(configFile.text());
|
||||
const appId = root.selectedApp.id || root.selectedApp.entry?.id;
|
||||
const appId = root.selectedApp.id || root.selectedApp.entry?.id;
|
||||
|
||||
if (config.launcher && config.launcher.hiddenApps) {
|
||||
root.hideFromLauncherChecked = config.launcher.hiddenApps.includes(appId);
|
||||
} else {
|
||||
root.hideFromLauncherChecked = false;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Failed to update toggle state:", e);
|
||||
if (Config.launcher.hiddenApps && Config.launcher.hiddenApps.length > 0) {
|
||||
root.hideFromLauncherChecked = Config.launcher.hiddenApps.includes(appId);
|
||||
} else {
|
||||
root.hideFromLauncherChecked = false;
|
||||
}
|
||||
}
|
||||
|
||||
function saveHiddenApps(isHidden) {
|
||||
if (!configFile.loaded || !root.selectedApp) {
|
||||
if (!root.selectedApp) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const config = JSON.parse(configFile.text());
|
||||
const appId = root.selectedApp.id || root.selectedApp.entry?.id;
|
||||
const appId = root.selectedApp.id || root.selectedApp.entry?.id;
|
||||
|
||||
if (!config.launcher) config.launcher = {};
|
||||
if (!config.launcher.hiddenApps) config.launcher.hiddenApps = [];
|
||||
// Create a new array to ensure change detection
|
||||
const hiddenApps = Config.launcher.hiddenApps ? [...Config.launcher.hiddenApps] : [];
|
||||
|
||||
const hiddenApps = config.launcher.hiddenApps;
|
||||
|
||||
if (isHidden) {
|
||||
// Add to hiddenApps if not already there
|
||||
if (!hiddenApps.includes(appId)) {
|
||||
hiddenApps.push(appId);
|
||||
}
|
||||
} else {
|
||||
// Remove from hiddenApps
|
||||
const index = hiddenApps.indexOf(appId);
|
||||
if (index !== -1) {
|
||||
hiddenApps.splice(index, 1);
|
||||
}
|
||||
if (isHidden) {
|
||||
// Add to hiddenApps if not already there
|
||||
if (!hiddenApps.includes(appId)) {
|
||||
hiddenApps.push(appId);
|
||||
}
|
||||
} else {
|
||||
// Remove from hiddenApps
|
||||
const index = hiddenApps.indexOf(appId);
|
||||
if (index !== -1) {
|
||||
hiddenApps.splice(index, 1);
|
||||
}
|
||||
|
||||
const jsonString = JSON.stringify(config, null, 4);
|
||||
configFile.setText(jsonString);
|
||||
} catch (e) {
|
||||
console.error("Failed to save config:", e);
|
||||
}
|
||||
|
||||
// Update Config to trigger save
|
||||
Config.launcher.hiddenApps = hiddenApps;
|
||||
}
|
||||
|
||||
onSelectedAppChanged: {
|
||||
|
|
@ -437,7 +408,7 @@ RowLayout {
|
|||
visible: root.selectedApp !== null
|
||||
label: qsTr("Hide from launcher")
|
||||
checked: root.hideFromLauncherChecked
|
||||
enabled: root.selectedApp !== null && configFile.loaded
|
||||
enabled: root.selectedApp !== null
|
||||
onToggled: checked => {
|
||||
root.hideFromLauncherChecked = checked;
|
||||
root.saveHiddenApps(checked);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ import qs.services
|
|||
import qs.config
|
||||
import qs.utils
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
|
||||
|
|
@ -19,171 +18,98 @@ RowLayout {
|
|||
required property Session session
|
||||
|
||||
// Bar Behavior
|
||||
property bool persistent: true
|
||||
property bool showOnHover: true
|
||||
property int dragThreshold: 20
|
||||
property bool persistent: Config.bar.persistent ?? true
|
||||
property bool showOnHover: Config.bar.showOnHover ?? true
|
||||
property int dragThreshold: Config.bar.dragThreshold ?? 20
|
||||
|
||||
// Status Icons
|
||||
property bool showAudio: true
|
||||
property bool showMicrophone: true
|
||||
property bool showKbLayout: false
|
||||
property bool showNetwork: true
|
||||
property bool showBluetooth: true
|
||||
property bool showBattery: true
|
||||
property bool showLockStatus: true
|
||||
property bool showAudio: Config.bar.status.showAudio ?? true
|
||||
property bool showMicrophone: Config.bar.status.showMicrophone ?? true
|
||||
property bool showKbLayout: Config.bar.status.showKbLayout ?? false
|
||||
property bool showNetwork: Config.bar.status.showNetwork ?? true
|
||||
property bool showBluetooth: Config.bar.status.showBluetooth ?? true
|
||||
property bool showBattery: Config.bar.status.showBattery ?? true
|
||||
property bool showLockStatus: Config.bar.status.showLockStatus ?? true
|
||||
|
||||
// Tray Settings
|
||||
property bool trayBackground: false
|
||||
property bool trayCompact: false
|
||||
property bool trayRecolour: false
|
||||
property bool trayBackground: Config.bar.tray.background ?? false
|
||||
property bool trayCompact: Config.bar.tray.compact ?? false
|
||||
property bool trayRecolour: Config.bar.tray.recolour ?? false
|
||||
|
||||
// Workspaces
|
||||
property int workspacesShown: 5
|
||||
property bool workspacesActiveIndicator: true
|
||||
property bool workspacesOccupiedBg: false
|
||||
property bool workspacesShowWindows: false
|
||||
property bool workspacesPerMonitor: true
|
||||
property int workspacesShown: Config.bar.workspaces.shown ?? 5
|
||||
property bool workspacesActiveIndicator: Config.bar.workspaces.activeIndicator ?? true
|
||||
property bool workspacesOccupiedBg: Config.bar.workspaces.occupiedBg ?? false
|
||||
property bool workspacesShowWindows: Config.bar.workspaces.showWindows ?? false
|
||||
property bool workspacesPerMonitor: Config.bar.workspaces.perMonitorWorkspaces ?? true
|
||||
|
||||
anchors.fill: parent
|
||||
|
||||
spacing: 0
|
||||
|
||||
FileView {
|
||||
id: configFile
|
||||
|
||||
path: `${Paths.config}/shell.json`
|
||||
watchChanges: true
|
||||
|
||||
onLoaded: {
|
||||
try {
|
||||
const config = JSON.parse(text());
|
||||
updateFromConfig(config);
|
||||
} catch (e) {
|
||||
console.error("Failed to parse config:", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateFromConfig(config) {
|
||||
Component.onCompleted: {
|
||||
// Update clock toggle
|
||||
if (config.bar && config.bar.clock) {
|
||||
clockShowIconSwitch.checked = config.bar.clock.showIcon !== false;
|
||||
}
|
||||
clockShowIconSwitch.checked = Config.bar.clock.showIcon ?? true;
|
||||
|
||||
// Update entries
|
||||
if (config.bar && config.bar.entries) {
|
||||
if (Config.bar.entries) {
|
||||
entriesModel.clear();
|
||||
for (const entry of config.bar.entries) {
|
||||
for (let i = 0; i < Config.bar.entries.length; i++) {
|
||||
const entry = Config.bar.entries[i];
|
||||
entriesModel.append({
|
||||
id: entry.id,
|
||||
enabled: entry.enabled !== false
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Update bar behavior
|
||||
if (config.bar) {
|
||||
root.persistent = config.bar.persistent !== false;
|
||||
root.showOnHover = config.bar.showOnHover !== false;
|
||||
root.dragThreshold = config.bar.dragThreshold || 20;
|
||||
}
|
||||
|
||||
// Update status icons
|
||||
if (config.bar && config.bar.status) {
|
||||
root.showAudio = config.bar.status.showAudio !== false;
|
||||
root.showMicrophone = config.bar.status.showMicrophone !== false;
|
||||
root.showKbLayout = config.bar.status.showKbLayout === true;
|
||||
root.showNetwork = config.bar.status.showNetwork !== false;
|
||||
root.showBluetooth = config.bar.status.showBluetooth !== false;
|
||||
root.showBattery = config.bar.status.showBattery !== false;
|
||||
root.showLockStatus = config.bar.status.showLockStatus !== false;
|
||||
}
|
||||
|
||||
// Update tray settings
|
||||
if (config.bar && config.bar.tray) {
|
||||
root.trayBackground = config.bar.tray.background === true;
|
||||
root.trayCompact = config.bar.tray.compact === true;
|
||||
root.trayRecolour = config.bar.tray.recolour === true;
|
||||
}
|
||||
|
||||
// Update workspaces
|
||||
if (config.bar && config.bar.workspaces) {
|
||||
root.workspacesShown = config.bar.workspaces.shown || 5;
|
||||
root.workspacesActiveIndicator = config.bar.workspaces.activeIndicator !== false;
|
||||
root.workspacesOccupiedBg = config.bar.workspaces.occupiedBg === true;
|
||||
root.workspacesShowWindows = config.bar.workspaces.showWindows === true;
|
||||
root.workspacesPerMonitor = config.bar.workspaces.perMonitorWorkspaces !== false;
|
||||
}
|
||||
}
|
||||
|
||||
function saveConfig(entryIndex, entryEnabled) {
|
||||
if (!configFile.loaded) {
|
||||
return;
|
||||
}
|
||||
// Update clock setting
|
||||
Config.bar.clock.showIcon = clockShowIconSwitch.checked;
|
||||
|
||||
try {
|
||||
const config = JSON.parse(configFile.text());
|
||||
// Update bar behavior
|
||||
Config.bar.persistent = root.persistent;
|
||||
Config.bar.showOnHover = root.showOnHover;
|
||||
Config.bar.dragThreshold = root.dragThreshold;
|
||||
|
||||
// Ensure bar object exists
|
||||
if (!config.bar) config.bar = {};
|
||||
// Update status icons
|
||||
Config.bar.status.showAudio = root.showAudio;
|
||||
Config.bar.status.showMicrophone = root.showMicrophone;
|
||||
Config.bar.status.showKbLayout = root.showKbLayout;
|
||||
Config.bar.status.showNetwork = root.showNetwork;
|
||||
Config.bar.status.showBluetooth = root.showBluetooth;
|
||||
Config.bar.status.showBattery = root.showBattery;
|
||||
Config.bar.status.showLockStatus = root.showLockStatus;
|
||||
|
||||
// Update clock setting
|
||||
if (!config.bar.clock) config.bar.clock = {};
|
||||
config.bar.clock.showIcon = clockShowIconSwitch.checked;
|
||||
// Update tray settings
|
||||
Config.bar.tray.background = root.trayBackground;
|
||||
Config.bar.tray.compact = root.trayCompact;
|
||||
Config.bar.tray.recolour = root.trayRecolour;
|
||||
|
||||
// Update bar behavior
|
||||
config.bar.persistent = root.persistent;
|
||||
config.bar.showOnHover = root.showOnHover;
|
||||
config.bar.dragThreshold = root.dragThreshold;
|
||||
// Update workspaces
|
||||
Config.bar.workspaces.shown = root.workspacesShown;
|
||||
Config.bar.workspaces.activeIndicator = root.workspacesActiveIndicator;
|
||||
Config.bar.workspaces.occupiedBg = root.workspacesOccupiedBg;
|
||||
Config.bar.workspaces.showWindows = root.workspacesShowWindows;
|
||||
Config.bar.workspaces.perMonitorWorkspaces = root.workspacesPerMonitor;
|
||||
|
||||
// Update status icons
|
||||
if (!config.bar.status) config.bar.status = {};
|
||||
config.bar.status.showAudio = root.showAudio;
|
||||
config.bar.status.showMicrophone = root.showMicrophone;
|
||||
config.bar.status.showKbLayout = root.showKbLayout;
|
||||
config.bar.status.showNetwork = root.showNetwork;
|
||||
config.bar.status.showBluetooth = root.showBluetooth;
|
||||
config.bar.status.showBattery = root.showBattery;
|
||||
config.bar.status.showLockStatus = root.showLockStatus;
|
||||
|
||||
// Update tray settings
|
||||
if (!config.bar.tray) config.bar.tray = {};
|
||||
config.bar.tray.background = root.trayBackground;
|
||||
config.bar.tray.compact = root.trayCompact;
|
||||
config.bar.tray.recolour = root.trayRecolour;
|
||||
|
||||
// Update workspaces
|
||||
if (!config.bar.workspaces) config.bar.workspaces = {};
|
||||
config.bar.workspaces.shown = root.workspacesShown;
|
||||
config.bar.workspaces.activeIndicator = root.workspacesActiveIndicator;
|
||||
config.bar.workspaces.occupiedBg = root.workspacesOccupiedBg;
|
||||
config.bar.workspaces.showWindows = root.workspacesShowWindows;
|
||||
config.bar.workspaces.perMonitorWorkspaces = root.workspacesPerMonitor;
|
||||
|
||||
// Update entries from the model (same approach as clock - use provided value if available)
|
||||
if (!config.bar.entries) config.bar.entries = [];
|
||||
config.bar.entries = [];
|
||||
|
||||
for (let i = 0; i < entriesModel.count; i++) {
|
||||
const entry = entriesModel.get(i);
|
||||
// If this is the entry being updated, use the provided value (same as clock toggle reads from switch)
|
||||
// Otherwise use the value from the model
|
||||
let enabled = entry.enabled;
|
||||
if (entryIndex !== undefined && i === entryIndex) {
|
||||
enabled = entryEnabled;
|
||||
}
|
||||
config.bar.entries.push({
|
||||
id: entry.id,
|
||||
enabled: enabled
|
||||
});
|
||||
// Update entries from the model (same approach as clock - use provided value if available)
|
||||
const entries = [];
|
||||
for (let i = 0; i < entriesModel.count; i++) {
|
||||
const entry = entriesModel.get(i);
|
||||
// If this is the entry being updated, use the provided value (same as clock toggle reads from switch)
|
||||
// Otherwise use the value from the model
|
||||
let enabled = entry.enabled;
|
||||
if (entryIndex !== undefined && i === entryIndex) {
|
||||
enabled = entryEnabled;
|
||||
}
|
||||
|
||||
// Write back to file using setText (same simple approach that worked for clock)
|
||||
const jsonString = JSON.stringify(config, null, 4);
|
||||
configFile.setText(jsonString);
|
||||
} catch (e) {
|
||||
console.error("Failed to save config:", e);
|
||||
entries.push({
|
||||
id: entry.id,
|
||||
enabled: enabled
|
||||
});
|
||||
}
|
||||
Config.bar.entries = entries;
|
||||
}
|
||||
|
||||
ListModel {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue