Browse Source

Merge pull request #1434 from Diapolo/GUI_fix_displayunit

GUI: init with correct display unit and update it, when user changes it via options dialog
0.8
Wladimir J. van der Laan 13 years ago
parent
commit
a54d2118be
  1. 24
      src/qt/overviewpage.cpp
  2. 2
      src/qt/overviewpage.h
  3. 16
      src/qt/sendcoinsdialog.cpp
  4. 2
      src/qt/sendcoinsdialog.h
  5. 18
      src/qt/sendcoinsentry.cpp
  6. 1
      src/qt/sendcoinsentry.h

24
src/qt/overviewpage.cpp

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

2
src/qt/overviewpage.h

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

16
src/qt/sendcoinsdialog.cpp

@ -46,10 +46,11 @@ void SendCoinsDialog::setModel(WalletModel *model)
entry->setModel(model); entry->setModel(model);
} }
} }
if(model) if(model && model->getOptionsModel())
{ {
setBalance(model->getBalance(), model->getUnconfirmedBalance(), model->getImmatureBalance()); setBalance(model->getBalance(), model->getUnconfirmedBalance(), model->getImmatureBalance());
connect(model, SIGNAL(balanceChanged(qint64, qint64, qint64)), this, SLOT(setBalance(qint64, qint64, qint64))); connect(model, SIGNAL(balanceChanged(qint64, qint64, qint64)), this, SLOT(setBalance(qint64, qint64, qint64)));
connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
} }
} }
@ -202,7 +203,7 @@ SendCoinsEntry *SendCoinsDialog::addEntry()
ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->sizeHint()); ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->sizeHint());
QCoreApplication::instance()->processEvents(); QCoreApplication::instance()->processEvents();
QScrollBar* bar = ui->scrollArea->verticalScrollBar(); QScrollBar* bar = ui->scrollArea->verticalScrollBar();
if (bar) if(bar)
bar->setSliderPosition(bar->maximum()); bar->setSliderPosition(bar->maximum());
return entry; return entry;
} }
@ -245,7 +246,7 @@ QWidget *SendCoinsDialog::setupTabChain(QWidget *prev)
void SendCoinsDialog::pasteEntry(const SendCoinsRecipient &rv) void SendCoinsDialog::pasteEntry(const SendCoinsRecipient &rv)
{ {
if (!fNewRecipientAllowed) if(!fNewRecipientAllowed)
return; return;
SendCoinsEntry *entry = 0; SendCoinsEntry *entry = 0;
@ -289,3 +290,12 @@ void SendCoinsDialog::setBalance(qint64 balance, qint64 unconfirmedBalance, qint
int unit = model->getOptionsModel()->getDisplayUnit(); int unit = model->getOptionsModel()->getDisplayUnit();
ui->labelBalance->setText(BitcoinUnits::formatWithUnit(unit, balance)); 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()));
}
}

2
src/qt/sendcoinsdialog.h

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

18
src/qt/sendcoinsentry.cpp

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

1
src/qt/sendcoinsentry.h

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

Loading…
Cancel
Save