Skip to content

Commit 72a88fa

Browse files
Remove 1 sec settings write, add deselect[CPP-597] (#380)
* Remove 1 sec settings write, add deselect[CPP-597]
1 parent 451156c commit 72a88fa

File tree

2 files changed

+150
-154
lines changed

2 files changed

+150
-154
lines changed

resources/SettingsTab.qml

Lines changed: 138 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -168,141 +168,156 @@ MainTab {
168168
SplitView.minimumWidth: parent.width * 0.55
169169
spacing: 0
170170

171-
GridLayout {
172-
property int colWidth: Math.max(Constants.settingsTab.buttonIconWidth, ((parent.width / (columns)) - columnSpacing * (columns)))
173-
property int buttonPadding: 3
174-
171+
Item {
175172
Layout.fillWidth: true
176-
rowSpacing: 0
177-
columnSpacing: 2
178-
columns: 5
179-
rows: 2
180-
enabled: settingsTable.settingsHealthy
181-
182-
SwiftButton {
183-
Layout.columnSpan: 1
184-
Layout.rowSpan: 1
185-
Layout.preferredWidth: parent.colWidth
186-
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
187-
padding: parent.buttonPadding
188-
text: "Save to\nDevice"
189-
icon.source: Constants.icons.savePath
190-
icon.width: Constants.settingsTab.buttonIconWidth
191-
icon.height: Constants.settingsTab.buttonIconHeight
192-
display: AbstractButton.TextUnderIcon
193-
flat: true
194-
onClicked: data_model.settings_save_request()
195-
}
173+
Layout.preferredHeight: grid.implicitHeight
196174

197-
SwiftButton {
198-
Layout.columnSpan: 1
199-
Layout.rowSpan: 1
200-
Layout.preferredWidth: parent.colWidth
201-
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
202-
padding: parent.buttonPadding
203-
text: "Export to\nfile"
204-
icon.source: Constants.icons.exportPath
205-
icon.width: Constants.settingsTab.buttonIconWidth
206-
icon.height: Constants.settingsTab.buttonIconHeight
207-
display: AbstractButton.TextUnderIcon
208-
flat: true
209-
onClicked: exportDialog.visible = true
175+
MouseArea {
176+
anchors.fill: parent
177+
onClicked: saveButton.forceActiveFocus()
210178
}
211179

212-
SwiftButton {
213-
Layout.columnSpan: 1
214-
Layout.rowSpan: 1
215-
Layout.preferredWidth: parent.colWidth
216-
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
217-
padding: parent.buttonPadding
218-
text: "Import from\nFile"
219-
icon.source: Constants.icons.importPath
220-
icon.width: Constants.settingsTab.buttonIconWidth
221-
icon.height: Constants.settingsTab.buttonIconHeight
222-
display: AbstractButton.TextUnderIcon
223-
flat: true
224-
onClicked: importDialog.visible = true
225-
}
180+
GridLayout {
181+
id: grid
182+
183+
property int colWidth: Math.max(Constants.settingsTab.buttonIconWidth, ((parent.width / (columns)) - columnSpacing * (columns)))
184+
property int buttonPadding: 3
185+
186+
anchors.fill: parent
187+
rowSpacing: 0
188+
columnSpacing: 2
189+
columns: 5
190+
rows: 2
191+
enabled: settingsTable.settingsHealthy
192+
193+
SwiftButton {
194+
id: saveButton
195+
196+
Layout.columnSpan: 1
197+
Layout.rowSpan: 1
198+
Layout.preferredWidth: parent.colWidth
199+
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
200+
padding: parent.buttonPadding
201+
text: "Save to\nDevice"
202+
icon.source: Constants.icons.savePath
203+
icon.width: Constants.settingsTab.buttonIconWidth
204+
icon.height: Constants.settingsTab.buttonIconHeight
205+
display: AbstractButton.TextUnderIcon
206+
flat: true
207+
onClicked: data_model.settings_save_request()
208+
}
226209

227-
SwiftButton {
228-
Layout.columnSpan: 1
229-
Layout.rowSpan: 1
230-
Layout.preferredWidth: parent.colWidth
231-
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
232-
padding: parent.buttonPadding
233-
text: "Reset to\nDefaults"
234-
icon.source: Constants.icons.warningPath
235-
icon.width: Constants.settingsTab.buttonIconWidth
236-
icon.height: Constants.settingsTab.buttonIconHeight
237-
display: AbstractButton.TextUnderIcon
238-
flat: true
239-
onClicked: resetDialog.visible = true
240-
}
210+
SwiftButton {
211+
Layout.columnSpan: 1
212+
Layout.rowSpan: 1
213+
Layout.preferredWidth: parent.colWidth
214+
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
215+
padding: parent.buttonPadding
216+
text: "Export to\nfile"
217+
icon.source: Constants.icons.exportPath
218+
icon.width: Constants.settingsTab.buttonIconWidth
219+
icon.height: Constants.settingsTab.buttonIconHeight
220+
display: AbstractButton.TextUnderIcon
221+
flat: true
222+
onClicked: exportDialog.visible = true
223+
}
224+
225+
SwiftButton {
226+
Layout.columnSpan: 1
227+
Layout.rowSpan: 1
228+
Layout.preferredWidth: parent.colWidth
229+
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
230+
padding: parent.buttonPadding
231+
text: "Import from\nFile"
232+
icon.source: Constants.icons.importPath
233+
icon.width: Constants.settingsTab.buttonIconWidth
234+
icon.height: Constants.settingsTab.buttonIconHeight
235+
display: AbstractButton.TextUnderIcon
236+
flat: true
237+
onClicked: importDialog.visible = true
238+
}
239+
240+
SwiftButton {
241+
Layout.columnSpan: 1
242+
Layout.rowSpan: 1
243+
Layout.preferredWidth: parent.colWidth
244+
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
245+
padding: parent.buttonPadding
246+
text: "Reset to\nDefaults"
247+
icon.source: Constants.icons.warningPath
248+
icon.width: Constants.settingsTab.buttonIconWidth
249+
icon.height: Constants.settingsTab.buttonIconHeight
250+
display: AbstractButton.TextUnderIcon
251+
flat: true
252+
onClicked: resetDialog.visible = true
253+
}
241254

242-
SwiftButton {
243-
id: autoSurveyButton
244-
245-
property bool buttonEnabled: (selectedRowField("group") === "surveyed_position")
246-
247-
Layout.columnSpan: 1
248-
Layout.rowSpan: 1
249-
Layout.preferredWidth: parent.colWidth
250-
Layout.preferredHeight: refreshButton.height
251-
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
252-
ToolTip.text: "Select element under \'surveyed_position\' group to enable."
253-
ToolTip.visible: !buttonEnabled && hovered
254-
background.visible: buttonEnabled
255-
padding: parent.buttonPadding
256-
text: "Auto Survey\n"
257-
opacity: buttonEnabled ? 1 : 0.5
258-
icon.source: Constants.icons.centerOnButtonUrl
259-
icon.width: Constants.settingsTab.buttonIconWidth
260-
icon.height: Constants.settingsTab.buttonIconHeight
261-
display: AbstractButton.TextUnderIcon
262-
flat: true
263-
onClicked: {
264-
if (buttonEnabled)
265-
autoSurveyDialog.visible = true;
255+
SwiftButton {
256+
id: autoSurveyButton
257+
258+
property bool buttonEnabled: (selectedRowField("group") === "surveyed_position")
259+
260+
Layout.columnSpan: 1
261+
Layout.rowSpan: 1
262+
Layout.preferredWidth: parent.colWidth
263+
Layout.preferredHeight: refreshButton.height
264+
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
265+
ToolTip.text: "Select element under \'surveyed_position\' group to enable."
266+
ToolTip.visible: !buttonEnabled && hovered
267+
background.visible: buttonEnabled
268+
padding: parent.buttonPadding
269+
text: "Auto Survey\n"
270+
opacity: buttonEnabled ? 1 : 0.5
271+
icon.source: Constants.icons.centerOnButtonUrl
272+
icon.width: Constants.settingsTab.buttonIconWidth
273+
icon.height: Constants.settingsTab.buttonIconHeight
274+
display: AbstractButton.TextUnderIcon
275+
flat: true
276+
onClicked: {
277+
if (buttonEnabled)
278+
autoSurveyDialog.visible = true;
266279

280+
}
267281
}
268-
}
269282

270-
SwiftButton {
271-
id: refreshButton
272-
273-
Layout.columnSpan: 1
274-
Layout.rowSpan: 1
275-
Layout.preferredWidth: parent.colWidth
276-
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
277-
padding: parent.buttonPadding
278-
text: "Refresh from\ndevice"
279-
icon.source: Constants.icons.refreshPath
280-
icon.width: Constants.settingsTab.buttonIconWidth
281-
icon.height: Constants.settingsTab.buttonIconHeight
282-
display: AbstractButton.TextUnderIcon
283-
flat: true
284-
onClicked: data_model.settings_refresh()
285-
}
283+
SwiftButton {
284+
id: refreshButton
285+
286+
Layout.columnSpan: 1
287+
Layout.rowSpan: 1
288+
Layout.preferredWidth: parent.colWidth
289+
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
290+
padding: parent.buttonPadding
291+
text: "Refresh from\ndevice"
292+
icon.source: Constants.icons.refreshPath
293+
icon.width: Constants.settingsTab.buttonIconWidth
294+
icon.height: Constants.settingsTab.buttonIconHeight
295+
display: AbstractButton.TextUnderIcon
296+
flat: true
297+
onClicked: data_model.settings_refresh()
298+
}
286299

287-
SmallCheckBox {
288-
Layout.columnSpan: 1
289-
Layout.rowSpan: 1
290-
Layout.preferredWidth: parent.colWidth
291-
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
292-
padding: parent.buttonPadding
293-
bottomPadding: refreshButton.bottomPadding
294-
text: "SHOW ADVANCED SETTINGS"
295-
font.pointSize: refreshButton.font.pointSize
296-
font.family: Constants.fontFamily
297-
font.bold: false
298-
onClicked: {
299-
if (this.enabled) {
300-
this.enabled = false;
301-
settingsTable.showExpert = checked;
302-
settingsTable.selectedRowIdx = -1;
303-
this.enabled = true;
300+
SmallCheckBox {
301+
Layout.columnSpan: 1
302+
Layout.rowSpan: 1
303+
Layout.preferredWidth: parent.colWidth
304+
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
305+
padding: parent.buttonPadding
306+
bottomPadding: refreshButton.bottomPadding
307+
text: "SHOW ADVANCED SETTINGS"
308+
font.pointSize: refreshButton.font.pointSize
309+
font.family: Constants.fontFamily
310+
font.bold: false
311+
onClicked: {
312+
if (this.enabled) {
313+
this.enabled = false;
314+
settingsTable.showExpert = checked;
315+
settingsTable.selectedRowIdx = -1;
316+
this.enabled = true;
317+
}
304318
}
305319
}
320+
306321
}
307322

308323
}

resources/SettingsTabComponents/SettingsPane.qml

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,12 @@ Rectangle {
291291
text: _title + ":"
292292
font.bold: true
293293
horizontalAlignment: Text.AlignRight
294+
295+
MouseArea {
296+
anchors.fill: parent
297+
onClicked: parent.forceActiveFocus()
298+
}
299+
294300
}
295301

296302
}
@@ -305,35 +311,16 @@ Rectangle {
305311
text: selectedRowField(_fieldName)
306312
anchors.fill: parent
307313
wrapMode: Text.WordWrap
308-
}
309-
310-
}
311314

312-
}
313-
314-
Timer {
315-
id: textFieldTimer
316-
317-
property string settingGroup: ""
318-
property string settingName: ""
319-
property string settingText: ""
315+
MouseArea {
316+
anchors.fill: parent
317+
onClicked: parent.forceActiveFocus()
318+
}
320319

321-
function startTimer(group, name, text) {
322-
textFieldTimer.stop();
323-
if (text === "")
324-
return ;
320+
}
325321

326-
settingGroup = group;
327-
settingName = name;
328-
settingText = text;
329-
textFieldTimer.start();
330322
}
331323

332-
interval: Constants.settingsTable.settingEditTimeoutMilliseconds
333-
repeat: false
334-
onTriggered: {
335-
data_model.settings_write_request(settingGroup, settingName, settingText);
336-
}
337324
}
338325

339326
Component {
@@ -355,14 +342,8 @@ Rectangle {
355342
selectByMouse: true
356343
anchors.centerIn: parent
357344
anchors.verticalCenterOffset: 5
358-
onTextChanged: {
359-
textFieldTimer.startTimer(settingGroup, settingName, text);
360-
}
361345
onEditingFinished: {
362-
if (textFieldTimer.running) {
363-
textFieldTimer.stop();
364-
data_model.settings_write_request(settingGroup, settingName, text);
365-
}
346+
data_model.settings_write_request(settingGroup, settingName, text);
366347
}
367348
validator: {
368349
if (settingType === "integer")

0 commit comments

Comments
 (0)