Changeset View
Changeset View
Standalone View
Standalone View
kcm/package/contents/ui/main.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 | import org.kde.kirigami 2.4 as Kirigami | ||||
21 | | ||||
22 | import org.kde.kcm 1.2 as KCM | ||||
23 | | ||||
24 | KCM.SimpleKCM { | ||||
25 | id: root | ||||
26 | | ||||
27 | implicitWidth: units.gridUnit * 40 | ||||
28 | implicitHeight: units.gridUnit * 50 | ||||
29 | | ||||
30 | property int selectedOutput: 0 | ||||
31 | | ||||
32 | ColumnLayout { | ||||
33 | Kirigami.InlineMessage { | ||||
34 | // Note1: There is an implicit height binding loop error on | ||||
35 | // first invokation. Seems to be an issue in Kirigami. | ||||
36 | // Note2: This should maybe go in header component of the KCM, | ||||
37 | // but there seems to be another issue in Kirigami then | ||||
38 | // being always hidden. Compare Night Color KCM with | ||||
39 | // the same issue. | ||||
40 | id: dangerousSaveMsg | ||||
41 | | ||||
42 | Layout.fillWidth: true | ||||
43 | type: Kirigami.MessageType.Warning | ||||
44 | text: i18n("Are you sure you want to disable all outputs? " + | ||||
45 | "This might render the device unusable.") | ||||
46 | showCloseButton: true | ||||
47 | | ||||
48 | actions: [ | ||||
49 | Kirigami.Action { | ||||
50 | iconName: "dialog-ok" | ||||
51 | text: i18n("Disable all outputs") | ||||
52 | onTriggered: { | ||||
53 | dangerousSaveMsg.visible = false; | ||||
54 | kcm.forceSave(); | ||||
55 | } | ||||
56 | } | ||||
57 | ] | ||||
58 | } | ||||
59 | Kirigami.InlineMessage { | ||||
60 | id: errBackendMsg | ||||
61 | Layout.fillWidth: true | ||||
62 | type: Kirigami.MessageType.Error | ||||
63 | text: i18n("No KScreen backend found. Please check your KScreen installation.") | ||||
64 | visible: false | ||||
65 | showCloseButton: false | ||||
66 | } | ||||
67 | Kirigami.InlineMessage { | ||||
68 | id: errSaveMsg | ||||
69 | Layout.fillWidth: true | ||||
70 | type: Kirigami.MessageType.Error | ||||
71 | text: i18n("Outputs could not be saved due to error.") | ||||
72 | visible: false | ||||
73 | showCloseButton: true | ||||
74 | } | ||||
75 | Kirigami.InlineMessage { | ||||
76 | id: scaleMsg | ||||
77 | Layout.fillWidth: true | ||||
78 | type: Kirigami.MessageType.Positive | ||||
79 | text: i18n("New global scale applied. " + | ||||
80 | "Change will come into effect after restart.") | ||||
81 | visible: false | ||||
82 | showCloseButton: true | ||||
83 | } | ||||
84 | Kirigami.InlineMessage { | ||||
85 | id: connectMsg | ||||
86 | Layout.fillWidth: true | ||||
87 | type: Kirigami.MessageType.Information | ||||
88 | visible: false | ||||
89 | showCloseButton: true | ||||
90 | } | ||||
91 | | ||||
92 | Connections { | ||||
93 | target: kcm | ||||
94 | onDangerousSave: dangerousSaveMsg.visible = true; | ||||
95 | onErrorOnSave: errSaveMsg.visible = true; | ||||
96 | onGlobalScaleWritten: scaleMsg.visible = true; | ||||
97 | onOutputConnect: { | ||||
98 | if (connected) { | ||||
99 | connectMsg.text = i18n("A new output has been added. " + | ||||
100 | " Settings have been reloaded."); | ||||
101 | } else { | ||||
102 | connectMsg.text = i18n("An output has been removed. " + | ||||
103 | " Settings have been reloaded."); | ||||
104 | } | ||||
105 | connectMsg.visible = true; | ||||
106 | } | ||||
107 | onBackendErrorChanged: errBackendMsg.visible = kcm.backendError | ||||
108 | | ||||
109 | onChanged: { | ||||
110 | dangerousSaveMsg.visible = false; | ||||
111 | errSaveMsg.visible = false; | ||||
112 | scaleMsg.visible = false; | ||||
113 | } | ||||
114 | } | ||||
115 | | ||||
116 | Screen { | ||||
117 | id: screen | ||||
118 | Layout.fillWidth: true | ||||
119 | enabled: kcm.outputModel && !kcm.backendError | ||||
120 | outputs: kcm.outputModel | ||||
121 | } | ||||
122 | | ||||
123 | Panel { | ||||
124 | enabled: kcm.outputModel && !kcm.backendError | ||||
125 | Layout.fillWidth: true | ||||
126 | } | ||||
127 | } | ||||
128 | } |