mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
56 lines
1.6 KiB
QML
56 lines
1.6 KiB
QML
import QtQuick
|
|
import QtQuick.Controls
|
|
import QtQuick.Layouts
|
|
import Quickshell
|
|
import qs.Commons
|
|
import qs.Services.Compositor
|
|
import qs.Widgets
|
|
|
|
ColumnLayout {
|
|
id: root
|
|
spacing: Style.marginL
|
|
Layout.fillWidth: true
|
|
|
|
// Helper functions to update arrays immutably
|
|
function addMonitor(list, name) {
|
|
const arr = (list || []).slice();
|
|
if (!arr.includes(name))
|
|
arr.push(name);
|
|
return arr;
|
|
}
|
|
function removeMonitor(list, name) {
|
|
return (list || []).filter(function (n) {
|
|
return n !== name;
|
|
});
|
|
}
|
|
|
|
Repeater {
|
|
model: Quickshell.screens || []
|
|
delegate: NCheckbox {
|
|
Layout.fillWidth: true
|
|
label: modelData.name || "Unknown"
|
|
description: {
|
|
const compositorScale = CompositorService.getDisplayScale(modelData.name);
|
|
I18n.tr("system.monitor-description", {
|
|
"model": modelData.model,
|
|
"width": modelData.width * compositorScale,
|
|
"height": modelData.height * compositorScale,
|
|
"scale": compositorScale
|
|
});
|
|
}
|
|
checked: (Settings.data.dock.monitors || []).indexOf(modelData.name) !== -1
|
|
onToggled: checked => {
|
|
if (checked) {
|
|
Settings.data.dock.monitors = root.addMonitor(Settings.data.dock.monitors, modelData.name);
|
|
} else {
|
|
Settings.data.dock.monitors = root.removeMonitor(Settings.data.dock.monitors, modelData.name);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
NLabel {
|
|
description: I18n.tr("settings.dock.monitors.section.description")
|
|
}
|
|
}
|