mirror of
https://github.com/monero-project/monero-gui.git
synced 2025-01-22 10:44:46 +00:00
ContextMenu: implement 'paste' context menu for all text fields
This commit is contained in:
parent
7f7a39292c
commit
74e12ce71d
12 changed files with 78 additions and 19 deletions
43
components/ContextMenu.qml
Normal file
43
components/ContextMenu.qml
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -32,6 +32,7 @@ import QtQuick 2.9
|
||||||
import "../components" as MoneroComponents
|
import "../components" as MoneroComponents
|
||||||
|
|
||||||
TextField {
|
TextField {
|
||||||
|
id: textField
|
||||||
font.family: MoneroComponents.Style.fontRegular.name
|
font.family: MoneroComponents.Style.fontRegular.name
|
||||||
font.pixelSize: 18
|
font.pixelSize: 18
|
||||||
font.bold: true
|
font.bold: true
|
||||||
|
@ -44,4 +45,11 @@ TextField {
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MoneroComponents.ContextMenu {
|
||||||
|
onPaste: {
|
||||||
|
textField.clear();
|
||||||
|
textField.paste();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ Item {
|
||||||
color: MoneroComponents.Style.defaultFontColor
|
color: MoneroComponents.Style.defaultFontColor
|
||||||
}
|
}
|
||||||
|
|
||||||
TextField {
|
MoneroComponents.Input {
|
||||||
id : input
|
id : input
|
||||||
focus: true
|
focus: true
|
||||||
Layout.topMargin: 6
|
Layout.topMargin: 6
|
||||||
|
|
|
@ -57,6 +57,10 @@ TextArea {
|
||||||
onTextChanged: {
|
onTextChanged: {
|
||||||
if(addressValidation){
|
if(addressValidation){
|
||||||
// js replacement for `RegExpValidator { regExp: /[0-9A-Fa-f]{95}/g }`
|
// 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,'');
|
textArea.text = textArea.text.replace(/[^a-z0-9.@\-]/gi,'');
|
||||||
var address_ok = TxUtils.checkAddress(textArea.text, appWindow.persistentSettings.nettype) || TxUtils.isValidOpenAliasAddress(textArea.text);
|
var address_ok = TxUtils.checkAddress(textArea.text, appWindow.persistentSettings.nettype) || TxUtils.isValidOpenAliasAddress(textArea.text);
|
||||||
if(!address_ok) error = true;
|
if(!address_ok) error = true;
|
||||||
|
@ -64,4 +68,11 @@ TextArea {
|
||||||
TextArea.cursorPosition = textArea.text.length;
|
TextArea.cursorPosition = textArea.text.length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MoneroComponents.ContextMenu {
|
||||||
|
onPaste: {
|
||||||
|
textArea.clear();
|
||||||
|
textArea.paste();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,9 +80,6 @@ ColumnLayout {
|
||||||
property alias readOnly: input.readOnly
|
property alias readOnly: input.readOnly
|
||||||
property bool copyButton: false
|
property bool copyButton: false
|
||||||
property bool pasteButton: false
|
property bool pasteButton: false
|
||||||
property var onPaste: function(clipboardText) {
|
|
||||||
item.text = clipboardText;
|
|
||||||
}
|
|
||||||
property bool showingHeader: labelText != "" || copyButton || pasteButton
|
property bool showingHeader: labelText != "" || copyButton || pasteButton
|
||||||
property var wrapMode: Text.NoWrap
|
property var wrapMode: Text.NoWrap
|
||||||
property alias addressValidation: input.addressValidation
|
property alias addressValidation: input.addressValidation
|
||||||
|
@ -146,7 +143,10 @@ ColumnLayout {
|
||||||
|
|
||||||
MoneroComponents.LabelButton {
|
MoneroComponents.LabelButton {
|
||||||
id: pasteButtonId
|
id: pasteButtonId
|
||||||
onClicked: item.onPaste(clipboard.text())
|
onClicked: {
|
||||||
|
input.clear();
|
||||||
|
input.paste();
|
||||||
|
}
|
||||||
text: qsTr("Paste") + translationManager.emptyString
|
text: qsTr("Paste") + translationManager.emptyString
|
||||||
visible: pasteButton
|
visible: pasteButton
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,7 +187,7 @@ Item {
|
||||||
text: qsTr("CAPSLOCKS IS ON.") + translationManager.emptyString;
|
text: qsTr("CAPSLOCKS IS ON.") + translationManager.emptyString;
|
||||||
}
|
}
|
||||||
|
|
||||||
TextField {
|
MoneroComponents.Input {
|
||||||
id: passwordInput1
|
id: passwordInput1
|
||||||
Layout.topMargin: 6
|
Layout.topMargin: 6
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
|
@ -296,7 +296,7 @@ Item {
|
||||||
color: MoneroComponents.Style.defaultFontColor
|
color: MoneroComponents.Style.defaultFontColor
|
||||||
}
|
}
|
||||||
|
|
||||||
TextField {
|
MoneroComponents.Input {
|
||||||
id: passwordInput2
|
id: passwordInput2
|
||||||
visible: !passwordDialogMode
|
visible: !passwordDialogMode
|
||||||
Layout.topMargin: 6
|
Layout.topMargin: 6
|
||||||
|
|
|
@ -325,8 +325,8 @@ Rectangle {
|
||||||
wrapMode: Text.WrapAnywhere
|
wrapMode: Text.WrapAnywhere
|
||||||
addressValidation: true
|
addressValidation: true
|
||||||
pasteButton: true
|
pasteButton: true
|
||||||
onPaste: function(clipboardText) {
|
onTextChanged: {
|
||||||
const parsed = walletManager.parse_uri_to_object(clipboardText);
|
const parsed = walletManager.parse_uri_to_object(addressLine.text);
|
||||||
if (!parsed.error) {
|
if (!parsed.error) {
|
||||||
addressLine.text = parsed.address;
|
addressLine.text = parsed.address;
|
||||||
descriptionLine.text = parsed.tx_description;
|
descriptionLine.text = parsed.tx_description;
|
||||||
|
|
|
@ -257,18 +257,14 @@ Rectangle {
|
||||||
appWindow.showPageRequest("AddressBook");
|
appWindow.showPageRequest("AddressBook");
|
||||||
}
|
}
|
||||||
pasteButton: true
|
pasteButton: true
|
||||||
onPaste: function(clipboardText) {
|
onTextChanged: {
|
||||||
const parsed = walletManager.parse_uri_to_object(clipboardText);
|
const parsed = walletManager.parse_uri_to_object(text);
|
||||||
if (!parsed.error) {
|
if (!parsed.error) {
|
||||||
addressLine.text = parsed.address;
|
addressLine.text = parsed.address;
|
||||||
setPaymentId(parsed.payment_id);
|
setPaymentId(parsed.payment_id);
|
||||||
amountLine.text = parsed.amount;
|
amountLine.text = parsed.amount;
|
||||||
setDescription(parsed.tx_description);
|
setDescription(parsed.tx_description);
|
||||||
} else {
|
|
||||||
addressLine.text = clipboardText;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
onTextChanged: {
|
|
||||||
warningLongPidTransfer = isLongPidService(text);
|
warningLongPidTransfer = isLongPidService(text);
|
||||||
}
|
}
|
||||||
inlineButton.text: FontAwesome.qrcode
|
inlineButton.text: FontAwesome.qrcode
|
||||||
|
|
|
@ -455,7 +455,7 @@ Item {
|
||||||
width: 220
|
width: 220
|
||||||
source: "qrc:///images/merchant/input_box.png"
|
source: "qrc:///images/merchant/input_box.png"
|
||||||
|
|
||||||
TextField {
|
MoneroComponents.Input {
|
||||||
id: amountToReceive
|
id: amountToReceive
|
||||||
topPadding: 0
|
topPadding: 0
|
||||||
leftPadding: 10
|
leftPadding: 10
|
||||||
|
|
1
qml.qrc
1
qml.qrc
|
@ -21,6 +21,7 @@
|
||||||
<file>pages/History.qml</file>
|
<file>pages/History.qml</file>
|
||||||
<file>pages/AddressBook.qml</file>
|
<file>pages/AddressBook.qml</file>
|
||||||
<file>pages/Mining.qml</file>
|
<file>pages/Mining.qml</file>
|
||||||
|
<file>components/ContextMenu.qml</file>
|
||||||
<file>components/NetworkStatusItem.qml</file>
|
<file>components/NetworkStatusItem.qml</file>
|
||||||
<file>components/Input.qml</file>
|
<file>components/Input.qml</file>
|
||||||
<file>components/StandardButton.qml</file>
|
<file>components/StandardButton.qml</file>
|
||||||
|
|
|
@ -150,7 +150,7 @@ ColumnLayout {
|
||||||
color: MoneroComponents.Style.defaultFontColor
|
color: MoneroComponents.Style.defaultFontColor
|
||||||
}
|
}
|
||||||
|
|
||||||
TextField {
|
MoneroComponents.Input {
|
||||||
id: passwordInput
|
id: passwordInput
|
||||||
|
|
||||||
Layout.topMargin: 6
|
Layout.topMargin: 6
|
||||||
|
@ -207,7 +207,7 @@ ColumnLayout {
|
||||||
color: MoneroComponents.Style.defaultFontColor
|
color: MoneroComponents.Style.defaultFontColor
|
||||||
}
|
}
|
||||||
|
|
||||||
TextField {
|
MoneroComponents.Input {
|
||||||
id : passwordInputConfirm
|
id : passwordInputConfirm
|
||||||
|
|
||||||
Layout.topMargin: 6
|
Layout.topMargin: 6
|
||||||
|
|
|
@ -185,7 +185,7 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TextArea {
|
MoneroComponents.InputMulti {
|
||||||
id: seedInput
|
id: seedInput
|
||||||
property bool error: false
|
property bool error: false
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
Loading…
Reference in a new issue