Skip to content

Commit

Permalink
Improve Save button
Browse files Browse the repository at this point in the history
- Remove updated value dialog
- Enable Save button onTextChanged
- Add valueUpdated signal
- Add "saving" state to Save button
- Show saving process indicator
  • Loading branch information
mrnom authored and uglide committed Aug 7, 2020
1 parent 91e417b commit 85dd8b3
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/modules/value-editor/valueviewmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ void ValueEditor::ValueViewModel::updateRow(int rowIndex, const QVariantMap& row
return;
}
emit dataChanged(index(rowIndex, 0), index(rowIndex, m_model->getColumnNames().size() - 1));
emit valueUpdated();
});
}

Expand Down
1 change: 1 addition & 0 deletions src/modules/value-editor/valueviewmodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class ValueViewModel : public BaseListModel {
void singlePageModeChanged();
void modelLoaded();
void tabClosed();
void valueUpdated();

private:
QSharedPointer<Model> m_model;
Expand Down
46 changes: 34 additions & 12 deletions src/qml/value-editor/editors/MultilineEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,6 @@ Item
}
}


ColumnLayout {
anchors.fill: parent

Expand Down Expand Up @@ -437,8 +436,6 @@ Item

function saveChanges() {
if (!valueEditor.item || !valueEditor.item.isEdited()) {
savingConfirmation.text = qsTranslate("RDM","Nothing to save")
savingConfirmation.open()
return
}

Expand All @@ -447,20 +444,45 @@ Item
return;

var value = valueEditor.item.getValue()
saveBtnTimer.start()
keyTab.keyModel.updateRow(valueEditor.currentRow, value)
})
}

states: [
State {
name: "saving"

PropertyChanges {
target: saveBtn
iconSource: "qrc:/images/wait.svg"
enabled: false
}
}
]

Connections {
target: keyTab.keyModel

onValueUpdated: {
root.isEdited = false
saveBtnTimer.resetSaveBtn()
}

savingConfirmation.text = qsTranslate("RDM","Value was updated!")
savingConfirmation.open()
})
onError: saveBtnTimer.resetSaveBtn()
}

OkDialog {
id: savingConfirmation
title: qsTranslate("RDM","Save value")
text: ""
visible: false
Timer {
id: saveBtnTimer
interval: 500
repeat: true
triggeredOnStart: true
onTriggered: saveBtn.state = "saving"

function resetSaveBtn() {
saveBtnTimer.stop()
saveBtn.state = ""
}
}
}

Expand Down Expand Up @@ -518,7 +540,7 @@ Item
textFormat: textView.textFormat
readOnly: textView.readOnly

Keys.onReleased: {
onTextChanged: {
root.isEdited = true
textView.model && textView.model.setTextChunk(index, textAreaPart.text)
}
Expand Down

0 comments on commit 85dd8b3

Please sign in to comment.