From: tobtoht Date: Fri, 5 Jan 2024 15:40:08 +0000 (+0100) Subject: Send: allow pasting monero: uris in pay to field X-Git-Url: https://git.nutra.tk/v2?a=commitdiff_plain;h=1a597fd2d9a212377965868e6d2065a5cd322ffd;p=gamesguru%2Ffeather.git Send: allow pasting monero: uris in pay to field --- diff --git a/src/widgets/PayToEdit.cpp b/src/widgets/PayToEdit.cpp index b6465061..e25f0921 100644 --- a/src/widgets/PayToEdit.cpp +++ b/src/widgets/PayToEdit.cpp @@ -80,22 +80,31 @@ bool PayToEdit::isOpenAlias() { void PayToEdit::keyPressEvent(QKeyEvent *event) { if (event->matches(QKeySequence::Paste)) { - this->pasteEvent(QApplication::clipboard()->mimeData()); - event->accept(); + bool uri = this->pasteEvent(QApplication::clipboard()->mimeData()); + if (uri) { + event->ignore(); + return; + } } QPlainTextEdit::keyPressEvent(event); } -void PayToEdit::pasteEvent(const QMimeData *mimeData) { +bool PayToEdit::pasteEvent(const QMimeData *mimeData) { + if (mimeData->hasText() && mimeData->text().startsWith("monero:")) { + dataPasted(mimeData->text()); + return true; + } + QImage image; if (mimeData->hasImage()) { image = qvariant_cast(mimeData->imageData()); } else if (mimeData->hasUrls()) { + // Path to image file QList urlList = mimeData->urls(); if (urlList.count() > 1) { - return; + return false; } QFileInfo file(urlList.at(0).toLocalFile()); if (file.exists()) { @@ -103,12 +112,12 @@ void PayToEdit::pasteEvent(const QMimeData *mimeData) { } } else { - return; + return false; } if (image.isNull()) { qDebug() << "Invalid image"; - return; + return false; } #if defined(WITH_SCANNER) @@ -116,7 +125,10 @@ void PayToEdit::pasteEvent(const QMimeData *mimeData) { QString result = QrCodeUtils::scanImage(image); dataPasted(result); + return true; #endif + + return false; } void PayToEdit::checkText() { diff --git a/src/widgets/PayToEdit.h b/src/widgets/PayToEdit.h index 7e3d7899..f37c4695 100644 --- a/src/widgets/PayToEdit.h +++ b/src/widgets/PayToEdit.h @@ -58,7 +58,7 @@ private: void checkText(); void updateSize(); - void pasteEvent(const QMimeData *mimeData); + bool pasteEvent(const QMimeData *mimeData); PartialTxOutput parseAddressAndAmount(const QString &line); quint64 parseAmount(QString amount);