aboutsummaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorxiphon <xiphon@protonmail.com>2019-11-08 00:56:10 +0000
committerxiphon <xiphon@protonmail.com>2019-11-08 12:41:32 +0000
commit74e12ce71d00e7e9aea43a985e8a9dbfc4ad0844 (patch)
tree917f48165df3aabf85a1e82211f6ad1668213c18 /components
parent7f7a39292c57f9b51090005d8a8e39297d988e0b (diff)
downloadmonzero-gui-74e12ce71d00e7e9aea43a985e8a9dbfc4ad0844.tar.gz
monzero-gui-74e12ce71d00e7e9aea43a985e8a9dbfc4ad0844.tar.xz
monzero-gui-74e12ce71d00e7e9aea43a985e8a9dbfc4ad0844.zip
ContextMenu: implement 'paste' context menu for all text fields
Diffstat (limited to 'components')
-rw-r--r--components/ContextMenu.qml43
-rw-r--r--components/Input.qml8
-rw-r--r--components/InputDialog.qml2
-rw-r--r--components/InputMulti.qml11
-rw-r--r--components/LineEditMulti.qml8
-rw-r--r--components/PasswordDialog.qml4
6 files changed, 69 insertions, 7 deletions
diff --git a/components/ContextMenu.qml b/components/ContextMenu.qml
new file mode 100644
index 00000000..58442e8d
--- /dev/null
+++ b/components/ContextMenu.qml
@@ -0,0 +1,43 @@
+import QtQuick.Controls 2.2
+import QtQuick 2.9
+
+import "../components" as MoneroComponents
+
+MouseArea {
+ signal paste()
+
+ id: root
+ acceptedButtons: Qt.RightButton
+ anchors.fill: parent
+ onClicked: {
+ if (mouse.button === Qt.RightButton)
+ contextMenu.open()
+ }
+
+ Menu {
+ id: contextMenu
+
+ background: Rectangle {
+ radius: 2
+ color: MoneroComponents.Style.buttonInlineBackgroundColor
+ }
+
+ font.family: MoneroComponents.Style.fontRegular.name
+ font.pixelSize: 14
+ width: 50
+ x: root.mouseX
+ y: root.mouseY
+
+ MenuItem {
+ id: pasteItem
+ background: Rectangle {
+ radius: 2
+ color: MoneroComponents.Style.buttonBackgroundColorDisabledHover
+ opacity: pasteItem.down ? 1 : 0
+ }
+ enabled: root.parent.canPaste
+ onTriggered: root.paste()
+ text: qsTr("Paste") + translationManager.emptyString
+ }
+ }
+}
diff --git a/components/Input.qml b/components/Input.qml
index 752b461d..3ac9a532 100644
--- a/components/Input.qml
+++ b/components/Input.qml
@@ -32,6 +32,7 @@ import QtQuick 2.9
import "../components" as MoneroComponents
TextField {
+ id: textField
font.family: MoneroComponents.Style.fontRegular.name
font.pixelSize: 18
font.bold: true
@@ -44,4 +45,11 @@ TextField {
background: Rectangle {
color: "transparent"
}
+
+ MoneroComponents.ContextMenu {
+ onPaste: {
+ textField.clear();
+ textField.paste();
+ }
+ }
}
diff --git a/components/InputDialog.qml b/components/InputDialog.qml
index 01d1e2c5..c5963f04 100644
--- a/components/InputDialog.qml
+++ b/components/InputDialog.qml
@@ -86,7 +86,7 @@ Item {
color: MoneroComponents.Style.defaultFontColor
}
- TextField {
+ MoneroComponents.Input {
id : input
focus: true
Layout.topMargin: 6
diff --git a/components/InputMulti.qml b/components/InputMulti.qml
index 891bdc4f..8fccb6a6 100644
--- a/components/InputMulti.qml
+++ b/components/InputMulti.qml
@@ -57,6 +57,10 @@ TextArea {
onTextChanged: {
if(addressValidation){
// js replacement for `RegExpValidator { regExp: /[0-9A-Fa-f]{95}/g }`
+ if (textArea.text.startsWith("monero:")) {
+ error = false;
+ return;
+ }
textArea.text = textArea.text.replace(/[^a-z0-9.@\-]/gi,'');
var address_ok = TxUtils.checkAddress(textArea.text, appWindow.persistentSettings.nettype) || TxUtils.isValidOpenAliasAddress(textArea.text);
if(!address_ok) error = true;
@@ -64,4 +68,11 @@ TextArea {
TextArea.cursorPosition = textArea.text.length;
}
}
+
+ MoneroComponents.ContextMenu {
+ onPaste: {
+ textArea.clear();
+ textArea.paste();
+ }
+ }
}
diff --git a/components/LineEditMulti.qml b/components/LineEditMulti.qml
index 266c6a30..46052495 100644
--- a/components/LineEditMulti.qml
+++ b/components/LineEditMulti.qml
@@ -80,9 +80,6 @@ ColumnLayout {
property alias readOnly: input.readOnly
property bool copyButton: false
property bool pasteButton: false
- property var onPaste: function(clipboardText) {
- item.text = clipboardText;
- }
property bool showingHeader: labelText != "" || copyButton || pasteButton
property var wrapMode: Text.NoWrap
property alias addressValidation: input.addressValidation
@@ -146,7 +143,10 @@ ColumnLayout {
MoneroComponents.LabelButton {
id: pasteButtonId
- onClicked: item.onPaste(clipboard.text())
+ onClicked: {
+ input.clear();
+ input.paste();
+ }
text: qsTr("Paste") + translationManager.emptyString
visible: pasteButton
}
diff --git a/components/PasswordDialog.qml b/components/PasswordDialog.qml
index 81e74ef3..bfea8948 100644
--- a/components/PasswordDialog.qml
+++ b/components/PasswordDialog.qml
@@ -187,7 +187,7 @@ Item {
text: qsTr("CAPSLOCKS IS ON.") + translationManager.emptyString;
}
- TextField {
+ MoneroComponents.Input {
id: passwordInput1
Layout.topMargin: 6
Layout.fillWidth: true
@@ -296,7 +296,7 @@ Item {
color: MoneroComponents.Style.defaultFontColor
}
- TextField {
+ MoneroComponents.Input {
id: passwordInput2
visible: !passwordDialogMode
Layout.topMargin: 6