Skip to content

Commit

Permalink
Fix shortcuts, update editor toolbar layout
Browse files Browse the repository at this point in the history
  • Loading branch information
mrnom authored and uglide committed Jun 23, 2020
1 parent 5eb53d0 commit 34e4592
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 112 deletions.
7 changes: 5 additions & 2 deletions src/qml/common/SaveToFileButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ import QtQuick.Layouts 1.1
ImageButton {
id: root
iconSource: "qrc:/images/document.svg"
tooltip: qsTranslate("RDM","Save to File")
tooltip: qsTranslate("RDM","Save to File") + " (" + shortcutText + ")"

property string fileUrl
property string folderUrl
property string path
property string shortcutText: ""


onClicked: {
onClicked: saveToFile()

function saveToFile() {
saveValueToFileDialog.open()
}

Expand Down
110 changes: 70 additions & 40 deletions src/qml/value-editor/editors/MultilineEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -358,53 +358,65 @@ Item
Layout.preferredWidth: isMultiRow ? 200 : 208
Layout.maximumWidth: isMultiRow ? 200 : 208

visible: showToolBar
visible: showToolBar

Item {
RowLayout {
Layout.fillWidth: true
}
Layout.preferredWidth: 98

ImageButton {
iconSource: "qrc:/images/add.svg"
implicitWidth: imgBtnWidth
implicitHeight: imgBtnHeight
imgWidth: imgBtnWidth
imgHeight: imgBtnHeight

ImageButton {
iconSource: "qrc:/images/add.svg"
implicitWidth: imgBtnWidth
implicitHeight: imgBtnHeight
imgWidth: imgBtnWidth
imgHeight: imgBtnHeight
Layout.alignment: Qt.AlignHCenter

tooltip: qsTranslate("RDM","Add Element to HLL");
visible: keyType === "hyperloglog"
tooltip: qsTranslate("RDM","Add Element to HLL");
visible: keyType === "hyperloglog"

onClicked: {
addRowDialog.open()
onClicked: {
addRowDialog.open()
}
}
}

ImageButton {
iconSource: "qrc:/images/copy.svg"
implicitWidth: imgBtnWidth
implicitHeight: imgBtnHeight
imgWidth: imgBtnWidth
imgHeight: imgBtnHeight
ImageButton {
id: copyValueToClipboardBtn
iconSource: "qrc:/images/copy.svg"
implicitWidth: imgBtnWidth
implicitHeight: imgBtnHeight
imgWidth: imgBtnWidth
imgHeight: imgBtnHeight

Layout.alignment: Qt.AlignHCenter

tooltip: qsTranslate("RDM","Copy to Clipboard")
enabled: root.value !== ""
tooltip: qsTranslate("RDM","Copy to Clipboard")
enabled: root.value !== ""

onClicked: {
if (textView.model) {
qmlUtils.copyToClipboard(textView.model.getText())
onClicked: copyValue()

function copyValue() {
console.log(textView.model)
if (textView.model) {
qmlUtils.copyToClipboard(textView.model.getText())
}
}
}
}

SaveToFileButton {
objectName: "rdm_save_value_to_file_btn"
SaveToFileButton {
id: saveAsBtn
objectName: "rdm_save_value_to_file_btn"

implicitWidth: imgBtnWidth
implicitHeight: imgBtnHeight
imgWidth: imgBtnWidth
imgHeight: imgBtnHeight
Layout.alignment: Qt.AlignHCenter

enabled: root.value !== ""
implicitWidth: imgBtnWidth
implicitHeight: imgBtnHeight
imgWidth: imgBtnWidth
imgHeight: imgBtnHeight

enabled: root.value !== ""
}
}

BetterButton {
Expand All @@ -415,11 +427,11 @@ Item
implicitWidth: isMultiRow ? 100 : 105

text: qsTranslate("RDM","Save")
tooltip: qsTranslate("RDM","Save Changes") + " (" + saveBtn.saveShortcut + ")"
tooltip: qsTranslate("RDM","Save Changes") + " (" + shortcutText + ")"
enabled: root.value !== "" && valueEditor.item.isEdited() && keyType != "stream"
visible: showSaveBtn

property string saveShortcut: PlatformUtils.isOSX()? "Meta+S" : "Ctrl+S"
property string shortcutText: ""

onClicked: saveChanges()

Expand Down Expand Up @@ -450,11 +462,6 @@ Item
text: ""
visible: false
}

Shortcut {
sequence: StandardKey.Save
onActivated: saveBtn.saveChanges()
}
}

Item {
Expand Down Expand Up @@ -515,6 +522,29 @@ Item
root.isEdited = true
textView.model && textView.model.setTextChunk(index, textAreaPart.text)
}

Keys.forwardTo: [saveShortcut, saveAsShortcut]

}

Shortcut {
id: saveShortcut
sequence: StandardKey.Save
onActivated: saveBtn.saveChanges()

Component.onCompleted: {
saveBtn.shortcutText = saveShortcut.nativeText
}
}

Shortcut {
id: saveAsShortcut
sequence: StandardKey.SaveAs
onActivated: saveAsBtn.saveToFile()

Component.onCompleted: {
saveAsBtn.shortcutText = saveAsShortcut.nativeText
}
}
}
}
Expand Down
28 changes: 14 additions & 14 deletions src/resources/translations/rdm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@
</message>
<message>
<location filename="../../qml/value-editor/ValueTabs.qml" line="575"/>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="374"/>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="376"/>
<source>Add Element to HLL</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -453,17 +453,17 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="428"/>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="440"/>
<source>Nothing to save</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="442"/>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="454"/>
<source>Value was updated!</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="449"/>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="461"/>
<source>Save value</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -855,8 +855,8 @@
<location filename="../../qml/ConnectionSettignsDialog.qml" line="555"/>
<location filename="../../qml/GlobalSettings.qml" line="217"/>
<location filename="../../qml/QuickStartDialog.qml" line="61"/>
<location filename="../../qml/common/SaveToFileButton.qml" line="105"/>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="538"/>
<location filename="../../qml/common/SaveToFileButton.qml" line="108"/>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="568"/>
<source>OK</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -1303,7 +1303,7 @@
<message>
<location filename="../../qml/common/BetterDialog.qml" line="25"/>
<location filename="../../qml/value-editor/AddKeyDialog.qml" line="68"/>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="417"/>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="429"/>
<source>Save</source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -1344,22 +1344,22 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="389"/>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="394"/>
<source>Copy to Clipboard</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="418"/>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="430"/>
<source>Save Changes</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="534"/>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="564"/>
<source>Binary value is too large to display</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="546"/>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="576"/>
<source>Save value to file: </source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -1460,17 +1460,17 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../qml/common/SaveToFileButton.qml" line="22"/>
<location filename="../../qml/common/SaveToFileButton.qml" line="25"/>
<source>Save Value</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../qml/common/SaveToFileButton.qml" line="41"/>
<location filename="../../qml/common/SaveToFileButton.qml" line="44"/>
<source>Save value to file</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../qml/common/SaveToFileButton.qml" line="62"/>
<location filename="../../qml/common/SaveToFileButton.qml" line="65"/>
<source>Value was saved to file:</source>
<translation type="unfinished"></translation>
</message>
Expand Down
28 changes: 14 additions & 14 deletions src/resources/translations/rdm_es_ES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@
</message>
<message>
<location filename="../../qml/value-editor/ValueTabs.qml" line="575"/>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="374"/>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="376"/>
<source>Add Element to HLL</source>
<translation>Añadir Elemento a HLL</translation>
</message>
Expand Down Expand Up @@ -503,17 +503,17 @@
<translation type="vanished">Buscar en Todos los valores</translation>
</message>
<message>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="428"/>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="440"/>
<source>Nothing to save</source>
<translation>Nada que gurdar</translation>
</message>
<message>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="442"/>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="454"/>
<source>Value was updated!</source>
<translation>¡Valor actualizado!</translation>
</message>
<message>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="449"/>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="461"/>
<source>Save value</source>
<translation>Guardar valor</translation>
</message>
Expand Down Expand Up @@ -963,8 +963,8 @@
<location filename="../../qml/ConnectionSettignsDialog.qml" line="555"/>
<location filename="../../qml/GlobalSettings.qml" line="217"/>
<location filename="../../qml/QuickStartDialog.qml" line="61"/>
<location filename="../../qml/common/SaveToFileButton.qml" line="105"/>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="538"/>
<location filename="../../qml/common/SaveToFileButton.qml" line="108"/>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="568"/>
<source>OK</source>
<translation>OK</translation>
</message>
Expand Down Expand Up @@ -1503,7 +1503,7 @@
<message>
<location filename="../../qml/common/BetterDialog.qml" line="25"/>
<location filename="../../qml/value-editor/AddKeyDialog.qml" line="68"/>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="417"/>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="429"/>
<source>Save</source>
<translation>Guardar</translation>
</message>
Expand Down Expand Up @@ -1548,22 +1548,22 @@
<translation> [Comprimido: </translation>
</message>
<message>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="389"/>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="394"/>
<source>Copy to Clipboard</source>
<translation>Copiar al Portapapeles</translation>
</message>
<message>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="418"/>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="430"/>
<source>Save Changes</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="534"/>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="564"/>
<source>Binary value is too large to display</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="546"/>
<location filename="../../qml/value-editor/editors/MultilineEditor.qml" line="576"/>
<source>Save value to file: </source>
<translation type="unfinished"></translation>
</message>
Expand Down Expand Up @@ -1672,17 +1672,17 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../qml/common/SaveToFileButton.qml" line="22"/>
<location filename="../../qml/common/SaveToFileButton.qml" line="25"/>
<source>Save Value</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../qml/common/SaveToFileButton.qml" line="41"/>
<location filename="../../qml/common/SaveToFileButton.qml" line="44"/>
<source>Save value to file</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../qml/common/SaveToFileButton.qml" line="62"/>
<location filename="../../qml/common/SaveToFileButton.qml" line="65"/>
<source>Value was saved to file:</source>
<translation type="unfinished"></translation>
</message>
Expand Down
Loading

0 comments on commit 34e4592

Please sign in to comment.