Changeset View
Changeset View
Standalone View
Standalone View
kcm/package/contents/ui/main.qml
Show All 11 Lines | |||||
12 | GNU General Public License for more details. | 12 | GNU General Public License for more details. | ||
13 | 13 | | |||
14 | You should have received a copy of the GNU General Public License | 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/>. | 15 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | *********************************************************************/ | 16 | *********************************************************************/ | ||
17 | import QtQuick 2.9 | 17 | import QtQuick 2.9 | ||
18 | import QtQuick.Layouts 1.1 | 18 | import QtQuick.Layouts 1.1 | ||
19 | import QtQuick.Controls 2.3 as Controls | 19 | import QtQuick.Controls 2.3 as Controls | ||
20 | import QtQuick.Dialogs 1.3 | ||||
20 | import org.kde.kirigami 2.4 as Kirigami | 21 | import org.kde.kirigami 2.4 as Kirigami | ||
21 | 22 | | |||
22 | import org.kde.kcm 1.2 as KCM | 23 | import org.kde.kcm 1.2 as KCM | ||
23 | 24 | | |||
24 | KCM.SimpleKCM { | 25 | KCM.SimpleKCM { | ||
25 | id: root | 26 | id: root | ||
26 | 27 | | |||
27 | implicitWidth: units.gridUnit * 32 | 28 | implicitWidth: units.gridUnit * 32 | ||
28 | implicitHeight: units.gridUnit * 38 | 29 | implicitHeight: units.gridUnit * 38 | ||
29 | 30 | | |||
30 | property int selectedOutput: 0 | 31 | property int selectedOutput: 0 | ||
32 | property int revertCountdown: 10 | ||||
ngraham: Doesn't seem to be used; the timer duration is hardcoded on the C++ side | |||||
liushuyu: Now, it's used by the Timer | |||||
31 | 33 | | |||
32 | ColumnLayout { | 34 | ColumnLayout { | ||
33 | Kirigami.InlineMessage { | 35 | Kirigami.InlineMessage { | ||
34 | // Note1: There is an implicit height binding loop error on | 36 | // Note1: There is an implicit height binding loop error on | ||
35 | // first invokation. Seems to be an issue in Kirigami. | 37 | // first invokation. Seems to be an issue in Kirigami. | ||
36 | // Note2: This should maybe go in header component of the KCM, | 38 | // Note2: This should maybe go in header component of the KCM, | ||
37 | // but there seems to be another issue in Kirigami then | 39 | // but there seems to be another issue in Kirigami then | ||
38 | // being always hidden. Compare Night Color KCM with | 40 | // being always hidden. Compare Night Color KCM with | ||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | |||||
81 | } | 83 | } | ||
82 | Kirigami.InlineMessage { | 84 | Kirigami.InlineMessage { | ||
83 | id: connectMsg | 85 | id: connectMsg | ||
84 | Layout.fillWidth: true | 86 | Layout.fillWidth: true | ||
85 | type: Kirigami.MessageType.Information | 87 | type: Kirigami.MessageType.Information | ||
86 | visible: false | 88 | visible: false | ||
87 | showCloseButton: true | 89 | showCloseButton: true | ||
88 | } | 90 | } | ||
91 | Kirigami.InlineMessage { | ||||
92 | id: revertMsg | ||||
93 | Layout.fillWidth: true | ||||
94 | type: Kirigami.MessageType.Information | ||||
95 | text: i18n("Settings are reverted to the previous state.") | ||||
96 | visible: false | ||||
97 | showCloseButton: true | ||||
98 | } | ||||
99 | Kirigami.InlineMessage { | ||||
100 | id: confirmMsg | ||||
101 | Layout.fillWidth: true | ||||
102 | type: Kirigami.MessageType.Warning | ||||
103 | visible: false | ||||
104 | showCloseButton: false | ||||
105 | | ||||
106 | actions: [ | ||||
107 | Kirigami.Action { | ||||
108 | iconName: "edit-undo" | ||||
109 | text: i18n("Undo") | ||||
Since you are keeping the recently applied configuration rather than applying a new one, wouldn't it be better to say something like "Keep"? It would also be better to use dialog-ok-apply as the icon for consistency with similar controls. ndavis: Since you are keeping the recently applied configuration rather than applying a new one… | |||||
liushuyu: Will do | |||||
110 | onTriggered: { | ||||
ngraham: I would change these to `StandardButton.Apply` and `StandardButton.Discard` | |||||
liushuyu: Now InlineMessage is used | |||||
111 | confirmMsg.visible = false; | ||||
112 | kcm.revertSettings(); | ||||
113 | revertTimer.stop(); | ||||
114 | } | ||||
115 | }, | ||||
I would put Undo to the left of Keep/Apply. Normally, Undo/Reset is to the far left of Apply. That can't be the case here, but I think preserving the order is better for muscle memory. ndavis: I would put Undo to the left of Keep/Apply. Normally, Undo/Reset is to the far left of Apply. | |||||
liushuyu: I will address this | |||||
116 | Kirigami.Action { | ||||
117 | iconName: "dialog-ok-apply" | ||||
118 | text: i18n("Keep") | ||||
119 | onTriggered: { | ||||
120 | confirmMsg.visible = false; | ||||
121 | revertTimer.stop(); | ||||
122 | } | ||||
123 | } | ||||
124 | ] | ||||
125 | } | ||||
89 | 126 | | |||
90 | Connections { | 127 | Connections { | ||
91 | target: kcm | 128 | target: kcm | ||
92 | onDangerousSave: dangerousSaveMsg.visible = true; | 129 | onDangerousSave: dangerousSaveMsg.visible = true; | ||
93 | onErrorOnSave: errSaveMsg.visible = true; | 130 | onErrorOnSave: errSaveMsg.visible = true; | ||
94 | onGlobalScaleWritten: scaleMsg.visible = true; | 131 | onGlobalScaleWritten: scaleMsg.visible = true; | ||
95 | onOutputConnect: { | 132 | onOutputConnect: { | ||
96 | if (connected) { | 133 | if (connected) { | ||
97 | connectMsg.text = i18n("A new output has been added. Settings have been reloaded."); | 134 | connectMsg.text = i18n("A new output has been added. Settings have been reloaded."); | ||
98 | } else { | 135 | } else { | ||
99 | connectMsg.text = i18n("An output has been removed. Settings have been reloaded."); | 136 | connectMsg.text = i18n("An output has been removed. Settings have been reloaded."); | ||
100 | } | 137 | } | ||
101 | connectMsg.visible = true; | 138 | connectMsg.visible = true; | ||
102 | } | 139 | } | ||
103 | onBackendError: errBackendMsg.visible = true; | 140 | onBackendError: errBackendMsg.visible = true; | ||
141 | onSettingsReverted: { | ||||
142 | revertMsg.visible = true; | ||||
143 | confirmMsg.visible = false; | ||||
144 | } | ||||
145 | onShowRevertWarning: { | ||||
146 | confirmMsg.text = i18n("Is your screen displaying correctly?") | ||||
147 | confirmMsg.visible = true; | ||||
148 | revertCountdown = 10; | ||||
149 | revertTimer.restart(); | ||||
150 | } | ||||
104 | 151 | | |||
105 | onChanged: { | 152 | onChanged: { | ||
106 | dangerousSaveMsg.visible = false; | 153 | dangerousSaveMsg.visible = false; | ||
107 | errSaveMsg.visible = false; | 154 | errSaveMsg.visible = false; | ||
108 | scaleMsg.visible = false; | 155 | scaleMsg.visible = false; | ||
109 | } | 156 | } | ||
110 | } | 157 | } | ||
111 | 158 | | |||
112 | Screen { | 159 | Screen { | ||
113 | id: screen | 160 | id: screen | ||
114 | 161 | | |||
115 | Layout.alignment: Qt.AlignHCenter | 162 | Layout.alignment: Qt.AlignHCenter | ||
116 | Layout.preferredWidth: Math.max(root.width * 0.8, units.gridUnit * 26) | 163 | Layout.preferredWidth: Math.max(root.width * 0.8, units.gridUnit * 26) | ||
117 | Layout.topMargin: Kirigami.Units.smallSpacing | 164 | Layout.topMargin: Kirigami.Units.smallSpacing | ||
118 | Layout.bottomMargin: Kirigami.Units.largeSpacing * 2 | 165 | Layout.bottomMargin: Kirigami.Units.largeSpacing * 2 | ||
119 | 166 | | |||
120 | enabled: kcm.outputModel && kcm.backendReady | 167 | enabled: kcm.outputModel && kcm.backendReady | ||
121 | outputs: kcm.outputModel | 168 | outputs: kcm.outputModel | ||
122 | } | 169 | } | ||
123 | 170 | | |||
124 | Panel { | 171 | Panel { | ||
125 | enabled: kcm.outputModel && kcm.backendReady | 172 | enabled: kcm.outputModel && kcm.backendReady | ||
126 | Layout.fillWidth: true | 173 | Layout.fillWidth: true | ||
127 | } | 174 | } | ||
175 | | ||||
176 | Timer { | ||||
177 | id: revertTimer | ||||
178 | interval: 1000 | ||||
179 | running: false | ||||
180 | repeat: true | ||||
181 | | ||||
182 | onTriggered: { | ||||
183 | if (revertCountdown < 1) { | ||||
184 | // stop the timer | ||||
185 | this.stop(); | ||||
186 | // reset the settings | ||||
187 | kcm.revertSettings(); | ||||
188 | return; | ||||
189 | } | ||||
190 | revertCountdown -= 1; | ||||
191 | confirmMsg.text = i18np("Is your screen displaying correctly?<br><strong>Settings will be reverted in 1 second</strong>.", | ||||
192 | "Is your screen displaying correctly?<br><strong>Settings will be reverted in %1 seconds</strong>.", revertCountdown); | ||||
193 | } | ||||
194 | } | ||||
128 | } | 195 | } | ||
129 | } | 196 | } |
Doesn't seem to be used; the timer duration is hardcoded on the C++ side