Browse Source

Coin Control improvements October 25th, 2013

* code nits
 * introduced GUIUtil::setClipboard
 * calling getBalance(coinControl) now in walletmodel.cpp
 * replaced "WARNING" with "Warning"
 * added notr="true" to ui non translatable strings
0.8
Cozz Lovan 11 years ago committed by Warren Togami
parent
commit
e9e6262c0e
  1. 29
      src/qt/coincontroldialog.cpp
  2. 12
      src/qt/forms/coincontroldialog.ui
  3. 12
      src/qt/forms/sendcoinsdialog.ui
  4. 6
      src/qt/guiutil.cpp
  5. 2
      src/qt/guiutil.h
  6. 20
      src/qt/sendcoinsdialog.cpp
  7. 20
      src/qt/walletmodel.cpp
  8. 2
      src/qt/walletmodel.h

29
src/qt/coincontroldialog.cpp

@ -6,6 +6,7 @@ @@ -6,6 +6,7 @@
#include "walletmodel.h"
#include "addresstablemodel.h"
#include "optionsmodel.h"
#include "guiutil.h"
#include "coincontrol.h"
#include <QApplication>
@ -213,31 +214,31 @@ void CoinControlDialog::showMenu(const QPoint &point) @@ -213,31 +214,31 @@ void CoinControlDialog::showMenu(const QPoint &point)
// context menu action: copy amount
void CoinControlDialog::copyAmount()
{
QApplication::clipboard()->setText(contextMenuItem->text(COLUMN_AMOUNT));
GUIUtil::setClipboard(contextMenuItem->text(COLUMN_AMOUNT));
}
// context menu action: copy label
void CoinControlDialog::copyLabel()
{
if (ui->radioTreeMode->isChecked() && contextMenuItem->text(COLUMN_LABEL).length() == 0 && contextMenuItem->parent())
QApplication::clipboard()->setText(contextMenuItem->parent()->text(COLUMN_LABEL));
GUIUtil::setClipboard(contextMenuItem->parent()->text(COLUMN_LABEL));
else
QApplication::clipboard()->setText(contextMenuItem->text(COLUMN_LABEL));
GUIUtil::setClipboard(contextMenuItem->text(COLUMN_LABEL));
}
// context menu action: copy address
void CoinControlDialog::copyAddress()
{
if (ui->radioTreeMode->isChecked() && contextMenuItem->text(COLUMN_ADDRESS).length() == 0 && contextMenuItem->parent())
QApplication::clipboard()->setText(contextMenuItem->parent()->text(COLUMN_ADDRESS));
GUIUtil::setClipboard(contextMenuItem->parent()->text(COLUMN_ADDRESS));
else
QApplication::clipboard()->setText(contextMenuItem->text(COLUMN_ADDRESS));
GUIUtil::setClipboard(contextMenuItem->text(COLUMN_ADDRESS));
}
// context menu action: copy transaction id
void CoinControlDialog::copyTransactionHash()
{
QApplication::clipboard()->setText(contextMenuItem->text(COLUMN_TXHASH));
GUIUtil::setClipboard(contextMenuItem->text(COLUMN_TXHASH));
}
// context menu action: lock coin
@ -266,49 +267,49 @@ void CoinControlDialog::unlockCoin() @@ -266,49 +267,49 @@ void CoinControlDialog::unlockCoin()
// copy label "Quantity" to clipboard
void CoinControlDialog::clipboardQuantity()
{
QApplication::clipboard()->setText(ui->labelCoinControlQuantity->text());
GUIUtil::setClipboard(ui->labelCoinControlQuantity->text());
}
// copy label "Amount" to clipboard
void CoinControlDialog::clipboardAmount()
{
QApplication::clipboard()->setText(ui->labelCoinControlAmount->text().left(ui->labelCoinControlAmount->text().indexOf(" ")));
GUIUtil::setClipboard(ui->labelCoinControlAmount->text().left(ui->labelCoinControlAmount->text().indexOf(" ")));
}
// copy label "Fee" to clipboard
void CoinControlDialog::clipboardFee()
{
QApplication::clipboard()->setText(ui->labelCoinControlFee->text().left(ui->labelCoinControlFee->text().indexOf(" ")));
GUIUtil::setClipboard(ui->labelCoinControlFee->text().left(ui->labelCoinControlFee->text().indexOf(" ")));
}
// copy label "After fee" to clipboard
void CoinControlDialog::clipboardAfterFee()
{
QApplication::clipboard()->setText(ui->labelCoinControlAfterFee->text().left(ui->labelCoinControlAfterFee->text().indexOf(" ")));
GUIUtil::setClipboard(ui->labelCoinControlAfterFee->text().left(ui->labelCoinControlAfterFee->text().indexOf(" ")));
}
// copy label "Bytes" to clipboard
void CoinControlDialog::clipboardBytes()
{
QApplication::clipboard()->setText(ui->labelCoinControlBytes->text());
GUIUtil::setClipboard(ui->labelCoinControlBytes->text());
}
// copy label "Priority" to clipboard
void CoinControlDialog::clipboardPriority()
{
QApplication::clipboard()->setText(ui->labelCoinControlPriority->text());
GUIUtil::setClipboard(ui->labelCoinControlPriority->text());
}
// copy label "Low output" to clipboard
void CoinControlDialog::clipboardLowOutput()
{
QApplication::clipboard()->setText(ui->labelCoinControlLowOutput->text());
GUIUtil::setClipboard(ui->labelCoinControlLowOutput->text());
}
// copy label "Change" to clipboard
void CoinControlDialog::clipboardChange()
{
QApplication::clipboard()->setText(ui->labelCoinControlChange->text().left(ui->labelCoinControlChange->text().indexOf(" ")));
GUIUtil::setClipboard(ui->labelCoinControlChange->text().left(ui->labelCoinControlChange->text().indexOf(" ")));
}
// treeview: sort

12
src/qt/forms/coincontroldialog.ui

@ -61,7 +61,7 @@ @@ -61,7 +61,7 @@
<enum>Qt::ActionsContextMenu</enum>
</property>
<property name="text">
<string>0</string>
<string notr="true">0</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
@ -93,7 +93,7 @@ @@ -93,7 +93,7 @@
<enum>Qt::ActionsContextMenu</enum>
</property>
<property name="text">
<string>0</string>
<string notr="true">0</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
@ -141,7 +141,7 @@ @@ -141,7 +141,7 @@
<enum>Qt::ActionsContextMenu</enum>
</property>
<property name="text">
<string>0.00 BTC</string>
<string notr="true">0.00 BTC</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
@ -221,7 +221,7 @@ @@ -221,7 +221,7 @@
<enum>Qt::ActionsContextMenu</enum>
</property>
<property name="text">
<string>0.00 BTC</string>
<string notr="true">0.00 BTC</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
@ -307,7 +307,7 @@ @@ -307,7 +307,7 @@
<enum>Qt::ActionsContextMenu</enum>
</property>
<property name="text">
<string>0.00 BTC</string>
<string notr="true">0.00 BTC</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
@ -345,7 +345,7 @@ @@ -345,7 +345,7 @@
<enum>Qt::ActionsContextMenu</enum>
</property>
<property name="text">
<string>0.00 BTC</string>
<string notr="true">0.00 BTC</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>

12
src/qt/forms/sendcoinsdialog.ui

@ -232,7 +232,7 @@ @@ -232,7 +232,7 @@
<enum>Qt::ActionsContextMenu</enum>
</property>
<property name="text">
<string>0</string>
<string notr="true">0</string>
</property>
<property name="margin">
<number>0</number>
@ -267,7 +267,7 @@ @@ -267,7 +267,7 @@
<enum>Qt::ActionsContextMenu</enum>
</property>
<property name="text">
<string>0</string>
<string notr="true">0</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
@ -321,7 +321,7 @@ @@ -321,7 +321,7 @@
<enum>Qt::ActionsContextMenu</enum>
</property>
<property name="text">
<string>0.00 BTC</string>
<string notr="true">0.00 BTC</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
@ -407,7 +407,7 @@ @@ -407,7 +407,7 @@
<enum>Qt::ActionsContextMenu</enum>
</property>
<property name="text">
<string>0.00 BTC</string>
<string notr="true">0.00 BTC</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
@ -493,7 +493,7 @@ @@ -493,7 +493,7 @@
<enum>Qt::ActionsContextMenu</enum>
</property>
<property name="text">
<string>0.00 BTC</string>
<string notr="true">0.00 BTC</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
@ -525,7 +525,7 @@ @@ -525,7 +525,7 @@
<enum>Qt::ActionsContextMenu</enum>
</property>
<property name="text">
<string>0.00 BTC</string>
<string notr="true">0.00 BTC</string>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>

6
src/qt/guiutil.cpp

@ -181,6 +181,12 @@ void copyEntryData(QAbstractItemView *view, int column, int role) @@ -181,6 +181,12 @@ void copyEntryData(QAbstractItemView *view, int column, int role)
}
}
void setClipboard(const QString& str)
{
QApplication::clipboard()->setText(str, QClipboard::Clipboard);
QApplication::clipboard()->setText(str, QClipboard::Selection);
}
QString getSaveFileName(QWidget *parent, const QString &caption,
const QString &dir,
const QString &filter,

2
src/qt/guiutil.h

@ -48,6 +48,8 @@ namespace GUIUtil @@ -48,6 +48,8 @@ namespace GUIUtil
*/
void copyEntryData(QAbstractItemView *view, int column, int role=Qt::EditRole);
void setClipboard(const QString& str);
/** Get save filename, mimics QFileDialog::getSaveFileName, except that it appends a default suffix
when no suffix is provided by the user.

20
src/qt/sendcoinsdialog.cpp

@ -387,49 +387,49 @@ void SendCoinsDialog::updateDisplayUnit() @@ -387,49 +387,49 @@ void SendCoinsDialog::updateDisplayUnit()
// Coin Control: copy label "Quantity" to clipboard
void SendCoinsDialog::coinControlClipboardQuantity()
{
QApplication::clipboard()->setText(ui->labelCoinControlQuantity->text());
GUIUtil::setClipboard(ui->labelCoinControlQuantity->text());
}
// Coin Control: copy label "Amount" to clipboard
void SendCoinsDialog::coinControlClipboardAmount()
{
QApplication::clipboard()->setText(ui->labelCoinControlAmount->text().left(ui->labelCoinControlAmount->text().indexOf(" ")));
GUIUtil::setClipboard(ui->labelCoinControlAmount->text().left(ui->labelCoinControlAmount->text().indexOf(" ")));
}
// Coin Control: copy label "Fee" to clipboard
void SendCoinsDialog::coinControlClipboardFee()
{
QApplication::clipboard()->setText(ui->labelCoinControlFee->text().left(ui->labelCoinControlFee->text().indexOf(" ")));
GUIUtil::setClipboard(ui->labelCoinControlFee->text().left(ui->labelCoinControlFee->text().indexOf(" ")));
}
// Coin Control: copy label "After fee" to clipboard
void SendCoinsDialog::coinControlClipboardAfterFee()
{
QApplication::clipboard()->setText(ui->labelCoinControlAfterFee->text().left(ui->labelCoinControlAfterFee->text().indexOf(" ")));
GUIUtil::setClipboard(ui->labelCoinControlAfterFee->text().left(ui->labelCoinControlAfterFee->text().indexOf(" ")));
}
// Coin Control: copy label "Bytes" to clipboard
void SendCoinsDialog::coinControlClipboardBytes()
{
QApplication::clipboard()->setText(ui->labelCoinControlBytes->text());
GUIUtil::setClipboard(ui->labelCoinControlBytes->text());
}
// Coin Control: copy label "Priority" to clipboard
void SendCoinsDialog::coinControlClipboardPriority()
{
QApplication::clipboard()->setText(ui->labelCoinControlPriority->text());
GUIUtil::setClipboard(ui->labelCoinControlPriority->text());
}
// Coin Control: copy label "Low output" to clipboard
void SendCoinsDialog::coinControlClipboardLowOutput()
{
QApplication::clipboard()->setText(ui->labelCoinControlLowOutput->text());
GUIUtil::setClipboard(ui->labelCoinControlLowOutput->text());
}
// Coin Control: copy label "Change" to clipboard
void SendCoinsDialog::coinControlClipboardChange()
{
QApplication::clipboard()->setText(ui->labelCoinControlChange->text().left(ui->labelCoinControlChange->text().indexOf(" ")));
GUIUtil::setClipboard(ui->labelCoinControlChange->text().left(ui->labelCoinControlChange->text().indexOf(" ")));
}
// Coin Control: settings menu - coin control enabled/disabled by user
@ -479,7 +479,7 @@ void SendCoinsDialog::coinControlChangeEdited(const QString & text) @@ -479,7 +479,7 @@ void SendCoinsDialog::coinControlChangeEdited(const QString & text)
else if (!CBitcoinAddress(text.toStdString()).IsValid())
{
ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}");
ui->labelCoinControlChangeLabel->setText(tr("WARNING: Invalid Bitcoin address"));
ui->labelCoinControlChangeLabel->setText(tr("Warning: Invalid Bitcoin address"));
}
else
{
@ -496,7 +496,7 @@ void SendCoinsDialog::coinControlChangeEdited(const QString & text) @@ -496,7 +496,7 @@ void SendCoinsDialog::coinControlChangeEdited(const QString & text)
else
{
ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}");
ui->labelCoinControlChangeLabel->setText(tr("WARNING: unknown change address"));
ui->labelCoinControlChangeLabel->setText(tr("Warning: Unknown change address"));
}
}
}

20
src/qt/walletmodel.cpp

@ -36,8 +36,19 @@ WalletModel::~WalletModel() @@ -36,8 +36,19 @@ WalletModel::~WalletModel()
unsubscribeFromCoreSignals();
}
qint64 WalletModel::getBalance() const
qint64 WalletModel::getBalance(const CCoinControl *coinControl) const
{
if (coinControl)
{
int64 nBalance = 0;
std::vector<COutput> vCoins;
wallet->AvailableCoins(vCoins, true, coinControl);
BOOST_FOREACH(const COutput& out, vCoins)
nBalance += out.tx->vout[out.i].nValue;
return nBalance;
}
return wallet->GetBalance();
}
@ -156,12 +167,7 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(const QList<SendCoinsRecipie @@ -156,12 +167,7 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(const QList<SendCoinsRecipie
return DuplicateAddress;
}
// we do not use getBalance() here, because some coins could be locked or coin control could be active
int64 nBalance = 0;
std::vector<COutput> vCoins;
wallet->AvailableCoins(vCoins, true, coinControl);
BOOST_FOREACH(const COutput& out, vCoins)
nBalance += out.tx->vout[out.i].nValue;
int64 nBalance = getBalance(coinControl);
if(total > nBalance)
{

2
src/qt/walletmodel.h

@ -63,7 +63,7 @@ public: @@ -63,7 +63,7 @@ public:
AddressTableModel *getAddressTableModel();
TransactionTableModel *getTransactionTableModel();
qint64 getBalance() const;
qint64 getBalance(const CCoinControl *coinControl=NULL) const;
qint64 getUnconfirmedBalance() const;
qint64 getImmatureBalance() const;
int getNumTransactions() const;

Loading…
Cancel
Save