aboutsummaryrefslogtreecommitdiff
path: root/src/qt
diff options
context:
space:
mode:
Diffstat (limited to 'src/qt')
-rw-r--r--src/qt/Makefile.am2
-rw-r--r--src/qt/coincontroldialog.cpp25
-rw-r--r--src/qt/forms/coincontroldialog.ui63
-rw-r--r--src/qt/forms/sendcoinsdialog.ui139
-rw-r--r--src/qt/openuridialog.cpp2
-rw-r--r--src/qt/paymentserver.cpp25
-rw-r--r--src/qt/paymentserver.h9
-rw-r--r--src/qt/sendcoinsdialog.cpp25
-rw-r--r--src/qt/test/Makefile.am2
-rw-r--r--src/qt/test/paymentservertests.cpp14
-rw-r--r--src/qt/test/paymentservertests.h2
-rw-r--r--src/qt/test/test_main.cpp8
12 files changed, 189 insertions, 127 deletions
diff --git a/src/qt/Makefile.am b/src/qt/Makefile.am
index e302adc89..08846604e 100644
--- a/src/qt/Makefile.am
+++ b/src/qt/Makefile.am
@@ -197,7 +197,7 @@ endif
bitcoin_qt_CPPFLAGS = $(AM_CPPFLAGS) $(QT_INCLUDES) \
-I$(top_srcdir)/src/qt/forms
bitcoin_qt_SOURCES = bitcoin.cpp
-bitcoin_qt_LDADD = libbitcoinqt.a $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBLEVELDB) $(LIBMEMENV) \
+bitcoin_qt_LDADD = libbitcoinqt.a $(LIBBITCOIN_SERVER) $(LIBBITCOIN_WALLET) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBLEVELDB) $(LIBMEMENV) \
$(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS)
# forms/foo.h -> forms/ui_foo.h
diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp
index 4ecc040bf..14e5b0713 100644
--- a/src/qt/coincontroldialog.cpp
+++ b/src/qt/coincontroldialog.cpp
@@ -590,7 +590,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
l4->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nAfterFee)); // After Fee
l5->setText(((nBytes > 0) ? "~" : "") + QString::number(nBytes)); // Bytes
l6->setText(sPriorityLabel); // Priority
- l7->setText((fLowOutput ? (fDust ? tr("DUST") : tr("yes")) : tr("no"))); // Low Output / Dust
+ l7->setText((fLowOutput ? (fDust ? tr("Dust") : tr("yes")) : tr("no"))); // Low Output / Dust
l8->setText(BitcoinUnits::formatWithUnit(nDisplayUnit, nChange)); // Change
// turn labels "red"
@@ -600,10 +600,25 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
l8->setStyleSheet((nChange > 0 && nChange < CENT) ? "color:red;" : ""); // Change < 0.01BTC
// tool tips
- l5->setToolTip(tr("This label turns red, if the transaction size is bigger than 1000 bytes.\n\n This means a fee of at least %1 per kb is required.\n\n Can vary +/- 1 Byte per input.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CTransaction::nMinTxFee)));
- l6->setToolTip(tr("Transactions with higher priority get more likely into a block.\n\nThis label turns red, if the priority is smaller than \"medium\".\n\n This means a fee of at least %1 per kb is required.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CTransaction::nMinTxFee)));
- l7->setToolTip(tr("This label turns red, if any recipient receives an amount smaller than %1.\n\n This means a fee of at least %2 is required. \n\n Amounts below 0.546 times the minimum relay fee are shown as DUST.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CENT)).arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CTransaction::nMinTxFee)));
- l8->setToolTip(tr("This label turns red, if the change is smaller than %1.\n\n This means a fee of at least %2 is required.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CENT)).arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CTransaction::nMinTxFee)));
+ QString toolTip1 = tr("This label turns red, if the transaction size is greater than 1000 bytes.") + "<br /><br />";
+ toolTip1 += tr("This means a fee of at least %1 per kB is required.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CTransaction::nMinTxFee)) + "<br /><br />";
+ toolTip1 += tr("Can vary +/- 1 byte per input.");
+
+ QString toolTip2 = tr("Transactions with higher priority are more likely to get included into a block.") + "<br /><br />";
+ toolTip2 += tr("This label turns red, if the priority is smaller than \"medium\"") + "<br /><br />";
+ toolTip2 += tr("This means a fee of at least %1 per kB is required.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CTransaction::nMinTxFee));
+
+ QString toolTip3 = tr("This label turns red, if any recipient receives an amount smaller than %1.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CENT)) + "<br /><br />";
+ toolTip3 += tr("This means a fee of at least %1 is required.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CTransaction::nMinTxFee)) + "<br /><br />";
+ toolTip3 += tr("Amounts below 0.546 times the minimum relay fee are shown as dust.");
+
+ QString toolTip4 = tr("This label turns red, if the change is smaller than %1.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CENT)) + "<br /><br />";
+ toolTip4 += tr("This means a fee of at least %1 is required.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CTransaction::nMinTxFee));
+
+ l5->setToolTip(toolTip1);
+ l6->setToolTip(toolTip2);
+ l7->setToolTip(toolTip3);
+ l8->setToolTip(toolTip4);
dialog->findChild<QLabel *>("labelCoinControlBytesText") ->setToolTip(l5->toolTip());
dialog->findChild<QLabel *>("labelCoinControlPriorityText") ->setToolTip(l6->toolTip());
dialog->findChild<QLabel *>("labelCoinControlLowOutputText")->setToolTip(l7->toolTip());
diff --git a/src/qt/forms/coincontroldialog.ui b/src/qt/forms/coincontroldialog.ui
index 055dd1f98..e4faa312d 100644
--- a/src/qt/forms/coincontroldialog.ui
+++ b/src/qt/forms/coincontroldialog.ui
@@ -38,8 +38,11 @@
</property>
<item row="0" column="0">
<widget class="QLabel" name="labelCoinControlQuantityText">
- <property name="styleSheet">
- <string notr="true">font-weight:bold;</string>
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
</property>
<property name="text">
<string>Quantity:</string>
@@ -64,8 +67,11 @@
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelCoinControlBytesText">
- <property name="styleSheet">
- <string notr="true">font-weight:bold;</string>
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
</property>
<property name="text">
<string>Bytes:</string>
@@ -106,8 +112,11 @@
</property>
<item row="0" column="0">
<widget class="QLabel" name="labelCoinControlAmountText">
- <property name="styleSheet">
- <string notr="true">font-weight:bold;</string>
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
</property>
<property name="text">
<string>Amount:</string>
@@ -132,8 +141,11 @@
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelCoinControlPriorityText">
- <property name="styleSheet">
- <string notr="true">font-weight:bold;</string>
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
</property>
<property name="text">
<string>Priority:</string>
@@ -148,6 +160,9 @@
<property name="contextMenuPolicy">
<enum>Qt::ActionsContextMenu</enum>
</property>
+ <property name="text">
+ <string notr="true">medium</string>
+ </property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
</property>
@@ -171,8 +186,11 @@
</property>
<item row="0" column="0">
<widget class="QLabel" name="labelCoinControlFeeText">
- <property name="styleSheet">
- <string notr="true">font-weight:bold;</string>
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
</property>
<property name="text">
<string>Fee:</string>
@@ -200,8 +218,11 @@
<property name="enabled">
<bool>false</bool>
</property>
- <property name="styleSheet">
- <string notr="true">font-weight:bold;</string>
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
</property>
<property name="text">
<string>Low Output:</string>
@@ -220,7 +241,7 @@
<enum>Qt::ActionsContextMenu</enum>
</property>
<property name="text">
- <string>no</string>
+ <string notr="true">no</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
@@ -245,8 +266,11 @@
</property>
<item row="0" column="0">
<widget class="QLabel" name="labelCoinControlAfterFeeText">
- <property name="styleSheet">
- <string notr="true">font-weight:bold;</string>
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
</property>
<property name="text">
<string>After Fee:</string>
@@ -274,8 +298,11 @@
<property name="enabled">
<bool>false</bool>
</property>
- <property name="styleSheet">
- <string notr="true">font-weight:bold;</string>
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
</property>
<property name="text">
<string>Change:</string>
@@ -377,7 +404,7 @@
<item>
<widget class="QLabel" name="labelLocked">
<property name="text">
- <string>(1 locked)</string>
+ <string notr="true">(1 locked)</string>
</property>
</widget>
</item>
diff --git a/src/qt/forms/sendcoinsdialog.ui b/src/qt/forms/sendcoinsdialog.ui
index 790d5d6c3..db8271b01 100644
--- a/src/qt/forms/sendcoinsdialog.ui
+++ b/src/qt/forms/sendcoinsdialog.ui
@@ -39,7 +39,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayoutCoinControl2">
<property name="spacing">
- <number>-1</number>
+ <number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
@@ -173,7 +173,16 @@
<string notr="true"/>
</property>
<layout class="QHBoxLayout" name="horizontalLayoutCoinControl5">
- <property name="margin">
+ <property name="leftMargin">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
<number>0</number>
</property>
<item>
@@ -206,8 +215,11 @@
</property>
<item row="0" column="0">
<widget class="QLabel" name="labelCoinControlQuantityText">
- <property name="styleSheet">
- <string notr="true">font-weight:bold;</string>
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
</property>
<property name="text">
<string>Quantity:</string>
@@ -219,12 +231,6 @@
</item>
<item row="0" column="1">
<widget class="QLabel" name="labelCoinControlQuantity">
- <property name="font">
- <font>
- <family>Monospace</family>
- <pointsize>10</pointsize>
- </font>
- </property>
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
@@ -244,8 +250,11 @@
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelCoinControlBytesText">
- <property name="styleSheet">
- <string notr="true">font-weight:bold;</string>
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
</property>
<property name="text">
<string>Bytes:</string>
@@ -254,12 +263,6 @@
</item>
<item row="1" column="1">
<widget class="QLabel" name="labelCoinControlBytes">
- <property name="font">
- <font>
- <family>Monospace</family>
- <pointsize>10</pointsize>
- </font>
- </property>
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
@@ -295,8 +298,11 @@
</property>
<item row="0" column="0">
<widget class="QLabel" name="labelCoinControlAmountText">
- <property name="styleSheet">
- <string notr="true">font-weight:bold;</string>
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
</property>
<property name="text">
<string>Amount:</string>
@@ -308,12 +314,6 @@
</item>
<item row="0" column="1">
<widget class="QLabel" name="labelCoinControlAmount">
- <property name="font">
- <font>
- <family>Monospace</family>
- <pointsize>10</pointsize>
- </font>
- </property>
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
@@ -330,8 +330,11 @@
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelCoinControlPriorityText">
- <property name="styleSheet">
- <string notr="true">font-weight:bold;</string>
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
</property>
<property name="text">
<string>Priority:</string>
@@ -340,12 +343,6 @@
</item>
<item row="1" column="1">
<widget class="QLabel" name="labelCoinControlPriority">
- <property name="font">
- <font>
- <family>Monospace</family>
- <pointsize>10</pointsize>
- </font>
- </property>
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
@@ -353,7 +350,7 @@
<enum>Qt::ActionsContextMenu</enum>
</property>
<property name="text">
- <string>medium</string>
+ <string notr="true">medium</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
@@ -381,8 +378,11 @@
</property>
<item row="0" column="0">
<widget class="QLabel" name="labelCoinControlFeeText">
- <property name="styleSheet">
- <string notr="true">font-weight:bold;</string>
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
</property>
<property name="text">
<string>Fee:</string>
@@ -394,12 +394,6 @@
</item>
<item row="0" column="1">
<widget class="QLabel" name="labelCoinControlFee">
- <property name="font">
- <font>
- <family>Monospace</family>
- <pointsize>10</pointsize>
- </font>
- </property>
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
@@ -416,8 +410,11 @@
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelCoinControlLowOutputText">
- <property name="styleSheet">
- <string notr="true">font-weight:bold;</string>
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
</property>
<property name="text">
<string>Low Output:</string>
@@ -426,12 +423,6 @@
</item>
<item row="1" column="1">
<widget class="QLabel" name="labelCoinControlLowOutput">
- <property name="font">
- <font>
- <family>Monospace</family>
- <pointsize>10</pointsize>
- </font>
- </property>
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
@@ -439,7 +430,7 @@
<enum>Qt::ActionsContextMenu</enum>
</property>
<property name="text">
- <string>no</string>
+ <string notr="true">no</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
@@ -467,8 +458,11 @@
</property>
<item row="0" column="0">
<widget class="QLabel" name="labelCoinControlAfterFeeText">
- <property name="styleSheet">
- <string notr="true">font-weight:bold;</string>
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
</property>
<property name="text">
<string>After Fee:</string>
@@ -480,12 +474,6 @@
</item>
<item row="0" column="1">
<widget class="QLabel" name="labelCoinControlAfterFee">
- <property name="font">
- <font>
- <family>Monospace</family>
- <pointsize>10</pointsize>
- </font>
- </property>
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
@@ -502,8 +490,11 @@
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelCoinControlChangeText">
- <property name="styleSheet">
- <string notr="true">font-weight:bold;</string>
+ <property name="font">
+ <font>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
</property>
<property name="text">
<string>Change:</string>
@@ -512,12 +503,6 @@
</item>
<item row="1" column="1">
<widget class="QLabel" name="labelCoinControlChange">
- <property name="font">
- <font>
- <family>Monospace</family>
- <pointsize>10</pointsize>
- </font>
- </property>
<property name="cursor">
<cursorShape>IBeamCursor</cursorShape>
</property>
@@ -555,13 +540,16 @@
</property>
<item>
<widget class="QCheckBox" name="checkBoxCoinControlChange">
+ <property name="toolTip">
+ <string>If this is activated, but the change address is empty or invalid, change will be sent to a newly generated address.</string>
+ </property>
<property name="text">
- <string>custom change address</string>
+ <string>Custom change address</string>
</property>
</widget>
</item>
<item>
- <widget class="QLineEdit" name="lineEditCoinControlChange">
+ <widget class="QValidatedLineEdit" name="lineEditCoinControlChange">
<property name="enabled">
<bool>false</bool>
</property>
@@ -626,7 +614,7 @@
<x>0</x>
<y>0</y>
<width>830</width>
- <height>165</height>
+ <height>178</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2" stretch="0,1">
@@ -729,7 +717,7 @@
<cursorShape>IBeamCursor</cursorShape>
</property>
<property name="text">
- <string>123.456 BTC</string>
+ <string notr="true">123.456 BTC</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
@@ -778,6 +766,13 @@
</item>
</layout>
</widget>
+ <customwidgets>
+ <customwidget>
+ <class>QValidatedLineEdit</class>
+ <extends>QLineEdit</extends>
+ <header>qvalidatedlineedit.h</header>
+ </customwidget>
+ </customwidgets>
<resources>
<include location="../bitcoin.qrc"/>
</resources>
diff --git a/src/qt/openuridialog.cpp b/src/qt/openuridialog.cpp
index 803a3c9dd..06189aeaf 100644
--- a/src/qt/openuridialog.cpp
+++ b/src/qt/openuridialog.cpp
@@ -48,5 +48,5 @@ void OpenURIDialog::on_selectFileButton_clicked()
if(filename.isEmpty())
return;
QUrl fileUri = QUrl::fromLocalFile(filename);
- ui->uriEdit->setText("bitcoin:?request=" + QUrl::toPercentEncoding(fileUri.toString()));
+ ui->uriEdit->setText("bitcoin:?r=" + QUrl::toPercentEncoding(fileUri.toString()));
}
diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp
index 34da0f90e..ba5c06064 100644
--- a/src/qt/paymentserver.cpp
+++ b/src/qt/paymentserver.cpp
@@ -232,7 +232,10 @@ bool PaymentServer::ipcSendCommandLine(int argc, char* argv[])
QLocalSocket* socket = new QLocalSocket();
socket->connectToServer(ipcServerName(), QIODevice::WriteOnly);
if (!socket->waitForConnected(BITCOIN_IPC_CONNECT_TIMEOUT))
+ {
+ delete socket;
return false;
+ }
QByteArray block;
QDataStream out(&block, QIODevice::WriteOnly);
@@ -277,8 +280,11 @@ PaymentServer::PaymentServer(QObject* parent, bool startLocalServer) :
{
uriServer = new QLocalServer(this);
- if (!uriServer->listen(name))
- qDebug() << "PaymentServer::PaymentServer : Cannot start bitcoin: click-to-pay handler";
+ if (!uriServer->listen(name)) {
+ // constructor is called early in init, so don't use "emit message()" here
+ QMessageBox::critical(0, tr("Payment request error"),
+ tr("Cannot start bitcoin: click-to-pay handler"));
+ }
else {
connect(uriServer, SIGNAL(newConnection()), this, SLOT(handleURIConnection()));
connect(this, SIGNAL(receivedPaymentACK(QString)), this, SLOT(handlePaymentACK(QString)));
@@ -295,12 +301,12 @@ PaymentServer::~PaymentServer()
// OSX-specific way of handling bitcoin: URIs and
// PaymentRequest mime types
//
-bool PaymentServer::eventFilter(QObject *, QEvent *event)
+bool PaymentServer::eventFilter(QObject *object, QEvent *event)
{
- // clicking on bitcoin: URIs creates FileOpen events on the Mac:
+ // clicking on bitcoin: URIs creates FileOpen events on the Mac
if (event->type() == QEvent::FileOpen)
{
- QFileOpenEvent* fileEvent = static_cast<QFileOpenEvent*>(event);
+ QFileOpenEvent *fileEvent = static_cast<QFileOpenEvent*>(event);
if (!fileEvent->file().isEmpty())
handleURIOrFile(fileEvent->file());
else if (!fileEvent->url().isEmpty())
@@ -308,7 +314,8 @@ bool PaymentServer::eventFilter(QObject *, QEvent *event)
return true;
}
- return false;
+
+ return QObject::eventFilter(object, event);
}
void PaymentServer::initNetManager()
@@ -359,17 +366,17 @@ void PaymentServer::handleURIOrFile(const QString& s)
return;
}
- if (s.startsWith(BITCOIN_IPC_PREFIX, Qt::CaseInsensitive)) // bitcoin:
+ if (s.startsWith(BITCOIN_IPC_PREFIX, Qt::CaseInsensitive)) // bitcoin: URI
{
#if QT_VERSION < 0x050000
QUrl uri(s);
#else
QUrlQuery uri((QUrl(s)));
#endif
- if (uri.hasQueryItem("request"))
+ if (uri.hasQueryItem("r"))
{
QByteArray temp;
- temp.append(uri.queryItemValue("request"));
+ temp.append(uri.queryItemValue("r"));
QString decoded = QUrl::fromPercentEncoding(temp);
QUrl fetchUrl(decoded, QUrl::StrictMode);
diff --git a/src/qt/paymentserver.h b/src/qt/paymentserver.h
index 50f077f3b..ab59388ac 100644
--- a/src/qt/paymentserver.h
+++ b/src/qt/paymentserver.h
@@ -77,10 +77,6 @@ public:
// Return certificate store
static X509_STORE* getCertStore() { return certStore; }
- // Constructor registers this on the parent QApplication to
- // receive QEvent::FileOpen events
- bool eventFilter(QObject *object, QEvent *event);
-
// OptionsModel is used for getting proxy settings and display unit
void setOptionsModel(OptionsModel *optionsModel);
@@ -111,6 +107,11 @@ private slots:
void reportSslErrors(QNetworkReply*, const QList<QSslError> &);
void handlePaymentACK(const QString& paymentACKMsg);
+protected:
+ // Constructor registers this on the parent QApplication to
+ // receive QEvent::FileOpen and QEvent:Drop events
+ bool eventFilter(QObject *object, QEvent *event);
+
private:
static bool readPaymentRequest(const QString& filename, PaymentRequestPlus& request);
bool processPaymentRequest(PaymentRequestPlus& request, SendCoinsRecipient& recipient);
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp
index 6c3535b2f..0a4e80811 100644
--- a/src/qt/sendcoinsdialog.cpp
+++ b/src/qt/sendcoinsdialog.cpp
@@ -260,7 +260,7 @@ void SendCoinsDialog::clear()
// Remove entries until only one left
while(ui->entries->count())
{
- delete ui->entries->takeAt(0)->widget();
+ ui->entries->takeAt(0)->widget()->deleteLater();
}
addEntry();
@@ -306,7 +306,7 @@ void SendCoinsDialog::updateTabsAndLabels()
void SendCoinsDialog::removeEntry(SendCoinsEntry* entry)
{
- delete entry;
+ entry->deleteLater();
// If the last entry was removed add an empty one
if (!ui->entries->count())
@@ -529,16 +529,17 @@ void SendCoinsDialog::coinControlButtonClicked()
// Coin Control: checkbox custom change address
void SendCoinsDialog::coinControlChangeChecked(int state)
{
- if (model)
+ if (state == Qt::Unchecked)
{
- if (state == Qt::Checked)
- CoinControlDialog::coinControl->destChange = CBitcoinAddress(ui->lineEditCoinControlChange->text().toStdString()).Get();
- else
- CoinControlDialog::coinControl->destChange = CNoDestination();
+ CoinControlDialog::coinControl->destChange = CNoDestination();
+ ui->lineEditCoinControlChange->setValid(true);
+ ui->labelCoinControlChangeLabel->clear();
}
+ else
+ // use this to re-validate an already entered address
+ coinControlChangeEdited(ui->lineEditCoinControlChange->text());
ui->lineEditCoinControlChange->setEnabled((state == Qt::Checked));
- ui->labelCoinControlChangeLabel->setVisible((state == Qt::Checked));
}
// Coin Control: custom change address changed
@@ -554,6 +555,10 @@ void SendCoinsDialog::coinControlChangeEdited(const QString & text)
ui->labelCoinControlChangeLabel->setText("");
else if (!CBitcoinAddress(text.toStdString()).IsValid())
{
+ // invalid change address
+ CoinControlDialog::coinControl->destChange = CNoDestination();
+
+ ui->lineEditCoinControlChange->setValid(false);
ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}");
ui->labelCoinControlChangeLabel->setText(tr("Warning: Invalid Bitcoin address"));
}
@@ -571,6 +576,10 @@ void SendCoinsDialog::coinControlChangeEdited(const QString & text)
ui->labelCoinControlChangeLabel->setText(tr("(no label)"));
else
{
+ // unknown change address
+ CoinControlDialog::coinControl->destChange = CNoDestination();
+
+ ui->lineEditCoinControlChange->setValid(false);
ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}");
ui->labelCoinControlChangeLabel->setText(tr("Warning: Unknown change address"));
}
diff --git a/src/qt/test/Makefile.am b/src/qt/test/Makefile.am
index 29247a79a..cb6874700 100644
--- a/src/qt/test/Makefile.am
+++ b/src/qt/test/Makefile.am
@@ -17,7 +17,7 @@ BUILT_SOURCES = $(TEST_QT_MOC_CPP)
test_bitcoin_qt_CPPFLAGS = $(AM_CPPFLAGS) $(QT_INCLUDES) $(QT_TEST_INCLUDES)
test_bitcoin_qt_SOURCES = test_main.cpp uritests.cpp paymentservertests.cpp $(TEST_QT_H)
nodist_test_bitcoin_qt_SOURCES = $(TEST_QT_MOC_CPP)
-test_bitcoin_qt_LDADD = $(LIBBITCOINQT) $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBLEVELDB) \
+test_bitcoin_qt_LDADD = $(LIBBITCOINQT) $(LIBBITCOIN_SERVER) $(LIBBITCOIN_WALLET) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBLEVELDB) \
$(LIBMEMENV) $(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) \
$(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS)
diff --git a/src/qt/test/paymentservertests.cpp b/src/qt/test/paymentservertests.cpp
index b8f2cc65c..7dee7a9cd 100644
--- a/src/qt/test/paymentservertests.cpp
+++ b/src/qt/test/paymentservertests.cpp
@@ -7,12 +7,9 @@
#include <openssl/x509.h>
#include <openssl/x509_vfy.h>
-#include <QCoreApplication>
-#include <QDebug>
+
#include <QFileOpenEvent>
#include <QTemporaryFile>
-#include <QVariant>
-
X509 *parse_b64der_cert(const char* cert_data)
{
@@ -41,9 +38,14 @@ static SendCoinsRecipient handleRequest(PaymentServer* server, std::vector<unsig
f.write((const char*)&data[0], data.size());
f.close();
- // Create a FileOpenEvent and send it directly to the server's event filter:
+ // Create a QObject, install event filter from PaymentServer
+ // and send a file open event to the object
+ QObject object;
+ object.installEventFilter(server);
QFileOpenEvent event(f.fileName());
- server->eventFilter(NULL, &event);
+ // If sending the event fails, this will cause sigCatcher to be empty,
+ // which will lead to a test failure anyway.
+ QCoreApplication::sendEvent(&object, &event);
QObject::disconnect(server, SIGNAL(receivedPaymentRequest(SendCoinsRecipient)),
&sigCatcher, SLOT(getRecipient(SendCoinsRecipient)));
diff --git a/src/qt/test/paymentservertests.h b/src/qt/test/paymentservertests.h
index 0bff923ad..884e535a6 100644
--- a/src/qt/test/paymentservertests.h
+++ b/src/qt/test/paymentservertests.h
@@ -20,8 +20,10 @@ private slots:
class RecipientCatcher : public QObject
{
Q_OBJECT
+
public slots:
void getRecipient(SendCoinsRecipient r);
+
public:
SendCoinsRecipient recipient;
};
diff --git a/src/qt/test/test_main.cpp b/src/qt/test/test_main.cpp
index 5c941c638..ae584706f 100644
--- a/src/qt/test/test_main.cpp
+++ b/src/qt/test/test_main.cpp
@@ -1,8 +1,7 @@
-
-
#include "paymentservertests.h"
#include "uritests.h"
+#include <QCoreApplication>
#include <QObject>
#include <QTest>
@@ -11,6 +10,11 @@ int main(int argc, char *argv[])
{
bool fInvalid = false;
+ // Don't remove this, it's needed to access
+ // QCoreApplication:: in the tests
+ QCoreApplication app(argc, argv);
+ app.setApplicationName("Bitcoin-Qt-test");
+
URITests test1;
if (QTest::qExec(&test1) != 0)
fInvalid = true;