diff options
Diffstat (limited to 'src/qt/bitcoingui.cpp')
-rw-r--r-- | src/qt/bitcoingui.cpp | 169 |
1 files changed, 64 insertions, 105 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 7b0e6f3bc0..19a6a65a1b 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -26,7 +26,7 @@ #include "guiutil.h" #include "rpcconsole.h" -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC #include "macdockiconhandler.h" #endif @@ -53,6 +53,7 @@ #include <QTimer> #include <QDragEnterEvent> #include <QUrl> +#include <QStyle> #include <iostream> @@ -69,7 +70,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): { resize(850, 550); setWindowTitle(tr("Bitcoin") + " - " + tr("Wallet")); -#ifndef Q_WS_MAC +#ifndef Q_OS_MAC qApp->setWindowIcon(QIcon(":icons/bitcoin")); setWindowIcon(QIcon(":icons/bitcoin")); #else @@ -114,9 +115,6 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): centralWidget->addWidget(addressBookPage); centralWidget->addWidget(receiveCoinsPage); centralWidget->addWidget(sendCoinsPage); -#ifdef FIRST_CLASS_MESSAGING - centralWidget->addWidget(signVerifyMessageDialog); -#endif setCentralWidget(centralWidget); // Create status bar @@ -148,6 +146,15 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): progressBar->setAlignment(Qt::AlignCenter); progressBar->setVisible(false); + // Override style sheet for progress bar for styles that have a segmented progress bar, + // as they make the text unreadable (workaround for issue #1071) + // See https://qt-project.org/doc/qt-4.8/gallery.html + QString curStyle = qApp->style()->metaObject()->className(); + if(curStyle == "QWindowsStyle" || curStyle == "QWindowsXPStyle") + { + progressBar->setStyleSheet("QProgressBar { background-color: #e8e8e8; border: 1px solid grey; border-radius: 7px; padding: 1px; text-align: center; } QProgressBar::chunk { background: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #FF8000, stop: 1 orange); border-radius: 7px; margin: 0px; }"); + } + statusBar()->addWidget(progressBarLabel); statusBar()->addWidget(progressBar); statusBar()->addPermanentWidget(frameBlocks); @@ -158,7 +165,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), this, SLOT(gotoHistoryPage())); connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), transactionView, SLOT(focusTransaction(QModelIndex))); - // Doubleclicking on a transaction on the transaction history page shows details + // Double-clicking on a transaction on the transaction history page shows details connect(transactionView, SIGNAL(doubleClicked(QModelIndex)), transactionView, SLOT(showDetails())); rpcConsole = new RPCConsole(this); @@ -176,7 +183,7 @@ BitcoinGUI::~BitcoinGUI() { if(trayIcon) // Hide tray icon, as deleting will let it linger until quit (on Ubuntu) trayIcon->hide(); -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC delete appMenuBar; #endif } @@ -191,6 +198,18 @@ void BitcoinGUI::createActions() overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1)); tabGroup->addAction(overviewAction); + sendCoinsAction = new QAction(QIcon(":/icons/send"), tr("&Send coins"), this); + sendCoinsAction->setToolTip(tr("Send coins to a Bitcoin address")); + sendCoinsAction->setCheckable(true); + sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2)); + tabGroup->addAction(sendCoinsAction); + + receiveCoinsAction = new QAction(QIcon(":/icons/receiving_addresses"), tr("&Receive coins"), this); + receiveCoinsAction->setToolTip(tr("Show the list of addresses for receiving payments")); + receiveCoinsAction->setCheckable(true); + receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3)); + tabGroup->addAction(receiveCoinsAction); + historyAction = new QAction(QIcon(":/icons/history"), tr("&Transactions"), this); historyAction->setToolTip(tr("Browse transaction history")); historyAction->setCheckable(true); @@ -203,52 +222,16 @@ void BitcoinGUI::createActions() addressBookAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_5)); tabGroup->addAction(addressBookAction); - receiveCoinsAction = new QAction(QIcon(":/icons/receiving_addresses"), tr("&Receive coins"), this); - receiveCoinsAction->setToolTip(tr("Show the list of addresses for receiving payments")); - receiveCoinsAction->setCheckable(true); - receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3)); - tabGroup->addAction(receiveCoinsAction); - - sendCoinsAction = new QAction(QIcon(":/icons/send"), tr("&Send coins"), this); - sendCoinsAction->setToolTip(tr("Send coins to a Bitcoin address")); - sendCoinsAction->setCheckable(true); - sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2)); - tabGroup->addAction(sendCoinsAction); - - 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 - 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 - connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage())); + connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); + connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage())); + connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); + connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage())); connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage())); connect(addressBookAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); connect(addressBookAction, SIGNAL(triggered()), this, SLOT(gotoAddressBookPage())); - connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); - connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage())); - connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); - connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage())); - 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")); @@ -257,16 +240,13 @@ void BitcoinGUI::createActions() 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); + aboutQtAction = new QAction(QIcon(":/trolltech/qmessagebox/images/qtlogo-64.png"), tr("About &Qt"), this); aboutQtAction->setToolTip(tr("Show information about Qt")); aboutQtAction->setMenuRole(QAction::AboutQtRole); optionsAction = new QAction(QIcon(":/icons/options"), tr("&Options..."), this); optionsAction->setToolTip(tr("Modify configuration options for Bitcoin")); optionsAction->setMenuRole(QAction::PreferencesRole); - toggleHideAction = new QAction(QIcon(":/icons/bitcoin"), tr("Show/Hide &Bitcoin"), this); - toggleHideAction->setToolTip(tr("Show or hide the Bitcoin window")); - exportAction = new QAction(QIcon(":/icons/export"), tr("&Export..."), this); - exportAction->setToolTip(tr("Export the data in the current tab to a file")); + toggleHideAction = new QAction(QIcon(":/icons/bitcoin"), tr("&Show / Hide"), this); encryptWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Encrypt Wallet..."), this); encryptWalletAction->setToolTip(tr("Encrypt or decrypt wallet")); encryptWalletAction->setCheckable(true); @@ -274,22 +254,29 @@ void BitcoinGUI::createActions() backupWalletAction->setToolTip(tr("Backup wallet to another location")); changePassphraseAction = new QAction(QIcon(":/icons/key"), tr("&Change Passphrase..."), this); changePassphraseAction->setToolTip(tr("Change the passphrase used for wallet encryption")); + signMessageAction = new QAction(QIcon(":/icons/edit"), tr("Sign &message..."), this); + verifyMessageAction = new QAction(QIcon(":/icons/transaction_0"), tr("&Verify message..."), this); + + exportAction = new QAction(QIcon(":/icons/export"), tr("&Export..."), this); + exportAction->setToolTip(tr("Export the data in the current tab to a file")); openRPCConsoleAction = new QAction(QIcon(":/icons/debugwindow"), tr("&Debug window"), this); openRPCConsoleAction->setToolTip(tr("Open debugging and diagnostic console")); connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); - connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked())); connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked())); connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); + connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked())); connect(toggleHideAction, SIGNAL(triggered()), this, SLOT(toggleHidden())); connect(encryptWalletAction, SIGNAL(triggered(bool)), this, SLOT(encryptWallet(bool))); connect(backupWalletAction, SIGNAL(triggered()), this, SLOT(backupWallet())); connect(changePassphraseAction, SIGNAL(triggered()), this, SLOT(changePassphrase())); + connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab())); + connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab())); } void BitcoinGUI::createMenuBar() { -#ifdef Q_WS_MAC +#ifdef Q_OS_MAC // Create a decoupled menu bar on Mac which stays even if the window is closed appMenuBar = new QMenuBar(); #else @@ -301,10 +288,8 @@ void BitcoinGUI::createMenuBar() QMenu *file = appMenuBar->addMenu(tr("&File")); file->addAction(backupWalletAction); file->addAction(exportAction); -#ifndef FIRST_CLASS_MESSAGING file->addAction(signMessageAction); file->addAction(verifyMessageAction); -#endif file->addSeparator(); file->addAction(quitAction); @@ -330,9 +315,6 @@ void BitcoinGUI::createToolBars() toolbar->addAction(receiveCoinsAction); toolbar->addAction(historyAction); toolbar->addAction(addressBookAction); -#ifdef FIRST_CLASS_MESSAGING - toolbar->addAction(firstClassMessagingAction); -#endif QToolBar *toolbar2 = addToolBar(tr("Actions toolbar")); toolbar2->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); @@ -348,7 +330,7 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel) if(clientModel->isTestNet()) { setWindowTitle(windowTitle() + QString(" ") + tr("[testnet]")); -#ifndef Q_WS_MAC +#ifndef Q_OS_MAC qApp->setWindowIcon(QIcon(":icons/bitcoin_testnet")); setWindowIcon(QIcon(":icons/bitcoin_testnet")); #else @@ -400,7 +382,7 @@ void BitcoinGUI::setWalletModel(WalletModel *walletModel) setEncryptionStatus(walletModel->getEncryptionStatus()); connect(walletModel, SIGNAL(encryptionStatusChanged(int)), this, SLOT(setEncryptionStatus(int))); - // Balloon popup for new transaction + // Balloon pop-up for new transaction connect(walletModel->getTransactionTableModel(), SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(incomingTransaction(QModelIndex,int,int))); @@ -412,7 +394,7 @@ void BitcoinGUI::setWalletModel(WalletModel *walletModel) void BitcoinGUI::createTrayIcon() { QMenu *trayIconMenu; -#ifndef Q_WS_MAC +#ifndef Q_OS_MAC trayIcon = new QSystemTrayIcon(this); trayIconMenu = new QMenu(this); trayIcon->setContextMenu(trayIconMenu); @@ -432,15 +414,13 @@ void BitcoinGUI::createTrayIcon() trayIconMenu->addSeparator(); trayIconMenu->addAction(sendCoinsAction); trayIconMenu->addAction(receiveCoinsAction); -#ifndef FIRST_CLASS_MESSAGING trayIconMenu->addSeparator(); -#endif trayIconMenu->addAction(signMessageAction); trayIconMenu->addAction(verifyMessageAction); trayIconMenu->addSeparator(); trayIconMenu->addAction(optionsAction); trayIconMenu->addAction(openRPCConsoleAction); -#ifndef Q_WS_MAC // This is built-in on Mac +#ifndef Q_OS_MAC // This is built-in on Mac trayIconMenu->addSeparator(); trayIconMenu->addAction(quitAction); #endif @@ -448,12 +428,12 @@ void BitcoinGUI::createTrayIcon() notificator = new Notificator(qApp->applicationName(), trayIcon); } -#ifndef Q_WS_MAC +#ifndef Q_OS_MAC void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason) { if(reason == QSystemTrayIcon::Trigger) { - // Click on system tray icon triggers "show/hide Bitcoin" + // Click on system tray icon triggers show/hide of the main window toggleHideAction->trigger(); } } @@ -492,7 +472,7 @@ void BitcoinGUI::setNumConnections(int count) void BitcoinGUI::setNumBlocks(int count, int nTotalBlocks) { - // don't show / hide progressBar and it's label if we have no connection(s) to the network + // don't show / hide progress bar and its label if we have no connection to the network if (!clientModel || clientModel->getNumConnections() == 0) { progressBarLabel->setVisible(false); @@ -501,6 +481,7 @@ void BitcoinGUI::setNumBlocks(int count, int nTotalBlocks) return; } + QString strStatusBarWarnings = clientModel->getStatusBarWarnings(); QString tooltip; if(count < nTotalBlocks) @@ -508,7 +489,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); @@ -517,30 +498,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 progress bar, 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 @@ -610,7 +589,7 @@ void BitcoinGUI::error(const QString &title, const QString &message, bool modal) void BitcoinGUI::changeEvent(QEvent *e) { QMainWindow::changeEvent(e); -#ifndef Q_WS_MAC // Ignored on Mac +#ifndef Q_OS_MAC // Ignored on Mac if(e->type() == QEvent::WindowStateChange) { if(clientModel && clientModel->getOptionsModel()->getMinimizeToTray()) @@ -630,7 +609,7 @@ void BitcoinGUI::closeEvent(QCloseEvent *event) { if(clientModel) { -#ifndef Q_WS_MAC // Ignored on Mac +#ifndef Q_OS_MAC // Ignored on Mac if(!clientModel->getOptionsModel()->getMinimizeToTray() && !clientModel->getOptionsModel()->getMinimizeOnClose()) { @@ -739,18 +718,8 @@ void BitcoinGUI::gotoSendCoinsPage() 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()) signVerifyMessageDialog->setAddress_SM(addr); @@ -758,18 +727,8 @@ void BitcoinGUI::gotoSignMessageTab(QString addr) void BitcoinGUI::gotoVerifyMessageTab(QString addr) { -#ifdef FIRST_CLASS_MESSAGING - firstClassMessagingAction->setChecked(true); - centralWidget->setCurrentWidget(signVerifyMessageDialog); - - exportAction->setEnabled(false); - disconnect(exportAction, SIGNAL(triggered()), 0, 0); - - signVerifyMessageDialog->showTab_VM(false); -#else // call show() in showTab_VM() signVerifyMessageDialog->showTab_VM(true); -#endif if(!addr.isEmpty()) signVerifyMessageDialog->setAddress_VM(addr); |