mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-11 00:02:28 -04:00
displays: support for multiple output profiles
- add support for deleting unplugged configs - Option to hide disconnected displays fixes #1453
This commit is contained in:
@@ -4,6 +4,45 @@ import qs.Common
|
||||
Rectangle {
|
||||
id: root
|
||||
|
||||
property var filteredOutputs: {
|
||||
const all = DisplayConfigState.allOutputs || {};
|
||||
const keys = Object.keys(all);
|
||||
if (SettingsData.displayShowDisconnected)
|
||||
return keys;
|
||||
return keys.filter(k => all[k]?.connected);
|
||||
}
|
||||
|
||||
property var filteredBounds: {
|
||||
const all = DisplayConfigState.allOutputs || {};
|
||||
let minX = Infinity, minY = Infinity, maxX = -Infinity, maxY = -Infinity;
|
||||
for (const name of filteredOutputs) {
|
||||
const output = all[name];
|
||||
if (!output?.logical)
|
||||
continue;
|
||||
const x = output.logical.x;
|
||||
const y = output.logical.y;
|
||||
const w = output.logical.width || 1920;
|
||||
const h = output.logical.height || 1080;
|
||||
minX = Math.min(minX, x);
|
||||
minY = Math.min(minY, y);
|
||||
maxX = Math.max(maxX, x + w);
|
||||
maxY = Math.max(maxY, y + h);
|
||||
}
|
||||
if (minX === Infinity)
|
||||
return {
|
||||
minX: 0,
|
||||
minY: 0,
|
||||
width: 1920,
|
||||
height: 1080
|
||||
};
|
||||
return {
|
||||
minX: minX,
|
||||
minY: minY,
|
||||
width: maxX - minX,
|
||||
height: maxY - minY
|
||||
};
|
||||
}
|
||||
|
||||
width: parent.width
|
||||
height: 280
|
||||
radius: Theme.cornerRadius
|
||||
@@ -16,7 +55,7 @@ Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.spacingL
|
||||
|
||||
property var bounds: DisplayConfigState.getOutputBounds()
|
||||
property var bounds: root.filteredBounds
|
||||
property real scaleFactor: {
|
||||
if (bounds.width === 0 || bounds.height === 0)
|
||||
return 0.1;
|
||||
@@ -27,15 +66,8 @@ Rectangle {
|
||||
}
|
||||
property point offset: Qt.point((width - bounds.width * scaleFactor) / 2 - bounds.minX * scaleFactor, (height - bounds.height * scaleFactor) / 2 - bounds.minY * scaleFactor)
|
||||
|
||||
Connections {
|
||||
target: DisplayConfigState
|
||||
function onAllOutputsChanged() {
|
||||
canvas.bounds = DisplayConfigState.getOutputBounds();
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: DisplayConfigState.allOutputs ? Object.keys(DisplayConfigState.allOutputs) : []
|
||||
model: root.filteredOutputs
|
||||
|
||||
delegate: MonitorRect {
|
||||
required property string modelData
|
||||
|
||||
Reference in New Issue
Block a user