mirror of
https://github.com/monero-project/monero-gui.git
synced 2025-01-26 20:45:54 +00:00
Merge pull request #1768
02134c4
transfer: paste Payment URL to fill the payment form fields (xiphon)
This commit is contained in:
commit
72808de1ad
6 changed files with 75 additions and 18 deletions
|
@ -38,3 +38,7 @@ void clipboardAdapter::setText(const QString &text) {
|
||||||
m_pClipboard->setText(text, QClipboard::Clipboard);
|
m_pClipboard->setText(text, QClipboard::Clipboard);
|
||||||
m_pClipboard->setText(text, QClipboard::Selection);
|
m_pClipboard->setText(text, QClipboard::Selection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString clipboardAdapter::text() const {
|
||||||
|
return m_pClipboard->text();
|
||||||
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ class clipboardAdapter : public QObject
|
||||||
public:
|
public:
|
||||||
explicit clipboardAdapter(QObject *parent = 0);
|
explicit clipboardAdapter(QObject *parent = 0);
|
||||||
Q_INVOKABLE void setText(const QString &text);
|
Q_INVOKABLE void setText(const QString &text);
|
||||||
|
Q_INVOKABLE QString text() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QClipboard *m_pClipboard;
|
QClipboard *m_pClipboard;
|
||||||
|
|
|
@ -74,6 +74,10 @@ ColumnLayout {
|
||||||
property bool mouseSelection: true
|
property bool mouseSelection: true
|
||||||
property alias readOnly: input.readOnly
|
property alias readOnly: input.readOnly
|
||||||
property bool copyButton: false
|
property bool copyButton: false
|
||||||
|
property bool pasteButton: false
|
||||||
|
property var onPaste: function(clipboardText) {
|
||||||
|
item.text = clipboardText;
|
||||||
|
}
|
||||||
property bool showingHeader: true
|
property bool showingHeader: true
|
||||||
property var wrapMode: Text.NoWrap
|
property var wrapMode: Text.NoWrap
|
||||||
property alias addressValidation: input.addressValidation
|
property alias addressValidation: input.addressValidation
|
||||||
|
@ -109,25 +113,35 @@ ColumnLayout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MoneroComponents.LabelButton {
|
RowLayout {
|
||||||
id: labelButton
|
anchors.right: parent.right
|
||||||
onClicked: labelButtonClicked()
|
spacing: 16 * scaleRatio
|
||||||
visible: labelButtonVisible
|
|
||||||
}
|
|
||||||
|
|
||||||
MoneroComponents.LabelButton {
|
MoneroComponents.LabelButton {
|
||||||
id: copyButtonId
|
id: labelButton
|
||||||
visible: copyButton && input.text !== ""
|
onClicked: labelButtonClicked()
|
||||||
text: qsTr("Copy")
|
visible: labelButtonVisible
|
||||||
anchors.right: labelButton.visible ? inputLabel.right : parent.right
|
}
|
||||||
anchors.rightMargin: labelButton.visible? 4 : 0
|
|
||||||
onClicked: {
|
MoneroComponents.LabelButton {
|
||||||
if (input.text.length > 0) {
|
id: copyButtonId
|
||||||
console.log("Copied to clipboard");
|
visible: copyButton && input.text !== ""
|
||||||
clipboard.setText(input.text);
|
text: qsTr("Copy")
|
||||||
appWindow.showStatusMessage(qsTr("Copied to clipboard"), 3);
|
onClicked: {
|
||||||
|
if (input.text.length > 0) {
|
||||||
|
console.log("Copied to clipboard");
|
||||||
|
clipboard.setText(input.text);
|
||||||
|
appWindow.showStatusMessage(qsTr("Copied to clipboard"), 3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MoneroComponents.LabelButton {
|
||||||
|
id: pasteButtonId
|
||||||
|
onClicked: item.onPaste(clipboard.text())
|
||||||
|
text: qsTr("Paste")
|
||||||
|
visible: pasteButton
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -215,6 +215,18 @@ Rectangle {
|
||||||
wrapMode: Text.WrapAnywhere
|
wrapMode: Text.WrapAnywhere
|
||||||
addressValidation: true
|
addressValidation: true
|
||||||
onInputLabelLinkActivated: { appWindow.showPageRequest("AddressBook") }
|
onInputLabelLinkActivated: { appWindow.showPageRequest("AddressBook") }
|
||||||
|
pasteButton: true
|
||||||
|
onPaste: function(clipboardText) {
|
||||||
|
const parsed = walletManager.parse_uri_to_object(clipboardText);
|
||||||
|
if (!parsed.error) {
|
||||||
|
addressLine.text = parsed.address;
|
||||||
|
paymentIdLine.text = parsed.payment_id;
|
||||||
|
amountLine.text = parsed.amount;
|
||||||
|
descriptionLine.text = parsed.tx_description;
|
||||||
|
} else {
|
||||||
|
addressLine.text = clipboardText;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
StandardButton {
|
StandardButton {
|
||||||
|
|
|
@ -296,13 +296,37 @@ QString WalletManager::resolveOpenAlias(const QString &address) const
|
||||||
res = std::string(dnssec_valid ? "true" : "false") + "|" + res;
|
res = std::string(dnssec_valid ? "true" : "false") + "|" + res;
|
||||||
return QString::fromStdString(res);
|
return QString::fromStdString(res);
|
||||||
}
|
}
|
||||||
bool WalletManager::parse_uri(const QString &uri, QString &address, QString &payment_id, uint64_t &amount, QString &tx_description, QString &recipient_name, QVector<QString> &unknown_parameters, QString &error)
|
bool WalletManager::parse_uri(const QString &uri, QString &address, QString &payment_id, uint64_t &amount, QString &tx_description, QString &recipient_name, QVector<QString> &unknown_parameters, QString &error) const
|
||||||
{
|
{
|
||||||
if (m_currentWallet)
|
if (m_currentWallet)
|
||||||
return m_currentWallet->parse_uri(uri, address, payment_id, amount, tx_description, recipient_name, unknown_parameters, error);
|
return m_currentWallet->parse_uri(uri, address, payment_id, amount, tx_description, recipient_name, unknown_parameters, error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariantMap WalletManager::parse_uri_to_object(const QString &uri) const
|
||||||
|
{
|
||||||
|
QString address;
|
||||||
|
QString payment_id;
|
||||||
|
uint64_t amount;
|
||||||
|
QString tx_description;
|
||||||
|
QString recipient_name;
|
||||||
|
QVector<QString> unknown_parameters;
|
||||||
|
QString error;
|
||||||
|
|
||||||
|
QVariantMap result;
|
||||||
|
if (this->parse_uri(uri, address, payment_id, amount, tx_description, recipient_name, unknown_parameters, error)) {
|
||||||
|
result.insert("address", address);
|
||||||
|
result.insert("payment_id", payment_id);
|
||||||
|
result.insert("amount", this->displayAmount(amount));
|
||||||
|
result.insert("tx_description", tx_description);
|
||||||
|
result.insert("recipient_name", recipient_name);
|
||||||
|
} else {
|
||||||
|
result.insert("error", error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
void WalletManager::setLogLevel(int logLevel)
|
void WalletManager::setLogLevel(int logLevel)
|
||||||
{
|
{
|
||||||
Monero::WalletManagerFactory::setLogLevel(logLevel);
|
Monero::WalletManagerFactory::setLogLevel(logLevel);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef WALLETMANAGER_H
|
#ifndef WALLETMANAGER_H
|
||||||
#define WALLETMANAGER_H
|
#define WALLETMANAGER_H
|
||||||
|
|
||||||
|
#include <QVariant>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <wallet/api/wallet2_api.h>
|
#include <wallet/api/wallet2_api.h>
|
||||||
|
@ -142,7 +143,8 @@ public:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Q_INVOKABLE QString resolveOpenAlias(const QString &address) const;
|
Q_INVOKABLE QString resolveOpenAlias(const QString &address) const;
|
||||||
Q_INVOKABLE bool parse_uri(const QString &uri, QString &address, QString &payment_id, uint64_t &amount, QString &tx_description, QString &recipient_name, QVector<QString> &unknown_parameters, QString &error);
|
Q_INVOKABLE bool parse_uri(const QString &uri, QString &address, QString &payment_id, uint64_t &amount, QString &tx_description, QString &recipient_name, QVector<QString> &unknown_parameters, QString &error) const;
|
||||||
|
Q_INVOKABLE QVariantMap parse_uri_to_object(const QString &uri) const;
|
||||||
Q_INVOKABLE bool saveQrCode(const QString &, const QString &) const;
|
Q_INVOKABLE bool saveQrCode(const QString &, const QString &) const;
|
||||||
Q_INVOKABLE void checkUpdatesAsync(const QString &software, const QString &subdir) const;
|
Q_INVOKABLE void checkUpdatesAsync(const QString &software, const QString &subdir) const;
|
||||||
Q_INVOKABLE QString checkUpdates(const QString &software, const QString &subdir) const;
|
Q_INVOKABLE QString checkUpdates(const QString &software, const QString &subdir) const;
|
||||||
|
|
Loading…
Reference in a new issue