From 90026028954c77d14b006ae768215fd0c07aafa2 Mon Sep 17 00:00:00 2001 From: Martchus Date: Tue, 5 Feb 2019 00:27:18 +0100 Subject: [PATCH] Quick GUI: Show buttons to copy when editing field --- CMakeLists.txt | 2 ++ qml/FieldsPage.qml | 53 +++++++++++++++++++++++++++++++++++----------- 2 files changed, 43 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4a043ae..9549109 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,6 +138,7 @@ set(REQUIRED_ICONS insert-text list-add list-remove + password-copy password-generate password-show-off password-show-on @@ -149,6 +150,7 @@ set(REQUIRED_ICONS system-file-manager system-run system-search + username-copy window-close ) diff --git a/qml/FieldsPage.qml b/qml/FieldsPage.qml index aaaa3e3..8c2f5cf 100644 --- a/qml/FieldsPage.qml +++ b/qml/FieldsPage.qml @@ -23,6 +23,7 @@ Kirigami.ScrollablePage { property alias isPassword: fieldIsPasswordCheckBox.checked title: qsTr("Edit field of %1").arg(nativeInterface.currentAccountName) standardButtons: Controls.Dialog.Ok | Controls.Dialog.Cancel + onAccepted: { var column0 = fieldsListView.model.index(entryIndex, 0) var column1 = fieldsListView.model.index(entryIndex, 1) @@ -33,19 +34,47 @@ Kirigami.ScrollablePage { } ColumnLayout { - Controls.TextField { - id: fieldNameEdit + GridLayout { Layout.preferredWidth: fieldDialog.availableWidth - text: fieldDialog.fieldName - Keys.onPressed: fieldDialog.acceptOnReturn(event) - } - Controls.TextField { - id: fieldValueEdit - Layout.preferredWidth: fieldDialog.availableWidth - text: fieldDialog.fieldValue - echoMode: fieldDialog.isPassword - && !showCharactersCheckBox.checked ? TextInput.PasswordEchoOnEdit : TextInput.Normal - Keys.onPressed: fieldDialog.acceptOnReturn(event) + columns: 2 + columnSpacing: 0 + + Controls.TextField { + id: fieldNameEdit + Layout.fillWidth: true + text: fieldDialog.fieldName + Keys.onPressed: fieldDialog.acceptOnReturn(event) + } + Controls.RoundButton { + flat: true + icon.name: "username-copy" + Layout.preferredWidth: height + onClicked: { + nativeInterface.copyToClipboard(fieldNameEdit.text) + showPassiveNotification(qsTr("Copied field name")) + } + } + Controls.TextField { + id: fieldValueEdit + property bool hideCharacters: fieldDialog.isPassword + && !showCharactersCheckBox.checked + + Layout.fillWidth: true + text: fieldDialog.fieldValue + echoMode: hideCharacters ? TextInput.PasswordEchoOnEdit : TextInput.Normal + Keys.onPressed: fieldDialog.acceptOnReturn(event) + } + Controls.RoundButton { + flat: true + icon.name: "password-copy" + Layout.preferredWidth: height + onClicked: { + nativeInterface.copyToClipboard(fieldValueEdit.text) + showPassiveNotification( + fieldDialog.isPassword ? qsTr("Copied password") : qsTr( + "Copied value")) + } + } } RowLayout { Layout.preferredWidth: fieldDialog.availableWidth