diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2011-05-12 20:28:07 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2011-05-12 20:28:07 +0200 |
commit | 1a6d504a382e84102b7e7009b08c920a345584f7 (patch) | |
tree | 2b6fcd9f7b02f3cabb9e6f928788296e558e72df | |
parent | 3f323a61feebccda9c7d7c66ade3dd21d7cbddf5 (diff) |
make balance/blocks/connections/transactions settable through slots
-rw-r--r-- | bitcoin.cpp | 4 | ||||
-rw-r--r-- | bitcoingui.cpp | 48 | ||||
-rw-r--r-- | bitcoingui.h | 9 |
3 files changed, 47 insertions, 14 deletions
diff --git a/bitcoin.cpp b/bitcoin.cpp index ad9835628b..456ce1e923 100644 --- a/bitcoin.cpp +++ b/bitcoin.cpp @@ -10,6 +10,10 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); BitcoinGUI window; + window.setBalance(1234.567890); + window.setNumConnections(4); + window.setNumTransactions(4); + window.setNumBlocks(33); window.show(); diff --git a/bitcoingui.cpp b/bitcoingui.cpp index 01b18f1b81..771b902667 100644 --- a/bitcoingui.cpp +++ b/bitcoingui.cpp @@ -66,7 +66,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): hbox_address->addWidget(new QLabel(tr("Your Bitcoin Address:"))); address = new QLineEdit(); address->setReadOnly(true); - address->setText("0123456789"); + address->setText("0123456789"); /* test */ hbox_address->addWidget(address); QPushButton *button_new = new QPushButton(tr("&New...")); @@ -79,7 +79,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): hbox_balance->addWidget(new QLabel(tr("Balance:"))); hbox_balance->addSpacing(5);/* Add some spacing between the label and the text */ - labelBalance = new QLabel(QLocale::system().toString(1345.54)); + labelBalance = new QLabel(); labelBalance->setFont(QFont("Teletype")); hbox_balance->addWidget(labelBalance); hbox_balance->addStretch(1); @@ -99,21 +99,21 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): /* Create status bar */ statusBar(); - QLabel *label_connections = new QLabel("6 connections"); - label_connections->setFrameStyle(QFrame::Panel | QFrame::Sunken); - label_connections->setMinimumWidth(100); + labelConnections = new QLabel(); + labelConnections->setFrameStyle(QFrame::Panel | QFrame::Sunken); + labelConnections->setMinimumWidth(130); - QLabel *label_blocks = new QLabel("6 blocks"); - label_blocks->setFrameStyle(QFrame::Panel | QFrame::Sunken); - label_blocks->setMinimumWidth(100); + labelBlocks = new QLabel(); + labelBlocks->setFrameStyle(QFrame::Panel | QFrame::Sunken); + labelBlocks->setMinimumWidth(130); - QLabel *label_transactions = new QLabel("6 transactions"); - label_transactions->setFrameStyle(QFrame::Panel | QFrame::Sunken); - label_transactions->setMinimumWidth(100); + labelTransactions = new QLabel(); + labelTransactions->setFrameStyle(QFrame::Panel | QFrame::Sunken); + labelTransactions->setMinimumWidth(130); - statusBar()->addPermanentWidget(label_connections); - statusBar()->addPermanentWidget(label_blocks); - statusBar()->addPermanentWidget(label_transactions); + statusBar()->addPermanentWidget(labelConnections); + statusBar()->addPermanentWidget(labelBlocks); + statusBar()->addPermanentWidget(labelTransactions); /* Action bindings */ connect(button_new, SIGNAL(clicked()), this, SLOT(newAddressClicked())); @@ -247,3 +247,23 @@ void BitcoinGUI::copyClipboardClicked() /* Copy text in address to clipboard */ QApplication::clipboard()->setText(address->text()); } + +void BitcoinGUI::setBalance(double balance) +{ + labelBalance->setText(QLocale::system().toString(balance, 8)); +} + +void BitcoinGUI::setNumConnections(int count) +{ + labelConnections->setText(QLocale::system().toString(count)+" "+tr("connections")); +} + +void BitcoinGUI::setNumBlocks(int count) +{ + labelBlocks->setText(QLocale::system().toString(count)+" "+tr("blocks")); +} + +void BitcoinGUI::setNumTransactions(int count) +{ + labelTransactions->setText(QLocale::system().toString(count)+" "+tr("transactions")); +} diff --git a/bitcoingui.h b/bitcoingui.h index 6e1003cd50..89e3897a6c 100644 --- a/bitcoingui.h +++ b/bitcoingui.h @@ -27,6 +27,9 @@ private: QLineEdit *address; QLabel *labelBalance; + QLabel *labelConnections; + QLabel *labelBlocks; + QLabel *labelTransactions; QAction *quit; QAction *sendcoins; @@ -42,6 +45,12 @@ private: QWidget *createTabs(); void createTrayIcon(); +public slots: + void setBalance(double balance); + void setNumConnections(int count); + void setNumBlocks(int count); + void setNumTransactions(int count); + private slots: void sendcoinsClicked(); void addressbookClicked(); |