|
| 1 | +pragma ComponentBehavior: Bound |
| 2 | + |
| 3 | +import QtQuick |
| 4 | +import QtQuick.Layouts |
| 5 | +import Caelestia.Config |
| 6 | +import qs.components |
| 7 | +import qs.components.controls |
| 8 | +import qs.services |
| 9 | + |
| 10 | +ColumnLayout { |
| 11 | + id: root |
| 12 | + |
| 13 | + spacing: Tokens.spacing.large |
| 14 | + |
| 15 | + RowLayout { |
| 16 | + Layout.fillWidth: true |
| 17 | + Layout.margins: Tokens.padding.medium |
| 18 | + |
| 19 | + StyledText { |
| 20 | + text: qsTr("Monitors") |
| 21 | + font: Tokens.font.title.large |
| 22 | + Layout.fillWidth: true |
| 23 | + } |
| 24 | + |
| 25 | + IconTextButton { |
| 26 | + icon: "info" |
| 27 | + text: qsTr("Identify") |
| 28 | + isToggle: true |
| 29 | + checked: Monitors.identifying |
| 30 | + onClicked: Monitors.toggleIdentification() |
| 31 | + } |
| 32 | + } |
| 33 | + |
| 34 | + Flickable { |
| 35 | + Layout.fillWidth: true |
| 36 | + Layout.fillHeight: true |
| 37 | + contentHeight: monitorsLayout.implicitHeight |
| 38 | + clip: true |
| 39 | + |
| 40 | + ColumnLayout { |
| 41 | + id: monitorsLayout |
| 42 | + |
| 43 | + anchors.left: parent.left |
| 44 | + anchors.right: parent.right |
| 45 | + spacing: Tokens.spacing.medium |
| 46 | + |
| 47 | + Repeater { |
| 48 | + model: Hyprctl.monitors |
| 49 | + |
| 50 | + delegate: StyledRect { |
| 51 | + id: monitorDelegate |
| 52 | + |
| 53 | + required property var modelData |
| 54 | + |
| 55 | + readonly property var mon: monitorDelegate.modelData |
| 56 | + readonly property var brightnessMon: Brightness.getMonitor(monitorDelegate.mon.name) |
| 57 | + |
| 58 | + Layout.fillWidth: true |
| 59 | + implicitHeight: monitorContent.implicitHeight + Tokens.padding.large * 2 |
| 60 | + color: Colours.tPalette.m3surfaceContainerHigh |
| 61 | + radius: Tokens.rounding.large |
| 62 | + |
| 63 | + ColumnLayout { |
| 64 | + id: monitorContent |
| 65 | + |
| 66 | + anchors.fill: parent |
| 67 | + anchors.margins: Tokens.padding.large |
| 68 | + spacing: Tokens.spacing.medium |
| 69 | + |
| 70 | + RowLayout { |
| 71 | + Layout.fillWidth: true |
| 72 | + MaterialIcon { |
| 73 | + text: "monitor" |
| 74 | + color: Colours.palette.m3primary |
| 75 | + } |
| 76 | + ColumnLayout { |
| 77 | + Layout.fillWidth: true |
| 78 | + spacing: 0 |
| 79 | + |
| 80 | + StyledText { |
| 81 | + text: `${monitorDelegate.mon.name} - ${monitorDelegate.mon.make} ${monitorDelegate.mon.model}` |
| 82 | + font: Tokens.font.title.medium |
| 83 | + Layout.fillWidth: true |
| 84 | + } |
| 85 | + StyledText { |
| 86 | + text: `${monitorDelegate.mon.width}x${monitorDelegate.mon.height}@${(monitorDelegate.mon.refreshRate ?? 0).toFixed(2)}Hz` |
| 87 | + color: Colours.palette.m3onSurfaceVariant |
| 88 | + font: Tokens.font.body.small |
| 89 | + } |
| 90 | + } |
| 91 | + StyledText { |
| 92 | + text: `ID: ${monitorDelegate.mon.id}` |
| 93 | + color: Colours.palette.m3onSurfaceVariant |
| 94 | + } |
| 95 | + } |
| 96 | +
|
| 97 | + // Brightness |
| 98 | + RowLayout { |
| 99 | + Layout.fillWidth: true |
| 100 | + visible: !!monitorDelegate.brightnessMon |
| 101 | +
|
| 102 | + MaterialIcon { |
| 103 | + text: "brightness_medium" |
| 104 | + fontStyle: Tokens.font.icon.medium |
| 105 | + } |
| 106 | +
|
| 107 | + StyledSlider { |
| 108 | + Layout.fillWidth: true |
| 109 | + value: monitorDelegate.brightnessMon?.brightness ?? 0 |
| 110 | + onMoved: if (monitorDelegate.brightnessMon) |
| 111 | + monitorDelegate.brightnessMon.setBrightness(value) |
| 112 | + } |
| 113 | +
|
| 114 | + StyledText { |
| 115 | + text: `${Math.round((monitorDelegate.brightnessMon?.brightness ?? 0) * 100)}%` |
| 116 | + Layout.preferredWidth: 40 |
| 117 | + } |
| 118 | + } |
| 119 | +
|
| 120 | + // Scaling |
| 121 | + RowLayout { |
| 122 | + Layout.fillWidth: true |
| 123 | +
|
| 124 | + MaterialIcon { |
| 125 | + text: "zoom_in" |
| 126 | + fontStyle: Tokens.font.icon.medium |
| 127 | + } |
| 128 | +
|
| 129 | + StyledSlider { |
| 130 | + Layout.fillWidth: true |
| 131 | + from: 0.5 |
| 132 | + to: 3.0 |
| 133 | + value: monitorDelegate.mon.scale |
| 134 | + onMoved: Monitors.setScale(monitorDelegate.mon.name, value) |
| 135 | + } |
| 136 | +
|
| 137 | + StyledText { |
| 138 | + text: `${monitorDelegate.mon.scale.toFixed(2)}x` |
| 139 | + Layout.preferredWidth: 40 |
| 140 | + } |
| 141 | + } |
| 142 | +
|
| 143 | + // Refresh Rate |
| 144 | + RowLayout { |
| 145 | + Layout.fillWidth: true |
| 146 | + spacing: Tokens.spacing.small |
| 147 | +
|
| 148 | + StyledText { |
| 149 | + text: qsTr("Refresh Rate") |
| 150 | + Layout.fillWidth: true |
| 151 | + } |
| 152 | +
|
| 153 | + CustomSpinBox { |
| 154 | + id: rrSelector |
| 155 | +
|
| 156 | + min: 10 |
| 157 | + max: 1000 |
| 158 | + step: 1 |
| 159 | + value: monitorDelegate.mon.refreshRate |
| 160 | + onValueModified: val => Monitors.setRefreshRate(monitorDelegate.mon.name, val) |
| 161 | + } |
| 162 | + } |
| 163 | +
|
| 164 | + // Rotation |
| 165 | + RowLayout { |
| 166 | + Layout.fillWidth: true |
| 167 | + spacing: Tokens.spacing.small |
| 168 | +
|
| 169 | + StyledText { |
| 170 | + text: qsTr("Rotation") |
| 171 | + Layout.fillWidth: true |
| 172 | + } |
| 173 | +
|
| 174 | + Repeater { |
| 175 | + model: [ |
| 176 | + { |
| 177 | + label: "0°", |
| 178 | + val: 0, |
| 179 | + icon: "screen_rotation" |
| 180 | + }, |
| 181 | + { |
| 182 | + label: "90°", |
| 183 | + val: 1, |
| 184 | + icon: "screen_rotation" |
| 185 | + }, |
| 186 | + { |
| 187 | + label: "180°", |
| 188 | + val: 2, |
| 189 | + icon: "screen_rotation" |
| 190 | + }, |
| 191 | + { |
| 192 | + label: "270°", |
| 193 | + val: 3, |
| 194 | + icon: "screen_rotation" |
| 195 | + } |
| 196 | + ] |
| 197 | +
|
| 198 | + delegate: IconButton { |
| 199 | + required property var modelData |
| 200 | + required property int index |
| 201 | +
|
| 202 | + icon: modelData.icon |
| 203 | + isToggle: true |
| 204 | + checked: monitorDelegate.mon.transform === modelData.val |
| 205 | + onClicked: Monitors.rotate(monitorDelegate.mon.name, modelData.val * 90) |
| 206 | + } |
| 207 | + } |
| 208 | + } |
| 209 | +
|
| 210 | + // Arrangement |
| 211 | + RowLayout { |
| 212 | + Layout.fillWidth: true |
| 213 | + spacing: Tokens.spacing.small |
| 214 | +
|
| 215 | + StyledText { |
| 216 | + text: qsTr("Position relative to:") |
| 217 | + Layout.fillWidth: true |
| 218 | + } |
| 219 | +
|
| 220 | + CustomSpinBox { |
| 221 | + id: targetMonSelector |
| 222 | +
|
| 223 | + min: 0 |
| 224 | + max: Math.max(0, (Hyprctl.monitors.length ?? 1) - 1) |
| 225 | + value: 0 |
| 226 | + } |
| 227 | +
|
| 228 | + IconButton { |
| 229 | + icon: "arrow_back" |
| 230 | + onClicked: Monitors.arrange(monitorDelegate.mon.name, "left", targetMonSelector.value) |
| 231 | + } |
| 232 | + IconButton { |
| 233 | + icon: "arrow_forward" |
| 234 | + onClicked: Monitors.arrange(monitorDelegate.mon.name, "right", targetMonSelector.value) |
| 235 | + } |
| 236 | + IconButton { |
| 237 | + icon: "arrow_upward" |
| 238 | + onClicked: Monitors.arrange(monitorDelegate.mon.name, "top", targetMonSelector.value) |
| 239 | + } |
| 240 | + IconButton { |
| 241 | + icon: "arrow_downward" |
| 242 | + onClicked: Monitors.arrange(monitorDelegate.mon.name, "bottom", targetMonSelector.value) |
| 243 | + } |
| 244 | + } |
| 245 | + } |
| 246 | + } |
| 247 | + } |
| 248 | + } |
| 249 | + } |
| 250 | +} |
0 commit comments