mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-29 07:52:50 -05:00
@@ -402,6 +402,24 @@ Item {
|
|||||||
setWidgetsForSection(sectionId, widgets);
|
setWidgetsForSection(sectionId, widgets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cloneWidgetData(widget) {
|
||||||
|
if (typeof widget === "string")
|
||||||
|
return {
|
||||||
|
"id": widget,
|
||||||
|
"enabled": true
|
||||||
|
};
|
||||||
|
var result = {
|
||||||
|
"id": widget.id,
|
||||||
|
"enabled": widget.enabled
|
||||||
|
};
|
||||||
|
var keys = ["size", "selectedGpuIndex", "pciId", "mountPath", "minimumWidth", "showSwap", "mediaSize", "clockCompactMode", "focusedWindowCompactMode", "runningAppsCompactMode", "keyboardLayoutNameCompactMode", "showNetworkIcon", "showBluetoothIcon", "showAudioIcon", "showAudioPercent", "showVpnIcon", "showBrightnessIcon", "showBrightnessPercent", "showMicIcon", "showMicPercent", "showBatteryIcon", "showPrinterIcon", "showScreenSharingIcon"];
|
||||||
|
for (var i = 0; i < keys.length; i++) {
|
||||||
|
if (widget[keys[i]] !== undefined)
|
||||||
|
result[keys[i]] = widget[keys[i]];
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
function handleItemEnabledChanged(sectionId, itemId, enabled) {
|
function handleItemEnabledChanged(sectionId, itemId, enabled) {
|
||||||
var widgets = getWidgetsForSection(sectionId).slice();
|
var widgets = getWidgetsForSection(sectionId).slice();
|
||||||
for (var i = 0; i < widgets.length; i++) {
|
for (var i = 0; i < widgets.length; i++) {
|
||||||
@@ -409,43 +427,8 @@ Item {
|
|||||||
var widgetId = typeof widget === "string" ? widget : widget.id;
|
var widgetId = typeof widget === "string" ? widget : widget.id;
|
||||||
if (widgetId !== itemId)
|
if (widgetId !== itemId)
|
||||||
continue;
|
continue;
|
||||||
|
var newWidget = cloneWidgetData(widget);
|
||||||
if (typeof widget === "string") {
|
newWidget.enabled = enabled;
|
||||||
widgets[i] = {
|
|
||||||
"id": widget,
|
|
||||||
"enabled": enabled
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
var newWidget = {
|
|
||||||
"id": widget.id,
|
|
||||||
"enabled": enabled
|
|
||||||
};
|
|
||||||
if (widget.size !== undefined)
|
|
||||||
newWidget.size = widget.size;
|
|
||||||
if (widget.selectedGpuIndex !== undefined)
|
|
||||||
newWidget.selectedGpuIndex = widget.selectedGpuIndex;
|
|
||||||
else if (widget.id === "gpuTemp")
|
|
||||||
newWidget.selectedGpuIndex = 0;
|
|
||||||
if (widget.pciId !== undefined)
|
|
||||||
newWidget.pciId = widget.pciId;
|
|
||||||
else if (widget.id === "gpuTemp")
|
|
||||||
newWidget.pciId = "";
|
|
||||||
if (widget.id === "controlCenterButton") {
|
|
||||||
newWidget.showNetworkIcon = widget.showNetworkIcon ?? SettingsData.controlCenterShowNetworkIcon;
|
|
||||||
newWidget.showBluetoothIcon = widget.showBluetoothIcon ?? SettingsData.controlCenterShowBluetoothIcon;
|
|
||||||
newWidget.showAudioIcon = widget.showAudioIcon ?? SettingsData.controlCenterShowAudioIcon;
|
|
||||||
newWidget.showAudioPercent = widget.showAudioPercent ?? SettingsData.controlCenterShowAudioPercent;
|
|
||||||
newWidget.showVpnIcon = widget.showVpnIcon ?? SettingsData.controlCenterShowVpnIcon;
|
|
||||||
newWidget.showBrightnessIcon = widget.showBrightnessIcon ?? SettingsData.controlCenterShowBrightnessIcon;
|
|
||||||
newWidget.showBrightnessPercent = widget.showBrightnessPercent ?? SettingsData.controlCenterShowBrightnessPercent;
|
|
||||||
newWidget.showMicIcon = widget.showMicIcon ?? SettingsData.controlCenterShowMicIcon;
|
|
||||||
newWidget.showMicPercent = widget.showMicPercent ?? SettingsData.controlCenterShowMicPercent;
|
|
||||||
newWidget.showBatteryIcon = widget.showBatteryIcon ?? SettingsData.controlCenterShowBatteryIcon;
|
|
||||||
newWidget.showPrinterIcon = widget.showPrinterIcon ?? SettingsData.controlCenterShowPrinterIcon;
|
|
||||||
newWidget.showScreenSharingIcon = widget.showScreenSharingIcon ?? SettingsData.controlCenterShowScreenSharingIcon;
|
|
||||||
}
|
|
||||||
widgets[i] = newWidget;
|
widgets[i] = newWidget;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -458,130 +441,36 @@ Item {
|
|||||||
|
|
||||||
function handleSpacerSizeChanged(sectionId, widgetIndex, newSize) {
|
function handleSpacerSizeChanged(sectionId, widgetIndex, newSize) {
|
||||||
var widgets = getWidgetsForSection(sectionId).slice();
|
var widgets = getWidgetsForSection(sectionId).slice();
|
||||||
if (widgetIndex < 0 || widgetIndex >= widgets.length) {
|
if (widgetIndex < 0 || widgetIndex >= widgets.length)
|
||||||
setWidgetsForSection(sectionId, widgets);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
var widget = widgets[widgetIndex];
|
var widget = widgets[widgetIndex];
|
||||||
var widgetId = typeof widget === "string" ? widget : widget.id;
|
var widgetId = typeof widget === "string" ? widget : widget.id;
|
||||||
if (widgetId !== "spacer") {
|
if (widgetId !== "spacer")
|
||||||
setWidgetsForSection(sectionId, widgets);
|
|
||||||
return;
|
return;
|
||||||
}
|
var newWidget = cloneWidgetData(widget);
|
||||||
|
newWidget.size = newSize;
|
||||||
if (typeof widget === "string") {
|
|
||||||
widgets[widgetIndex] = {
|
|
||||||
"id": widget,
|
|
||||||
"enabled": true,
|
|
||||||
"size": newSize
|
|
||||||
};
|
|
||||||
setWidgetsForSection(sectionId, widgets);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var newWidget = {
|
|
||||||
"id": widget.id,
|
|
||||||
"enabled": widget.enabled,
|
|
||||||
"size": newSize
|
|
||||||
};
|
|
||||||
if (widget.selectedGpuIndex !== undefined)
|
|
||||||
newWidget.selectedGpuIndex = widget.selectedGpuIndex;
|
|
||||||
if (widget.pciId !== undefined)
|
|
||||||
newWidget.pciId = widget.pciId;
|
|
||||||
if (widget.id === "controlCenterButton") {
|
|
||||||
newWidget.showNetworkIcon = widget.showNetworkIcon ?? SettingsData.controlCenterShowNetworkIcon;
|
|
||||||
newWidget.showBluetoothIcon = widget.showBluetoothIcon ?? SettingsData.controlCenterShowBluetoothIcon;
|
|
||||||
newWidget.showAudioIcon = widget.showAudioIcon ?? SettingsData.controlCenterShowAudioIcon;
|
|
||||||
newWidget.showAudioPercent = widget.showAudioPercent ?? SettingsData.controlCenterShowAudioPercent;
|
|
||||||
newWidget.showVpnIcon = widget.showVpnIcon ?? SettingsData.controlCenterShowVpnIcon;
|
|
||||||
newWidget.showBrightnessIcon = widget.showBrightnessIcon ?? SettingsData.controlCenterShowBrightnessIcon;
|
|
||||||
newWidget.showBrightnessPercent = widget.showBrightnessPercent ?? SettingsData.controlCenterShowBrightnessPercent;
|
|
||||||
newWidget.showMicIcon = widget.showMicIcon ?? SettingsData.controlCenterShowMicIcon;
|
|
||||||
newWidget.showMicPercent = widget.showMicPercent ?? SettingsData.controlCenterShowMicPercent;
|
|
||||||
newWidget.showBatteryIcon = widget.showBatteryIcon ?? SettingsData.controlCenterShowBatteryIcon;
|
|
||||||
newWidget.showPrinterIcon = widget.showPrinterIcon ?? SettingsData.controlCenterShowPrinterIcon;
|
|
||||||
newWidget.showScreenSharingIcon = widget.showScreenSharingIcon ?? SettingsData.controlCenterShowScreenSharingIcon;
|
|
||||||
}
|
|
||||||
widgets[widgetIndex] = newWidget;
|
widgets[widgetIndex] = newWidget;
|
||||||
setWidgetsForSection(sectionId, widgets);
|
setWidgetsForSection(sectionId, widgets);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleGpuSelectionChanged(sectionId, widgetIndex, selectedGpuIndex) {
|
function handleGpuSelectionChanged(sectionId, widgetIndex, selectedGpuIndex) {
|
||||||
var widgets = getWidgetsForSection(sectionId).slice();
|
var widgets = getWidgetsForSection(sectionId).slice();
|
||||||
if (widgetIndex < 0 || widgetIndex >= widgets.length) {
|
if (widgetIndex < 0 || widgetIndex >= widgets.length)
|
||||||
setWidgetsForSection(sectionId, widgets);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
var pciId = DgopService.availableGpus && DgopService.availableGpus.length > selectedGpuIndex ? DgopService.availableGpus[selectedGpuIndex].pciId : "";
|
var pciId = DgopService.availableGpus && DgopService.availableGpus.length > selectedGpuIndex ? DgopService.availableGpus[selectedGpuIndex].pciId : "";
|
||||||
var widget = widgets[widgetIndex];
|
var newWidget = cloneWidgetData(widgets[widgetIndex]);
|
||||||
if (typeof widget === "string") {
|
newWidget.selectedGpuIndex = selectedGpuIndex;
|
||||||
widgets[widgetIndex] = {
|
newWidget.pciId = pciId;
|
||||||
"id": widget,
|
|
||||||
"enabled": true,
|
|
||||||
"selectedGpuIndex": selectedGpuIndex,
|
|
||||||
"pciId": pciId
|
|
||||||
};
|
|
||||||
setWidgetsForSection(sectionId, widgets);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var newWidget = {
|
|
||||||
"id": widget.id,
|
|
||||||
"enabled": widget.enabled,
|
|
||||||
"selectedGpuIndex": selectedGpuIndex,
|
|
||||||
"pciId": pciId
|
|
||||||
};
|
|
||||||
if (widget.size !== undefined)
|
|
||||||
newWidget.size = widget.size;
|
|
||||||
widgets[widgetIndex] = newWidget;
|
widgets[widgetIndex] = newWidget;
|
||||||
setWidgetsForSection(sectionId, widgets);
|
setWidgetsForSection(sectionId, widgets);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleDiskMountSelectionChanged(sectionId, widgetIndex, mountPath) {
|
function handleDiskMountSelectionChanged(sectionId, widgetIndex, mountPath) {
|
||||||
var widgets = getWidgetsForSection(sectionId).slice();
|
var widgets = getWidgetsForSection(sectionId).slice();
|
||||||
if (widgetIndex < 0 || widgetIndex >= widgets.length) {
|
if (widgetIndex < 0 || widgetIndex >= widgets.length)
|
||||||
setWidgetsForSection(sectionId, widgets);
|
|
||||||
return;
|
return;
|
||||||
}
|
var newWidget = cloneWidgetData(widgets[widgetIndex]);
|
||||||
|
newWidget.mountPath = mountPath;
|
||||||
var widget = widgets[widgetIndex];
|
|
||||||
if (typeof widget === "string") {
|
|
||||||
widgets[widgetIndex] = {
|
|
||||||
"id": widget,
|
|
||||||
"enabled": true,
|
|
||||||
"mountPath": mountPath
|
|
||||||
};
|
|
||||||
setWidgetsForSection(sectionId, widgets);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var newWidget = {
|
|
||||||
"id": widget.id,
|
|
||||||
"enabled": widget.enabled,
|
|
||||||
"mountPath": mountPath
|
|
||||||
};
|
|
||||||
if (widget.size !== undefined)
|
|
||||||
newWidget.size = widget.size;
|
|
||||||
if (widget.selectedGpuIndex !== undefined)
|
|
||||||
newWidget.selectedGpuIndex = widget.selectedGpuIndex;
|
|
||||||
if (widget.pciId !== undefined)
|
|
||||||
newWidget.pciId = widget.pciId;
|
|
||||||
if (widget.id === "controlCenterButton") {
|
|
||||||
newWidget.showNetworkIcon = widget.showNetworkIcon ?? SettingsData.controlCenterShowNetworkIcon;
|
|
||||||
newWidget.showBluetoothIcon = widget.showBluetoothIcon ?? SettingsData.controlCenterShowBluetoothIcon;
|
|
||||||
newWidget.showAudioIcon = widget.showAudioIcon ?? SettingsData.controlCenterShowAudioIcon;
|
|
||||||
newWidget.showAudioPercent = widget.showAudioPercent ?? SettingsData.controlCenterShowAudioPercent;
|
|
||||||
newWidget.showVpnIcon = widget.showVpnIcon ?? SettingsData.controlCenterShowVpnIcon;
|
|
||||||
newWidget.showBrightnessIcon = widget.showBrightnessIcon ?? SettingsData.controlCenterShowBrightnessIcon;
|
|
||||||
newWidget.showBrightnessPercent = widget.showBrightnessPercent ?? SettingsData.controlCenterShowBrightnessPercent;
|
|
||||||
newWidget.showMicIcon = widget.showMicIcon ?? SettingsData.controlCenterShowMicIcon;
|
|
||||||
newWidget.showMicPercent = widget.showMicPercent ?? SettingsData.controlCenterShowMicPercent;
|
|
||||||
newWidget.showBatteryIcon = widget.showBatteryIcon ?? SettingsData.controlCenterShowBatteryIcon;
|
|
||||||
newWidget.showPrinterIcon = widget.showPrinterIcon ?? SettingsData.controlCenterShowPrinterIcon;
|
|
||||||
newWidget.showScreenSharingIcon = widget.showScreenSharingIcon ?? SettingsData.controlCenterShowScreenSharingIcon;
|
|
||||||
}
|
|
||||||
widgets[widgetIndex] = newWidget;
|
widgets[widgetIndex] = newWidget;
|
||||||
setWidgetsForSection(sectionId, widgets);
|
setWidgetsForSection(sectionId, widgets);
|
||||||
}
|
}
|
||||||
@@ -590,33 +479,8 @@ Item {
|
|||||||
var widgets = getWidgetsForSection(sectionId).slice();
|
var widgets = getWidgetsForSection(sectionId).slice();
|
||||||
if (widgetIndex < 0 || widgetIndex >= widgets.length)
|
if (widgetIndex < 0 || widgetIndex >= widgets.length)
|
||||||
return;
|
return;
|
||||||
|
var newWidget = cloneWidgetData(widgets[widgetIndex]);
|
||||||
var widget = widgets[widgetIndex];
|
|
||||||
if (typeof widget === "string") {
|
|
||||||
widget = {
|
|
||||||
"id": widget,
|
|
||||||
"enabled": true
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
var newWidget = {
|
|
||||||
"id": widget.id,
|
|
||||||
"enabled": widget.enabled !== undefined ? widget.enabled : true,
|
|
||||||
"showNetworkIcon": widget.showNetworkIcon ?? SettingsData.controlCenterShowNetworkIcon,
|
|
||||||
"showBluetoothIcon": widget.showBluetoothIcon ?? SettingsData.controlCenterShowBluetoothIcon,
|
|
||||||
"showAudioIcon": widget.showAudioIcon ?? SettingsData.controlCenterShowAudioIcon,
|
|
||||||
"showAudioPercent": widget.showAudioPercent ?? SettingsData.controlCenterShowAudioPercent,
|
|
||||||
"showVpnIcon": widget.showVpnIcon ?? SettingsData.controlCenterShowVpnIcon,
|
|
||||||
"showBrightnessIcon": widget.showBrightnessIcon ?? SettingsData.controlCenterShowBrightnessIcon,
|
|
||||||
"showBrightnessPercent": widget.showBrightnessPercent ?? SettingsData.controlCenterShowBrightnessPercent,
|
|
||||||
"showMicIcon": widget.showMicIcon ?? SettingsData.controlCenterShowMicIcon,
|
|
||||||
"showMicPercent": widget.showMicPercent ?? SettingsData.controlCenterShowMicPercent,
|
|
||||||
"showBatteryIcon": widget.showBatteryIcon ?? SettingsData.controlCenterShowBatteryIcon,
|
|
||||||
"showPrinterIcon": widget.showPrinterIcon ?? SettingsData.controlCenterShowPrinterIcon,
|
|
||||||
"showScreenSharingIcon": widget.showScreenSharingIcon ?? SettingsData.controlCenterShowScreenSharingIcon
|
|
||||||
};
|
|
||||||
newWidget[settingName] = value;
|
newWidget[settingName] = value;
|
||||||
|
|
||||||
widgets[widgetIndex] = newWidget;
|
widgets[widgetIndex] = newWidget;
|
||||||
setWidgetsForSection(sectionId, widgets);
|
setWidgetsForSection(sectionId, widgets);
|
||||||
}
|
}
|
||||||
@@ -641,47 +505,8 @@ Item {
|
|||||||
setWidgetsForSection(sectionId, widgets);
|
setWidgetsForSection(sectionId, widgets);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var newWidget = cloneWidgetData(widgets[widgetIndex]);
|
||||||
var widget = widgets[widgetIndex];
|
newWidget.minimumWidth = enabled;
|
||||||
if (typeof widget === "string") {
|
|
||||||
widgets[widgetIndex] = {
|
|
||||||
"id": widget,
|
|
||||||
"enabled": true,
|
|
||||||
"minimumWidth": enabled
|
|
||||||
};
|
|
||||||
setWidgetsForSection(sectionId, widgets);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var newWidget = {
|
|
||||||
"id": widget.id,
|
|
||||||
"enabled": widget.enabled,
|
|
||||||
"minimumWidth": enabled
|
|
||||||
};
|
|
||||||
if (widget.size !== undefined)
|
|
||||||
newWidget.size = widget.size;
|
|
||||||
if (widget.selectedGpuIndex !== undefined)
|
|
||||||
newWidget.selectedGpuIndex = widget.selectedGpuIndex;
|
|
||||||
if (widget.pciId !== undefined)
|
|
||||||
newWidget.pciId = widget.pciId;
|
|
||||||
if (widget.mountPath !== undefined)
|
|
||||||
newWidget.mountPath = widget.mountPath;
|
|
||||||
if (widget.showSwap !== undefined)
|
|
||||||
newWidget.showSwap = widget.showSwap;
|
|
||||||
if (widget.id === "controlCenterButton") {
|
|
||||||
newWidget.showNetworkIcon = widget.showNetworkIcon ?? SettingsData.controlCenterShowNetworkIcon;
|
|
||||||
newWidget.showBluetoothIcon = widget.showBluetoothIcon ?? SettingsData.controlCenterShowBluetoothIcon;
|
|
||||||
newWidget.showAudioIcon = widget.showAudioIcon ?? SettingsData.controlCenterShowAudioIcon;
|
|
||||||
newWidget.showAudioPercent = widget.showAudioPercent ?? SettingsData.controlCenterShowAudioPercent;
|
|
||||||
newWidget.showVpnIcon = widget.showVpnIcon ?? SettingsData.controlCenterShowVpnIcon;
|
|
||||||
newWidget.showBrightnessIcon = widget.showBrightnessIcon ?? SettingsData.controlCenterShowBrightnessIcon;
|
|
||||||
newWidget.showBrightnessPercent = widget.showBrightnessPercent ?? SettingsData.controlCenterShowBrightnessPercent;
|
|
||||||
newWidget.showMicIcon = widget.showMicIcon ?? SettingsData.controlCenterShowMicIcon;
|
|
||||||
newWidget.showMicPercent = widget.showMicPercent ?? SettingsData.controlCenterShowMicPercent;
|
|
||||||
newWidget.showBatteryIcon = widget.showBatteryIcon ?? SettingsData.controlCenterShowBatteryIcon;
|
|
||||||
newWidget.showPrinterIcon = widget.showPrinterIcon ?? SettingsData.controlCenterShowPrinterIcon;
|
|
||||||
newWidget.showScreenSharingIcon = widget.showScreenSharingIcon ?? SettingsData.controlCenterShowScreenSharingIcon;
|
|
||||||
}
|
|
||||||
widgets[widgetIndex] = newWidget;
|
widgets[widgetIndex] = newWidget;
|
||||||
setWidgetsForSection(sectionId, widgets);
|
setWidgetsForSection(sectionId, widgets);
|
||||||
}
|
}
|
||||||
@@ -692,143 +517,41 @@ Item {
|
|||||||
setWidgetsForSection(sectionId, widgets);
|
setWidgetsForSection(sectionId, widgets);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var newWidget = cloneWidgetData(widgets[widgetIndex]);
|
||||||
var widget = widgets[widgetIndex];
|
newWidget.showSwap = enabled;
|
||||||
if (typeof widget === "string") {
|
|
||||||
widgets[widgetIndex] = {
|
|
||||||
"id": widget,
|
|
||||||
"enabled": true,
|
|
||||||
"showSwap": enabled
|
|
||||||
};
|
|
||||||
setWidgetsForSection(sectionId, widgets);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var newWidget = {
|
|
||||||
"id": widget.id,
|
|
||||||
"enabled": widget.enabled,
|
|
||||||
"showSwap": enabled
|
|
||||||
};
|
|
||||||
if (widget.size !== undefined)
|
|
||||||
newWidget.size = widget.size;
|
|
||||||
if (widget.selectedGpuIndex !== undefined)
|
|
||||||
newWidget.selectedGpuIndex = widget.selectedGpuIndex;
|
|
||||||
if (widget.pciId !== undefined)
|
|
||||||
newWidget.pciId = widget.pciId;
|
|
||||||
if (widget.mountPath !== undefined)
|
|
||||||
newWidget.mountPath = widget.mountPath;
|
|
||||||
if (widget.minimumWidth !== undefined)
|
|
||||||
newWidget.minimumWidth = widget.minimumWidth;
|
|
||||||
if (widget.mediaSize !== undefined)
|
|
||||||
newWidget.mediaSize = widget.mediaSize;
|
|
||||||
if (widget.clockCompactMode !== undefined)
|
|
||||||
newWidget.clockCompactMode = widget.clockCompactMode;
|
|
||||||
if (widget.focusedWindowCompactMode !== undefined)
|
|
||||||
newWidget.focusedWindowCompactMode = widget.focusedWindowCompactMode;
|
|
||||||
if (widget.runningAppsCompactMode !== undefined)
|
|
||||||
newWidget.runningAppsCompactMode = widget.runningAppsCompactMode;
|
|
||||||
if (widget.keyboardLayoutNameCompactMode !== undefined)
|
|
||||||
newWidget.keyboardLayoutNameCompactMode = widget.keyboardLayoutNameCompactMode;
|
|
||||||
if (widget.id === "controlCenterButton") {
|
|
||||||
newWidget.showNetworkIcon = widget.showNetworkIcon ?? SettingsData.controlCenterShowNetworkIcon;
|
|
||||||
newWidget.showBluetoothIcon = widget.showBluetoothIcon ?? SettingsData.controlCenterShowBluetoothIcon;
|
|
||||||
newWidget.showAudioIcon = widget.showAudioIcon ?? SettingsData.controlCenterShowAudioIcon;
|
|
||||||
newWidget.showAudioPercent = widget.showAudioPercent ?? SettingsData.controlCenterShowAudioPercent;
|
|
||||||
newWidget.showVpnIcon = widget.showVpnIcon ?? SettingsData.controlCenterShowVpnIcon;
|
|
||||||
newWidget.showBrightnessIcon = widget.showBrightnessIcon ?? SettingsData.controlCenterShowBrightnessIcon;
|
|
||||||
newWidget.showBrightnessPercent = widget.showBrightnessPercent ?? SettingsData.controlCenterShowBrightnessPercent;
|
|
||||||
newWidget.showMicIcon = widget.showMicIcon ?? SettingsData.controlCenterShowMicIcon;
|
|
||||||
newWidget.showMicPercent = widget.showMicPercent ?? SettingsData.controlCenterShowMicPercent;
|
|
||||||
newWidget.showBatteryIcon = widget.showBatteryIcon ?? SettingsData.controlCenterShowBatteryIcon;
|
|
||||||
newWidget.showPrinterIcon = widget.showPrinterIcon ?? SettingsData.controlCenterShowPrinterIcon;
|
|
||||||
newWidget.showScreenSharingIcon = widget.showScreenSharingIcon ?? SettingsData.controlCenterShowScreenSharingIcon;
|
|
||||||
}
|
|
||||||
widgets[widgetIndex] = newWidget;
|
widgets[widgetIndex] = newWidget;
|
||||||
setWidgetsForSection(sectionId, widgets);
|
setWidgetsForSection(sectionId, widgets);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleCompactModeChanged(sectionId, widgetId, value) {
|
function handleCompactModeChanged(sectionId, widgetId, value) {
|
||||||
var widgets = getWidgetsForSection(sectionId).slice();
|
var widgets = getWidgetsForSection(sectionId).slice();
|
||||||
|
|
||||||
for (var i = 0; i < widgets.length; i++) {
|
for (var i = 0; i < widgets.length; i++) {
|
||||||
var widget = widgets[i];
|
var widget = widgets[i];
|
||||||
var currentId = typeof widget === "string" ? widget : widget.id;
|
var currentId = typeof widget === "string" ? widget : widget.id;
|
||||||
|
|
||||||
if (currentId !== widgetId)
|
if (currentId !== widgetId)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (typeof widget === "string") {
|
var newWidget = cloneWidgetData(widget);
|
||||||
widgets[i] = {
|
|
||||||
"id": widget,
|
|
||||||
"enabled": true
|
|
||||||
};
|
|
||||||
widget = widgets[i];
|
|
||||||
} else {
|
|
||||||
var newWidget = {
|
|
||||||
"id": widget.id,
|
|
||||||
"enabled": widget.enabled
|
|
||||||
};
|
|
||||||
if (widget.size !== undefined)
|
|
||||||
newWidget.size = widget.size;
|
|
||||||
if (widget.selectedGpuIndex !== undefined)
|
|
||||||
newWidget.selectedGpuIndex = widget.selectedGpuIndex;
|
|
||||||
if (widget.pciId !== undefined)
|
|
||||||
newWidget.pciId = widget.pciId;
|
|
||||||
if (widget.mountPath !== undefined)
|
|
||||||
newWidget.mountPath = widget.mountPath;
|
|
||||||
if (widget.minimumWidth !== undefined)
|
|
||||||
newWidget.minimumWidth = widget.minimumWidth;
|
|
||||||
if (widget.showSwap !== undefined)
|
|
||||||
newWidget.showSwap = widget.showSwap;
|
|
||||||
if (widget.mediaSize !== undefined)
|
|
||||||
newWidget.mediaSize = widget.mediaSize;
|
|
||||||
if (widget.clockCompactMode !== undefined)
|
|
||||||
newWidget.clockCompactMode = widget.clockCompactMode;
|
|
||||||
if (widget.focusedWindowCompactMode !== undefined)
|
|
||||||
newWidget.focusedWindowCompactMode = widget.focusedWindowCompactMode;
|
|
||||||
if (widget.runningAppsCompactMode !== undefined)
|
|
||||||
newWidget.runningAppsCompactMode = widget.runningAppsCompactMode;
|
|
||||||
if (widget.keyboardLayoutNameCompactMode !== undefined)
|
|
||||||
newWidget.keyboardLayoutNameCompactMode = widget.keyboardLayoutNameCompactMode;
|
|
||||||
if (widget.id === "controlCenterButton") {
|
|
||||||
newWidget.showNetworkIcon = widget.showNetworkIcon ?? SettingsData.controlCenterShowNetworkIcon;
|
|
||||||
newWidget.showBluetoothIcon = widget.showBluetoothIcon ?? SettingsData.controlCenterShowBluetoothIcon;
|
|
||||||
newWidget.showAudioIcon = widget.showAudioIcon ?? SettingsData.controlCenterShowAudioIcon;
|
|
||||||
newWidget.showAudioPercent = widget.showAudioPercent ?? SettingsData.controlCenterShowAudioPercent;
|
|
||||||
newWidget.showVpnIcon = widget.showVpnIcon ?? SettingsData.controlCenterShowVpnIcon;
|
|
||||||
newWidget.showBrightnessIcon = widget.showBrightnessIcon ?? SettingsData.controlCenterShowBrightnessIcon;
|
|
||||||
newWidget.showBrightnessPercent = widget.showBrightnessPercent ?? SettingsData.controlCenterShowBrightnessPercent;
|
|
||||||
newWidget.showMicIcon = widget.showMicIcon ?? SettingsData.controlCenterShowMicIcon;
|
|
||||||
newWidget.showMicPercent = widget.showMicPercent ?? SettingsData.controlCenterShowMicPercent;
|
|
||||||
newWidget.showBatteryIcon = widget.showBatteryIcon ?? SettingsData.controlCenterShowBatteryIcon;
|
|
||||||
newWidget.showPrinterIcon = widget.showPrinterIcon ?? SettingsData.controlCenterShowPrinterIcon;
|
|
||||||
newWidget.showScreenSharingIcon = widget.showScreenSharingIcon ?? SettingsData.controlCenterShowScreenSharingIcon;
|
|
||||||
}
|
|
||||||
widgets[i] = newWidget;
|
|
||||||
widget = newWidget;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (widgetId) {
|
switch (widgetId) {
|
||||||
case "music":
|
case "music":
|
||||||
widget.mediaSize = value;
|
newWidget.mediaSize = value;
|
||||||
break;
|
break;
|
||||||
case "clock":
|
case "clock":
|
||||||
widget.clockCompactMode = value;
|
newWidget.clockCompactMode = value;
|
||||||
break;
|
break;
|
||||||
case "focusedWindow":
|
case "focusedWindow":
|
||||||
widget.focusedWindowCompactMode = value;
|
newWidget.focusedWindowCompactMode = value;
|
||||||
break;
|
break;
|
||||||
case "runningApps":
|
case "runningApps":
|
||||||
widget.runningAppsCompactMode = value;
|
newWidget.runningAppsCompactMode = value;
|
||||||
break;
|
break;
|
||||||
case "keyboard_layout_name":
|
case "keyboard_layout_name":
|
||||||
widget.keyboardLayoutNameCompactMode = value;
|
newWidget.keyboardLayoutNameCompactMode = value;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
widgets[i] = newWidget;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
setWidgetsForSection(sectionId, widgets);
|
setWidgetsForSection(sectionId, widgets);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,19 @@ Column {
|
|||||||
signal minimumWidthChanged(string sectionId, int widgetIndex, bool enabled)
|
signal minimumWidthChanged(string sectionId, int widgetIndex, bool enabled)
|
||||||
signal showSwapChanged(string sectionId, int widgetIndex, bool enabled)
|
signal showSwapChanged(string sectionId, int widgetIndex, bool enabled)
|
||||||
|
|
||||||
|
function cloneWidgetData(widget) {
|
||||||
|
var result = {
|
||||||
|
"id": widget.id,
|
||||||
|
"enabled": widget.enabled
|
||||||
|
};
|
||||||
|
var keys = ["size", "selectedGpuIndex", "pciId", "mountPath", "minimumWidth", "showSwap", "mediaSize", "clockCompactMode", "focusedWindowCompactMode", "runningAppsCompactMode", "keyboardLayoutNameCompactMode", "showNetworkIcon", "showBluetoothIcon", "showAudioIcon", "showAudioPercent", "showVpnIcon", "showBrightnessIcon", "showBrightnessPercent", "showMicIcon", "showMicPercent", "showBatteryIcon", "showPrinterIcon", "showScreenSharingIcon"];
|
||||||
|
for (var i = 0; i < keys.length; i++) {
|
||||||
|
if (widget[keys[i]] !== undefined)
|
||||||
|
result[keys[i]] = widget[keys[i]];
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: implicitHeight
|
height: implicitHeight
|
||||||
spacing: Theme.spacingM
|
spacing: Theme.spacingM
|
||||||
@@ -727,13 +740,7 @@ Column {
|
|||||||
var newItems = root.items.slice();
|
var newItems = root.items.slice();
|
||||||
var draggedItem = newItems.splice(index, 1)[0];
|
var draggedItem = newItems.splice(index, 1)[0];
|
||||||
newItems.splice(newIndex, 0, draggedItem);
|
newItems.splice(newIndex, 0, draggedItem);
|
||||||
root.itemOrderChanged(newItems.map(item => {
|
root.itemOrderChanged(newItems.map(item => root.cloneWidgetData(item)));
|
||||||
return ({
|
|
||||||
"id": item.id,
|
|
||||||
"enabled": item.enabled,
|
|
||||||
"size": item.size
|
|
||||||
});
|
|
||||||
}));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
delegateItem.x = 0;
|
delegateItem.x = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user