From 34e459228fa8bf3b7270d05398ba205ab0c51b69 Mon Sep 17 00:00:00 2001 From: Mrn Om Date: Tue, 23 Jun 2020 14:34:35 +0300 Subject: [PATCH] Fix shortcuts, update editor toolbar layout --- src/qml/common/SaveToFileButton.qml | 7 +- .../value-editor/editors/MultilineEditor.qml | 110 +++++++++++------- src/resources/translations/rdm.ts | 28 ++--- src/resources/translations/rdm_es_ES.ts | 28 ++--- src/resources/translations/rdm_ru_RU.ts | 28 ++--- src/resources/translations/rdm_zh_CN.ts | 28 ++--- src/resources/translations/rdm_zh_TW.ts | 28 ++--- 7 files changed, 145 insertions(+), 112 deletions(-) diff --git a/src/qml/common/SaveToFileButton.qml b/src/qml/common/SaveToFileButton.qml index 354c67d56..6f4f3058e 100644 --- a/src/qml/common/SaveToFileButton.qml +++ b/src/qml/common/SaveToFileButton.qml @@ -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() } diff --git a/src/qml/value-editor/editors/MultilineEditor.qml b/src/qml/value-editor/editors/MultilineEditor.qml index a4d9fc421..415c29386 100644 --- a/src/qml/value-editor/editors/MultilineEditor.qml +++ b/src/qml/value-editor/editors/MultilineEditor.qml @@ -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 { @@ -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() @@ -450,11 +462,6 @@ Item text: "" visible: false } - - Shortcut { - sequence: StandardKey.Save - onActivated: saveBtn.saveChanges() - } } Item { @@ -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 + } } } } diff --git a/src/resources/translations/rdm.ts b/src/resources/translations/rdm.ts index d8d8b8145..61cbd7c88 100644 --- a/src/resources/translations/rdm.ts +++ b/src/resources/translations/rdm.ts @@ -417,7 +417,7 @@ - + Add Element to HLL @@ -453,17 +453,17 @@ - + Nothing to save - + Value was updated! - + Save value @@ -855,8 +855,8 @@ - - + + OK @@ -1303,7 +1303,7 @@ - + Save @@ -1344,22 +1344,22 @@ - + Copy to Clipboard - + Save Changes - + Binary value is too large to display - + Save value to file: @@ -1460,17 +1460,17 @@ - + Save Value - + Save value to file - + Value was saved to file: diff --git a/src/resources/translations/rdm_es_ES.ts b/src/resources/translations/rdm_es_ES.ts index 0e29a0356..d7046f845 100644 --- a/src/resources/translations/rdm_es_ES.ts +++ b/src/resources/translations/rdm_es_ES.ts @@ -463,7 +463,7 @@ - + Add Element to HLL Añadir Elemento a HLL @@ -503,17 +503,17 @@ Buscar en Todos los valores - + Nothing to save Nada que gurdar - + Value was updated! ¡Valor actualizado! - + Save value Guardar valor @@ -963,8 +963,8 @@ - - + + OK OK @@ -1503,7 +1503,7 @@ - + Save Guardar @@ -1548,22 +1548,22 @@ [Comprimido: - + Copy to Clipboard Copiar al Portapapeles - + Save Changes - + Binary value is too large to display - + Save value to file: @@ -1672,17 +1672,17 @@ - + Save Value - + Save value to file - + Value was saved to file: diff --git a/src/resources/translations/rdm_ru_RU.ts b/src/resources/translations/rdm_ru_RU.ts index 8570443ed..37e55e71e 100644 --- a/src/resources/translations/rdm_ru_RU.ts +++ b/src/resources/translations/rdm_ru_RU.ts @@ -443,7 +443,7 @@ - + Add Element to HLL @@ -479,17 +479,17 @@ - + Nothing to save Нечего сохранять - + Value was updated! Значение обновлено! - + Save value Сохранить значение @@ -919,8 +919,8 @@ - - + + OK ОК @@ -1435,7 +1435,7 @@ - + Save Сохранить @@ -1480,22 +1480,22 @@ - + Copy to Clipboard Скопировать в буфер обмена - + Save Changes - + Binary value is too large to display - + Save value to file: @@ -1596,17 +1596,17 @@ - + Save Value - + Save value to file - + Value was saved to file: diff --git a/src/resources/translations/rdm_zh_CN.ts b/src/resources/translations/rdm_zh_CN.ts index a20a58f5b..edc8bdea7 100644 --- a/src/resources/translations/rdm_zh_CN.ts +++ b/src/resources/translations/rdm_zh_CN.ts @@ -463,7 +463,7 @@ - + Add Element to HLL 添加元素到HLL @@ -507,17 +507,17 @@ 在所有值中搜索 - + Nothing to save 不需要保存 - + Value was updated! 键值已经更新! - + Save value 保存键值 @@ -965,8 +965,8 @@ - - + + OK 确定 @@ -1497,7 +1497,7 @@ - + Save 保存 @@ -1542,22 +1542,22 @@ [压缩的: - + Copy to Clipboard 复制到剪切板 - + Save Changes - + Binary value is too large to display - + Save value to file: @@ -1666,17 +1666,17 @@ - + Save Value - + Save value to file - + Value was saved to file: diff --git a/src/resources/translations/rdm_zh_TW.ts b/src/resources/translations/rdm_zh_TW.ts index 2bfe2f275..b16caa4e0 100644 --- a/src/resources/translations/rdm_zh_TW.ts +++ b/src/resources/translations/rdm_zh_TW.ts @@ -463,7 +463,7 @@ - + Add Element to HLL 新增元素到 HHL @@ -507,17 +507,17 @@ 搜尋全部的鍵值 - + Nothing to save 不需要儲存 - + Value was updated! 鍵值已經更新! - + Save value 儲存鍵值 @@ -967,8 +967,8 @@ - - + + OK 確定 @@ -1499,7 +1499,7 @@ - + Save 儲存 @@ -1544,22 +1544,22 @@ [被壓縮的: - + Copy to Clipboard 複製到剪貼簿 - + Save Changes - + Binary value is too large to display - + Save value to file: @@ -1668,17 +1668,17 @@ - + Save Value - + Save value to file - + Value was saved to file: