1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-24 21:42:51 -05:00

config refacotr: separate settings.json, session.json, appusage.json

This commit is contained in:
bbedward
2025-08-06 11:47:24 -04:00
parent defc50eec6
commit 18aa557ef1
45 changed files with 639 additions and 529 deletions

View File

@@ -60,9 +60,9 @@ ScrollView {
width: parent.width
text: "Night Mode"
description: "Apply warm color temperature to reduce eye strain"
checked: Prefs.nightModeEnabled
checked: SettingsData.nightModeEnabled
onToggled: (checked) => {
Prefs.setNightModeEnabled(checked);
SettingsData.setNightModeEnabled(checked);
if (checked)
nightModeEnableProcess.running = true;
else
@@ -74,9 +74,9 @@ ScrollView {
width: parent.width
text: "Light Mode"
description: "Use light theme instead of dark theme"
checked: Prefs.isLightMode
checked: SessionData.isLightMode
onToggled: (checked) => {
Prefs.setLightMode(checked);
SessionData.setLightMode(checked);
Theme.isLightMode = checked;
PortalService.setLightMode(checked);
}
@@ -86,17 +86,17 @@ ScrollView {
width: parent.width
text: "Icon Theme"
description: "Select icon theme"
currentValue: Prefs.iconTheme
currentValue: SettingsData.iconTheme
enableFuzzySearch: true
popupWidthOffset: 100
maxPopupHeight: 400
options: {
Prefs.detectAvailableIconThemes();
return Prefs.availableIconThemes;
SettingsData.detectAvailableIconThemes();
return SettingsData.availableIconThemes;
}
onValueChanged: (value) => {
Prefs.setIconTheme(value);
if (value !== "System Default" && !Prefs.qt5ctAvailable && !Prefs.qt6ctAvailable)
SettingsData.setIconTheme(value);
if (value !== "System Default" && !SettingsData.qt5ctAvailable && !SettingsData.qt6ctAvailable)
ToastService.showWarning("qt5ct or qt6ct not found - Qt app themes may not update without these tools");
}
@@ -107,16 +107,16 @@ ScrollView {
text: "Font Family"
description: "Select system font family"
currentValue: {
if (Prefs.fontFamily === Prefs.defaultFontFamily)
return "Default (" + Prefs.defaultFontFamily + ")";
if (SettingsData.fontFamily === SettingsData.defaultFontFamily)
return "Default (" + SettingsData.defaultFontFamily + ")";
else
return Prefs.fontFamily || "Default (" + Prefs.defaultFontFamily + ")";
return SettingsData.fontFamily || "Default (" + SettingsData.defaultFontFamily + ")";
}
enableFuzzySearch: true
popupWidthOffset: 100
maxPopupHeight: 400
options: {
var fonts = ["Default (" + Prefs.defaultFontFamily + ")"];
var fonts = ["Default (" + SettingsData.defaultFontFamily + ")"];
var availableFonts = Qt.fontFamilies();
var rootFamilies = [];
var seenFamilies = new Set();
@@ -125,7 +125,7 @@ ScrollView {
if (fontName.startsWith("."))
continue;
if (fontName === Prefs.defaultFontFamily)
if (fontName === SettingsData.defaultFontFamily)
continue;
var rootName = fontName.replace(/ (Thin|Extra Light|Light|Regular|Medium|Semi Bold|Demi Bold|Bold|Extra Bold|Black|Heavy)$/i, "").replace(/ (Italic|Oblique|Condensed|Extended|Narrow|Wide)$/i, "").replace(/ (UI|Display|Text|Mono|Sans|Serif)$/i, function(match, suffix) {
@@ -140,9 +140,9 @@ ScrollView {
}
onValueChanged: (value) => {
if (value.startsWith("Default ("))
Prefs.setFontFamily(Prefs.defaultFontFamily);
SettingsData.setFontFamily(SettingsData.defaultFontFamily);
else
Prefs.setFontFamily(value);
SettingsData.setFontFamily(value);
}
}
@@ -151,7 +151,7 @@ ScrollView {
text: "Font Weight"
description: "Select font weight"
currentValue: {
switch (Prefs.fontWeight) {
switch (SettingsData.fontWeight) {
case Font.Thin:
return "Thin";
case Font.ExtraLight:
@@ -209,7 +209,7 @@ ScrollView {
weight = Font.Normal;
break;
}
Prefs.setFontWeight(weight);
SettingsData.setFontWeight(weight);
}
}
@@ -218,10 +218,10 @@ ScrollView {
text: "Monospace Font"
description: "Select monospace font for process list and technical displays"
currentValue: {
if (Prefs.monoFontFamily === Prefs.defaultMonoFontFamily)
if (SettingsData.monoFontFamily === SettingsData.defaultMonoFontFamily)
return "Default";
return Prefs.monoFontFamily || "Default";
return SettingsData.monoFontFamily || "Default";
}
enableFuzzySearch: true
popupWidthOffset: 100
@@ -236,7 +236,7 @@ ScrollView {
if (fontName.startsWith("."))
continue;
if (fontName === Prefs.defaultMonoFontFamily)
if (fontName === SettingsData.defaultMonoFontFamily)
continue;
var lowerName = fontName.toLowerCase();
@@ -252,9 +252,9 @@ ScrollView {
}
onValueChanged: (value) => {
if (value === "Default")
Prefs.setMonoFontFamily(Prefs.defaultMonoFontFamily);
SettingsData.setMonoFontFamily(SettingsData.defaultMonoFontFamily);
else
Prefs.setMonoFontFamily(value);
SettingsData.setMonoFontFamily(value);
}
}
@@ -312,13 +312,13 @@ ScrollView {
DankSlider {
width: parent.width
height: 24
value: Math.round(Prefs.topBarTransparency * 100)
value: Math.round(SettingsData.topBarTransparency * 100)
minimum: 0
maximum: 100
unit: ""
showValue: true
onSliderValueChanged: (newValue) => {
Prefs.setTopBarTransparency(newValue / 100);
SettingsData.setTopBarTransparency(newValue / 100);
}
}
@@ -338,13 +338,13 @@ ScrollView {
DankSlider {
width: parent.width
height: 24
value: Math.round(Prefs.topBarWidgetTransparency * 100)
value: Math.round(SettingsData.topBarWidgetTransparency * 100)
minimum: 0
maximum: 100
unit: ""
showValue: true
onSliderValueChanged: (newValue) => {
Prefs.setTopBarWidgetTransparency(newValue / 100);
SettingsData.setTopBarWidgetTransparency(newValue / 100);
}
}
@@ -364,13 +364,13 @@ ScrollView {
DankSlider {
width: parent.width
height: 24
value: Math.round(Prefs.popupTransparency * 100)
value: Math.round(SettingsData.popupTransparency * 100)
minimum: 0
maximum: 100
unit: ""
showValue: true
onSliderValueChanged: (newValue) => {
Prefs.setPopupTransparency(newValue / 100);
SettingsData.setPopupTransparency(newValue / 100);
}
}
@@ -790,9 +790,9 @@ ScrollView {
text: "Theme GTK Applications"
description: Colors.gtkThemingEnabled ? "File managers, text editors, and system dialogs will match your theme" : "GTK theming not available (install gsettings)"
enabled: Colors.gtkThemingEnabled
checked: Colors.gtkThemingEnabled && Prefs.gtkThemingEnabled
checked: Colors.gtkThemingEnabled && SettingsData.gtkThemingEnabled
onToggled: function(checked) {
Prefs.setGtkThemingEnabled(checked);
SettingsData.setGtkThemingEnabled(checked);
if (checked && Theme.isDynamicTheme)
Colors.generateGtkThemes();
@@ -804,9 +804,9 @@ ScrollView {
text: "Theme Qt Applications"
description: Colors.qtThemingEnabled ? "Qt applications will match your theme colors" : "Qt theming not available (install qt5ct or qt6ct)"
enabled: Colors.qtThemingEnabled
checked: Colors.qtThemingEnabled && Prefs.qtThemingEnabled
checked: Colors.qtThemingEnabled && SettingsData.qtThemingEnabled
onToggled: function(checked) {
Prefs.setQtThemingEnabled(checked);
SettingsData.setQtThemingEnabled(checked);
if (checked && Theme.isDynamicTheme)
Colors.generateQtThemes();
@@ -826,7 +826,7 @@ ScrollView {
running: false
onExited: (exitCode) => {
if (exitCode !== 0)
Prefs.setNightModeEnabled(true);
SettingsData.setNightModeEnabled(true);
}
}
@@ -838,7 +838,7 @@ ScrollView {
running: false
onExited: (exitCode) => {
if (exitCode !== 0)
Prefs.setNightModeEnabled(false);
SettingsData.setNightModeEnabled(false);
}
}

View File

@@ -37,16 +37,16 @@ ScrollView {
width: parent.width
text: "Use OS Logo"
description: "Display operating system logo instead of apps icon"
checked: Prefs.useOSLogo
checked: SettingsData.useOSLogo
onToggled: (checked) => {
return Prefs.setUseOSLogo(checked);
return SettingsData.setUseOSLogo(checked);
}
}
Row {
width: parent.width - Theme.spacingL
spacing: Theme.spacingL
visible: Prefs.useOSLogo
visible: SettingsData.useOSLogo
opacity: visible ? 1 : 0
anchors.left: parent.left
anchors.leftMargin: Theme.spacingL
@@ -66,7 +66,7 @@ ScrollView {
width: 100
height: 28
placeholderText: "#ffffff"
text: Prefs.osLogoColorOverride
text: SettingsData.osLogoColorOverride
maximumLength: 7
font.pixelSize: Theme.fontSizeSmall
topPadding: Theme.spacingXS
@@ -74,9 +74,9 @@ ScrollView {
onEditingFinished: {
var color = text.trim();
if (color === "" || /^#[0-9A-Fa-f]{6}$/.test(color))
Prefs.setOSLogoColorOverride(color);
SettingsData.setOSLogoColorOverride(color);
else
text = Prefs.osLogoColorOverride;
text = SettingsData.osLogoColorOverride;
}
}
@@ -98,11 +98,11 @@ ScrollView {
height: 20
minimum: 0
maximum: 100
value: Math.round(Prefs.osLogoBrightness * 100)
value: Math.round(SettingsData.osLogoBrightness * 100)
unit: "%"
showValue: true
onSliderValueChanged: (newValue) => {
Prefs.setOSLogoBrightness(newValue / 100);
SettingsData.setOSLogoBrightness(newValue / 100);
}
}
@@ -124,11 +124,11 @@ ScrollView {
height: 20
minimum: 0
maximum: 200
value: Math.round(Prefs.osLogoContrast * 100)
value: Math.round(SettingsData.osLogoContrast * 100)
unit: "%"
showValue: true
onSliderValueChanged: (newValue) => {
Prefs.setOSLogoContrast(newValue / 100);
SettingsData.setOSLogoContrast(newValue / 100);
}
}
@@ -187,9 +187,9 @@ ScrollView {
width: parent.width
text: "Show Dock"
description: "Display a dock at the bottom of the screen with pinned and running applications"
checked: Prefs.showDock
checked: SettingsData.showDock
onToggled: (checked) => {
Prefs.setShowDock(checked)
SettingsData.setShowDock(checked)
}
}
@@ -197,11 +197,11 @@ ScrollView {
width: parent.width
text: "Auto-hide Dock"
description: "Hide the dock when not in use and reveal it when hovering near the bottom of the screen"
checked: Prefs.dockAutoHide
visible: Prefs.showDock
checked: SettingsData.dockAutoHide
visible: SettingsData.showDock
opacity: visible ? 1 : 0
onToggled: (checked) => {
Prefs.setDockAutoHide(checked)
SettingsData.setDockAutoHide(checked)
}
Behavior on opacity {
@@ -215,7 +215,7 @@ ScrollView {
Column {
width: parent.width
spacing: Theme.spacingS
visible: Prefs.showDock
visible: SettingsData.showDock
opacity: visible ? 1 : 0
StyledText {
@@ -228,13 +228,13 @@ ScrollView {
DankSlider {
width: parent.width
height: 24
value: Math.round(Prefs.dockTransparency * 100)
value: Math.round(SettingsData.dockTransparency * 100)
minimum: 0
maximum: 100
unit: ""
showValue: true
onSliderValueChanged: (newValue) => {
Prefs.setDockTransparency(newValue / 100);
SettingsData.setDockTransparency(newValue / 100);
}
}
@@ -262,8 +262,8 @@ ScrollView {
property var rankedAppsModel: {
var apps = [];
for (var appId in Prefs.appUsageRanking) {
var appData = Prefs.appUsageRanking[appId];
for (var appId in AppUsageHistoryData.appUsageRanking) {
var appData = AppUsageHistoryData.appUsageRanking[appId];
apps.push({
"id": appId,
"name": appData.name,
@@ -320,9 +320,9 @@ ScrollView {
hoverColor: Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.12)
anchors.verticalCenter: parent.verticalCenter
onClicked: {
Prefs.appUsageRanking = {
AppUsageHistoryData.appUsageRanking = {
};
Prefs.saveSettings();
SettingsData.saveSettings();
}
}
@@ -438,10 +438,10 @@ ScrollView {
hoverColor: Qt.rgba(Theme.error.r, Theme.error.g, Theme.error.b, 0.12)
onClicked: {
var currentRanking = Object.assign({
}, Prefs.appUsageRanking);
}, AppUsageHistoryData.appUsageRanking);
delete currentRanking[modelData.id];
Prefs.appUsageRanking = currentRanking;
Prefs.saveSettings();
AppUsageHistoryData.appUsageRanking = currentRanking;
SettingsData.saveSettings();
}
}

View File

@@ -334,9 +334,9 @@ ScrollView {
CachingImage {
anchors.fill: parent
anchors.margins: 1
imagePath: Prefs.wallpaperPath || ""
imagePath: SessionData.wallpaperPath || ""
fillMode: Image.PreserveAspectCrop
visible: Prefs.wallpaperPath !== ""
visible: SessionData.wallpaperPath !== ""
maxCacheSize: 160
layer.enabled: true
@@ -365,7 +365,7 @@ ScrollView {
name: "image"
size: Theme.iconSizeLarge + 8
color: Theme.surfaceVariantText
visible: Prefs.wallpaperPath === ""
visible: SessionData.wallpaperPath === ""
}
}
@@ -376,7 +376,7 @@ ScrollView {
anchors.verticalCenter: parent.verticalCenter
StyledText {
text: Prefs.wallpaperPath ? Prefs.wallpaperPath.split('/').pop() : "No wallpaper selected"
text: SessionData.wallpaperPath ? SessionData.wallpaperPath.split('/').pop() : "No wallpaper selected"
font.pixelSize: Theme.fontSizeLarge
color: Theme.surfaceText
elide: Text.ElideMiddle
@@ -384,12 +384,12 @@ ScrollView {
}
StyledText {
text: Prefs.wallpaperPath ? Prefs.wallpaperPath : ""
text: SessionData.wallpaperPath ? SessionData.wallpaperPath : ""
font.pixelSize: Theme.fontSizeSmall
color: Theme.surfaceVariantText
elide: Text.ElideMiddle
width: parent.width
visible: Prefs.wallpaperPath !== ""
visible: SessionData.wallpaperPath !== ""
}
Row {
@@ -437,7 +437,7 @@ ScrollView {
height: 32
radius: Theme.cornerRadius
color: Theme.surfaceVariant
opacity: Prefs.wallpaperPath !== "" ? 1 : 0.5
opacity: SessionData.wallpaperPath !== "" ? 1 : 0.5
Row {
anchors.centerIn: parent
@@ -461,10 +461,10 @@ ScrollView {
MouseArea {
anchors.fill: parent
enabled: Prefs.wallpaperPath !== ""
enabled: SessionData.wallpaperPath !== ""
cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor
onClicked: {
Prefs.setWallpaperPath("");
SessionData.setWallpaper("");
}
}
@@ -593,7 +593,7 @@ ScrollView {
browserType: "wallpaper"
fileExtensions: ["*.jpg", "*.jpeg", "*.png", "*.bmp", "*.gif", "*.webp"]
onFileSelected: (path) => {
Prefs.setWallpaperPath(path);
SessionData.setWallpaper(path);
visible = false;
}
onDialogClosed: {}

View File

@@ -55,9 +55,9 @@ ScrollView {
width: parent.width
text: "24-Hour Format"
description: "Use 24-hour time format instead of 12-hour AM/PM"
checked: Prefs.use24HourClock
checked: SettingsData.use24HourClock
onToggled: (checked) => {
return Prefs.setClockFormat(checked);
return SettingsData.setClockFormat(checked);
}
}
@@ -105,9 +105,9 @@ ScrollView {
width: parent.width
text: "Enable Weather"
description: "Show weather information in top bar and centcom center"
checked: Prefs.weatherEnabled
checked: SettingsData.weatherEnabled
onToggled: (checked) => {
return Prefs.setWeatherEnabled(checked);
return SettingsData.setWeatherEnabled(checked);
}
}
@@ -115,10 +115,10 @@ ScrollView {
width: parent.width
text: "Fahrenheit"
description: "Use Fahrenheit instead of Celsius for temperature"
checked: Prefs.useFahrenheit
enabled: Prefs.weatherEnabled
checked: SettingsData.useFahrenheit
enabled: SettingsData.weatherEnabled
onToggled: (checked) => {
return Prefs.setTemperatureUnit(checked);
return SettingsData.setTemperatureUnit(checked);
}
}
@@ -126,17 +126,17 @@ ScrollView {
width: parent.width
text: "Auto Location"
description: "Allow wttr.in to determine location based on IP address"
checked: Prefs.useAutoLocation
enabled: Prefs.weatherEnabled
checked: SettingsData.useAutoLocation
enabled: SettingsData.weatherEnabled
onToggled: (checked) => {
return Prefs.setAutoLocation(checked);
return SettingsData.setAutoLocation(checked);
}
}
Column {
width: parent.width
spacing: Theme.spacingXS
visible: !Prefs.useAutoLocation && Prefs.weatherEnabled
visible: !SettingsData.useAutoLocation && SettingsData.weatherEnabled
StyledText {
text: "Location"
@@ -147,10 +147,10 @@ ScrollView {
DankLocationSearch {
width: parent.width
currentLocation: Prefs.weatherLocation
currentLocation: SettingsData.weatherLocation
placeholderText: "New York, NY"
onLocationSelected: (displayName, coordinates) => {
Prefs.setWeatherLocation(displayName, coordinates);
SettingsData.setWeatherLocation(displayName, coordinates);
}
}

View File

@@ -141,54 +141,54 @@ ScrollView {
var widgets = [];
if (targetSection === "left") {
widgets = Prefs.topBarLeftWidgets.slice();
widgets = SettingsData.topBarLeftWidgets.slice();
widgets.push(widgetObj);
Prefs.setTopBarLeftWidgets(widgets);
SettingsData.setTopBarLeftWidgets(widgets);
} else if (targetSection === "center") {
widgets = Prefs.topBarCenterWidgets.slice();
widgets = SettingsData.topBarCenterWidgets.slice();
widgets.push(widgetObj);
Prefs.setTopBarCenterWidgets(widgets);
SettingsData.setTopBarCenterWidgets(widgets);
} else if (targetSection === "right") {
widgets = Prefs.topBarRightWidgets.slice();
widgets = SettingsData.topBarRightWidgets.slice();
widgets.push(widgetObj);
Prefs.setTopBarRightWidgets(widgets);
SettingsData.setTopBarRightWidgets(widgets);
}
}
function removeWidgetFromSection(sectionId, itemId) {
var widgets = [];
if (sectionId === "left") {
widgets = Prefs.topBarLeftWidgets.slice();
widgets = SettingsData.topBarLeftWidgets.slice();
widgets = widgets.filter((widget) => {
var widgetId = typeof widget === "string" ? widget : widget.id;
return widgetId !== itemId;
});
Prefs.setTopBarLeftWidgets(widgets);
SettingsData.setTopBarLeftWidgets(widgets);
} else if (sectionId === "center") {
widgets = Prefs.topBarCenterWidgets.slice();
widgets = SettingsData.topBarCenterWidgets.slice();
widgets = widgets.filter((widget) => {
var widgetId = typeof widget === "string" ? widget : widget.id;
return widgetId !== itemId;
});
Prefs.setTopBarCenterWidgets(widgets);
SettingsData.setTopBarCenterWidgets(widgets);
} else if (sectionId === "right") {
widgets = Prefs.topBarRightWidgets.slice();
widgets = SettingsData.topBarRightWidgets.slice();
widgets = widgets.filter((widget) => {
var widgetId = typeof widget === "string" ? widget : widget.id;
return widgetId !== itemId;
});
Prefs.setTopBarRightWidgets(widgets);
SettingsData.setTopBarRightWidgets(widgets);
}
}
function handleItemEnabledChanged(sectionId, itemId, enabled) {
var widgets = [];
if (sectionId === "left")
widgets = Prefs.topBarLeftWidgets.slice();
widgets = SettingsData.topBarLeftWidgets.slice();
else if (sectionId === "center")
widgets = Prefs.topBarCenterWidgets.slice();
widgets = SettingsData.topBarCenterWidgets.slice();
else if (sectionId === "right")
widgets = Prefs.topBarRightWidgets.slice();
widgets = SettingsData.topBarRightWidgets.slice();
for (var i = 0; i < widgets.length; i++) {
var widget = widgets[i];
var widgetId = typeof widget === "string" ? widget : widget.id;
@@ -205,30 +205,30 @@ ScrollView {
}
}
if (sectionId === "left")
Prefs.setTopBarLeftWidgets(widgets);
SettingsData.setTopBarLeftWidgets(widgets);
else if (sectionId === "center")
Prefs.setTopBarCenterWidgets(widgets);
SettingsData.setTopBarCenterWidgets(widgets);
else if (sectionId === "right")
Prefs.setTopBarRightWidgets(widgets);
SettingsData.setTopBarRightWidgets(widgets);
}
function handleItemOrderChanged(sectionId, newOrder) {
if (sectionId === "left")
Prefs.setTopBarLeftWidgets(newOrder);
SettingsData.setTopBarLeftWidgets(newOrder);
else if (sectionId === "center")
Prefs.setTopBarCenterWidgets(newOrder);
SettingsData.setTopBarCenterWidgets(newOrder);
else if (sectionId === "right")
Prefs.setTopBarRightWidgets(newOrder);
SettingsData.setTopBarRightWidgets(newOrder);
}
function handleSpacerSizeChanged(sectionId, itemId, newSize) {
var widgets = [];
if (sectionId === "left")
widgets = Prefs.topBarLeftWidgets.slice();
widgets = SettingsData.topBarLeftWidgets.slice();
else if (sectionId === "center")
widgets = Prefs.topBarCenterWidgets.slice();
widgets = SettingsData.topBarCenterWidgets.slice();
else if (sectionId === "right")
widgets = Prefs.topBarRightWidgets.slice();
widgets = SettingsData.topBarRightWidgets.slice();
for (var i = 0; i < widgets.length; i++) {
var widget = widgets[i];
var widgetId = typeof widget === "string" ? widget : widget.id;
@@ -246,22 +246,22 @@ ScrollView {
}
}
if (sectionId === "left")
Prefs.setTopBarLeftWidgets(widgets);
SettingsData.setTopBarLeftWidgets(widgets);
else if (sectionId === "center")
Prefs.setTopBarCenterWidgets(widgets);
SettingsData.setTopBarCenterWidgets(widgets);
else if (sectionId === "right")
Prefs.setTopBarRightWidgets(widgets);
SettingsData.setTopBarRightWidgets(widgets);
}
function getItemsForSection(sectionId) {
var widgets = [];
var widgetData = [];
if (sectionId === "left")
widgetData = Prefs.topBarLeftWidgets || [];
widgetData = SettingsData.topBarLeftWidgets || [];
else if (sectionId === "center")
widgetData = Prefs.topBarCenterWidgets || [];
widgetData = SettingsData.topBarCenterWidgets || [];
else if (sectionId === "right")
widgetData = Prefs.topBarRightWidgets || [];
widgetData = SettingsData.topBarRightWidgets || [];
widgetData.forEach((widget) => {
var widgetId = typeof widget === "string" ? widget : widget.id;
var widgetEnabled = typeof widget === "string" ? true : widget.enabled;
@@ -285,23 +285,23 @@ ScrollView {
contentHeight: column.implicitHeight + Theme.spacingXL
clip: true
Component.onCompleted: {
if (!Prefs.topBarLeftWidgets || Prefs.topBarLeftWidgets.length === 0)
Prefs.setTopBarLeftWidgets(defaultLeftWidgets);
if (!SettingsData.topBarLeftWidgets || SettingsData.topBarLeftWidgets.length === 0)
SettingsData.setTopBarLeftWidgets(defaultLeftWidgets);
if (!Prefs.topBarCenterWidgets || Prefs.topBarCenterWidgets.length === 0)
Prefs.setTopBarCenterWidgets(defaultCenterWidgets);
if (!SettingsData.topBarCenterWidgets || SettingsData.topBarCenterWidgets.length === 0)
SettingsData.setTopBarCenterWidgets(defaultCenterWidgets);
if (!Prefs.topBarRightWidgets || Prefs.topBarRightWidgets.length === 0)
Prefs.setTopBarRightWidgets(defaultRightWidgets);
if (!SettingsData.topBarRightWidgets || SettingsData.topBarRightWidgets.length === 0)
SettingsData.setTopBarRightWidgets(defaultRightWidgets);
["left", "center", "right"].forEach((sectionId) => {
var widgets = [];
if (sectionId === "left")
widgets = Prefs.topBarLeftWidgets.slice();
widgets = SettingsData.topBarLeftWidgets.slice();
else if (sectionId === "center")
widgets = Prefs.topBarCenterWidgets.slice();
widgets = SettingsData.topBarCenterWidgets.slice();
else if (sectionId === "right")
widgets = Prefs.topBarRightWidgets.slice();
widgets = SettingsData.topBarRightWidgets.slice();
var updated = false;
for (var i = 0; i < widgets.length; i++) {
var widget = widgets[i];
@@ -315,11 +315,11 @@ ScrollView {
}
if (updated) {
if (sectionId === "left")
Prefs.setTopBarLeftWidgets(widgets);
SettingsData.setTopBarLeftWidgets(widgets);
else if (sectionId === "center")
Prefs.setTopBarCenterWidgets(widgets);
SettingsData.setTopBarCenterWidgets(widgets);
else if (sectionId === "right")
Prefs.setTopBarRightWidgets(widgets);
SettingsData.setTopBarRightWidgets(widgets);
}
});
}
@@ -393,9 +393,9 @@ ScrollView {
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
Prefs.setTopBarLeftWidgets(defaultLeftWidgets);
Prefs.setTopBarCenterWidgets(defaultCenterWidgets);
Prefs.setTopBarRightWidgets(defaultRightWidgets);
SettingsData.setTopBarLeftWidgets(defaultLeftWidgets);
SettingsData.setTopBarCenterWidgets(defaultCenterWidgets);
SettingsData.setTopBarRightWidgets(defaultRightWidgets);
}
}
@@ -473,9 +473,9 @@ ScrollView {
}
onCompactModeChanged: (widgetId, enabled) => {
if (widgetId === "clock") {
Prefs.setClockCompactMode(enabled);
SettingsData.setClockCompactMode(enabled);
} else if (widgetId === "music") {
Prefs.setMediaCompactMode(enabled);
SettingsData.setMediaCompactMode(enabled);
}
}
}
@@ -506,9 +506,9 @@ ScrollView {
}
onCompactModeChanged: (widgetId, enabled) => {
if (widgetId === "clock") {
Prefs.setClockCompactMode(enabled);
SettingsData.setClockCompactMode(enabled);
} else if (widgetId === "music") {
Prefs.setMediaCompactMode(enabled);
SettingsData.setMediaCompactMode(enabled);
}
}
}
@@ -539,9 +539,9 @@ ScrollView {
}
onCompactModeChanged: (widgetId, enabled) => {
if (widgetId === "clock") {
Prefs.setClockCompactMode(enabled);
SettingsData.setClockCompactMode(enabled);
} else if (widgetId === "music") {
Prefs.setMediaCompactMode(enabled);
SettingsData.setMediaCompactMode(enabled);
}
}
}
@@ -588,9 +588,9 @@ ScrollView {
width: parent.width
text: "Workspace Index Numbers"
description: "Show workspace index numbers in the top bar workspace switcher"
checked: Prefs.showWorkspaceIndex
checked: SettingsData.showWorkspaceIndex
onToggled: (checked) => {
return Prefs.setShowWorkspaceIndex(checked);
return SettingsData.setShowWorkspaceIndex(checked);
}
}
@@ -598,9 +598,9 @@ ScrollView {
width: parent.width
text: "Workspace Padding"
description: "Always show a minimum of 3 workspaces, even if fewer are available"
checked: Prefs.showWorkspacePadding
checked: SettingsData.showWorkspacePadding
onToggled: (checked) => {
return Prefs.setShowWorkspacePadding(checked);
return SettingsData.setShowWorkspacePadding(checked);
}
}