mirror of
https://github.com/feather-wallet/feather.git
synced 2024-11-16 17:27:38 +00:00
Send: allow pasting monero: uris in pay to field
This commit is contained in:
parent
8509924ebd
commit
1a597fd2d9
2 changed files with 19 additions and 7 deletions
|
@ -80,22 +80,31 @@ bool PayToEdit::isOpenAlias() {
|
||||||
|
|
||||||
void PayToEdit::keyPressEvent(QKeyEvent *event) {
|
void PayToEdit::keyPressEvent(QKeyEvent *event) {
|
||||||
if (event->matches(QKeySequence::Paste)) {
|
if (event->matches(QKeySequence::Paste)) {
|
||||||
this->pasteEvent(QApplication::clipboard()->mimeData());
|
bool uri = this->pasteEvent(QApplication::clipboard()->mimeData());
|
||||||
event->accept();
|
if (uri) {
|
||||||
|
event->ignore();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QPlainTextEdit::keyPressEvent(event);
|
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;
|
QImage image;
|
||||||
if (mimeData->hasImage()) {
|
if (mimeData->hasImage()) {
|
||||||
image = qvariant_cast<QImage>(mimeData->imageData());
|
image = qvariant_cast<QImage>(mimeData->imageData());
|
||||||
}
|
}
|
||||||
else if (mimeData->hasUrls()) {
|
else if (mimeData->hasUrls()) {
|
||||||
|
// Path to image file
|
||||||
QList<QUrl> urlList = mimeData->urls();
|
QList<QUrl> urlList = mimeData->urls();
|
||||||
if (urlList.count() > 1) {
|
if (urlList.count() > 1) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
QFileInfo file(urlList.at(0).toLocalFile());
|
QFileInfo file(urlList.at(0).toLocalFile());
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
|
@ -103,12 +112,12 @@ void PayToEdit::pasteEvent(const QMimeData *mimeData) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (image.isNull()) {
|
if (image.isNull()) {
|
||||||
qDebug() << "Invalid image";
|
qDebug() << "Invalid image";
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(WITH_SCANNER)
|
#if defined(WITH_SCANNER)
|
||||||
|
@ -116,7 +125,10 @@ void PayToEdit::pasteEvent(const QMimeData *mimeData) {
|
||||||
QString result = QrCodeUtils::scanImage(image);
|
QString result = QrCodeUtils::scanImage(image);
|
||||||
|
|
||||||
dataPasted(result);
|
dataPasted(result);
|
||||||
|
return true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PayToEdit::checkText() {
|
void PayToEdit::checkText() {
|
||||||
|
|
|
@ -58,7 +58,7 @@ private:
|
||||||
void checkText();
|
void checkText();
|
||||||
void updateSize();
|
void updateSize();
|
||||||
|
|
||||||
void pasteEvent(const QMimeData *mimeData);
|
bool pasteEvent(const QMimeData *mimeData);
|
||||||
|
|
||||||
PartialTxOutput parseAddressAndAmount(const QString &line);
|
PartialTxOutput parseAddressAndAmount(const QString &line);
|
||||||
quint64 parseAmount(QString amount);
|
quint64 parseAmount(QString amount);
|
||||||
|
|
Loading…
Reference in a new issue