diff options
Diffstat (limited to 'src/qt/bitcoingui.cpp')
-rw-r--r-- | src/qt/bitcoingui.cpp | 130 |
1 files changed, 82 insertions, 48 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index c642f4aa0b..afb829e08a 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -8,8 +8,7 @@ #include "transactiontablemodel.h" #include "addressbookpage.h" #include "sendcoinsdialog.h" -#include "messagepage.h" -#include "verifymessagedialog.h" +#include "signverifymessagedialog.h" #include "optionsdialog.h" #include "aboutdialog.h" #include "clientmodel.h" @@ -52,7 +51,6 @@ #include <QFileDialog> #include <QDesktopServices> #include <QTimer> - #include <QDragEnterEvent> #include <QUrl> @@ -70,7 +68,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): rpcConsole(0) { resize(850, 550); - setWindowTitle(tr("Bitcoin Wallet")); + setWindowTitle(tr("Bitcoin") + " - " + tr("Wallet")); #ifndef Q_WS_MAC qApp->setWindowIcon(QIcon(":icons/bitcoin")); setWindowIcon(QIcon(":icons/bitcoin")); @@ -108,7 +106,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): sendCoinsPage = new SendCoinsDialog(this); - messagePage = new MessagePage(this); + signVerifyMessageDialog = new SignVerifyMessageDialog(this); centralWidget = new QStackedWidget(this); centralWidget->addWidget(overviewPage); @@ -117,7 +115,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): centralWidget->addWidget(receiveCoinsPage); centralWidget->addWidget(sendCoinsPage); #ifdef FIRST_CLASS_MESSAGING - centralWidget->addWidget(messagePage); + centralWidget->addWidget(signVerifyMessageDialog); #endif setCentralWidget(centralWidget); @@ -166,6 +164,11 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): rpcConsole = new RPCConsole(this); connect(openRPCConsoleAction, SIGNAL(triggered()), rpcConsole, SLOT(show())); + // Clicking on "Verify Message" in the address book sends you to the verify message tab + connect(addressBookPage, SIGNAL(verifyMessage(QString)), this, SLOT(gotoVerifyMessageTab(QString))); + // Clicking on "Sign Message" in the receive coins page sends you to the sign message tab + connect(receiveCoinsPage, SIGNAL(signMessage(QString)), this, SLOT(gotoSignMessageTab(QString))); + gotoOverviewPage(); } @@ -212,12 +215,20 @@ void BitcoinGUI::createActions() sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2)); tabGroup->addAction(sendCoinsAction); - messageAction = new QAction(QIcon(":/icons/edit"), tr("Sign &message..."), this); - messageAction->setToolTip(tr("Prove you control an address")); + signMessageAction = new QAction(QIcon(":/icons/edit"), tr("Sign &message..."), this); + signMessageAction->setToolTip(tr("Sign a message to prove you own a Bitcoin address")); + tabGroup->addAction(signMessageAction); + + verifyMessageAction = new QAction(QIcon(":/icons/transaction_0"), tr("&Verify message..."), this); + verifyMessageAction->setToolTip(tr("Verify a message to ensure it was signed with a specified Bitcoin address")); + tabGroup->addAction(verifyMessageAction); + #ifdef FIRST_CLASS_MESSAGING - messageAction->setCheckable(true); + firstClassMessagingAction = new QAction(QIcon(":/icons/edit"), tr("S&ignatures"), this); + firstClassMessagingAction->setToolTip(signMessageAction->toolTip() + QString(". / ") + verifyMessageAction->toolTip() + QString(".")); + firstClassMessagingAction->setCheckable(true); + tabGroup->addAction(firstClassMessagingAction); #endif - tabGroup->addAction(messageAction); connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage())); @@ -229,14 +240,21 @@ void BitcoinGUI::createActions() connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage())); connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage())); - connect(messageAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); - connect(messageAction, SIGNAL(triggered()), this, SLOT(gotoMessagePage())); + connect(signMessageAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); + connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab())); + connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); + connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab())); +#ifdef FIRST_CLASS_MESSAGING + connect(firstClassMessagingAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); + // Always start with the sign message tab for FIRST_CLASS_MESSAGING + connect(firstClassMessagingAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab())); +#endif quitAction = new QAction(QIcon(":/icons/quit"), tr("E&xit"), this); quitAction->setToolTip(tr("Quit application")); quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q)); quitAction->setMenuRole(QAction::QuitRole); - aboutAction = new QAction(QIcon(":/icons/bitcoin"), tr("&About %1").arg(qApp->applicationName()), this); + aboutAction = new QAction(QIcon(":/icons/bitcoin"), tr("&About Bitcoin"), this); aboutAction->setToolTip(tr("Show information about Bitcoin")); aboutAction->setMenuRole(QAction::AboutRole); aboutQtAction = new QAction(tr("About &Qt"), this); @@ -258,8 +276,6 @@ void BitcoinGUI::createActions() changePassphraseAction->setToolTip(tr("Change the passphrase used for wallet encryption")); openRPCConsoleAction = new QAction(QIcon(":/icons/debugwindow"), tr("&Debug window"), this); openRPCConsoleAction->setToolTip(tr("Open debugging and diagnostic console")); - verifyMessageAction = new QAction(QIcon(":/icons/transaction_0"), tr("&Verify message..."), this); - verifyMessageAction->setToolTip(tr("Verify a message signature")); connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked())); @@ -269,7 +285,6 @@ void BitcoinGUI::createActions() connect(encryptWalletAction, SIGNAL(triggered(bool)), this, SLOT(encryptWallet(bool))); connect(backupWalletAction, SIGNAL(triggered()), this, SLOT(backupWallet())); connect(changePassphraseAction, SIGNAL(triggered()), this, SLOT(changePassphrase())); - connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(verifyMessage())); } void BitcoinGUI::createMenuBar() @@ -287,9 +302,9 @@ void BitcoinGUI::createMenuBar() file->addAction(backupWalletAction); file->addAction(exportAction); #ifndef FIRST_CLASS_MESSAGING - file->addAction(messageAction); -#endif + file->addAction(signMessageAction); file->addAction(verifyMessageAction); +#endif file->addSeparator(); file->addAction(quitAction); @@ -316,7 +331,7 @@ void BitcoinGUI::createToolBars() toolbar->addAction(historyAction); toolbar->addAction(addressBookAction); #ifdef FIRST_CLASS_MESSAGING - toolbar->addAction(messageAction); + toolbar->addAction(firstClassMessagingAction); #endif QToolBar *toolbar2 = addToolBar(tr("Actions toolbar")); @@ -329,6 +344,7 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel) this->clientModel = clientModel; if(clientModel) { + // Replace some strings and icons, when using the testnet if(clientModel->isTestNet()) { setWindowTitle(windowTitle() + QString(" ") + tr("[testnet]")); @@ -344,6 +360,8 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel) trayIcon->setIcon(QIcon(":/icons/toolbar_testnet")); toggleHideAction->setIcon(QIcon(":/icons/toolbar_testnet")); } + + aboutAction->setIcon(QIcon(":/icons/toolbar_testnet")); } // Keep up to date with client @@ -357,6 +375,8 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel) connect(clientModel, SIGNAL(error(QString,QString,bool)), this, SLOT(error(QString,QString,bool))); rpcConsole->setClientModel(clientModel); + addressBookPage->setOptionsModel(clientModel->getOptionsModel()); + receiveCoinsPage->setOptionsModel(clientModel->getOptionsModel()); } } @@ -375,7 +395,7 @@ void BitcoinGUI::setWalletModel(WalletModel *walletModel) addressBookPage->setModel(walletModel->getAddressTableModel()); receiveCoinsPage->setModel(walletModel->getAddressTableModel()); sendCoinsPage->setModel(walletModel); - messagePage->setModel(walletModel); + signVerifyMessageDialog->setModel(walletModel); setEncryptionStatus(walletModel->getEncryptionStatus()); connect(walletModel, SIGNAL(encryptionStatusChanged(int)), this, SLOT(setEncryptionStatus(int))); @@ -415,7 +435,7 @@ void BitcoinGUI::createTrayIcon() #ifndef FIRST_CLASS_MESSAGING trayIconMenu->addSeparator(); #endif - trayIconMenu->addAction(messageAction); + trayIconMenu->addAction(signMessageAction); trayIconMenu->addAction(verifyMessageAction); trayIconMenu->addSeparator(); trayIconMenu->addAction(optionsAction); @@ -481,6 +501,7 @@ void BitcoinGUI::setNumBlocks(int count, int nTotalBlocks) return; } + QString strStatusBarWarnings = clientModel->getStatusBarWarnings(); QString tooltip; if(count < nTotalBlocks) @@ -488,7 +509,7 @@ void BitcoinGUI::setNumBlocks(int count, int nTotalBlocks) int nRemainingBlocks = nTotalBlocks - count; float nPercentageDone = count / (nTotalBlocks * 0.01f); - if (clientModel->getStatusBarWarnings() == "") + if (strStatusBarWarnings.isEmpty()) { progressBarLabel->setText(tr("Synchronizing with network...")); progressBarLabel->setVisible(true); @@ -497,30 +518,28 @@ void BitcoinGUI::setNumBlocks(int count, int nTotalBlocks) progressBar->setValue(count); progressBar->setVisible(true); } - else - { - progressBarLabel->setText(clientModel->getStatusBarWarnings()); - progressBarLabel->setVisible(true); - progressBar->setVisible(false); - } + tooltip = tr("Downloaded %1 of %2 blocks of transaction history (%3% done).").arg(count).arg(nTotalBlocks).arg(nPercentageDone, 0, 'f', 2); } else { - if (clientModel->getStatusBarWarnings() == "") + if (strStatusBarWarnings.isEmpty()) progressBarLabel->setVisible(false); - else - { - progressBarLabel->setText(clientModel->getStatusBarWarnings()); - progressBarLabel->setVisible(true); - } + progressBar->setVisible(false); tooltip = tr("Downloaded %1 blocks of transaction history.").arg(count); } - QDateTime now = QDateTime::currentDateTime(); + // Override progressBarLabel text and hide progressBar, when we have warnings to display + if (!strStatusBarWarnings.isEmpty()) + { + progressBarLabel->setText(strStatusBarWarnings); + progressBarLabel->setVisible(true); + progressBar->setVisible(false); + } + QDateTime lastBlockDate = clientModel->getLastBlockDate(); - int secs = lastBlockDate.secsTo(now); + int secs = lastBlockDate.secsTo(QDateTime::currentDateTime()); QString text; // Represent time from last generated block in human readable text @@ -717,20 +736,42 @@ void BitcoinGUI::gotoSendCoinsPage() disconnect(exportAction, SIGNAL(triggered()), 0, 0); } -void BitcoinGUI::gotoMessagePage(QString addr) +void BitcoinGUI::gotoSignMessageTab(QString addr) { +#ifdef FIRST_CLASS_MESSAGING + firstClassMessagingAction->setChecked(true); + centralWidget->setCurrentWidget(signVerifyMessageDialog); + + exportAction->setEnabled(false); + disconnect(exportAction, SIGNAL(triggered()), 0, 0); + + signVerifyMessageDialog->showTab_SM(false); +#else + // call show() in showTab_SM() + signVerifyMessageDialog->showTab_SM(true); +#endif + if(!addr.isEmpty()) - messagePage->setAddress(addr); + signVerifyMessageDialog->setAddress_SM(addr); +} +void BitcoinGUI::gotoVerifyMessageTab(QString addr) +{ #ifdef FIRST_CLASS_MESSAGING - messageAction->setChecked(true); - centralWidget->setCurrentWidget(messagePage); + firstClassMessagingAction->setChecked(true); + centralWidget->setCurrentWidget(signVerifyMessageDialog); exportAction->setEnabled(false); disconnect(exportAction, SIGNAL(triggered()), 0, 0); + + signVerifyMessageDialog->showTab_VM(false); #else - messagePage->show(); + // call show() in showTab_VM() + signVerifyMessageDialog->showTab_VM(true); #endif + + if(!addr.isEmpty()) + signVerifyMessageDialog->setAddress_VM(addr); } void BitcoinGUI::dragEnterEvent(QDragEnterEvent *event) @@ -833,13 +874,6 @@ void BitcoinGUI::changePassphrase() dlg.exec(); } -void BitcoinGUI::verifyMessage() -{ - VerifyMessageDialog *dlg = new VerifyMessageDialog(this); - dlg->setAttribute(Qt::WA_DeleteOnClose); - dlg->show(); -} - void BitcoinGUI::unlockWallet() { if(!walletModel) |