mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 13:32:47 +01:00
URI-handling code update: added safety checks and tray-notifications
This commit is contained in:
parent
7a98f19fb6
commit
93b7af3099
@ -744,12 +744,19 @@ void BitcoinGUI::dropEvent(QDropEvent *event)
|
|||||||
{
|
{
|
||||||
if(event->mimeData()->hasUrls())
|
if(event->mimeData()->hasUrls())
|
||||||
{
|
{
|
||||||
gotoSendCoinsPage();
|
int nValidUrisFound = 0;
|
||||||
QList<QUrl> uris = event->mimeData()->urls();
|
QList<QUrl> uris = event->mimeData()->urls();
|
||||||
foreach(const QUrl &uri, uris)
|
foreach(const QUrl &uri, uris)
|
||||||
{
|
{
|
||||||
sendCoinsPage->handleURI(uri.toString());
|
if (sendCoinsPage->handleURI(uri.toString()))
|
||||||
|
nValidUrisFound++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if valid URIs were found
|
||||||
|
if (nValidUrisFound)
|
||||||
|
gotoSendCoinsPage();
|
||||||
|
else
|
||||||
|
notificator->notify(Notificator::Warning, tr("URI handling"), tr("URI can not be parsed! This can be caused by an invalid Bitcoin address or malformed URI parameters."));
|
||||||
}
|
}
|
||||||
|
|
||||||
event->acceptProposedAction();
|
event->acceptProposedAction();
|
||||||
@ -757,10 +764,14 @@ void BitcoinGUI::dropEvent(QDropEvent *event)
|
|||||||
|
|
||||||
void BitcoinGUI::handleURI(QString strURI)
|
void BitcoinGUI::handleURI(QString strURI)
|
||||||
{
|
{
|
||||||
gotoSendCoinsPage();
|
// URI has to be valid
|
||||||
sendCoinsPage->handleURI(strURI);
|
if (sendCoinsPage->handleURI(strURI))
|
||||||
|
{
|
||||||
showNormalIfMinimized();
|
showNormalIfMinimized();
|
||||||
|
gotoSendCoinsPage();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
notificator->notify(Notificator::Warning, tr("URI handling"), tr("URI can not be parsed! This can be caused by an invalid Bitcoin address or malformed URI parameters."));
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinGUI::setEncryptionStatus(int status)
|
void BitcoinGUI::setEncryptionStatus(int status)
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "bitcoinunits.h"
|
#include "bitcoinunits.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
|
#include "base58.h"
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
@ -80,6 +81,11 @@ bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out)
|
|||||||
if(uri.scheme() != QString("bitcoin"))
|
if(uri.scheme() != QString("bitcoin"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// check if the address is valid
|
||||||
|
CBitcoinAddress addressFromUri(uri.path().toStdString());
|
||||||
|
if (!addressFromUri.IsValid())
|
||||||
|
return false;
|
||||||
|
|
||||||
SendCoinsRecipient rv;
|
SendCoinsRecipient rv;
|
||||||
rv.address = uri.path();
|
rv.address = uri.path();
|
||||||
rv.amount = 0;
|
rv.amount = 0;
|
||||||
@ -222,19 +228,18 @@ Qt::ConnectionType blockingGUIThreadConnection()
|
|||||||
|
|
||||||
bool checkPoint(const QPoint &p, const QWidget *w)
|
bool checkPoint(const QPoint &p, const QWidget *w)
|
||||||
{
|
{
|
||||||
QWidget *atW = qApp->widgetAt(w->mapToGlobal(p));
|
QWidget *atW = qApp->widgetAt(w->mapToGlobal(p));
|
||||||
if(!atW) return false;
|
if (!atW) return false;
|
||||||
return atW->topLevelWidget() == w;
|
return atW->topLevelWidget() == w;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isObscured(QWidget *w)
|
bool isObscured(QWidget *w)
|
||||||
{
|
{
|
||||||
|
return !(checkPoint(QPoint(0, 0), w)
|
||||||
return !(checkPoint(QPoint(0, 0), w)
|
&& checkPoint(QPoint(w->width() - 1, 0), w)
|
||||||
&& checkPoint(QPoint(w->width() - 1, 0), w)
|
&& checkPoint(QPoint(0, w->height() - 1), w)
|
||||||
&& checkPoint(QPoint(0, w->height() - 1), w)
|
&& checkPoint(QPoint(w->width() - 1, w->height() - 1), w)
|
||||||
&& checkPoint(QPoint(w->width() - 1, w->height() - 1), w)
|
&& checkPoint(QPoint(w->width() / 2, w->height() / 2), w));
|
||||||
&& checkPoint(QPoint(w->width()/2, w->height()/2), w));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void openDebugLogfile()
|
void openDebugLogfile()
|
||||||
|
@ -266,15 +266,17 @@ void SendCoinsDialog::pasteEntry(const SendCoinsRecipient &rv)
|
|||||||
entry->setValue(rv);
|
entry->setValue(rv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SendCoinsDialog::handleURI(const QString &uri)
|
||||||
void SendCoinsDialog::handleURI(const QString &uri)
|
|
||||||
{
|
{
|
||||||
SendCoinsRecipient rv;
|
SendCoinsRecipient rv;
|
||||||
if(!GUIUtil::parseBitcoinURI(uri, &rv))
|
// URI has to be valid
|
||||||
|
if (GUIUtil::parseBitcoinURI(uri, &rv))
|
||||||
{
|
{
|
||||||
return;
|
pasteEntry(rv);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
pasteEntry(rv);
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SendCoinsDialog::setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance)
|
void SendCoinsDialog::setBalance(qint64 balance, qint64 unconfirmedBalance, qint64 immatureBalance)
|
||||||
|
@ -30,7 +30,7 @@ public:
|
|||||||
QWidget *setupTabChain(QWidget *prev);
|
QWidget *setupTabChain(QWidget *prev);
|
||||||
|
|
||||||
void pasteEntry(const SendCoinsRecipient &rv);
|
void pasteEntry(const SendCoinsRecipient &rv);
|
||||||
void handleURI(const QString &uri);
|
bool handleURI(const QString &uri);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void clear();
|
void clear();
|
||||||
|
Loading…
Reference in New Issue
Block a user