diff options
| author | AlexanderCurl <alexc@alexc.hu> | 2026-04-18 17:46:06 +0100 |
|---|---|---|
| committer | AlexanderCurl <alexc@alexc.hu> | 2026-04-18 17:46:06 +0100 |
| commit | 70ca3fef77ee8bdc6e3ac28589a6fa08c024cc69 (patch) | |
| tree | ab1123d4067c1b086dd6faa7ee4ea643236b565a /raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/Modules/ControlCenter/utils | |
| parent | 5d94c0a7d44a2255b81815a52a7056a94a39842d (diff) | |
| download | RaveOS-PKGBUILD-70ca3fef77ee8bdc6e3ac28589a6fa08c024cc69.tar.gz RaveOS-PKGBUILD-70ca3fef77ee8bdc6e3ac28589a6fa08c024cc69.zip | |
Replaced file structures for themes in the correct format
Diffstat (limited to 'raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/Modules/ControlCenter/utils')
3 files changed, 152 insertions, 0 deletions
diff --git a/raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/Modules/ControlCenter/utils/layout.js b/raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/Modules/ControlCenter/utils/layout.js new file mode 100644 index 0000000..b8e5651 --- /dev/null +++ b/raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/Modules/ControlCenter/utils/layout.js @@ -0,0 +1,45 @@ +function calculateRowsAndWidgets(controlCenterColumn, expandedSection, expandedWidgetIndex) { + var rows = [] + var currentRow = [] + var currentWidth = 0 + var expandedRow = -1 + + const widgets = SettingsData.controlCenterWidgets || [] + const baseWidth = controlCenterColumn.width + const spacing = Theme.spacingS + + for (var i = 0; i < widgets.length; i++) { + const widget = widgets[i] + const widgetWidth = widget.width || 50 + + var itemWidth + if (widgetWidth <= 25) { + itemWidth = (baseWidth - spacing * 3) / 4 + } else if (widgetWidth <= 50) { + itemWidth = (baseWidth - spacing) / 2 + } else if (widgetWidth <= 75) { + itemWidth = (baseWidth - spacing * 2) * 0.75 + } else { + itemWidth = baseWidth + } + + if (currentRow.length > 0 && (currentWidth + spacing + itemWidth > baseWidth)) { + rows.push([...currentRow]) + currentRow = [widget] + currentWidth = itemWidth + } else { + currentRow.push(widget) + currentWidth += (currentRow.length > 1 ? spacing : 0) + itemWidth + } + + if (expandedWidgetIndex === i) { + expandedRow = rows.length + } + } + + if (currentRow.length > 0) { + rows.push(currentRow) + } + + return { rows: rows, expandedRowIndex: expandedRow } +} diff --git a/raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/Modules/ControlCenter/utils/state.js b/raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/Modules/ControlCenter/utils/state.js new file mode 100644 index 0000000..a2d59a6 --- /dev/null +++ b/raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/Modules/ControlCenter/utils/state.js @@ -0,0 +1,17 @@ +function openWithSection(root, section) { + if (root.shouldBeVisible) { + root.close(); + } else { + root.expandedSection = section; + root.open(); + } +} + +function toggleSection(root, section) { + if (root.expandedSection === section) { + root.expandedSection = ""; + root.expandedWidgetIndex = -1; + } else { + root.expandedSection = section; + } +} diff --git a/raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/Modules/ControlCenter/utils/widgets.js b/raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/Modules/ControlCenter/utils/widgets.js new file mode 100644 index 0000000..3e11d88 --- /dev/null +++ b/raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/Modules/ControlCenter/utils/widgets.js @@ -0,0 +1,90 @@ +function getWidgetForId(baseWidgetDefinitions, widgetId) { + return baseWidgetDefinitions.find(w => w.id === widgetId) +} + +function addWidget(widgetId) { + var widgets = SettingsData.controlCenterWidgets.slice() + var widget = { + "id": widgetId, + "enabled": true, + "width": 50 + } + + if (widgetId === "diskUsage") { + widget.instanceId = generateUniqueId() + widget.mountPath = "/" + } + + if (widgetId === "brightnessSlider") { + widget.instanceId = generateUniqueId() + widget.deviceName = "" + } + + widgets.push(widget) + SettingsData.set("controlCenterWidgets", widgets) +} + +function generateUniqueId() { + return Date.now().toString(36) + Math.random().toString(36).substr(2) +} + +function removeWidget(index) { + var widgets = SettingsData.controlCenterWidgets.slice() + if (index >= 0 && index < widgets.length) { + widgets.splice(index, 1) + SettingsData.set("controlCenterWidgets", widgets) + } +} + +function toggleWidgetSize(index) { + var widgets = SettingsData.controlCenterWidgets.slice() + if (index >= 0 && index < widgets.length) { + const currentWidth = widgets[index].width || 50 + const id = widgets[index].id || "" + + if (id === "wifi" || id === "bluetooth" || id === "audioOutput" || id === "audioInput") { + widgets[index].width = currentWidth <= 50 ? 100 : 50 + } else { + if (currentWidth <= 25) { + widgets[index].width = 50 + } else if (currentWidth <= 50) { + widgets[index].width = 100 + } else { + widgets[index].width = 25 + } + } + + SettingsData.set("controlCenterWidgets", widgets) + } +} + +function reorderWidgets(newOrder) { + SettingsData.set("controlCenterWidgets", newOrder) +} + +function moveWidget(fromIndex, toIndex) { + let widgets = [...(SettingsData.controlCenterWidgets || [])] + if (fromIndex >= 0 && fromIndex < widgets.length && toIndex >= 0 && toIndex < widgets.length) { + const movedWidget = widgets.splice(fromIndex, 1)[0] + widgets.splice(toIndex, 0, movedWidget) + SettingsData.set("controlCenterWidgets", widgets) + } +} + +function resetToDefault() { + const defaultWidgets = [ + {"id": "volumeSlider", "enabled": true, "width": 50}, + {"id": "brightnessSlider", "enabled": true, "width": 50}, + {"id": "wifi", "enabled": true, "width": 50}, + {"id": "bluetooth", "enabled": true, "width": 50}, + {"id": "audioOutput", "enabled": true, "width": 50}, + {"id": "audioInput", "enabled": true, "width": 50}, + {"id": "nightMode", "enabled": true, "width": 50}, + {"id": "darkMode", "enabled": true, "width": 50} + ] + SettingsData.set("controlCenterWidgets", defaultWidgets) +} + +function clearAll() { + SettingsData.set("controlCenterWidgets", []) +} |