Changeset View
Changeset View
Standalone View
Standalone View
kcm/package/contents/ui/Screen.qml
- This file was added.
1 | /******************************************************************** | ||||
---|---|---|---|---|---|
2 | Copyright © 2019 Roman Gilg <subdiff@gmail.com> | ||||
3 | | ||||
4 | This program is free software; you can redistribute it and/or modify | ||||
5 | it under the terms of the GNU General Public License as published by | ||||
6 | the Free Software Foundation; either version 2 of the License, or | ||||
7 | (at your option) any later version. | ||||
8 | | ||||
9 | This program is distributed in the hope that it will be useful, | ||||
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
12 | GNU General Public License for more details. | ||||
13 | | ||||
14 | You should have received a copy of the GNU General Public License | ||||
15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
16 | *********************************************************************/ | ||||
17 | import QtQuick 2.9 | ||||
18 | import QtQuick.Layouts 1.1 | ||||
19 | import QtQuick.Controls 2.3 as Controls | ||||
20 | | ||||
21 | Rectangle { | ||||
22 | property var outputs | ||||
23 | property size totalSize | ||||
24 | | ||||
25 | function resetTotalSize() { | ||||
26 | totalSize = kcm.normalizeScreen(); | ||||
27 | } | ||||
28 | | ||||
29 | onWidthChanged: resetTotalSize() | ||||
30 | onHeightChanged: resetTotalSize() | ||||
31 | | ||||
32 | property real relativeFactor: { | ||||
33 | var relativeSize = Qt.size(totalSize.width / (0.6 * width), | ||||
34 | totalSize.height / (0.6 * height)); | ||||
35 | if (relativeSize.width > relativeSize.height) { | ||||
36 | // Available width smaller than height, optimize for width (we have | ||||
37 | // '>' because the available width, height is in the denominator). | ||||
38 | return relativeSize.width; | ||||
39 | } else { | ||||
40 | return relativeSize.height; | ||||
41 | } | ||||
42 | } | ||||
43 | | ||||
44 | property int xOffset: (width - totalSize.width / relativeFactor) / 2; | ||||
45 | property int yOffset: (height - totalSize.height / relativeFactor) / 2; | ||||
46 | | ||||
47 | implicitHeight: root.height * 0.45 | ||||
48 | color: "white" | ||||
49 | clip: true | ||||
50 | | ||||
51 | Row { | ||||
52 | z: 90 | ||||
53 | anchors { | ||||
54 | bottom: parent.bottom | ||||
55 | horizontalCenter: parent.horizontalCenter | ||||
56 | margins: units.smallSpacing | ||||
57 | } | ||||
58 | spacing: units.smallSpacing | ||||
59 | Controls.Button { | ||||
60 | onClicked: kcm.identifyOutputs() | ||||
61 | text: i18n("Identify") | ||||
62 | focusPolicy: Qt.NoFocus | ||||
63 | } | ||||
64 | Controls.Button { | ||||
65 | enabled: !kcm.screenNormalized | ||||
66 | onClicked: resetTotalSize() | ||||
67 | text: i18n("Center view") | ||||
68 | focusPolicy: Qt.NoFocus | ||||
69 | } | ||||
70 | } | ||||
71 | | ||||
72 | Repeater { | ||||
73 | model: kcm.outputModel | ||||
74 | delegate: Output {} | ||||
75 | | ||||
76 | onCountChanged: resetTotalSize() | ||||
77 | } | ||||
78 | } |