You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

overviewpage.cpp 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #include "overviewpage.h"
  2. #include "ui_overviewpage.h"
  3. #include "walletmodel.h"
  4. #include "guiutil.h"
  5. OverviewPage::OverviewPage(QWidget *parent) :
  6. QWidget(parent),
  7. ui(new Ui::OverviewPage)
  8. {
  9. ui->setupUi(this);
  10. // Balance: <balance>
  11. ui->labelBalance->setFont(QFont("Monospace", -1, QFont::Bold));
  12. ui->labelBalance->setToolTip(tr("Your current balance"));
  13. ui->labelBalance->setTextInteractionFlags(Qt::TextSelectableByMouse|Qt::TextSelectableByKeyboard);
  14. // Balance: <balance>
  15. ui->labelUnconfirmed->setFont(QFont("Monospace", -1, QFont::Bold));
  16. ui->labelUnconfirmed->setToolTip(tr("Balance of transactions that have yet to be confirmed"));
  17. ui->labelUnconfirmed->setTextInteractionFlags(Qt::TextSelectableByMouse|Qt::TextSelectableByKeyboard);
  18. ui->labelNumTransactions->setToolTip(tr("Total number of transactions in wallet"));
  19. // Overview page should show:
  20. // Last received transaction(s)
  21. // Last sent transaction(s)
  22. }
  23. OverviewPage::~OverviewPage()
  24. {
  25. delete ui;
  26. }
  27. void OverviewPage::setBalance(qint64 balance, qint64 unconfirmedBalance)
  28. {
  29. ui->labelBalance->setText(GUIUtil::formatMoney(balance) + QString(" BTC"));
  30. ui->labelUnconfirmed->setText(GUIUtil::formatMoney(unconfirmedBalance) + QString(" BTC"));
  31. }
  32. void OverviewPage::setNumTransactions(int count)
  33. {
  34. ui->labelNumTransactions->setText(QLocale::system().toString(count));
  35. }
  36. void OverviewPage::setModel(WalletModel *model)
  37. {
  38. this->model = model;
  39. // Keep up to date with wallet
  40. setBalance(model->getBalance(), model->getUnconfirmedBalance());
  41. connect(model, SIGNAL(balanceChanged(qint64)), this, SLOT(setBalance(qint64)));
  42. setNumTransactions(model->getNumTransactions());
  43. connect(model, SIGNAL(numTransactionsChanged(int)), this, SLOT(setNumTransactions(int)));
  44. }