Changeset View
Changeset View
Standalone View
Standalone View
kcm/package/contents/ui/Output.qml
Show All 17 Lines | |||||
18 | import QtQuick 2.12 | 18 | import QtQuick 2.12 | ||
19 | import QtQuick.Layouts 1.1 | 19 | import QtQuick.Layouts 1.1 | ||
20 | import QtQuick.Controls 2.3 as Controls | 20 | import QtQuick.Controls 2.3 as Controls | ||
21 | import QtGraphicalEffects 1.0 | 21 | import QtGraphicalEffects 1.0 | ||
22 | 22 | | |||
23 | Rectangle { | 23 | Rectangle { | ||
24 | id: output | 24 | id: output | ||
25 | 25 | | |||
26 | property rect visibleBounds | ||||
27 | | ||||
26 | property bool isSelected: root.selectedOutput === model.index | 28 | property bool isSelected: root.selectedOutput === model.index | ||
27 | 29 | | |||
28 | onIsSelectedChanged: { | 30 | onIsSelectedChanged: { | ||
29 | if (isSelected) { | 31 | if (isSelected) { | ||
30 | z = 89; | 32 | z = 89; | ||
31 | } else { | 33 | } else { | ||
32 | z = 0; | 34 | z = 0; | ||
33 | } | 35 | } | ||
▲ Show 20 Lines • Show All 224 Lines • ▼ Show 20 Line(s) | 257 | DragHandler { | |||
258 | acceptedButtons: Qt.LeftButton | 260 | acceptedButtons: Qt.LeftButton | ||
259 | target: null | 261 | target: null | ||
260 | 262 | | |||
261 | onTranslationChanged: { | 263 | onTranslationChanged: { | ||
262 | var newX = dragStartPosition.x + translation.x; | 264 | var newX = dragStartPosition.x + translation.x; | ||
263 | var newY = dragStartPosition.y + translation.y; | 265 | var newY = dragStartPosition.y + translation.y; | ||
264 | model.position = getAbsolutePosition(Qt.point(newX, newY)); | 266 | model.position = getAbsolutePosition(Qt.point(newX, newY)); | ||
265 | } | 267 | } | ||
268 | onActiveChanged: { | ||||
269 | if (!active && visibleBounds.width > 0 && visibleBounds.height > 0) { | ||||
270 | // When dragging stops, ensure screens are within bounds | ||||
271 | var newX = Math.max(visibleBounds.left - width, Math.min(visibleBounds.right, dragStartPosition.x + translation.x)); | ||||
272 | var newY = Math.max(visibleBounds.top - height, Math.min(visibleBounds.bottom, dragStartPosition.y + translation.y)); | ||||
273 | model.position = getAbsolutePosition(Qt.point(newX, newY)); | ||||
274 | } | ||||
275 | } | ||||
266 | } | 276 | } | ||
267 | } | 277 | } | ||
268 | 278 | |