From 834e14e57f3c163bc898e6a89ce467d850ee4ea2 Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Wed, 20 Nov 2013 15:49:34 +0100 Subject: [PATCH 1/2] [Qt] coin-control features GUI cleanup 2 - remove monospace labels from sendcoinsdialog also - use a validated line edit for the change address - add a tooltip to change address switch - ensure we have a valid change address in CoinControlDialog::coinControl->destChange or just CNoDestination() - some small ui file changes --- src/qt/forms/sendcoinsdialog.ui | 77 ++++++++++----------------------- src/qt/sendcoinsdialog.cpp | 21 ++++++--- 2 files changed, 39 insertions(+), 59 deletions(-) diff --git a/src/qt/forms/sendcoinsdialog.ui b/src/qt/forms/sendcoinsdialog.ui index 790d5d6c3..ad4aa5290 100644 --- a/src/qt/forms/sendcoinsdialog.ui +++ b/src/qt/forms/sendcoinsdialog.ui @@ -39,7 +39,7 @@ - -1 + 0 0 @@ -173,7 +173,16 @@ - + + 0 + + + 0 + + + 0 + + 0 @@ -219,12 +228,6 @@ - - - Monospace - 10 - - IBeamCursor @@ -254,12 +257,6 @@ - - - Monospace - 10 - - IBeamCursor @@ -308,12 +305,6 @@ - - - Monospace - 10 - - IBeamCursor @@ -340,12 +331,6 @@ - - - Monospace - 10 - - IBeamCursor @@ -394,12 +379,6 @@ - - - Monospace - 10 - - IBeamCursor @@ -426,12 +405,6 @@ - - - Monospace - 10 - - IBeamCursor @@ -480,12 +453,6 @@ - - - Monospace - 10 - - IBeamCursor @@ -512,12 +479,6 @@ - - - Monospace - 10 - - IBeamCursor @@ -555,13 +516,16 @@ + + If this is activated, but the change address is empty or invalid, change will be sent to a newly generated address. + - custom change address + Custom change address - + false @@ -626,7 +590,7 @@ 0 0 830 - 165 + 178 @@ -778,6 +742,13 @@ + + + QValidatedLineEdit + QLineEdit +
qvalidatedlineedit.h
+
+
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 6c3535b2f..73cfa27c8 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -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")); } From d3207b6fa8283cdd15bfa89b222880cf20524c35 Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Mon, 2 Dec 2013 13:36:19 +0100 Subject: [PATCH 2/2] [Qt] coin-control features GUI cleanup 3 - remove style sheets from ui files and use Qt attributes instead - make some more strings untranslatable, to make life for translators easier - split up long tooltips an rework the texts a little --- src/qt/coincontroldialog.cpp | 25 +++++++++--- src/qt/forms/coincontroldialog.ui | 63 ++++++++++++++++++++++--------- src/qt/forms/sendcoinsdialog.ui | 62 ++++++++++++++++++++---------- 3 files changed, 108 insertions(+), 42 deletions(-) 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.") + "

"; + toolTip1 += tr("This means a fee of at least %1 per kB is required.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CTransaction::nMinTxFee)) + "

"; + toolTip1 += tr("Can vary +/- 1 byte per input."); + + QString toolTip2 = tr("Transactions with higher priority are more likely to get included into a block.") + "

"; + toolTip2 += tr("This label turns red, if the priority is smaller than \"medium\"") + "

"; + 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)) + "

"; + toolTip3 += tr("This means a fee of at least %1 is required.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CTransaction::nMinTxFee)) + "

"; + 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)) + "

"; + 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("labelCoinControlBytesText") ->setToolTip(l5->toolTip()); dialog->findChild("labelCoinControlPriorityText") ->setToolTip(l6->toolTip()); dialog->findChild("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 @@ - - font-weight:bold; + + + 75 + true + Quantity: @@ -64,8 +67,11 @@ - - font-weight:bold; + + + 75 + true + Bytes: @@ -106,8 +112,11 @@ - - font-weight:bold; + + + 75 + true + Amount: @@ -132,8 +141,11 @@ - - font-weight:bold; + + + 75 + true + Priority: @@ -148,6 +160,9 @@ Qt::ActionsContextMenu + + medium + Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse @@ -171,8 +186,11 @@ - - font-weight:bold; + + + 75 + true + Fee: @@ -200,8 +218,11 @@ false - - font-weight:bold; + + + 75 + true + Low Output: @@ -220,7 +241,7 @@ Qt::ActionsContextMenu - no + no Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse @@ -245,8 +266,11 @@ - - font-weight:bold; + + + 75 + true + After Fee: @@ -274,8 +298,11 @@ false - - font-weight:bold; + + + 75 + true + Change: @@ -377,7 +404,7 @@ - (1 locked) + (1 locked) diff --git a/src/qt/forms/sendcoinsdialog.ui b/src/qt/forms/sendcoinsdialog.ui index ad4aa5290..db8271b01 100644 --- a/src/qt/forms/sendcoinsdialog.ui +++ b/src/qt/forms/sendcoinsdialog.ui @@ -215,8 +215,11 @@ - - font-weight:bold; + + + 75 + true + Quantity: @@ -247,8 +250,11 @@ - - font-weight:bold; + + + 75 + true + Bytes: @@ -292,8 +298,11 @@ - - font-weight:bold; + + + 75 + true + Amount: @@ -321,8 +330,11 @@ - - font-weight:bold; + + + 75 + true + Priority: @@ -338,7 +350,7 @@ Qt::ActionsContextMenu - medium + medium Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse @@ -366,8 +378,11 @@ - - font-weight:bold; + + + 75 + true + Fee: @@ -395,8 +410,11 @@ - - font-weight:bold; + + + 75 + true + Low Output: @@ -412,7 +430,7 @@ Qt::ActionsContextMenu - no + no Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse @@ -440,8 +458,11 @@ - - font-weight:bold; + + + 75 + true + After Fee: @@ -469,8 +490,11 @@ - - font-weight:bold; + + + 75 + true + Change: @@ -693,7 +717,7 @@ IBeamCursor - 123.456 BTC + 123.456 BTC Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse