#include "optionsmodel.h"
#include "addresstablemodel.h"
-#include "qapplication.h"
-#include "qclipboard.h"
-
-#include <QDebug>
+#include <QApplication>
+#include <QClipboard>
SendCoinsEntry::SendCoinsEntry(QWidget *parent) :
QFrame(parent),
{
ui->setupUi(this);
+#ifdef Q_OS_MAC
+ ui->payToLayout->setSpacing(4);
+#endif
#if QT_VERSION >= 0x040700
- ui->payTo->setPlaceholderText(tr("Enter a Bitcoin address (e.g. 1NS17iag9jJgTHD1VXjvLCEnZuQ3rJDE9L)"));
+ /* Do not move this to the XML file, Qt before 4.7 will choke on it */
ui->addAsLabel->setPlaceholderText(tr("Enter a label for this address to add it to your address book"));
+ ui->payTo->setPlaceholderText(tr("Enter a NovaCoin address (e.g. 4Zo1ga6xuKuQ7JV7M9rGDoxdbYwV5zgQJ5)"));
#endif
setFocusPolicy(Qt::TabFocus);
setFocusProxy(ui->payTo);
void SendCoinsEntry::on_addressBookButton_clicked()
{
+ if(!model)
+ return;
AddressBookPage dlg(AddressBookPage::ForSending, AddressBookPage::SendingTab, this);
dlg.setModel(model->getAddressTableModel());
if(dlg.exec())
void SendCoinsEntry::on_payTo_textChanged(const QString &address)
{
+ if(!model)
+ return;
+ // Fill in label from address book
ui->addAsLabel->setText(model->getAddressTableModel()->labelForAddress(address));
}
void SendCoinsEntry::setModel(WalletModel *model)
{
this->model = model;
+
+ if(model && model->getOptionsModel())
+ connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
+
+ connect(ui->payAmount, SIGNAL(textChanged()), this, SIGNAL(payAmountChanged()));
+
+ clear();
}
void SendCoinsEntry::setRemoveEnabled(bool enabled)
ui->addAsLabel->clear();
ui->payAmount->clear();
ui->payTo->setFocus();
- if(model)
- {
- ui->payAmount->setDisplayUnit(model->getOptionsModel()->getDisplayUnit());
- }
+ // update the display unit, to not use the default ("BTC")
+ updateDisplayUnit();
}
void SendCoinsEntry::on_deleteButton_clicked()
return ui->payTo->text().isEmpty();
}
+void SendCoinsEntry::setFocus()
+{
+ ui->payTo->setFocus();
+}
+
+void SendCoinsEntry::updateDisplayUnit()
+{
+ if(model && model->getOptionsModel())
+ {
+ // Update payAmount with the current unit
+ ui->payAmount->setDisplayUnit(model->getOptionsModel()->getDisplayUnit());
+ }
+}