1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-25 05:52:50 -05:00
Files
DankMaterialShell/quickshell/Modules/Settings/Widgets/SettingsDisplayPicker.qml
2025-12-22 10:39:19 -05:00

104 lines
3.2 KiB
QML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
pragma ComponentBehavior: Bound
import QtQuick
import Quickshell
import qs.Common
import qs.Widgets
Item {
id: root
property var displayPreferences: []
signal preferencesChanged(var preferences)
property bool localAllDisplays: true
onDisplayPreferencesChanged: {
if (!Array.isArray(displayPreferences) || displayPreferences.length === 0) {
localAllDisplays = true;
return;
}
localAllDisplays = displayPreferences.includes("all");
}
width: parent?.width ?? 0
height: displayColumn.height + Theme.spacingM * 2
Column {
id: displayColumn
width: parent.width - Theme.spacingM * 2
x: Theme.spacingM
anchors.verticalCenter: parent.verticalCenter
spacing: Theme.spacingM
StyledText {
text: I18n.tr("Displays")
font.pixelSize: Theme.fontSizeMedium
color: Theme.surfaceText
}
DankToggle {
width: parent.width
text: I18n.tr("All displays")
checked: root.localAllDisplays
onToggled: isChecked => {
root.localAllDisplays = isChecked;
if (isChecked) {
root.preferencesChanged(["all"]);
return;
}
var screens = [];
for (var i = 0; i < Quickshell.screens.length; i++) {
var s = Quickshell.screens[i];
screens.push({
name: s.name,
model: s.model || ""
});
}
root.preferencesChanged(screens);
}
}
Column {
width: parent.width
spacing: Theme.spacingXS
visible: !root.localAllDisplays
Repeater {
model: Quickshell.screens
DankToggle {
required property var modelData
property bool localChecked: {
const prefs = root.displayPreferences;
if (!Array.isArray(prefs) || prefs.includes("all"))
return true;
return prefs.some(p => p.name === modelData.name);
}
width: parent.width
text: SettingsData.getScreenDisplayName(modelData)
description: modelData.width + "×" + modelData.height
checked: localChecked
onToggled: isChecked => {
localChecked = isChecked;
var prefs = JSON.parse(JSON.stringify(root.displayPreferences));
if (!Array.isArray(prefs) || prefs.includes("all"))
prefs = [];
prefs = prefs.filter(p => p.name !== modelData.name);
if (isChecked) {
prefs.push({
name: modelData.name,
model: modelData.model || ""
});
}
root.preferencesChanged(prefs);
}
}
}
}
}
}