added services page + rename barConfig json property to bar, migration helper function
This commit is contained in:
@@ -72,6 +72,12 @@ JsonObject {
|
||||
property bool upower: true
|
||||
}
|
||||
component Tray: JsonObject {
|
||||
property bool showAudio: true
|
||||
property bool showBluetooth: false
|
||||
property bool showMicrophone: true
|
||||
property bool showNetwork: false
|
||||
property bool showPower: true
|
||||
property bool showWifi: false
|
||||
property int trayIconSize: 24
|
||||
}
|
||||
}
|
||||
|
||||
+48
-364
@@ -12,7 +12,7 @@ Singleton {
|
||||
|
||||
property alias appearance: adapter.appearance
|
||||
property alias background: adapter.background
|
||||
property alias barConfig: adapter.barConfig
|
||||
property alias bar: adapter.bar
|
||||
property alias clipboard: adapter.clipboard
|
||||
property alias colors: adapter.colors
|
||||
property alias dashboard: adapter.dashboard
|
||||
@@ -20,6 +20,7 @@ Singleton {
|
||||
property alias general: adapter.general
|
||||
property alias launcher: adapter.launcher
|
||||
property alias lock: adapter.lock
|
||||
property bool migratingLegacyBar: false
|
||||
property alias notifs: adapter.notifs
|
||||
property alias osd: adapter.osd
|
||||
property alias overview: adapter.overview
|
||||
@@ -29,6 +30,41 @@ Singleton {
|
||||
property alias sidebar: adapter.sidebar
|
||||
property alias utilities: adapter.utilities
|
||||
|
||||
function applyLegacyBarConfig(legacy): void {
|
||||
const tray = legacy.tray ?? {};
|
||||
const popouts = legacy.popouts ?? {};
|
||||
|
||||
bar.autoHide = pick(legacy.autoHide, bar.autoHide);
|
||||
bar.hideWhenNotif = pick(legacy.hideWhenNotif, bar.hideWhenNotif);
|
||||
bar.rounding = pick(legacy.rounding, bar.rounding);
|
||||
bar.border = pick(legacy.border, bar.border);
|
||||
bar.smoothing = pick(legacy.smoothing, bar.smoothing);
|
||||
bar.height = pick(legacy.height, bar.height);
|
||||
bar.tray.trayIconSize = pick(tray.trayIconSize, bar.tray.trayIconSize);
|
||||
bar.popouts.tray = pick(popouts.tray, bar.popouts.tray);
|
||||
bar.popouts.audio = pick(popouts.audio, bar.popouts.audio);
|
||||
bar.popouts.activeWindow = pick(popouts.activeWindow, bar.popouts.activeWindow);
|
||||
bar.popouts.resources = pick(popouts.resources, bar.popouts.resources);
|
||||
bar.popouts.clock = pick(popouts.clock, bar.popouts.clock);
|
||||
bar.popouts.network = pick(popouts.network, bar.popouts.network);
|
||||
bar.popouts.upower = pick(popouts.upower, bar.popouts.upower);
|
||||
bar.entries = pick(legacy.entries, bar.entries);
|
||||
}
|
||||
|
||||
function migrateLegacyBarConfig(raw): bool {
|
||||
if (raw.bar !== undefined || raw.barConfig === undefined)
|
||||
return false;
|
||||
|
||||
migratingLegacyBar = true;
|
||||
applyLegacyBarConfig(raw.barConfig);
|
||||
migratingLegacyBar = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function pick(value, fallback) {
|
||||
return value === undefined ? fallback : value;
|
||||
}
|
||||
|
||||
function save(): void {
|
||||
saveTimer.restart();
|
||||
recentlySaved = true;
|
||||
@@ -39,353 +75,6 @@ Singleton {
|
||||
saveTimer.restart();
|
||||
}
|
||||
|
||||
function serializeAppearance(): var {
|
||||
return {
|
||||
rounding: {
|
||||
scale: appearance.rounding.scale
|
||||
},
|
||||
spacing: {
|
||||
scale: appearance.spacing.scale
|
||||
},
|
||||
padding: {
|
||||
scale: appearance.padding.scale
|
||||
},
|
||||
deform: {
|
||||
scale: appearance.deform.scale
|
||||
},
|
||||
font: {
|
||||
family: {
|
||||
sans: appearance.font.family.sans,
|
||||
mono: appearance.font.family.mono,
|
||||
material: appearance.font.family.material,
|
||||
clock: appearance.font.family.clock
|
||||
},
|
||||
size: {
|
||||
scale: appearance.font.size.scale
|
||||
}
|
||||
},
|
||||
anim: {
|
||||
mediaGifSpeedAdjustment: appearance.anim.mediaGifSpeedAdjustment,
|
||||
sessionGifSpeed: appearance.anim.sessionGifSpeed,
|
||||
durations: {
|
||||
scale: appearance.anim.durations.scale
|
||||
}
|
||||
},
|
||||
transparency: {
|
||||
enabled: appearance.transparency.enabled,
|
||||
base: appearance.transparency.base,
|
||||
layers: appearance.transparency.layers
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function serializeBackground(): var {
|
||||
return {
|
||||
wallFadeDuration: background.wallFadeDuration,
|
||||
enabled: background.enabled,
|
||||
alignX: background.alignX,
|
||||
sourceClipX: background.sourceClipX,
|
||||
sourceClipY: background.sourceClipY,
|
||||
sourceClipW: background.sourceClipW,
|
||||
sourceClipH: background.sourceClipH,
|
||||
alignY: background.alignY,
|
||||
zoom: background.zoom
|
||||
};
|
||||
}
|
||||
|
||||
function serializeBar(): var {
|
||||
return {
|
||||
autoHide: barConfig.autoHide,
|
||||
hideWhenNotif: barConfig.hideWhenNotif,
|
||||
rounding: barConfig.rounding,
|
||||
border: barConfig.border,
|
||||
smoothing: barConfig.smoothing,
|
||||
height: barConfig.height,
|
||||
tray: {
|
||||
trayIconSize: barConfig.tray.trayIconSize
|
||||
},
|
||||
popouts: {
|
||||
tray: barConfig.popouts.tray,
|
||||
audio: barConfig.popouts.audio,
|
||||
activeWindow: barConfig.popouts.activeWindow,
|
||||
resources: barConfig.popouts.resources,
|
||||
clock: barConfig.popouts.clock,
|
||||
network: barConfig.popouts.network,
|
||||
upower: barConfig.popouts.upower
|
||||
},
|
||||
entries: barConfig.entries
|
||||
};
|
||||
}
|
||||
|
||||
function serializeClipboard(): var {
|
||||
return {
|
||||
enabled: clipboard.enabled,
|
||||
maxEntriesShown: clipboard.maxEntriesShown,
|
||||
sizes: {
|
||||
width: clipboard.sizes.width,
|
||||
previewWidth: clipboard.sizes.previewWidth,
|
||||
minPreviewWidth: clipboard.sizes.minPreviewWidth,
|
||||
itemHeight: clipboard.sizes.itemHeight
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function serializeColors(): var {
|
||||
return {
|
||||
schemeType: colors.schemeType,
|
||||
presets: {
|
||||
name: colors.presets.name,
|
||||
variant: colors.presets.variant,
|
||||
accent: colors.presets.accent
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function serializeConfig(): var {
|
||||
return {
|
||||
barConfig: serializeBar(),
|
||||
lock: serializeLock(),
|
||||
general: serializeGeneral(),
|
||||
services: serializeServices(),
|
||||
notifs: serializeNotifs(),
|
||||
sidebar: serializeSidebar(),
|
||||
utilities: serializeUtilities(),
|
||||
dashboard: serializeDashboard(),
|
||||
appearance: serializeAppearance(),
|
||||
osd: serializeOsd(),
|
||||
background: serializeBackground(),
|
||||
launcher: serializeLauncher(),
|
||||
colors: serializeColors(),
|
||||
dock: serializeDock(),
|
||||
screenshot: serializeScreenshot(),
|
||||
clipboard: serializeClipboard()
|
||||
};
|
||||
}
|
||||
|
||||
function serializeDashboard(): var {
|
||||
return {
|
||||
enabled: dashboard.enabled,
|
||||
mediaUpdateInterval: dashboard.mediaUpdateInterval,
|
||||
resourceUpdateInterval: dashboard.resourceUpdateInterval,
|
||||
performance: {
|
||||
showBattery: dashboard.performance.showBattery,
|
||||
showGpu: dashboard.performance.showGpu,
|
||||
showCpu: dashboard.performance.showCpu,
|
||||
showMemory: dashboard.performance.showMemory,
|
||||
showStorage: dashboard.performance.showStorage,
|
||||
showNetwork: dashboard.performance.showNetwork
|
||||
},
|
||||
sizes: {
|
||||
tabIndicatorHeight: dashboard.sizes.tabIndicatorHeight,
|
||||
tabIndicatorSpacing: dashboard.sizes.tabIndicatorSpacing,
|
||||
infoWidth: dashboard.sizes.infoWidth,
|
||||
infoIconSize: dashboard.sizes.infoIconSize,
|
||||
dateTimeWidth: dashboard.sizes.dateTimeWidth,
|
||||
mediaWidth: dashboard.sizes.mediaWidth,
|
||||
mediaProgressSweep: dashboard.sizes.mediaProgressSweep,
|
||||
mediaProgressThickness: dashboard.sizes.mediaProgressThickness,
|
||||
resourceProgessThickness: dashboard.sizes.resourceProgessThickness,
|
||||
weatherWidth: dashboard.sizes.weatherWidth,
|
||||
mediaCoverArtSize: dashboard.sizes.mediaCoverArtSize,
|
||||
mediaVisualizerSize: dashboard.sizes.mediaVisualizerSize,
|
||||
resourceSize: dashboard.sizes.resourceSize
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function serializeDock(): var {
|
||||
return {
|
||||
enable: dock.enable,
|
||||
height: dock.height,
|
||||
hoverToReveal: dock.hoverToReveal,
|
||||
pinnedApps: dock.pinnedApps,
|
||||
pinnedOnStartup: dock.pinnedOnStartup,
|
||||
ignoredAppRegexes: dock.ignoredAppRegexes
|
||||
};
|
||||
}
|
||||
|
||||
function serializeGeneral(): var {
|
||||
return {
|
||||
logo: general.logo,
|
||||
wallpaperPath: general.wallpaperPath,
|
||||
showOverFullscreen: general.showOverFullscreen,
|
||||
desktopIcons: general.desktopIcons,
|
||||
dateFormat: general.dateFormat,
|
||||
color: {
|
||||
mode: general.color.mode,
|
||||
smart: general.color.smart,
|
||||
scheduleDark: general.color.scheduleDark,
|
||||
scheduleHyprsunset: general.color.scheduleHyprsunset,
|
||||
scheduleHyprsunsetStart: general.color.scheduleHyprsunsetStart,
|
||||
hyprsunsetTemp: general.color.hyprsunsetTemp,
|
||||
scheduleHyprsunsetEnd: general.color.scheduleHyprsunsetEnd,
|
||||
schemeGeneration: general.color.schemeGeneration,
|
||||
scheduleDarkStart: general.color.scheduleDarkStart,
|
||||
scheduleDarkEnd: general.color.scheduleDarkEnd,
|
||||
neovimColors: general.color.neovimColors
|
||||
},
|
||||
apps: {
|
||||
terminal: general.apps.terminal,
|
||||
audio: general.apps.audio,
|
||||
playback: general.apps.playback,
|
||||
explorer: general.apps.explorer
|
||||
},
|
||||
idle: {
|
||||
timeouts: general.idle.timeouts
|
||||
},
|
||||
battery: {
|
||||
popupThresholds: general.battery.popupThresholds,
|
||||
critPerc: general.battery.critPerc
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function serializeLauncher(): var {
|
||||
return {
|
||||
maxAppsShown: launcher.maxAppsShown,
|
||||
maxWallpapers: launcher.maxWallpapers,
|
||||
dragThreshold: launcher.dragThreshold,
|
||||
enableDangerousActions: launcher.enableDangerousActions,
|
||||
enabled: launcher.enabled,
|
||||
hiddenApps: launcher.hiddenApps,
|
||||
favoriteApps: launcher.favoriteApps,
|
||||
uwsm: launcher.uwsm,
|
||||
actionPrefix: launcher.actionPrefix,
|
||||
specialPrefix: launcher.specialPrefix,
|
||||
useFuzzy: {
|
||||
apps: launcher.useFuzzy.apps,
|
||||
actions: launcher.useFuzzy.actions,
|
||||
schemes: launcher.useFuzzy.schemes,
|
||||
variants: launcher.useFuzzy.variants,
|
||||
wallpapers: launcher.useFuzzy.wallpapers
|
||||
},
|
||||
sizes: {
|
||||
itemWidth: launcher.sizes.itemWidth,
|
||||
itemHeight: launcher.sizes.itemHeight,
|
||||
wallpaperWidth: launcher.sizes.wallpaperWidth,
|
||||
wallpaperHeight: launcher.sizes.wallpaperHeight
|
||||
},
|
||||
actions: launcher.actions
|
||||
};
|
||||
}
|
||||
|
||||
function serializeLock(): var {
|
||||
return {
|
||||
recolorLogo: lock.recolorLogo,
|
||||
enableFprint: lock.enableFprint,
|
||||
showNotifContent: lock.showNotifContent,
|
||||
showNotifIcon: lock.showNotifIcon,
|
||||
maxFprintTries: lock.maxFprintTries,
|
||||
blurAmount: lock.blurAmount,
|
||||
sizes: {
|
||||
heightMult: lock.sizes.heightMult,
|
||||
ratio: lock.sizes.ratio,
|
||||
centerWidth: lock.sizes.centerWidth
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function serializeNotifs(): var {
|
||||
return {
|
||||
expire: notifs.expire,
|
||||
defaultExpireTimeout: notifs.defaultExpireTimeout,
|
||||
appNotifCooldown: notifs.appNotifCooldown,
|
||||
clearThreshold: notifs.clearThreshold,
|
||||
expandThreshold: notifs.expandThreshold,
|
||||
actionOnClick: notifs.actionOnClick,
|
||||
groupPreviewNum: notifs.groupPreviewNum,
|
||||
sizes: {
|
||||
width: notifs.sizes.width,
|
||||
image: notifs.sizes.image,
|
||||
badge: notifs.sizes.badge
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function serializeOsd(): var {
|
||||
return {
|
||||
enabled: osd.enabled,
|
||||
hideDelay: osd.hideDelay,
|
||||
enableBrightness: osd.enableBrightness,
|
||||
enableMicrophone: osd.enableMicrophone,
|
||||
allMonBrightness: osd.allMonBrightness,
|
||||
sizes: {
|
||||
sliderWidth: osd.sizes.sliderWidth,
|
||||
sliderHeight: osd.sizes.sliderHeight
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function serializeScreenshot(): var {
|
||||
return {
|
||||
enable_pp: screenshot.enable_pp,
|
||||
mode: screenshot.mode,
|
||||
radius: screenshot.radius,
|
||||
shadow: screenshot.shadow,
|
||||
rounding: screenshot.rounding,
|
||||
shadow_blur: screenshot.shadow_blur,
|
||||
shadow_color: screenshot.shadow_color,
|
||||
shadow_offset_x: screenshot.shadow_offset_x,
|
||||
shadow_offset_y: screenshot.shadow_offset_y
|
||||
};
|
||||
}
|
||||
|
||||
function serializeServices(): var {
|
||||
return {
|
||||
weatherLocation: services.weatherLocation,
|
||||
updates: services.updates,
|
||||
useFahrenheit: services.useFahrenheit,
|
||||
minBrightness: services.minBrightness,
|
||||
ddcutilService: services.ddcutilService,
|
||||
useTwelveHourClock: services.useTwelveHourClock,
|
||||
gpuType: services.gpuType,
|
||||
audioIncrement: services.audioIncrement,
|
||||
brightnessIncrement: services.brightnessIncrement,
|
||||
maxVolume: services.maxVolume,
|
||||
defaultPlayer: services.defaultPlayer,
|
||||
playerAliases: services.playerAliases,
|
||||
visualizerBars: services.visualizerBars
|
||||
};
|
||||
}
|
||||
|
||||
function serializeSidebar(): var {
|
||||
return {
|
||||
enabled: sidebar.enabled,
|
||||
dragThreshold: sidebar.dragThreshold,
|
||||
sizes: {
|
||||
width: sidebar.sizes.width
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function serializeUtilities(): var {
|
||||
return {
|
||||
enabled: utilities.enabled,
|
||||
maxToasts: utilities.maxToasts,
|
||||
sizes: {
|
||||
width: utilities.sizes.width,
|
||||
toastWidth: utilities.sizes.toastWidth
|
||||
},
|
||||
toasts: {
|
||||
configLoaded: utilities.toasts.configLoaded,
|
||||
chargingChanged: utilities.toasts.chargingChanged,
|
||||
gameModeChanged: utilities.toasts.gameModeChanged,
|
||||
dndChanged: utilities.toasts.dndChanged,
|
||||
audioOutputChanged: utilities.toasts.audioOutputChanged,
|
||||
audioInputChanged: utilities.toasts.audioInputChanged,
|
||||
capsLockChanged: utilities.toasts.capsLockChanged,
|
||||
numLockChanged: utilities.toasts.numLockChanged,
|
||||
kbLayoutChanged: utilities.toasts.kbLayoutChanged,
|
||||
vpnChanged: utilities.toasts.vpnChanged,
|
||||
nowPlaying: utilities.toasts.nowPlaying
|
||||
},
|
||||
vpn: {
|
||||
enabled: utilities.vpn.enabled,
|
||||
provider: utilities.vpn.provider
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ElapsedTimer {
|
||||
id: timer
|
||||
}
|
||||
@@ -397,20 +86,7 @@ Singleton {
|
||||
|
||||
onTriggered: {
|
||||
timer.restart();
|
||||
try {
|
||||
let config = {};
|
||||
try {
|
||||
config = JSON.parse(fileView.text());
|
||||
} catch (e) {
|
||||
config = {};
|
||||
}
|
||||
|
||||
config = root.serializeConfig();
|
||||
|
||||
fileView.setText(JSON.stringify(config, null, 4));
|
||||
} catch (e) {
|
||||
Toaster.toast(qsTr("Failed to serialize config"), e.message, "settings_alert", Toast.Error);
|
||||
}
|
||||
fileView.writeAdapter();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -430,6 +106,10 @@ Singleton {
|
||||
path: `${Paths.config}/config.json`
|
||||
watchChanges: true
|
||||
|
||||
onAdapterUpdated: {
|
||||
if (!root.migratingLegacyBar)
|
||||
root.save();
|
||||
}
|
||||
onFileChanged: {
|
||||
if (!root.recentlySaved) {
|
||||
timer.restart();
|
||||
@@ -446,7 +126,11 @@ Singleton {
|
||||
ModeScheduler.checkStartup();
|
||||
Hyprsunset.checkStartup();
|
||||
try {
|
||||
JSON.parse(text());
|
||||
const raw = JSON.parse(text());
|
||||
const migrated = root.migrateLegacyBarConfig(raw);
|
||||
if (migrated)
|
||||
root.save();
|
||||
|
||||
const elapsed = timer.elapsedMs();
|
||||
|
||||
if (adapter.utilities.toasts.configLoaded && !root.recentlySaved) {
|
||||
@@ -467,7 +151,7 @@ Singleton {
|
||||
}
|
||||
property BackgroundConfig background: BackgroundConfig {
|
||||
}
|
||||
property BarConfig barConfig: BarConfig {
|
||||
property BarConfig bar: BarConfig {
|
||||
}
|
||||
property ClipboardConfig clipboard: ClipboardConfig {
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ JsonObject {
|
||||
}
|
||||
|
||||
component Performance: JsonObject {
|
||||
property bool enabled: true
|
||||
property bool showBattery: true
|
||||
property bool showCpu: true
|
||||
property bool showGpu: true
|
||||
|
||||
@@ -9,6 +9,7 @@ JsonObject {
|
||||
property bool expire: true
|
||||
property int groupPreviewNum: 3
|
||||
property bool openExpanded: false
|
||||
property bool showInFullscreen: true
|
||||
property Sizes sizes: Sizes {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user