Changeset View
Changeset View
Standalone View
Standalone View
kcm/package/contents/ui/Output.qml
Show All 18 Lines | |||||
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 bool isSelected: root.selectedOutput === model.index | 26 | property bool isSelected: root.selectedOutput === model.index | ||
27 | property size outputSize: model.size | ||||
27 | 28 | | |||
28 | onIsSelectedChanged: { | 29 | onIsSelectedChanged: { | ||
29 | if (isSelected) { | 30 | if (isSelected) { | ||
30 | z = 89; | 31 | z = 89; | ||
31 | } else { | 32 | } else { | ||
32 | z = 0; | 33 | z = 0; | ||
33 | } | 34 | } | ||
34 | } | 35 | } | ||
35 | 36 | | |||
36 | function getAbsolutePosition(pos) { | 37 | function getAbsolutePosition(pos) { | ||
37 | return Qt.point((pos.x - screen.xOffset) * screen.relativeFactor, | 38 | return Qt.point((pos.x - screen.xOffset) * screen.relativeFactor, | ||
38 | (pos.y - screen.yOffset) * screen.relativeFactor) ; | 39 | (pos.y - screen.yOffset) * screen.relativeFactor) ; | ||
39 | } | 40 | } | ||
40 | 41 | | |||
41 | visible: model.enabled && model.replicationSourceIndex === 0 | 42 | visible: model.enabled && model.replicationSourceIndex === 0 | ||
43 | | ||||
42 | onVisibleChanged: screen.resetTotalSize() | 44 | onVisibleChanged: screen.resetTotalSize() | ||
45 | onOutputSizeChanged: screen.resetTotalSize() | ||||
43 | 46 | | |||
44 | x: model.position ? model.position.x / screen.relativeFactor + screen.xOffset : 0 | 47 | x: model.position ? model.position.x / screen.relativeFactor + screen.xOffset : 0 | ||
45 | y: model.position ? model.position.y / screen.relativeFactor + screen.yOffset : 0 | 48 | y: model.position ? model.position.y / screen.relativeFactor + screen.yOffset : 0 | ||
46 | 49 | | |||
47 | width: model.size ? model.size.width / screen.relativeFactor : 1 | 50 | width: model.size ? model.size.width / screen.relativeFactor : 1 | ||
48 | height: model.size ? model.size.height / screen.relativeFactor : 1 | 51 | height: model.size ? model.size.height / screen.relativeFactor : 1 | ||
49 | 52 | | |||
50 | SystemPalette { | 53 | SystemPalette { | ||
▲ Show 20 Lines • Show All 206 Lines • ▼ Show 20 Line(s) | 257 | DragHandler { | |||
257 | acceptedButtons: Qt.LeftButton | 260 | acceptedButtons: Qt.LeftButton | ||
258 | target: null | 261 | target: null | ||
259 | 262 | | |||
260 | onTranslationChanged: { | 263 | onTranslationChanged: { | ||
261 | var newX = dragStartPosition.x + translation.x; | 264 | var newX = dragStartPosition.x + translation.x; | ||
262 | var newY = dragStartPosition.y + translation.y; | 265 | var newY = dragStartPosition.y + translation.y; | ||
263 | model.position = getAbsolutePosition(Qt.point(newX, newY)); | 266 | model.position = getAbsolutePosition(Qt.point(newX, newY)); | ||
264 | } | 267 | } | ||
268 | onActiveChanged: { | ||||
269 | if (!active) { | ||||
270 | screen.resetTotalSize(); | ||||
271 | } | ||||
272 | } | ||||
265 | } | 273 | } | ||
266 | 274 | | |||
267 | // So we can show a grabby hand cursor when hovered over | 275 | // So we can show a grabby hand cursor when hovered over | ||
268 | MouseArea { | 276 | MouseArea { | ||
269 | anchors.fill: parent | 277 | anchors.fill: parent | ||
270 | cursorShape: Qt.SizeAllCursor | 278 | cursorShape: Qt.SizeAllCursor | ||
271 | acceptedButtons: Qt.NoButton // Otherwise it interferes with the drag handler | 279 | acceptedButtons: Qt.NoButton // Otherwise it interferes with the drag handler | ||
272 | visible: kcm.outputModel && kcm.outputModel.rowCount() > 1 | 280 | visible: kcm.outputModel && kcm.outputModel.rowCount() > 1 | ||
273 | } | 281 | } | ||
274 | } | 282 | } | ||
275 | 283 | |