Improved Mac experience; QDoubleSpinBox for BitcoinAmountField
[novacoin.git] / src / qt / sendcoinsdialog.cpp
index a9a89c2..719cc51 100644 (file)
@@ -6,6 +6,7 @@
 #include "optionsmodel.h"
 #include "sendcoinsentry.h"
 #include "guiutil.h"
+#include "askpassphrasedialog.h"
 
 #include <QMessageBox>
 #include <QLocale>
@@ -18,9 +19,16 @@ SendCoinsDialog::SendCoinsDialog(QWidget *parent) :
 {
     ui->setupUi(this);
 
+#ifdef Q_WS_MAC // Icons on push buttons are very uncommon on Mac
+    ui->addButton->setIcon(QIcon());
+    ui->clearButton->setIcon(QIcon());
+    ui->sendButton->setIcon(QIcon());
+#endif
+
     addEntry();
 
     connect(ui->addButton, SIGNAL(clicked()), this, SLOT(addEntry()));
+    connect(ui->clearButton, SIGNAL(clicked()), this, SLOT(clear()));
 }
 
 void SendCoinsDialog::setModel(WalletModel *model)
@@ -35,6 +43,9 @@ void SendCoinsDialog::setModel(WalletModel *model)
             entry->setModel(model);
         }
     }
+
+    setBalance(model->getBalance(), model->getUnconfirmedBalance());
+    connect(model, SIGNAL(balanceChanged(qint64, qint64)), this, SLOT(setBalance(qint64, qint64)));
 }
 
 SendCoinsDialog::~SendCoinsDialog()
@@ -84,6 +95,13 @@ void SendCoinsDialog::on_sendButton_clicked()
         return;
     }
 
+    WalletModel::UnlockContext ctx(model->requestUnlock());
+    if(!ctx.isValid())
+    {
+        // Unlock wallet was cancelled
+        return;
+    }
+
     WalletModel::SendCoinsReturn sendstatus = model->sendCoins(recipients);
     switch(sendstatus.status)
     {
@@ -118,7 +136,6 @@ void SendCoinsDialog::on_sendButton_clicked()
             tr("Error: Transaction creation failed  "),
             QMessageBox::Ok, QMessageBox::Ok);
         break;
-        break;
     case WalletModel::TransactionCommitFailed:
         QMessageBox::warning(this, tr("Send Coins"),
             tr("Error: The transaction was rejected.  This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here."),
@@ -234,3 +251,10 @@ void SendCoinsDialog::handleURL(const QUrl *url)
     }
     pasteEntry(rv);
 }
+
+void SendCoinsDialog::setBalance(qint64 balance, qint64 unconfirmedBalance)
+{
+    Q_UNUSED(unconfirmedBalance);
+    int unit = model->getOptionsModel()->getDisplayUnit();
+    ui->labelBalance->setText(BitcoinUnits::formatWithUnit(unit, balance));
+}