Merge pull request #2429

74e12ce ContextMenu: implement 'paste' context menu for all text fields (xiphon)
This commit is contained in:
luigi1111
2019-11-13 09:03:02 -06:00
12 changed files with 78 additions and 19 deletions

View File

@@ -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
}
}
}

View File

@@ -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();
}
}
}

View File

@@ -86,7 +86,7 @@ Item {
color: MoneroComponents.Style.defaultFontColor
}
TextField {
MoneroComponents.Input {
id : input
focus: true
Layout.topMargin: 6

View File

@@ -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();
}
}
}

View File

@@ -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
}

View File

@@ -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