add the slot updateDisplayUnit() to overviewpage, sendcoinsdialog, sendcoinsentry and connect it to displayUnitChanged() - this ensures all fields in the GUI, who use a display unit are imediately updated, when the user changes this setting in the optionsdialog / ensure used fields init with the current set display unit

This commit is contained in:
Philip Kaufmann 2012-06-09 15:41:21 +02:00
parent fab7858a35
commit e0873dafc5
6 changed files with 45 additions and 18 deletions

View file

@ -152,7 +152,7 @@ void OverviewPage::setNumTransactions(int count)
void OverviewPage::setModel(WalletModel *model)
{
this->model = model;
if(model)
if(model && model->getOptionsModel())
{
// Set up transaction list
filter = new TransactionFilterProxy();
@ -172,20 +172,26 @@ void OverviewPage::setModel(WalletModel *model)
setNumTransactions(model->getNumTransactions());
connect(model, SIGNAL(numTransactionsChanged(int)), this, SLOT(setNumTransactions(int)));
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(displayUnitChanged()));
}
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
}
void OverviewPage::displayUnitChanged()
// update the display unit, to not use the default ("BTC")
updateDisplayUnit();
}
void OverviewPage::updateDisplayUnit()
{
if(model && model->getOptionsModel())
{
if(!model || !model->getOptionsModel())
return;
if(currentBalance != -1)
setBalance(currentBalance, currentUnconfirmedBalance, currentImmatureBalance);
// Update txdelegate->unit with the current unit
txdelegate->unit = model->getOptionsModel()->getDisplayUnit();
ui->listTransactions->update();
}
}
void OverviewPage::showOutOfSyncWarning(bool fShow)
{

View file

@ -44,7 +44,7 @@ private:
TransactionFilterProxy *filter;
private slots:
void displayUnitChanged();
void updateDisplayUnit();
void handleTransactionClicked(const QModelIndex &index);
};

View file

@ -46,10 +46,11 @@ void SendCoinsDialog::setModel(WalletModel *model)
entry->setModel(model);
}
}
if(model)
if(model && model->getOptionsModel())
{
setBalance(model->getBalance(), model->getUnconfirmedBalance(), model->getImmatureBalance());
connect(model, SIGNAL(balanceChanged(qint64, qint64, qint64)), this, SLOT(setBalance(qint64, qint64, qint64)));
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
}
}
@ -289,3 +290,12 @@ void SendCoinsDialog::setBalance(qint64 balance, qint64 unconfirmedBalance, qint
int unit = model->getOptionsModel()->getDisplayUnit();
ui->labelBalance->setText(BitcoinUnits::formatWithUnit(unit, balance));
}
void SendCoinsDialog::updateDisplayUnit()
{
if(model && model->getOptionsModel())
{
// Update labelBalance with the current balance and the current unit
ui->labelBalance->setText(BitcoinUnits::formatWithUnit(model->getOptionsModel()->getDisplayUnit(), model->getBalance()));
}
}

View file

@ -47,8 +47,8 @@ private:
private slots:
void on_sendButton_clicked();
void removeEntry(SendCoinsEntry* entry);
void updateDisplayUnit();
};
#endif // SENDCOINSDIALOG_H

View file

@ -68,6 +68,10 @@ void SendCoinsEntry::on_payTo_textChanged(const QString &address)
void SendCoinsEntry::setModel(WalletModel *model)
{
this->model = model;
if(model && model->getOptionsModel())
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
clear();
}
@ -82,10 +86,8 @@ void SendCoinsEntry::clear()
ui->addAsLabel->clear();
ui->payAmount->clear();
ui->payTo->setFocus();
if(model && model->getOptionsModel())
{
ui->payAmount->setDisplayUnit(model->getOptionsModel()->getDisplayUnit());
}
// update the display unit, to not use the default ("BTC")
updateDisplayUnit();
}
void SendCoinsEntry::on_deleteButton_clicked()
@ -160,3 +162,11 @@ 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());
}
}

View file

@ -45,6 +45,7 @@ private slots:
void on_payTo_textChanged(const QString &address);
void on_addressBookButton_clicked();
void on_pasteButton_clicked();
void updateDisplayUnit();
private:
Ui::SendCoinsEntry *ui;