aboutsummaryrefslogtreecommitdiff
path: root/src/qt
diff options
context:
space:
mode:
authorPhilip Kaufmann <phil.kaufmann@t-online.de>2012-06-09 15:41:21 +0200
committerLuke Dashjr <luke-jr+git@utopios.org>2012-06-18 16:26:09 +0000
commit506bf85de57bdf079824a14e492c112338768c2a (patch)
tree5f767f89869a751fe360171b4630614ee6c8e2f4 /src/qt
parent133bc2e5f0e9566b3dc3f8f231243b77e4871ac6 (diff)
downloadbitcoin-506bf85de57bdf079824a14e492c112338768c2a.tar.xz
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
Diffstat (limited to 'src/qt')
-rw-r--r--src/qt/overviewpage.cpp24
-rw-r--r--src/qt/overviewpage.h2
-rw-r--r--src/qt/sendcoinsdialog.cpp14
-rw-r--r--src/qt/sendcoinsdialog.h2
-rw-r--r--src/qt/sendcoinsentry.cpp18
-rw-r--r--src/qt/sendcoinsentry.h1
6 files changed, 44 insertions, 17 deletions
diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp
index 5b5a8f5271..2c3d8a49e3 100644
--- a/src/qt/overviewpage.cpp
+++ b/src/qt/overviewpage.cpp
@@ -143,7 +143,7 @@ void OverviewPage::setNumTransactions(int count)
void OverviewPage::setModel(WalletModel *model)
{
this->model = model;
- if(model)
+ if(model && model->getOptionsModel())
{
// Set up transaction list
TransactionFilterProxy *filter = new TransactionFilterProxy();
@@ -163,17 +163,23 @@ 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()));
}
+
+ // update the display unit, to not use the default ("BTC")
+ updateDisplayUnit();
}
-void OverviewPage::displayUnitChanged()
+void OverviewPage::updateDisplayUnit()
{
- if(!model || !model->getOptionsModel())
- return;
- if(currentBalance != -1)
- setBalance(currentBalance, currentUnconfirmedBalance);
+ if(model && model->getOptionsModel())
+ {
+ if(currentBalance != -1)
+ setBalance(currentBalance, currentUnconfirmedBalance);
- txdelegate->unit = model->getOptionsModel()->getDisplayUnit();
- ui->listTransactions->update();
+ // Update txdelegate->unit with the current unit
+ txdelegate->unit = model->getOptionsModel()->getDisplayUnit();
+
+ ui->listTransactions->update();
+ }
}
diff --git a/src/qt/overviewpage.h b/src/qt/overviewpage.h
index 1199227168..99fe486494 100644
--- a/src/qt/overviewpage.h
+++ b/src/qt/overviewpage.h
@@ -40,7 +40,7 @@ private:
TxViewDelegate *txdelegate;
private slots:
- void displayUnitChanged();
+ void updateDisplayUnit();
};
#endif // OVERVIEWPAGE_H
diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp
index 4c58b38b78..ef2f1c3186 100644
--- a/src/qt/sendcoinsdialog.cpp
+++ b/src/qt/sendcoinsdialog.cpp
@@ -44,10 +44,11 @@ void SendCoinsDialog::setModel(WalletModel *model)
entry->setModel(model);
}
}
- if(model)
+ if(model && model->getOptionsModel())
{
setBalance(model->getBalance(), model->getUnconfirmedBalance());
connect(model, SIGNAL(balanceChanged(qint64, qint64)), this, SLOT(setBalance(qint64, qint64)));
+ connect(model->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit()));
}
}
@@ -195,7 +196,7 @@ SendCoinsEntry *SendCoinsDialog::addEntry()
ui->scrollAreaWidgetContents->resize(ui->scrollAreaWidgetContents->sizeHint());
QCoreApplication::instance()->processEvents();
QScrollBar* bar = ui->scrollArea->verticalScrollBar();
- if (bar)
+ if(bar)
bar->setSliderPosition(bar->maximum());
return entry;
}
@@ -286,3 +287,12 @@ void SendCoinsDialog::setBalance(qint64 balance, qint64 unconfirmedBalance)
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()));
+ }
+}
diff --git a/src/qt/sendcoinsdialog.h b/src/qt/sendcoinsdialog.h
index 79125766e3..ed56214191 100644
--- a/src/qt/sendcoinsdialog.h
+++ b/src/qt/sendcoinsdialog.h
@@ -47,8 +47,8 @@ private:
private slots:
void on_sendButton_clicked();
-
void removeEntry(SendCoinsEntry* entry);
+ void updateDisplayUnit();
};
#endif // SENDCOINSDIALOG_H
diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp
index c8242d8352..599a804c46 100644
--- a/src/qt/sendcoinsentry.cpp
+++ b/src/qt/sendcoinsentry.cpp
@@ -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());
+ }
+}
diff --git a/src/qt/sendcoinsentry.h b/src/qt/sendcoinsentry.h
index cdbf893264..db6cba0d80 100644
--- a/src/qt/sendcoinsentry.h
+++ b/src/qt/sendcoinsentry.h
@@ -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;