mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
displays: add "show on last display" for some components.
- Lets the components migrate when un-docked to the otehr monitor, basically
This commit is contained in:
@@ -259,6 +259,7 @@ Singleton {
|
||||
property string updaterTerminalAdditionalParams: ""
|
||||
|
||||
property var screenPreferences: ({})
|
||||
property var showOnLastDisplay: ({})
|
||||
|
||||
signal forceDankBarLayoutRefresh
|
||||
signal forceDockLayoutRefresh
|
||||
@@ -494,6 +495,7 @@ Singleton {
|
||||
widgetBackgroundColor = settings.widgetBackgroundColor !== undefined ? settings.widgetBackgroundColor : "sch"
|
||||
surfaceBase = settings.surfaceBase !== undefined ? settings.surfaceBase : "s"
|
||||
screenPreferences = settings.screenPreferences !== undefined ? settings.screenPreferences : ({})
|
||||
showOnLastDisplay = settings.showOnLastDisplay !== undefined ? settings.showOnLastDisplay : ({})
|
||||
wallpaperFillMode = settings.wallpaperFillMode !== undefined ? settings.wallpaperFillMode : "Fill"
|
||||
animationSpeed = settings.animationSpeed !== undefined ? settings.animationSpeed : SettingsData.AnimationSpeed.Short
|
||||
customAnimationDuration = settings.customAnimationDuration !== undefined ? settings.customAnimationDuration : 500
|
||||
@@ -677,6 +679,7 @@ Singleton {
|
||||
"updaterCustomCommand": updaterCustomCommand,
|
||||
"updaterTerminalAdditionalParams": updaterTerminalAdditionalParams,
|
||||
"screenPreferences": screenPreferences,
|
||||
"showOnLastDisplay": showOnLastDisplay,
|
||||
"animationSpeed": animationSpeed,
|
||||
"customAnimationDuration": customAnimationDuration,
|
||||
"acMonitorTimeout": acMonitorTimeout,
|
||||
@@ -743,7 +746,7 @@ Singleton {
|
||||
"customPowerActionLock", "customPowerActionLogout", "customPowerActionSuspend",
|
||||
"customPowerActionHibernate", "customPowerActionReboot", "customPowerActionPowerOff",
|
||||
"updaterUseCustomCommand", "updaterCustomCommand", "updaterTerminalAdditionalParams",
|
||||
"screenPreferences", "animationSpeed", "customAnimationDuration", "acMonitorTimeout", "acLockTimeout",
|
||||
"screenPreferences", "showOnLastDisplay", "animationSpeed", "customAnimationDuration", "acMonitorTimeout", "acLockTimeout",
|
||||
"acSuspendTimeout", "acHibernateTimeout", "batteryMonitorTimeout", "batteryLockTimeout",
|
||||
"batterySuspendTimeout", "batteryHibernateTimeout", "lockBeforeSuspend",
|
||||
"loginctlLockIntegration", "launchPrefix", "brightnessDevicePins", "configVersion"
|
||||
@@ -943,7 +946,11 @@ Singleton {
|
||||
if (prefs.includes("all")) {
|
||||
return Quickshell.screens
|
||||
}
|
||||
return Quickshell.screens.filter(screen => prefs.includes(screen.name))
|
||||
var filtered = Quickshell.screens.filter(screen => prefs.includes(screen.name))
|
||||
if (filtered.length === 0 && showOnLastDisplay && showOnLastDisplay[componentId] && Quickshell.screens.length === 1) {
|
||||
return Quickshell.screens
|
||||
}
|
||||
return filtered
|
||||
}
|
||||
|
||||
function sendTestNotifications() {
|
||||
@@ -1812,6 +1819,11 @@ Singleton {
|
||||
saveSettings()
|
||||
}
|
||||
|
||||
function setShowOnLastDisplay(prefs) {
|
||||
showOnLastDisplay = prefs
|
||||
saveSettings()
|
||||
}
|
||||
|
||||
function setBrightnessDevicePins(pins) {
|
||||
brightnessDevicePins = pins
|
||||
saveSettings()
|
||||
|
||||
@@ -56,10 +56,21 @@ Item {
|
||||
}
|
||||
|
||||
function setScreenPreferences(componentId, screenNames) {
|
||||
var prefs = SettingsData.screenPreferences || {
|
||||
};
|
||||
prefs[componentId] = screenNames;
|
||||
SettingsData.setScreenPreferences(prefs);
|
||||
var prefs = SettingsData.screenPreferences || {};
|
||||
var newPrefs = Object.assign({}, prefs);
|
||||
newPrefs[componentId] = screenNames;
|
||||
SettingsData.setScreenPreferences(newPrefs);
|
||||
}
|
||||
|
||||
function getShowOnLastDisplay(componentId) {
|
||||
return SettingsData.showOnLastDisplay && SettingsData.showOnLastDisplay[componentId] || false;
|
||||
}
|
||||
|
||||
function setShowOnLastDisplay(componentId, enabled) {
|
||||
var prefs = SettingsData.showOnLastDisplay || {};
|
||||
var newPrefs = Object.assign({}, prefs);
|
||||
newPrefs[componentId] = enabled;
|
||||
SettingsData.setShowOnLastDisplay(newPrefs);
|
||||
}
|
||||
|
||||
DankFlickable {
|
||||
@@ -660,7 +671,6 @@ Item {
|
||||
|
||||
Column {
|
||||
property string componentId: modelData.id
|
||||
property var selectedScreens: displaysTab.getScreenPreferences(componentId)
|
||||
|
||||
width: parent.width
|
||||
spacing: Theme.spacingXS
|
||||
@@ -669,7 +679,7 @@ Item {
|
||||
width: parent.width
|
||||
text: I18n.tr("All displays")
|
||||
description: I18n.tr("Show on all connected displays")
|
||||
checked: parent.selectedScreens.includes("all")
|
||||
checked: displaysTab.getScreenPreferences(parent.componentId).includes("all")
|
||||
onToggled: (checked) => {
|
||||
if (checked)
|
||||
displaysTab.setScreenPreferences(parent.componentId, ["all"]);
|
||||
@@ -678,18 +688,29 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
DankToggle {
|
||||
width: parent.width
|
||||
text: I18n.tr("Show on Last Display")
|
||||
description: I18n.tr("Always show when there's only one connected display")
|
||||
checked: displaysTab.getShowOnLastDisplay(parent.componentId)
|
||||
visible: !displaysTab.getScreenPreferences(parent.componentId).includes("all") && ["dankBar", "dock", "notifications", "osd", "toast"].includes(parent.componentId)
|
||||
onToggled: (checked) => {
|
||||
displaysTab.setShowOnLastDisplay(parent.componentId, checked);
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: parent.width
|
||||
height: 1
|
||||
color: Theme.outline
|
||||
opacity: 0.2
|
||||
visible: !parent.selectedScreens.includes("all")
|
||||
visible: !displaysTab.getScreenPreferences(parent.componentId).includes("all")
|
||||
}
|
||||
|
||||
Column {
|
||||
width: parent.width
|
||||
spacing: Theme.spacingXS
|
||||
visible: !parent.selectedScreens.includes("all")
|
||||
visible: !displaysTab.getScreenPreferences(parent.componentId).includes("all")
|
||||
|
||||
Repeater {
|
||||
model: Quickshell.screens
|
||||
|
||||
Reference in New Issue
Block a user