mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-05-16 17:22:45 -04:00
feat: add Display Profiles builtin control center widget (#2410)
* feat: add Display Profiles builtin control center widget Adds a new built-in widget that lets users switch between their configured display profiles directly from the Control Center, without opening Settings. - Widget shows the active profile name and cycles profiles on pill click - Detail panel shows all profiles as a button group for direct selection - Integrates with existing DisplayConfigState/SettingsData singletons - Follows the same loader/instance pattern as VPN, CUPS, and Tailscale widgets * fix: refine display profiles widget behavior
This commit is contained in:
@@ -11,6 +11,7 @@ QtObject {
|
||||
property var vpnBuiltinInstance: null
|
||||
property var cupsBuiltinInstance: null
|
||||
property var tailscaleBuiltinInstance: null
|
||||
property var displayProfilesBuiltinInstance: null
|
||||
|
||||
property var vpnLoader: Loader {
|
||||
active: false
|
||||
@@ -93,6 +94,34 @@ QtObject {
|
||||
}
|
||||
}
|
||||
|
||||
property var displayProfilesLoader: Loader {
|
||||
active: false
|
||||
sourceComponent: Component {
|
||||
DisplayProfilesWidget {}
|
||||
}
|
||||
|
||||
onItemChanged: {
|
||||
root.displayProfilesBuiltinInstance = item;
|
||||
}
|
||||
|
||||
onActiveChanged: {
|
||||
if (!active)
|
||||
root.displayProfilesBuiltinInstance = null;
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: SettingsData
|
||||
function onControlCenterWidgetsChanged() {
|
||||
const widgets = SettingsData.controlCenterWidgets || [];
|
||||
const hasWidget = widgets.some(w => w.id === "builtin_display_profiles");
|
||||
if (!hasWidget && displayProfilesLoader.active) {
|
||||
root.log.debug("No Display Profiles widget in control center, deactivating loader");
|
||||
displayProfilesLoader.active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
readonly property var coreWidgetDefinitions: [
|
||||
{
|
||||
"id": "nightMode",
|
||||
@@ -242,6 +271,15 @@ QtObject {
|
||||
"enabled": TailscaleService.available,
|
||||
"warning": !TailscaleService.available ? I18n.tr("Tailscale not available", "Warning when Tailscale service is not running") : undefined,
|
||||
"isBuiltinPlugin": true
|
||||
},
|
||||
{
|
||||
"id": "builtin_display_profiles",
|
||||
"text": I18n.tr("Display Profiles"),
|
||||
"description": I18n.tr("Switch between display configurations"),
|
||||
"icon": "monitor",
|
||||
"type": "builtin_plugin",
|
||||
"enabled": true,
|
||||
"isBuiltinPlugin": true
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user