2014-12-17 02:47:57 +01:00
|
|
|
// Copyright (c) 2011-2014 The Bitcoin Core developers
|
2014-12-13 05:09:33 +01:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2013-11-04 16:20:43 +01:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2013-01-23 21:51:02 +01:00
|
|
|
|
2011-05-12 14:49:42 +02:00
|
|
|
#include "bitcoingui.h"
|
2013-01-23 21:51:02 +01:00
|
|
|
|
2011-07-25 21:35:45 +02:00
|
|
|
#include "bitcoinunits.h"
|
2013-04-13 07:13:08 +02:00
|
|
|
#include "clientmodel.h"
|
2011-08-23 20:08:42 +02:00
|
|
|
#include "guiconstants.h"
|
2012-02-17 15:34:53 +01:00
|
|
|
#include "guiutil.h"
|
2014-10-09 11:04:49 +02:00
|
|
|
#include "networkstyle.h"
|
2013-04-13 07:13:08 +02:00
|
|
|
#include "notificator.h"
|
2013-11-14 19:47:45 +01:00
|
|
|
#include "openuridialog.h"
|
2013-04-13 07:13:08 +02:00
|
|
|
#include "optionsdialog.h"
|
|
|
|
#include "optionsmodel.h"
|
2015-07-28 15:20:14 +02:00
|
|
|
#include "platformstyle.h"
|
2012-04-09 21:07:25 +02:00
|
|
|
#include "rpcconsole.h"
|
2014-01-16 16:05:44 +01:00
|
|
|
#include "utilitydialog.h"
|
2014-09-05 13:18:35 +02:00
|
|
|
|
2013-12-11 15:00:56 +01:00
|
|
|
#ifdef ENABLE_WALLET
|
2013-04-13 07:13:08 +02:00
|
|
|
#include "walletframe.h"
|
|
|
|
#include "walletmodel.h"
|
2014-10-30 07:31:34 +01:00
|
|
|
#endif // ENABLE_WALLET
|
2011-05-07 22:13:39 +02:00
|
|
|
|
2012-09-21 19:06:53 +02:00
|
|
|
#ifdef Q_OS_MAC
|
2011-10-07 13:21:45 +02:00
|
|
|
#include "macdockiconhandler.h"
|
|
|
|
#endif
|
|
|
|
|
2013-04-13 07:13:08 +02:00
|
|
|
#include "init.h"
|
|
|
|
#include "ui_interface.h"
|
2014-09-05 13:18:35 +02:00
|
|
|
#include "util.h"
|
2013-04-13 07:13:08 +02:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
2014-06-07 08:20:22 +02:00
|
|
|
#include <QAction>
|
2013-07-23 08:52:24 +02:00
|
|
|
#include <QApplication>
|
2013-04-13 07:13:08 +02:00
|
|
|
#include <QDateTime>
|
|
|
|
#include <QDesktopWidget>
|
|
|
|
#include <QDragEnterEvent>
|
|
|
|
#include <QListWidget>
|
|
|
|
#include <QMenuBar>
|
2011-05-30 20:20:12 +02:00
|
|
|
#include <QMessageBox>
|
2013-04-13 07:13:08 +02:00
|
|
|
#include <QMimeData>
|
2011-06-18 21:25:38 +02:00
|
|
|
#include <QProgressBar>
|
2014-05-23 18:04:09 +02:00
|
|
|
#include <QProgressDialog>
|
2013-04-13 07:13:08 +02:00
|
|
|
#include <QSettings>
|
2015-11-12 12:59:26 +01:00
|
|
|
#include <QShortcut>
|
2011-07-05 22:09:39 +02:00
|
|
|
#include <QStackedWidget>
|
2013-04-13 07:13:08 +02:00
|
|
|
#include <QStatusBar>
|
|
|
|
#include <QStyle>
|
2012-03-15 22:30:08 +01:00
|
|
|
#include <QTimer>
|
2013-04-13 07:13:08 +02:00
|
|
|
#include <QToolBar>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
2013-05-31 14:02:24 +02:00
|
|
|
#if QT_VERSION < 0x050000
|
2013-07-22 08:50:39 +02:00
|
|
|
#include <QTextDocument>
|
2014-09-05 13:18:35 +02:00
|
|
|
#include <QUrl>
|
2013-04-13 07:13:08 +02:00
|
|
|
#else
|
|
|
|
#include <QUrlQuery>
|
2013-05-31 14:02:24 +02:00
|
|
|
#endif
|
2011-05-07 22:13:39 +02:00
|
|
|
|
2015-11-28 22:44:55 +01:00
|
|
|
const std::string BitcoinGUI::DEFAULT_UIPLATFORM =
|
|
|
|
#if defined(Q_OS_MAC)
|
|
|
|
"macosx"
|
|
|
|
#elif defined(Q_OS_WIN)
|
|
|
|
"windows"
|
|
|
|
#else
|
|
|
|
"other"
|
|
|
|
#endif
|
|
|
|
;
|
|
|
|
|
2013-03-22 18:32:49 +01:00
|
|
|
const QString BitcoinGUI::DEFAULT_WALLET = "~Default";
|
|
|
|
|
2015-07-28 15:20:14 +02:00
|
|
|
BitcoinGUI::BitcoinGUI(const PlatformStyle *platformStyle, const NetworkStyle *networkStyle, QWidget *parent) :
|
2011-06-30 18:05:29 +02:00
|
|
|
QMainWindow(parent),
|
|
|
|
clientModel(0),
|
2013-12-11 15:00:56 +01:00
|
|
|
walletFrame(0),
|
2014-08-07 09:34:31 +02:00
|
|
|
unitDisplayControl(0),
|
|
|
|
labelEncryptionIcon(0),
|
|
|
|
labelConnectionsIcon(0),
|
|
|
|
labelBlocksIcon(0),
|
|
|
|
progressBarLabel(0),
|
|
|
|
progressBar(0),
|
|
|
|
progressDialog(0),
|
|
|
|
appMenuBar(0),
|
|
|
|
overviewAction(0),
|
|
|
|
historyAction(0),
|
|
|
|
quitAction(0),
|
|
|
|
sendCoinsAction(0),
|
2015-01-12 21:59:58 +01:00
|
|
|
sendCoinsMenuAction(0),
|
2014-08-07 09:34:31 +02:00
|
|
|
usedSendingAddressesAction(0),
|
|
|
|
usedReceivingAddressesAction(0),
|
|
|
|
signMessageAction(0),
|
|
|
|
verifyMessageAction(0),
|
|
|
|
aboutAction(0),
|
|
|
|
receiveCoinsAction(0),
|
2015-01-12 21:59:58 +01:00
|
|
|
receiveCoinsMenuAction(0),
|
2014-08-07 09:34:31 +02:00
|
|
|
optionsAction(0),
|
|
|
|
toggleHideAction(0),
|
2011-08-24 22:07:26 +02:00
|
|
|
encryptWalletAction(0),
|
2014-08-07 09:34:31 +02:00
|
|
|
backupWalletAction(0),
|
2011-08-24 22:07:26 +02:00
|
|
|
changePassphraseAction(0),
|
2011-12-13 17:30:13 +01:00
|
|
|
aboutQtAction(0),
|
2014-08-07 09:34:31 +02:00
|
|
|
openRPCConsoleAction(0),
|
|
|
|
openAction(0),
|
|
|
|
showHelpMessageAction(0),
|
2011-09-03 20:52:54 +02:00
|
|
|
trayIcon(0),
|
2014-08-07 09:37:21 +02:00
|
|
|
trayIconMenu(0),
|
2012-04-09 21:07:25 +02:00
|
|
|
notificator(0),
|
2013-02-10 19:01:30 +01:00
|
|
|
rpcConsole(0),
|
2015-08-27 21:53:16 +02:00
|
|
|
helpMessageDialog(0),
|
2014-01-13 14:16:48 +01:00
|
|
|
prevBlocks(0),
|
2015-07-28 15:20:14 +02:00
|
|
|
spinnerFrame(0),
|
|
|
|
platformStyle(platformStyle)
|
2011-05-07 22:13:39 +02:00
|
|
|
{
|
2013-07-13 13:14:23 +02:00
|
|
|
GUIUtil::restoreWindowGeometry("nWindow", QSize(850, 550), this);
|
2013-05-19 20:20:06 +02:00
|
|
|
|
2013-12-11 15:00:56 +01:00
|
|
|
QString windowTitle = tr("Bitcoin Core") + " - ";
|
|
|
|
#ifdef ENABLE_WALLET
|
|
|
|
/* if compiled with wallet support, -disablewallet can still disable the wallet */
|
2014-11-08 19:48:35 +01:00
|
|
|
enableWallet = !GetBoolArg("-disablewallet", false);
|
2013-12-11 15:00:56 +01:00
|
|
|
#else
|
2014-11-08 19:48:35 +01:00
|
|
|
enableWallet = false;
|
2014-10-30 07:31:34 +01:00
|
|
|
#endif // ENABLE_WALLET
|
2013-12-11 15:00:56 +01:00
|
|
|
if(enableWallet)
|
|
|
|
{
|
|
|
|
windowTitle += tr("Wallet");
|
|
|
|
} else {
|
|
|
|
windowTitle += tr("Node");
|
|
|
|
}
|
2014-10-09 11:04:49 +02:00
|
|
|
windowTitle += " " + networkStyle->getTitleAddText();
|
2013-11-21 17:59:31 +01:00
|
|
|
#ifndef Q_OS_MAC
|
2014-11-14 17:16:31 +01:00
|
|
|
QApplication::setWindowIcon(networkStyle->getTrayAndWindowIcon());
|
|
|
|
setWindowIcon(networkStyle->getTrayAndWindowIcon());
|
2011-10-07 13:21:45 +02:00
|
|
|
#else
|
2014-10-09 11:04:49 +02:00
|
|
|
MacDockIconHandler::instance()->setIcon(networkStyle->getAppIcon());
|
2011-10-07 13:21:45 +02:00
|
|
|
#endif
|
2013-12-11 15:00:56 +01:00
|
|
|
setWindowTitle(windowTitle);
|
2013-11-21 17:59:31 +01:00
|
|
|
|
|
|
|
#if defined(Q_OS_MAC) && QT_VERSION < 0x050000
|
|
|
|
// This property is not implemented in Qt 5. Setting it has no effect.
|
|
|
|
// A replacement API (QtMacUnifiedToolBar) is available in QtMacExtras.
|
|
|
|
setUnifiedTitleAndToolBarOnMac(true);
|
|
|
|
#endif
|
2013-05-19 20:20:06 +02:00
|
|
|
|
2015-07-28 15:20:14 +02:00
|
|
|
rpcConsole = new RPCConsole(platformStyle, 0);
|
2015-08-27 21:53:16 +02:00
|
|
|
helpMessageDialog = new HelpMessageDialog(this, false);
|
2013-12-11 15:00:56 +01:00
|
|
|
#ifdef ENABLE_WALLET
|
|
|
|
if(enableWallet)
|
|
|
|
{
|
|
|
|
/** Create wallet frame and make it the central widget */
|
2015-07-28 15:20:14 +02:00
|
|
|
walletFrame = new WalletFrame(platformStyle, this);
|
2013-12-11 15:00:56 +01:00
|
|
|
setCentralWidget(walletFrame);
|
|
|
|
} else
|
2014-10-30 07:31:34 +01:00
|
|
|
#endif // ENABLE_WALLET
|
2013-12-11 15:00:56 +01:00
|
|
|
{
|
|
|
|
/* When compiled without wallet or -disablewallet is provided,
|
|
|
|
* the central widget is the rpc console.
|
|
|
|
*/
|
|
|
|
setCentralWidget(rpcConsole);
|
|
|
|
}
|
2013-04-06 18:11:15 +02:00
|
|
|
|
2011-08-08 17:38:17 +02:00
|
|
|
// Accept D&D of URIs
|
|
|
|
setAcceptDrops(true);
|
2011-05-12 20:16:42 +02:00
|
|
|
|
2011-10-07 13:21:45 +02:00
|
|
|
// Create actions for the toolbar, menu bar and tray/dock icon
|
2013-04-06 18:11:15 +02:00
|
|
|
// Needs walletFrame to be initialized
|
2015-03-03 08:42:52 +01:00
|
|
|
createActions();
|
2011-05-10 19:03:10 +02:00
|
|
|
|
2011-10-07 13:21:45 +02:00
|
|
|
// Create application menu bar
|
|
|
|
createMenuBar();
|
2011-07-16 19:28:15 +02:00
|
|
|
|
2011-10-07 13:21:45 +02:00
|
|
|
// Create the toolbars
|
|
|
|
createToolBars();
|
2011-05-07 22:13:39 +02:00
|
|
|
|
2012-11-27 22:20:43 +01:00
|
|
|
// Create system tray icon and notification
|
2014-10-09 11:04:49 +02:00
|
|
|
createTrayIcon(networkStyle);
|
2011-07-05 22:09:39 +02:00
|
|
|
|
2011-06-05 14:19:57 +02:00
|
|
|
// Create status bar
|
2011-05-12 20:16:42 +02:00
|
|
|
statusBar();
|
2015-03-18 11:26:09 +01:00
|
|
|
|
2015-01-13 08:38:57 +01:00
|
|
|
// Disable size grip because it looks ugly and nobody needs it
|
|
|
|
statusBar()->setSizeGripEnabled(false);
|
2011-06-14 21:34:51 +02:00
|
|
|
|
2011-08-08 17:38:17 +02:00
|
|
|
// Status bar notification icons
|
2011-07-17 17:30:58 +02:00
|
|
|
QFrame *frameBlocks = new QFrame();
|
2011-08-04 19:04:42 +02:00
|
|
|
frameBlocks->setContentsMargins(0,0,0,0);
|
2014-03-06 14:47:07 +01:00
|
|
|
frameBlocks->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
|
2011-07-17 17:30:58 +02:00
|
|
|
QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
|
|
|
|
frameBlocksLayout->setContentsMargins(3,0,3,0);
|
|
|
|
frameBlocksLayout->setSpacing(3);
|
2015-07-28 15:20:14 +02:00
|
|
|
unitDisplayControl = new UnitDisplayStatusBarControl(platformStyle);
|
2011-08-23 20:08:42 +02:00
|
|
|
labelEncryptionIcon = new QLabel();
|
2011-08-04 19:04:42 +02:00
|
|
|
labelConnectionsIcon = new QLabel();
|
2011-07-17 17:30:58 +02:00
|
|
|
labelBlocksIcon = new QLabel();
|
2014-07-13 06:27:29 +02:00
|
|
|
if(enableWallet)
|
|
|
|
{
|
|
|
|
frameBlocksLayout->addStretch();
|
|
|
|
frameBlocksLayout->addWidget(unitDisplayControl);
|
|
|
|
frameBlocksLayout->addStretch();
|
|
|
|
frameBlocksLayout->addWidget(labelEncryptionIcon);
|
|
|
|
}
|
2011-08-23 20:08:42 +02:00
|
|
|
frameBlocksLayout->addStretch();
|
2011-08-04 19:04:42 +02:00
|
|
|
frameBlocksLayout->addWidget(labelConnectionsIcon);
|
|
|
|
frameBlocksLayout->addStretch();
|
2011-07-17 17:30:58 +02:00
|
|
|
frameBlocksLayout->addWidget(labelBlocksIcon);
|
|
|
|
frameBlocksLayout->addStretch();
|
2011-06-11 12:46:09 +02:00
|
|
|
|
2012-04-02 19:07:03 +02:00
|
|
|
// Progress bar and label for blocks download
|
|
|
|
progressBarLabel = new QLabel();
|
2011-06-18 21:25:38 +02:00
|
|
|
progressBarLabel->setVisible(false);
|
2014-11-18 09:55:39 +01:00
|
|
|
progressBar = new GUIUtil::ProgressBar();
|
2012-04-13 18:25:56 +02:00
|
|
|
progressBar->setAlignment(Qt::AlignCenter);
|
2011-06-18 21:25:38 +02:00
|
|
|
progressBar->setVisible(false);
|
|
|
|
|
2012-08-24 14:47:54 +02:00
|
|
|
// 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
|
2013-04-02 17:30:14 +02:00
|
|
|
QString curStyle = QApplication::style()->metaObject()->className();
|
2012-08-24 14:47:54 +02:00
|
|
|
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; }");
|
|
|
|
}
|
|
|
|
|
2011-06-18 21:25:38 +02:00
|
|
|
statusBar()->addWidget(progressBarLabel);
|
|
|
|
statusBar()->addWidget(progressBar);
|
2011-07-17 17:30:58 +02:00
|
|
|
statusBar()->addPermanentWidget(frameBlocks);
|
2011-06-18 21:25:38 +02:00
|
|
|
|
2012-10-12 16:08:47 +02:00
|
|
|
// Install event filter to be able to catch status tip events (QEvent::StatusTip)
|
|
|
|
this->installEventFilter(this);
|
2013-11-12 14:54:43 +01:00
|
|
|
|
|
|
|
// Initially wallet actions should be disabled
|
|
|
|
setWalletActionsEnabled(false);
|
2014-01-08 08:59:24 +01:00
|
|
|
|
|
|
|
// Subscribe to notifications from core
|
|
|
|
subscribeToCoreSignals();
|
2011-05-12 20:16:42 +02:00
|
|
|
}
|
|
|
|
|
2011-10-07 13:21:45 +02:00
|
|
|
BitcoinGUI::~BitcoinGUI()
|
|
|
|
{
|
2014-01-08 08:59:24 +01:00
|
|
|
// Unsubscribe from notifications from core
|
|
|
|
unsubscribeFromCoreSignals();
|
|
|
|
|
2013-07-13 13:14:23 +02:00
|
|
|
GUIUtil::saveWindowGeometry("nWindow", this);
|
2012-02-19 12:07:07 +01:00
|
|
|
if(trayIcon) // Hide tray icon, as deleting will let it linger until quit (on Ubuntu)
|
|
|
|
trayIcon->hide();
|
2012-09-21 19:06:53 +02:00
|
|
|
#ifdef Q_OS_MAC
|
2011-10-07 13:21:45 +02:00
|
|
|
delete appMenuBar;
|
2015-03-13 15:40:53 +01:00
|
|
|
MacDockIconHandler::cleanup();
|
2011-10-07 13:21:45 +02:00
|
|
|
#endif
|
2014-11-10 16:41:57 +01:00
|
|
|
|
|
|
|
delete rpcConsole;
|
2011-10-07 13:21:45 +02:00
|
|
|
}
|
|
|
|
|
2015-03-03 08:42:52 +01:00
|
|
|
void BitcoinGUI::createActions()
|
2011-05-12 20:16:42 +02:00
|
|
|
{
|
2011-07-05 22:09:39 +02:00
|
|
|
QActionGroup *tabGroup = new QActionGroup(this);
|
2011-07-07 17:33:15 +02:00
|
|
|
|
2015-07-28 15:20:14 +02:00
|
|
|
overviewAction = new QAction(platformStyle->SingleColorIcon(":/icons/overview"), tr("&Overview"), this);
|
2012-10-12 16:08:47 +02:00
|
|
|
overviewAction->setStatusTip(tr("Show general overview of wallet"));
|
|
|
|
overviewAction->setToolTip(overviewAction->statusTip());
|
2011-07-05 22:09:39 +02:00
|
|
|
overviewAction->setCheckable(true);
|
2011-10-09 21:40:03 +02:00
|
|
|
overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1));
|
2011-07-05 22:09:39 +02:00
|
|
|
tabGroup->addAction(overviewAction);
|
2011-07-07 17:33:15 +02:00
|
|
|
|
2015-07-28 15:20:14 +02:00
|
|
|
sendCoinsAction = new QAction(platformStyle->SingleColorIcon(":/icons/send"), tr("&Send"), this);
|
2012-10-12 16:08:47 +02:00
|
|
|
sendCoinsAction->setStatusTip(tr("Send coins to a Bitcoin address"));
|
|
|
|
sendCoinsAction->setToolTip(sendCoinsAction->statusTip());
|
2012-08-29 10:12:34 +02:00
|
|
|
sendCoinsAction->setCheckable(true);
|
|
|
|
sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2));
|
|
|
|
tabGroup->addAction(sendCoinsAction);
|
|
|
|
|
2015-07-28 15:20:14 +02:00
|
|
|
sendCoinsMenuAction = new QAction(platformStyle->TextColorIcon(":/icons/send"), sendCoinsAction->text(), this);
|
2015-01-12 21:59:58 +01:00
|
|
|
sendCoinsMenuAction->setStatusTip(sendCoinsAction->statusTip());
|
|
|
|
sendCoinsMenuAction->setToolTip(sendCoinsMenuAction->statusTip());
|
|
|
|
|
2015-07-28 15:20:14 +02:00
|
|
|
receiveCoinsAction = new QAction(platformStyle->SingleColorIcon(":/icons/receiving_addresses"), tr("&Receive"), this);
|
2013-10-25 14:19:44 +02:00
|
|
|
receiveCoinsAction->setStatusTip(tr("Request payments (generates QR codes and bitcoin: URIs)"));
|
2012-10-12 16:08:47 +02:00
|
|
|
receiveCoinsAction->setToolTip(receiveCoinsAction->statusTip());
|
2012-08-29 10:12:34 +02:00
|
|
|
receiveCoinsAction->setCheckable(true);
|
|
|
|
receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3));
|
|
|
|
tabGroup->addAction(receiveCoinsAction);
|
|
|
|
|
2015-07-28 15:20:14 +02:00
|
|
|
receiveCoinsMenuAction = new QAction(platformStyle->TextColorIcon(":/icons/receiving_addresses"), receiveCoinsAction->text(), this);
|
2015-01-12 21:59:58 +01:00
|
|
|
receiveCoinsMenuAction->setStatusTip(receiveCoinsAction->statusTip());
|
|
|
|
receiveCoinsMenuAction->setToolTip(receiveCoinsMenuAction->statusTip());
|
|
|
|
|
2015-07-28 15:20:14 +02:00
|
|
|
historyAction = new QAction(platformStyle->SingleColorIcon(":/icons/history"), tr("&Transactions"), this);
|
2012-10-12 16:08:47 +02:00
|
|
|
historyAction->setStatusTip(tr("Browse transaction history"));
|
|
|
|
historyAction->setToolTip(historyAction->statusTip());
|
2011-07-05 22:09:39 +02:00
|
|
|
historyAction->setCheckable(true);
|
2011-10-09 21:40:03 +02:00
|
|
|
historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
|
2011-07-05 22:09:39 +02:00
|
|
|
tabGroup->addAction(historyAction);
|
|
|
|
|
2014-10-30 07:31:34 +01:00
|
|
|
#ifdef ENABLE_WALLET
|
2013-12-20 09:33:44 +01:00
|
|
|
// These showNormalIfMinimized are needed because Send Coins and Receive Coins
|
|
|
|
// can be triggered from the tray menu, and need to show the GUI to be useful.
|
2012-02-17 23:19:52 +01:00
|
|
|
connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
|
2011-07-07 17:33:15 +02:00
|
|
|
connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage()));
|
2012-08-29 10:12:34 +02:00
|
|
|
connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
|
|
|
|
connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage()));
|
2015-01-12 21:59:58 +01:00
|
|
|
connect(sendCoinsMenuAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
|
|
|
|
connect(sendCoinsMenuAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage()));
|
2012-08-29 10:12:34 +02:00
|
|
|
connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
|
|
|
|
connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
|
2015-01-12 21:59:58 +01:00
|
|
|
connect(receiveCoinsMenuAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
|
|
|
|
connect(receiveCoinsMenuAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
|
2012-02-17 23:19:52 +01:00
|
|
|
connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
|
2011-07-07 17:33:15 +02:00
|
|
|
connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage()));
|
2014-10-30 07:31:34 +01:00
|
|
|
#endif // ENABLE_WALLET
|
2013-04-01 14:43:50 +02:00
|
|
|
|
2015-07-28 15:20:14 +02:00
|
|
|
quitAction = new QAction(platformStyle->TextColorIcon(":/icons/quit"), tr("E&xit"), this);
|
2012-10-12 16:08:47 +02:00
|
|
|
quitAction->setStatusTip(tr("Quit application"));
|
2011-10-09 21:06:28 +02:00
|
|
|
quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
|
2011-10-07 13:21:45 +02:00
|
|
|
quitAction->setMenuRole(QAction::QuitRole);
|
2015-07-28 15:20:14 +02:00
|
|
|
aboutAction = new QAction(platformStyle->TextColorIcon(":/icons/about"), tr("&About Bitcoin Core"), this);
|
2014-08-04 21:09:38 +02:00
|
|
|
aboutAction->setStatusTip(tr("Show information about Bitcoin Core"));
|
2011-12-13 17:30:13 +01:00
|
|
|
aboutAction->setMenuRole(QAction::AboutRole);
|
2015-07-28 15:20:14 +02:00
|
|
|
aboutQtAction = new QAction(platformStyle->TextColorIcon(":/icons/about_qt"), tr("About &Qt"), this);
|
2012-10-12 16:08:47 +02:00
|
|
|
aboutQtAction->setStatusTip(tr("Show information about Qt"));
|
2011-12-13 17:30:13 +01:00
|
|
|
aboutQtAction->setMenuRole(QAction::AboutQtRole);
|
2015-07-28 15:20:14 +02:00
|
|
|
optionsAction = new QAction(platformStyle->TextColorIcon(":/icons/options"), tr("&Options..."), this);
|
2014-11-21 13:52:26 +01:00
|
|
|
optionsAction->setStatusTip(tr("Modify configuration options for Bitcoin Core"));
|
2011-10-07 13:21:45 +02:00
|
|
|
optionsAction->setMenuRole(QAction::PreferencesRole);
|
2015-07-28 15:20:14 +02:00
|
|
|
toggleHideAction = new QAction(platformStyle->TextColorIcon(":/icons/about"), tr("&Show / Hide"), this);
|
2012-10-12 16:08:47 +02:00
|
|
|
toggleHideAction->setStatusTip(tr("Show or hide the main Window"));
|
2013-04-03 17:29:02 +02:00
|
|
|
|
2015-07-28 15:20:14 +02:00
|
|
|
encryptWalletAction = new QAction(platformStyle->TextColorIcon(":/icons/lock_closed"), tr("&Encrypt Wallet..."), this);
|
2012-10-12 16:08:47 +02:00
|
|
|
encryptWalletAction->setStatusTip(tr("Encrypt the private keys that belong to your wallet"));
|
2011-08-24 22:07:26 +02:00
|
|
|
encryptWalletAction->setCheckable(true);
|
2015-07-28 15:20:14 +02:00
|
|
|
backupWalletAction = new QAction(platformStyle->TextColorIcon(":/icons/filesave"), tr("&Backup Wallet..."), this);
|
2012-10-12 16:08:47 +02:00
|
|
|
backupWalletAction->setStatusTip(tr("Backup wallet to another location"));
|
2015-07-28 15:20:14 +02:00
|
|
|
changePassphraseAction = new QAction(platformStyle->TextColorIcon(":/icons/key"), tr("&Change Passphrase..."), this);
|
2012-10-12 16:08:47 +02:00
|
|
|
changePassphraseAction->setStatusTip(tr("Change the passphrase used for wallet encryption"));
|
2015-07-28 15:20:14 +02:00
|
|
|
signMessageAction = new QAction(platformStyle->TextColorIcon(":/icons/edit"), tr("Sign &message..."), this);
|
2012-10-12 16:08:47 +02:00
|
|
|
signMessageAction->setStatusTip(tr("Sign messages with your Bitcoin addresses to prove you own them"));
|
2015-07-28 15:20:14 +02:00
|
|
|
verifyMessageAction = new QAction(platformStyle->TextColorIcon(":/icons/verify"), tr("&Verify message..."), this);
|
2012-10-12 16:08:47 +02:00
|
|
|
verifyMessageAction->setStatusTip(tr("Verify messages to ensure they were signed with specified Bitcoin addresses"));
|
2012-08-29 10:12:34 +02:00
|
|
|
|
2015-07-28 15:20:14 +02:00
|
|
|
openRPCConsoleAction = new QAction(platformStyle->TextColorIcon(":/icons/debugwindow"), tr("&Debug window"), this);
|
2012-10-12 16:08:47 +02:00
|
|
|
openRPCConsoleAction->setStatusTip(tr("Open debugging and diagnostic console"));
|
2011-05-12 20:16:42 +02:00
|
|
|
|
2015-07-28 15:20:14 +02:00
|
|
|
usedSendingAddressesAction = new QAction(platformStyle->TextColorIcon(":/icons/address-book"), tr("&Sending addresses..."), this);
|
2013-10-25 14:19:44 +02:00
|
|
|
usedSendingAddressesAction->setStatusTip(tr("Show the list of used sending addresses and labels"));
|
2015-07-28 15:20:14 +02:00
|
|
|
usedReceivingAddressesAction = new QAction(platformStyle->TextColorIcon(":/icons/address-book"), tr("&Receiving addresses..."), this);
|
2013-10-25 14:19:44 +02:00
|
|
|
usedReceivingAddressesAction->setStatusTip(tr("Show the list of used receiving addresses and labels"));
|
2013-10-16 15:14:26 +02:00
|
|
|
|
2015-07-28 15:20:14 +02:00
|
|
|
openAction = new QAction(platformStyle->TextColorIcon(":/icons/open"), tr("Open &URI..."), this);
|
2013-11-06 15:08:56 +01:00
|
|
|
openAction->setStatusTip(tr("Open a bitcoin: URI or payment request"));
|
|
|
|
|
2015-07-28 15:20:14 +02:00
|
|
|
showHelpMessageAction = new QAction(platformStyle->TextColorIcon(":/icons/info"), tr("&Command-line options"), this);
|
2015-03-06 09:33:23 +01:00
|
|
|
showHelpMessageAction->setMenuRole(QAction::NoRole);
|
2014-01-22 14:47:33 +01:00
|
|
|
showHelpMessageAction->setStatusTip(tr("Show the Bitcoin Core help message to get a list with possible Bitcoin command-line options"));
|
|
|
|
|
2011-07-07 17:33:15 +02:00
|
|
|
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
|
|
|
|
connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked()));
|
2011-12-13 17:30:13 +01:00
|
|
|
connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
|
2012-08-29 10:12:34 +02:00
|
|
|
connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked()));
|
2012-02-17 15:34:53 +01:00
|
|
|
connect(toggleHideAction, SIGNAL(triggered()), this, SLOT(toggleHidden()));
|
2014-01-22 14:47:33 +01:00
|
|
|
connect(showHelpMessageAction, SIGNAL(triggered()), this, SLOT(showHelpMessageClicked()));
|
2015-09-07 11:00:59 +02:00
|
|
|
connect(openRPCConsoleAction, SIGNAL(triggered()), this, SLOT(showDebugWindow()));
|
|
|
|
// prevents an open debug window from becoming stuck/unusable on client shutdown
|
|
|
|
connect(quitAction, SIGNAL(triggered()), rpcConsole, SLOT(hide()));
|
|
|
|
|
2013-12-11 15:00:56 +01:00
|
|
|
#ifdef ENABLE_WALLET
|
|
|
|
if(walletFrame)
|
|
|
|
{
|
|
|
|
connect(encryptWalletAction, SIGNAL(triggered(bool)), walletFrame, SLOT(encryptWallet(bool)));
|
|
|
|
connect(backupWalletAction, SIGNAL(triggered()), walletFrame, SLOT(backupWallet()));
|
|
|
|
connect(changePassphraseAction, SIGNAL(triggered()), walletFrame, SLOT(changePassphrase()));
|
|
|
|
connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab()));
|
|
|
|
connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab()));
|
|
|
|
connect(usedSendingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedSendingAddresses()));
|
|
|
|
connect(usedReceivingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedReceivingAddresses()));
|
|
|
|
connect(openAction, SIGNAL(triggered()), this, SLOT(openClicked()));
|
|
|
|
}
|
2014-10-30 07:31:34 +01:00
|
|
|
#endif // ENABLE_WALLET
|
2015-11-12 12:59:26 +01:00
|
|
|
|
|
|
|
new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C), this, SLOT(showDebugWindowActivateConsole()));
|
|
|
|
new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_D), this, SLOT(showDebugWindow()));
|
2011-05-12 20:16:42 +02:00
|
|
|
}
|
|
|
|
|
2011-10-07 13:21:45 +02:00
|
|
|
void BitcoinGUI::createMenuBar()
|
|
|
|
{
|
2012-09-21 19:06:53 +02:00
|
|
|
#ifdef Q_OS_MAC
|
2011-10-07 13:21:45 +02:00
|
|
|
// Create a decoupled menu bar on Mac which stays even if the window is closed
|
|
|
|
appMenuBar = new QMenuBar();
|
|
|
|
#else
|
|
|
|
// Get the main window's menu bar on other platforms
|
|
|
|
appMenuBar = menuBar();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Configure the menus
|
|
|
|
QMenu *file = appMenuBar->addMenu(tr("&File"));
|
2013-12-11 15:00:56 +01:00
|
|
|
if(walletFrame)
|
|
|
|
{
|
|
|
|
file->addAction(openAction);
|
|
|
|
file->addAction(backupWalletAction);
|
|
|
|
file->addAction(signMessageAction);
|
|
|
|
file->addAction(verifyMessageAction);
|
|
|
|
file->addSeparator();
|
|
|
|
file->addAction(usedSendingAddressesAction);
|
|
|
|
file->addAction(usedReceivingAddressesAction);
|
|
|
|
file->addSeparator();
|
|
|
|
}
|
2011-10-07 13:21:45 +02:00
|
|
|
file->addAction(quitAction);
|
|
|
|
|
|
|
|
QMenu *settings = appMenuBar->addMenu(tr("&Settings"));
|
2013-12-11 15:00:56 +01:00
|
|
|
if(walletFrame)
|
|
|
|
{
|
|
|
|
settings->addAction(encryptWalletAction);
|
|
|
|
settings->addAction(changePassphraseAction);
|
|
|
|
settings->addSeparator();
|
|
|
|
}
|
2011-10-07 13:21:45 +02:00
|
|
|
settings->addAction(optionsAction);
|
|
|
|
|
|
|
|
QMenu *help = appMenuBar->addMenu(tr("&Help"));
|
2013-12-11 15:00:56 +01:00
|
|
|
if(walletFrame)
|
|
|
|
{
|
|
|
|
help->addAction(openRPCConsoleAction);
|
|
|
|
}
|
2014-01-22 14:47:33 +01:00
|
|
|
help->addAction(showHelpMessageAction);
|
|
|
|
help->addSeparator();
|
2011-10-07 13:21:45 +02:00
|
|
|
help->addAction(aboutAction);
|
2011-12-13 17:30:13 +01:00
|
|
|
help->addAction(aboutQtAction);
|
2011-10-07 13:21:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void BitcoinGUI::createToolBars()
|
|
|
|
{
|
2013-12-11 15:00:56 +01:00
|
|
|
if(walletFrame)
|
|
|
|
{
|
|
|
|
QToolBar *toolbar = addToolBar(tr("Tabs toolbar"));
|
2015-05-19 17:23:32 +02:00
|
|
|
toolbar->setMovable(false);
|
2013-12-11 15:00:56 +01:00
|
|
|
toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
|
|
|
toolbar->addAction(overviewAction);
|
|
|
|
toolbar->addAction(sendCoinsAction);
|
|
|
|
toolbar->addAction(receiveCoinsAction);
|
|
|
|
toolbar->addAction(historyAction);
|
|
|
|
overviewAction->setChecked(true);
|
|
|
|
}
|
2011-10-07 13:21:45 +02:00
|
|
|
}
|
|
|
|
|
2011-06-30 18:05:29 +02:00
|
|
|
void BitcoinGUI::setClientModel(ClientModel *clientModel)
|
2011-05-22 17:19:43 +02:00
|
|
|
{
|
2011-06-30 18:05:29 +02:00
|
|
|
this->clientModel = clientModel;
|
2011-11-08 21:18:36 +01:00
|
|
|
if(clientModel)
|
2011-06-30 19:14:42 +02:00
|
|
|
{
|
2012-11-27 22:20:43 +01:00
|
|
|
// Create system tray menu (or setup the dock menu) that late to prevent users from calling actions,
|
|
|
|
// while the client has not yet fully loaded
|
2013-03-19 23:33:36 +01:00
|
|
|
createTrayIconMenu();
|
2012-11-27 22:20:43 +01:00
|
|
|
|
2011-11-08 21:18:36 +01:00
|
|
|
// Keep up to date with client
|
|
|
|
setNumConnections(clientModel->getNumConnections());
|
|
|
|
connect(clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
|
2011-05-22 17:19:43 +02:00
|
|
|
|
2015-11-27 18:22:18 +01:00
|
|
|
setNumBlocks(clientModel->getNumBlocks(), clientModel->getLastBlockDate(), clientModel->getVerificationProgress(NULL));
|
|
|
|
connect(clientModel, SIGNAL(numBlocksChanged(int,QDateTime,double)), this, SLOT(setNumBlocks(int,QDateTime,double)));
|
2011-05-22 17:19:43 +02:00
|
|
|
|
2013-11-14 19:47:45 +01:00
|
|
|
// Receive and report messages from client model
|
2012-12-03 13:24:42 +01:00
|
|
|
connect(clientModel, SIGNAL(message(QString,QString,unsigned int)), this, SLOT(message(QString,QString,unsigned int)));
|
2012-04-09 21:07:25 +02:00
|
|
|
|
2014-05-23 18:04:09 +02:00
|
|
|
// Show progress dialog
|
|
|
|
connect(clientModel, SIGNAL(showProgress(QString,int)), this, SLOT(showProgress(QString,int)));
|
|
|
|
|
2013-04-01 15:19:40 +02:00
|
|
|
rpcConsole->setClientModel(clientModel);
|
2013-12-11 15:00:56 +01:00
|
|
|
#ifdef ENABLE_WALLET
|
|
|
|
if(walletFrame)
|
|
|
|
{
|
|
|
|
walletFrame->setClientModel(clientModel);
|
|
|
|
}
|
2014-10-30 07:31:34 +01:00
|
|
|
#endif // ENABLE_WALLET
|
2014-08-07 09:37:21 +02:00
|
|
|
unitDisplayControl->setOptionsModel(clientModel->getOptionsModel());
|
|
|
|
} else {
|
|
|
|
// Disable possibility to show main window via action
|
|
|
|
toggleHideAction->setEnabled(false);
|
2014-08-26 17:44:57 +02:00
|
|
|
if(trayIconMenu)
|
|
|
|
{
|
|
|
|
// Disable context menu on tray icon
|
|
|
|
trayIconMenu->clear();
|
|
|
|
}
|
2011-11-08 21:18:36 +01:00
|
|
|
}
|
2011-06-30 18:05:29 +02:00
|
|
|
}
|
|
|
|
|
2013-12-11 15:00:56 +01:00
|
|
|
#ifdef ENABLE_WALLET
|
2013-03-22 18:32:49 +01:00
|
|
|
bool BitcoinGUI::addWallet(const QString& name, WalletModel *walletModel)
|
2011-06-30 18:05:29 +02:00
|
|
|
{
|
2013-12-11 15:00:56 +01:00
|
|
|
if(!walletFrame)
|
|
|
|
return false;
|
2013-11-12 14:54:43 +01:00
|
|
|
setWalletActionsEnabled(true);
|
2013-03-22 18:32:49 +01:00
|
|
|
return walletFrame->addWallet(name, walletModel);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool BitcoinGUI::setCurrentWallet(const QString& name)
|
|
|
|
{
|
2013-12-11 15:00:56 +01:00
|
|
|
if(!walletFrame)
|
|
|
|
return false;
|
2013-03-22 18:32:49 +01:00
|
|
|
return walletFrame->setCurrentWallet(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BitcoinGUI::removeAllWallets()
|
|
|
|
{
|
2013-12-11 15:00:56 +01:00
|
|
|
if(!walletFrame)
|
|
|
|
return;
|
2013-11-12 14:54:43 +01:00
|
|
|
setWalletActionsEnabled(false);
|
2013-03-22 18:32:49 +01:00
|
|
|
walletFrame->removeAllWallets();
|
2011-05-22 17:19:43 +02:00
|
|
|
}
|
2014-10-30 07:31:34 +01:00
|
|
|
#endif // ENABLE_WALLET
|
2011-05-22 17:19:43 +02:00
|
|
|
|
2013-11-12 14:54:43 +01:00
|
|
|
void BitcoinGUI::setWalletActionsEnabled(bool enabled)
|
|
|
|
{
|
|
|
|
overviewAction->setEnabled(enabled);
|
|
|
|
sendCoinsAction->setEnabled(enabled);
|
2015-01-12 21:59:58 +01:00
|
|
|
sendCoinsMenuAction->setEnabled(enabled);
|
2013-11-12 14:54:43 +01:00
|
|
|
receiveCoinsAction->setEnabled(enabled);
|
2015-01-12 21:59:58 +01:00
|
|
|
receiveCoinsMenuAction->setEnabled(enabled);
|
2013-11-12 14:54:43 +01:00
|
|
|
historyAction->setEnabled(enabled);
|
|
|
|
encryptWalletAction->setEnabled(enabled);
|
|
|
|
backupWalletAction->setEnabled(enabled);
|
|
|
|
changePassphraseAction->setEnabled(enabled);
|
|
|
|
signMessageAction->setEnabled(enabled);
|
|
|
|
verifyMessageAction->setEnabled(enabled);
|
|
|
|
usedSendingAddressesAction->setEnabled(enabled);
|
|
|
|
usedReceivingAddressesAction->setEnabled(enabled);
|
|
|
|
openAction->setEnabled(enabled);
|
|
|
|
}
|
|
|
|
|
2014-10-09 11:04:49 +02:00
|
|
|
void BitcoinGUI::createTrayIcon(const NetworkStyle *networkStyle)
|
2011-05-12 20:16:42 +02:00
|
|
|
{
|
2012-09-21 19:06:53 +02:00
|
|
|
#ifndef Q_OS_MAC
|
2011-05-12 20:16:42 +02:00
|
|
|
trayIcon = new QSystemTrayIcon(this);
|
2014-10-09 11:04:49 +02:00
|
|
|
QString toolTip = tr("Bitcoin Core client") + " " + networkStyle->getTitleAddText();
|
|
|
|
trayIcon->setToolTip(toolTip);
|
2014-11-14 17:16:31 +01:00
|
|
|
trayIcon->setIcon(networkStyle->getTrayAndWindowIcon());
|
2012-11-27 22:20:43 +01:00
|
|
|
trayIcon->show();
|
|
|
|
#endif
|
|
|
|
|
2013-12-03 09:25:24 +01:00
|
|
|
notificator = new Notificator(QApplication::applicationName(), trayIcon, this);
|
2012-11-27 22:20:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void BitcoinGUI::createTrayIconMenu()
|
|
|
|
{
|
|
|
|
#ifndef Q_OS_MAC
|
2013-03-19 23:33:36 +01:00
|
|
|
// return if trayIcon is unset (only on non-Mac OSes)
|
|
|
|
if (!trayIcon)
|
|
|
|
return;
|
|
|
|
|
2012-11-27 22:20:43 +01:00
|
|
|
trayIconMenu = new QMenu(this);
|
|
|
|
trayIcon->setContextMenu(trayIconMenu);
|
|
|
|
|
2011-06-05 14:19:57 +02:00
|
|
|
connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
|
|
|
|
this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
|
2011-10-07 13:21:45 +02:00
|
|
|
#else
|
|
|
|
// Note: On Mac, the dock icon is used to provide the tray's functionality.
|
|
|
|
MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance();
|
2013-04-14 22:11:55 +02:00
|
|
|
dockIconHandler->setMainWindow((QMainWindow *)this);
|
2011-10-07 13:21:45 +02:00
|
|
|
trayIconMenu = dockIconHandler->dockMenu();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Configuration of the tray icon (or dock icon) icon menu
|
2012-02-17 15:34:53 +01:00
|
|
|
trayIconMenu->addAction(toggleHideAction);
|
2011-10-07 13:21:45 +02:00
|
|
|
trayIconMenu->addSeparator();
|
2015-01-12 21:59:58 +01:00
|
|
|
trayIconMenu->addAction(sendCoinsMenuAction);
|
|
|
|
trayIconMenu->addAction(receiveCoinsMenuAction);
|
2011-12-23 16:14:57 +01:00
|
|
|
trayIconMenu->addSeparator();
|
2012-06-15 09:48:26 +02:00
|
|
|
trayIconMenu->addAction(signMessageAction);
|
2012-06-14 07:57:10 +02:00
|
|
|
trayIconMenu->addAction(verifyMessageAction);
|
2011-10-07 13:21:45 +02:00
|
|
|
trayIconMenu->addSeparator();
|
|
|
|
trayIconMenu->addAction(optionsAction);
|
2012-06-14 07:57:10 +02:00
|
|
|
trayIconMenu->addAction(openRPCConsoleAction);
|
2012-09-21 19:06:53 +02:00
|
|
|
#ifndef Q_OS_MAC // This is built-in on Mac
|
2011-10-07 13:21:45 +02:00
|
|
|
trayIconMenu->addSeparator();
|
|
|
|
trayIconMenu->addAction(quitAction);
|
|
|
|
#endif
|
2011-05-12 20:16:42 +02:00
|
|
|
}
|
|
|
|
|
2012-09-21 19:06:53 +02:00
|
|
|
#ifndef Q_OS_MAC
|
2011-06-05 14:19:57 +02:00
|
|
|
void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
|
|
|
|
{
|
2011-08-08 17:38:17 +02:00
|
|
|
if(reason == QSystemTrayIcon::Trigger)
|
2011-06-05 14:19:57 +02:00
|
|
|
{
|
2012-07-21 13:01:02 +02:00
|
|
|
// Click on system tray icon triggers show/hide of the main window
|
2014-08-07 09:37:21 +02:00
|
|
|
toggleHidden();
|
2011-06-05 14:19:57 +02:00
|
|
|
}
|
|
|
|
}
|
2011-10-07 13:21:45 +02:00
|
|
|
#endif
|
2011-06-05 14:19:57 +02:00
|
|
|
|
2011-05-10 19:03:10 +02:00
|
|
|
void BitcoinGUI::optionsClicked()
|
|
|
|
{
|
2011-11-08 21:18:36 +01:00
|
|
|
if(!clientModel || !clientModel->getOptionsModel())
|
|
|
|
return;
|
2013-11-14 19:47:45 +01:00
|
|
|
|
2014-11-08 19:48:35 +01:00
|
|
|
OptionsDialog dlg(this, enableWallet);
|
2011-06-30 18:05:29 +02:00
|
|
|
dlg.setModel(clientModel->getOptionsModel());
|
2011-05-12 09:40:40 +02:00
|
|
|
dlg.exec();
|
2011-05-10 19:03:10 +02:00
|
|
|
}
|
|
|
|
|
2011-05-12 09:40:40 +02:00
|
|
|
void BitcoinGUI::aboutClicked()
|
2011-05-10 19:03:10 +02:00
|
|
|
{
|
2013-11-14 19:47:45 +01:00
|
|
|
if(!clientModel)
|
|
|
|
return;
|
|
|
|
|
2014-06-11 21:44:47 +02:00
|
|
|
HelpMessageDialog dlg(this, true);
|
2011-05-12 09:40:40 +02:00
|
|
|
dlg.exec();
|
2011-05-10 19:03:10 +02:00
|
|
|
}
|
|
|
|
|
2015-09-07 11:00:59 +02:00
|
|
|
void BitcoinGUI::showDebugWindow()
|
|
|
|
{
|
|
|
|
rpcConsole->showNormal();
|
|
|
|
rpcConsole->show();
|
|
|
|
rpcConsole->raise();
|
|
|
|
rpcConsole->activateWindow();
|
|
|
|
}
|
|
|
|
|
2015-11-12 12:59:26 +01:00
|
|
|
void BitcoinGUI::showDebugWindowActivateConsole()
|
|
|
|
{
|
|
|
|
rpcConsole->setTabFocus(RPCConsole::TAB_CONSOLE);
|
|
|
|
showDebugWindow();
|
|
|
|
}
|
|
|
|
|
2014-01-22 14:47:33 +01:00
|
|
|
void BitcoinGUI::showHelpMessageClicked()
|
|
|
|
{
|
2015-08-27 21:53:16 +02:00
|
|
|
helpMessageDialog->show();
|
2014-01-22 14:47:33 +01:00
|
|
|
}
|
|
|
|
|
2013-12-11 15:00:56 +01:00
|
|
|
#ifdef ENABLE_WALLET
|
2013-11-06 15:08:56 +01:00
|
|
|
void BitcoinGUI::openClicked()
|
|
|
|
{
|
2013-11-14 19:47:45 +01:00
|
|
|
OpenURIDialog dlg(this);
|
2013-11-06 15:08:56 +01:00
|
|
|
if(dlg.exec())
|
|
|
|
{
|
2015-07-14 13:59:05 +02:00
|
|
|
Q_EMIT receivedURI(dlg.getURI());
|
2013-11-06 15:08:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-03-22 18:32:49 +01:00
|
|
|
void BitcoinGUI::gotoOverviewPage()
|
|
|
|
{
|
2013-10-18 18:43:07 +02:00
|
|
|
overviewAction->setChecked(true);
|
2013-03-22 18:32:49 +01:00
|
|
|
if (walletFrame) walletFrame->gotoOverviewPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BitcoinGUI::gotoHistoryPage()
|
|
|
|
{
|
2013-10-18 18:43:07 +02:00
|
|
|
historyAction->setChecked(true);
|
2013-03-22 18:32:49 +01:00
|
|
|
if (walletFrame) walletFrame->gotoHistoryPage();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BitcoinGUI::gotoReceiveCoinsPage()
|
|
|
|
{
|
2013-10-18 18:43:07 +02:00
|
|
|
receiveCoinsAction->setChecked(true);
|
2013-03-22 18:32:49 +01:00
|
|
|
if (walletFrame) walletFrame->gotoReceiveCoinsPage();
|
|
|
|
}
|
|
|
|
|
2013-04-01 14:43:50 +02:00
|
|
|
void BitcoinGUI::gotoSendCoinsPage(QString addr)
|
2013-03-22 18:32:49 +01:00
|
|
|
{
|
2013-10-18 18:43:07 +02:00
|
|
|
sendCoinsAction->setChecked(true);
|
2013-04-01 14:43:50 +02:00
|
|
|
if (walletFrame) walletFrame->gotoSendCoinsPage(addr);
|
2013-03-22 18:32:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void BitcoinGUI::gotoSignMessageTab(QString addr)
|
|
|
|
{
|
|
|
|
if (walletFrame) walletFrame->gotoSignMessageTab(addr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void BitcoinGUI::gotoVerifyMessageTab(QString addr)
|
|
|
|
{
|
2013-04-03 15:28:16 +02:00
|
|
|
if (walletFrame) walletFrame->gotoVerifyMessageTab(addr);
|
2013-03-22 18:32:49 +01:00
|
|
|
}
|
2014-10-30 07:31:34 +01:00
|
|
|
#endif // ENABLE_WALLET
|
2013-03-22 18:32:49 +01:00
|
|
|
|
2011-05-12 20:28:07 +02:00
|
|
|
void BitcoinGUI::setNumConnections(int count)
|
|
|
|
{
|
2011-06-14 21:34:51 +02:00
|
|
|
QString icon;
|
|
|
|
switch(count)
|
|
|
|
{
|
2011-06-17 17:47:40 +02:00
|
|
|
case 0: icon = ":/icons/connect_0"; break;
|
|
|
|
case 1: case 2: case 3: icon = ":/icons/connect_1"; break;
|
|
|
|
case 4: case 5: case 6: icon = ":/icons/connect_2"; break;
|
|
|
|
case 7: case 8: case 9: icon = ":/icons/connect_3"; break;
|
|
|
|
default: icon = ":/icons/connect_4"; break;
|
2011-06-14 21:34:51 +02:00
|
|
|
}
|
2015-07-28 15:20:14 +02:00
|
|
|
labelConnectionsIcon->setPixmap(platformStyle->SingleColorIcon(icon).pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
|
2011-08-05 15:37:49 +02:00
|
|
|
labelConnectionsIcon->setToolTip(tr("%n active connection(s) to Bitcoin network", "", count));
|
2011-05-12 20:28:07 +02:00
|
|
|
}
|
|
|
|
|
2015-11-27 18:22:18 +01:00
|
|
|
void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress)
|
2011-05-12 20:28:07 +02:00
|
|
|
{
|
2014-09-22 14:41:54 +02:00
|
|
|
if(!clientModel)
|
|
|
|
return;
|
|
|
|
|
2012-10-12 16:08:47 +02:00
|
|
|
// Prevent orphan statusbar messages (e.g. hover Quit in main menu, wait until chain-sync starts -> garbelled text)
|
|
|
|
statusBar()->clearMessage();
|
|
|
|
|
2013-04-10 15:45:49 +02:00
|
|
|
// Acquire current block source
|
|
|
|
enum BlockSource blockSource = clientModel->getBlockSource();
|
|
|
|
switch (blockSource) {
|
|
|
|
case BLOCK_SOURCE_NETWORK:
|
|
|
|
progressBarLabel->setText(tr("Synchronizing with network..."));
|
|
|
|
break;
|
|
|
|
case BLOCK_SOURCE_DISK:
|
|
|
|
progressBarLabel->setText(tr("Importing blocks from disk..."));
|
|
|
|
break;
|
|
|
|
case BLOCK_SOURCE_REINDEX:
|
|
|
|
progressBarLabel->setText(tr("Reindexing blocks on disk..."));
|
|
|
|
break;
|
|
|
|
case BLOCK_SOURCE_NONE:
|
|
|
|
// Case: not Importing, not Reindexing and no network connection
|
|
|
|
progressBarLabel->setText(tr("No block source available..."));
|
|
|
|
break;
|
2012-04-02 10:18:51 +02:00
|
|
|
}
|
|
|
|
|
2011-07-17 14:06:43 +02:00
|
|
|
QString tooltip;
|
|
|
|
|
2013-02-10 19:01:30 +01:00
|
|
|
QDateTime currentDate = QDateTime::currentDateTime();
|
2015-02-09 11:19:01 +01:00
|
|
|
qint64 secs = blockDate.secsTo(currentDate);
|
2011-07-08 18:05:10 +02:00
|
|
|
|
2015-05-04 12:25:22 +02:00
|
|
|
tooltip = tr("Processed %n block(s) of transaction history.", "", count);
|
2011-07-18 06:55:05 +02:00
|
|
|
|
2011-08-08 17:38:17 +02:00
|
|
|
// Set icon state: spinning if catching up, tick otherwise
|
2014-05-05 19:43:14 +02:00
|
|
|
if(secs < 90*60)
|
2011-07-18 06:55:05 +02:00
|
|
|
{
|
2012-04-13 17:10:50 +02:00
|
|
|
tooltip = tr("Up to date") + QString(".<br>") + tooltip;
|
2015-07-28 15:20:14 +02:00
|
|
|
labelBlocksIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
|
2012-05-15 16:57:59 +02:00
|
|
|
|
2013-12-11 15:00:56 +01:00
|
|
|
#ifdef ENABLE_WALLET
|
|
|
|
if(walletFrame)
|
|
|
|
walletFrame->showOutOfSyncWarning(false);
|
2014-10-30 07:31:34 +01:00
|
|
|
#endif // ENABLE_WALLET
|
2013-02-10 19:01:30 +01:00
|
|
|
|
|
|
|
progressBarLabel->setVisible(false);
|
|
|
|
progressBar->setVisible(false);
|
2011-07-18 06:55:05 +02:00
|
|
|
}
|
2011-08-04 19:04:42 +02:00
|
|
|
else
|
|
|
|
{
|
2013-02-10 19:01:30 +01:00
|
|
|
// Represent time from last generated block in human readable text
|
|
|
|
QString timeBehindText;
|
2014-03-15 10:13:37 +01:00
|
|
|
const int HOUR_IN_SECONDS = 60*60;
|
|
|
|
const int DAY_IN_SECONDS = 24*60*60;
|
|
|
|
const int WEEK_IN_SECONDS = 7*24*60*60;
|
|
|
|
const int YEAR_IN_SECONDS = 31556952; // Average length of year in Gregorian calendar
|
|
|
|
if(secs < 2*DAY_IN_SECONDS)
|
2013-02-10 19:01:30 +01:00
|
|
|
{
|
2014-03-15 10:13:37 +01:00
|
|
|
timeBehindText = tr("%n hour(s)","",secs/HOUR_IN_SECONDS);
|
2013-02-10 19:01:30 +01:00
|
|
|
}
|
2014-03-15 10:13:37 +01:00
|
|
|
else if(secs < 2*WEEK_IN_SECONDS)
|
2013-02-10 19:01:30 +01:00
|
|
|
{
|
2014-03-15 10:13:37 +01:00
|
|
|
timeBehindText = tr("%n day(s)","",secs/DAY_IN_SECONDS);
|
|
|
|
}
|
|
|
|
else if(secs < YEAR_IN_SECONDS)
|
|
|
|
{
|
|
|
|
timeBehindText = tr("%n week(s)","",secs/WEEK_IN_SECONDS);
|
2013-02-10 19:01:30 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-02-09 11:21:26 +01:00
|
|
|
qint64 years = secs / YEAR_IN_SECONDS;
|
|
|
|
qint64 remainder = secs % YEAR_IN_SECONDS;
|
2014-03-15 10:13:37 +01:00
|
|
|
timeBehindText = tr("%1 and %2").arg(tr("%n year(s)", "", years)).arg(tr("%n week(s)","", remainder/WEEK_IN_SECONDS));
|
2013-02-10 19:01:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
progressBarLabel->setVisible(true);
|
|
|
|
progressBar->setFormat(tr("%1 behind").arg(timeBehindText));
|
2013-02-10 19:46:42 +01:00
|
|
|
progressBar->setMaximum(1000000000);
|
2015-11-27 18:22:18 +01:00
|
|
|
progressBar->setValue(nVerificationProgress * 1000000000.0 + 0.5);
|
2013-02-10 19:01:30 +01:00
|
|
|
progressBar->setVisible(true);
|
|
|
|
|
2012-04-13 17:10:50 +02:00
|
|
|
tooltip = tr("Catching up...") + QString("<br>") + tooltip;
|
2013-02-10 19:01:30 +01:00
|
|
|
if(count != prevBlocks)
|
2014-01-13 14:16:48 +01:00
|
|
|
{
|
2015-07-28 15:20:14 +02:00
|
|
|
labelBlocksIcon->setPixmap(platformStyle->SingleColorIcon(QString(
|
2014-01-13 14:16:48 +01:00
|
|
|
":/movies/spinner-%1").arg(spinnerFrame, 3, 10, QChar('0')))
|
|
|
|
.pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
|
|
|
|
spinnerFrame = (spinnerFrame + 1) % SPINNER_FRAMES;
|
|
|
|
}
|
2013-02-10 19:01:30 +01:00
|
|
|
prevBlocks = count;
|
2012-05-15 16:57:59 +02:00
|
|
|
|
2013-12-11 15:00:56 +01:00
|
|
|
#ifdef ENABLE_WALLET
|
|
|
|
if(walletFrame)
|
|
|
|
walletFrame->showOutOfSyncWarning(true);
|
2014-10-30 07:31:34 +01:00
|
|
|
#endif // ENABLE_WALLET
|
2011-07-18 06:55:05 +02:00
|
|
|
|
2012-04-13 17:10:50 +02:00
|
|
|
tooltip += QString("<br>");
|
2013-02-10 19:01:30 +01:00
|
|
|
tooltip += tr("Last received block was generated %1 ago.").arg(timeBehindText);
|
|
|
|
tooltip += QString("<br>");
|
|
|
|
tooltip += tr("Transactions after this will not yet be visible.");
|
2012-02-25 19:07:53 +01:00
|
|
|
}
|
2011-07-17 17:30:58 +02:00
|
|
|
|
2012-04-13 17:10:50 +02:00
|
|
|
// Don't word-wrap this (fixed-width) tooltip
|
|
|
|
tooltip = QString("<nobr>") + tooltip + QString("</nobr>");
|
|
|
|
|
2011-07-17 17:30:58 +02:00
|
|
|
labelBlocksIcon->setToolTip(tooltip);
|
2011-07-17 14:06:43 +02:00
|
|
|
progressBarLabel->setToolTip(tooltip);
|
|
|
|
progressBar->setToolTip(tooltip);
|
2011-05-12 20:28:07 +02:00
|
|
|
}
|
|
|
|
|
2013-02-16 17:58:45 +01:00
|
|
|
void BitcoinGUI::message(const QString &title, const QString &message, unsigned int style, bool *ret)
|
2011-05-30 20:20:12 +02:00
|
|
|
{
|
2013-04-09 09:54:19 +02:00
|
|
|
QString strTitle = tr("Bitcoin"); // default title
|
2012-11-05 08:04:21 +01:00
|
|
|
// Default to information icon
|
|
|
|
int nMBoxIcon = QMessageBox::Information;
|
|
|
|
int nNotifyIcon = Notificator::Information;
|
|
|
|
|
2013-04-09 09:54:19 +02:00
|
|
|
QString msgType;
|
2013-09-14 11:44:12 +02:00
|
|
|
|
|
|
|
// Prefer supplied title over style based title
|
|
|
|
if (!title.isEmpty()) {
|
|
|
|
msgType = title;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
switch (style) {
|
|
|
|
case CClientUIInterface::MSG_ERROR:
|
|
|
|
msgType = tr("Error");
|
|
|
|
break;
|
|
|
|
case CClientUIInterface::MSG_WARNING:
|
|
|
|
msgType = tr("Warning");
|
|
|
|
break;
|
|
|
|
case CClientUIInterface::MSG_INFORMATION:
|
|
|
|
msgType = tr("Information");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2012-11-05 08:04:21 +01:00
|
|
|
}
|
2013-09-14 11:44:12 +02:00
|
|
|
// Append title to "Bitcoin - "
|
2013-04-09 09:54:19 +02:00
|
|
|
if (!msgType.isEmpty())
|
|
|
|
strTitle += " - " + msgType;
|
2012-11-05 08:04:21 +01:00
|
|
|
|
|
|
|
// Check for error/warning icon
|
|
|
|
if (style & CClientUIInterface::ICON_ERROR) {
|
|
|
|
nMBoxIcon = QMessageBox::Critical;
|
|
|
|
nNotifyIcon = Notificator::Critical;
|
2012-03-25 20:47:33 +02:00
|
|
|
}
|
2012-11-05 08:04:21 +01:00
|
|
|
else if (style & CClientUIInterface::ICON_WARNING) {
|
|
|
|
nMBoxIcon = QMessageBox::Warning;
|
|
|
|
nNotifyIcon = Notificator::Warning;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Display message
|
2012-12-03 13:24:42 +01:00
|
|
|
if (style & CClientUIInterface::MODAL) {
|
2012-11-05 08:04:21 +01:00
|
|
|
// Check for buttons, use OK as default, if none was supplied
|
|
|
|
QMessageBox::StandardButton buttons;
|
|
|
|
if (!(buttons = (QMessageBox::StandardButton)(style & CClientUIInterface::BTN_MASK)))
|
|
|
|
buttons = QMessageBox::Ok;
|
|
|
|
|
2014-07-14 10:46:06 +02:00
|
|
|
showNormalIfMinimized();
|
2013-09-14 11:44:12 +02:00
|
|
|
QMessageBox mBox((QMessageBox::Icon)nMBoxIcon, strTitle, message, buttons, this);
|
2013-02-16 17:58:45 +01:00
|
|
|
int r = mBox.exec();
|
|
|
|
if (ret != NULL)
|
|
|
|
*ret = r == QMessageBox::Ok;
|
2012-11-05 08:04:21 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
notificator->notify((Notificator::Class)nNotifyIcon, strTitle, message);
|
2011-05-30 20:20:12 +02:00
|
|
|
}
|
2011-06-05 14:19:57 +02:00
|
|
|
|
|
|
|
void BitcoinGUI::changeEvent(QEvent *e)
|
|
|
|
{
|
2012-03-15 22:30:08 +01:00
|
|
|
QMainWindow::changeEvent(e);
|
2012-09-21 19:06:53 +02:00
|
|
|
#ifndef Q_OS_MAC // Ignored on Mac
|
2011-11-13 08:45:29 +01:00
|
|
|
if(e->type() == QEvent::WindowStateChange)
|
2011-06-05 14:19:57 +02:00
|
|
|
{
|
2014-09-22 14:41:54 +02:00
|
|
|
if(clientModel && clientModel->getOptionsModel() && clientModel->getOptionsModel()->getMinimizeToTray())
|
2011-06-05 14:19:57 +02:00
|
|
|
{
|
2012-02-17 13:50:32 +01:00
|
|
|
QWindowStateChangeEvent *wsevt = static_cast<QWindowStateChangeEvent*>(e);
|
2012-03-15 22:30:08 +01:00
|
|
|
if(!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized())
|
2011-06-07 18:59:01 +02:00
|
|
|
{
|
2012-03-15 22:30:08 +01:00
|
|
|
QTimer::singleShot(0, this, SLOT(hide()));
|
|
|
|
e->ignore();
|
2011-06-05 14:19:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-10-07 13:21:45 +02:00
|
|
|
#endif
|
2011-06-05 14:19:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void BitcoinGUI::closeEvent(QCloseEvent *event)
|
|
|
|
{
|
2012-09-21 19:06:53 +02:00
|
|
|
#ifndef Q_OS_MAC // Ignored on Mac
|
2014-09-22 14:41:54 +02:00
|
|
|
if(clientModel && clientModel->getOptionsModel())
|
|
|
|
{
|
2011-11-08 21:18:36 +01:00
|
|
|
if(!clientModel->getOptionsModel()->getMinimizeToTray() &&
|
|
|
|
!clientModel->getOptionsModel()->getMinimizeOnClose())
|
|
|
|
{
|
2014-11-10 16:41:57 +01:00
|
|
|
// close rpcConsole in case it was open to make some space for the shutdown window
|
|
|
|
rpcConsole->close();
|
|
|
|
|
2013-04-02 17:30:14 +02:00
|
|
|
QApplication::quit();
|
2011-11-08 21:18:36 +01:00
|
|
|
}
|
|
|
|
}
|
2014-09-22 14:41:54 +02:00
|
|
|
#endif
|
2011-06-05 14:19:57 +02:00
|
|
|
QMainWindow::closeEvent(event);
|
|
|
|
}
|
2011-06-05 17:36:52 +02:00
|
|
|
|
2013-12-11 15:00:56 +01:00
|
|
|
#ifdef ENABLE_WALLET
|
2015-02-26 21:57:08 +01:00
|
|
|
void BitcoinGUI::incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label)
|
2011-06-10 21:59:29 +02:00
|
|
|
{
|
2013-04-01 14:43:50 +02:00
|
|
|
// On new transaction, make an info balloon
|
2015-02-26 21:57:08 +01:00
|
|
|
QString msg = tr("Date: %1\n").arg(date) +
|
|
|
|
tr("Amount: %1\n").arg(BitcoinUnits::formatWithUnit(unit, amount, true)) +
|
|
|
|
tr("Type: %1\n").arg(type);
|
|
|
|
if (!label.isEmpty())
|
|
|
|
msg += tr("Label: %1\n").arg(label);
|
|
|
|
else if (!address.isEmpty())
|
|
|
|
msg += tr("Address: %1\n").arg(address);
|
2012-11-27 22:02:50 +01:00
|
|
|
message((amount)<0 ? tr("Sent transaction") : tr("Incoming transaction"),
|
2015-02-26 21:57:08 +01:00
|
|
|
msg, CClientUIInterface::MSG_INFORMATION);
|
2011-06-10 21:59:29 +02:00
|
|
|
}
|
2014-10-30 07:31:34 +01:00
|
|
|
#endif // ENABLE_WALLET
|
2011-07-05 22:09:39 +02:00
|
|
|
|
2011-08-07 16:04:48 +02:00
|
|
|
void BitcoinGUI::dragEnterEvent(QDragEnterEvent *event)
|
|
|
|
{
|
2012-03-25 23:25:10 +02:00
|
|
|
// Accept only URIs
|
2011-08-07 16:04:48 +02:00
|
|
|
if(event->mimeData()->hasUrls())
|
|
|
|
event->acceptProposedAction();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BitcoinGUI::dropEvent(QDropEvent *event)
|
|
|
|
{
|
|
|
|
if(event->mimeData()->hasUrls())
|
|
|
|
{
|
2015-07-14 13:59:05 +02:00
|
|
|
Q_FOREACH(const QUrl &uri, event->mimeData()->urls())
|
2011-08-07 16:04:48 +02:00
|
|
|
{
|
2015-07-14 13:59:05 +02:00
|
|
|
Q_EMIT receivedURI(uri.toString());
|
2011-08-07 16:04:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
event->acceptProposedAction();
|
|
|
|
}
|
|
|
|
|
2012-10-12 16:08:47 +02:00
|
|
|
bool BitcoinGUI::eventFilter(QObject *object, QEvent *event)
|
|
|
|
{
|
|
|
|
// Catch status tip events
|
|
|
|
if (event->type() == QEvent::StatusTip)
|
|
|
|
{
|
|
|
|
// Prevent adding text from setStatusTip(), if we currently use the status bar for displaying other stuff
|
2013-04-06 12:20:02 +02:00
|
|
|
if (progressBarLabel->isVisible() || progressBar->isVisible())
|
2012-10-12 16:08:47 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return QMainWindow::eventFilter(object, event);
|
|
|
|
}
|
|
|
|
|
2013-12-11 15:00:56 +01:00
|
|
|
#ifdef ENABLE_WALLET
|
2013-10-24 15:49:13 +02:00
|
|
|
bool BitcoinGUI::handlePaymentRequest(const SendCoinsRecipient& recipient)
|
2011-12-24 05:27:12 +01:00
|
|
|
{
|
2013-10-24 15:49:13 +02:00
|
|
|
// URI has to be valid
|
2013-12-11 15:00:56 +01:00
|
|
|
if (walletFrame && walletFrame->handlePaymentRequest(recipient))
|
2013-10-24 15:49:13 +02:00
|
|
|
{
|
|
|
|
showNormalIfMinimized();
|
|
|
|
gotoSendCoinsPage();
|
|
|
|
return true;
|
|
|
|
}
|
2014-09-22 14:41:54 +02:00
|
|
|
return false;
|
2013-07-22 08:50:39 +02:00
|
|
|
}
|
|
|
|
|
2011-08-23 20:08:42 +02:00
|
|
|
void BitcoinGUI::setEncryptionStatus(int status)
|
|
|
|
{
|
|
|
|
switch(status)
|
|
|
|
{
|
|
|
|
case WalletModel::Unencrypted:
|
|
|
|
labelEncryptionIcon->hide();
|
2011-08-24 22:07:26 +02:00
|
|
|
encryptWalletAction->setChecked(false);
|
|
|
|
changePassphraseAction->setEnabled(false);
|
|
|
|
encryptWalletAction->setEnabled(true);
|
2011-08-23 20:08:42 +02:00
|
|
|
break;
|
|
|
|
case WalletModel::Unlocked:
|
|
|
|
labelEncryptionIcon->show();
|
2015-07-28 15:20:14 +02:00
|
|
|
labelEncryptionIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/lock_open").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
|
2011-08-23 20:08:42 +02:00
|
|
|
labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b>"));
|
2011-08-24 22:07:26 +02:00
|
|
|
encryptWalletAction->setChecked(true);
|
|
|
|
changePassphraseAction->setEnabled(true);
|
|
|
|
encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
|
2011-08-23 20:08:42 +02:00
|
|
|
break;
|
|
|
|
case WalletModel::Locked:
|
|
|
|
labelEncryptionIcon->show();
|
2015-07-28 15:20:14 +02:00
|
|
|
labelEncryptionIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/lock_closed").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
|
2011-08-23 20:08:42 +02:00
|
|
|
labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>locked</b>"));
|
2011-08-24 22:07:26 +02:00
|
|
|
encryptWalletAction->setChecked(true);
|
|
|
|
changePassphraseAction->setEnabled(true);
|
|
|
|
encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
|
2011-08-23 20:08:42 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2014-10-30 07:31:34 +01:00
|
|
|
#endif // ENABLE_WALLET
|
2011-08-24 22:07:26 +02:00
|
|
|
|
2012-06-05 07:23:26 +02:00
|
|
|
void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden)
|
2012-02-17 23:19:52 +01:00
|
|
|
{
|
2014-07-14 10:46:06 +02:00
|
|
|
if(!clientModel)
|
|
|
|
return;
|
2014-08-07 09:37:21 +02:00
|
|
|
|
2012-06-05 07:23:26 +02:00
|
|
|
// activateWindow() (sometimes) helps with keyboard focus on Windows
|
|
|
|
if (isHidden())
|
|
|
|
{
|
2012-02-17 23:19:52 +01:00
|
|
|
show();
|
2012-06-05 07:23:26 +02:00
|
|
|
activateWindow();
|
|
|
|
}
|
|
|
|
else if (isMinimized())
|
|
|
|
{
|
2012-02-17 23:19:52 +01:00
|
|
|
showNormal();
|
2012-06-05 07:23:26 +02:00
|
|
|
activateWindow();
|
|
|
|
}
|
|
|
|
else if (GUIUtil::isObscured(this))
|
|
|
|
{
|
|
|
|
raise();
|
|
|
|
activateWindow();
|
|
|
|
}
|
|
|
|
else if(fToggleHidden)
|
|
|
|
hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
void BitcoinGUI::toggleHidden()
|
|
|
|
{
|
|
|
|
showNormalIfMinimized(true);
|
2012-02-17 23:19:52 +01:00
|
|
|
}
|
2013-03-23 23:14:12 +01:00
|
|
|
|
|
|
|
void BitcoinGUI::detectShutdown()
|
|
|
|
{
|
|
|
|
if (ShutdownRequested())
|
2014-01-08 10:45:00 +01:00
|
|
|
{
|
|
|
|
if(rpcConsole)
|
|
|
|
rpcConsole->hide();
|
|
|
|
qApp->quit();
|
|
|
|
}
|
2013-03-23 23:14:12 +01:00
|
|
|
}
|
2014-01-08 08:59:24 +01:00
|
|
|
|
2014-05-23 18:04:09 +02:00
|
|
|
void BitcoinGUI::showProgress(const QString &title, int nProgress)
|
|
|
|
{
|
|
|
|
if (nProgress == 0)
|
|
|
|
{
|
|
|
|
progressDialog = new QProgressDialog(title, "", 0, 100);
|
|
|
|
progressDialog->setWindowModality(Qt::ApplicationModal);
|
|
|
|
progressDialog->setMinimumDuration(0);
|
|
|
|
progressDialog->setCancelButton(0);
|
|
|
|
progressDialog->setAutoClose(false);
|
|
|
|
progressDialog->setValue(0);
|
|
|
|
}
|
|
|
|
else if (nProgress == 100)
|
|
|
|
{
|
|
|
|
if (progressDialog)
|
|
|
|
{
|
|
|
|
progressDialog->close();
|
|
|
|
progressDialog->deleteLater();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (progressDialog)
|
|
|
|
progressDialog->setValue(nProgress);
|
|
|
|
}
|
|
|
|
|
2014-01-08 08:59:24 +01:00
|
|
|
static bool ThreadSafeMessageBox(BitcoinGUI *gui, const std::string& message, const std::string& caption, unsigned int style)
|
|
|
|
{
|
|
|
|
bool modal = (style & CClientUIInterface::MODAL);
|
2014-10-17 01:16:29 +02:00
|
|
|
// The SECURE flag has no effect in the Qt GUI.
|
|
|
|
// bool secure = (style & CClientUIInterface::SECURE);
|
|
|
|
style &= ~CClientUIInterface::SECURE;
|
2014-01-08 08:59:24 +01:00
|
|
|
bool ret = false;
|
|
|
|
// In case of modal message, use blocking connection to wait for user to click a button
|
|
|
|
QMetaObject::invokeMethod(gui, "message",
|
|
|
|
modal ? GUIUtil::blockingGUIThreadConnection() : Qt::QueuedConnection,
|
|
|
|
Q_ARG(QString, QString::fromStdString(caption)),
|
|
|
|
Q_ARG(QString, QString::fromStdString(message)),
|
|
|
|
Q_ARG(unsigned int, style),
|
|
|
|
Q_ARG(bool*, &ret));
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BitcoinGUI::subscribeToCoreSignals()
|
|
|
|
{
|
|
|
|
// Connect signals to client
|
|
|
|
uiInterface.ThreadSafeMessageBox.connect(boost::bind(ThreadSafeMessageBox, this, _1, _2, _3));
|
|
|
|
}
|
|
|
|
|
|
|
|
void BitcoinGUI::unsubscribeFromCoreSignals()
|
|
|
|
{
|
|
|
|
// Disconnect signals from client
|
|
|
|
uiInterface.ThreadSafeMessageBox.disconnect(boost::bind(ThreadSafeMessageBox, this, _1, _2, _3));
|
|
|
|
}
|
2014-06-07 08:20:22 +02:00
|
|
|
|
2015-07-28 15:20:14 +02:00
|
|
|
UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *platformStyle) :
|
2014-08-07 09:34:31 +02:00
|
|
|
optionsModel(0),
|
|
|
|
menu(0)
|
2014-06-07 08:20:22 +02:00
|
|
|
{
|
|
|
|
createContextMenu();
|
|
|
|
setToolTip(tr("Unit to show amounts in. Click to select another unit."));
|
2014-12-27 20:19:51 +01:00
|
|
|
QList<BitcoinUnits::Unit> units = BitcoinUnits::availableUnits();
|
|
|
|
int max_width = 0;
|
|
|
|
const QFontMetrics fm(font());
|
2015-07-14 13:59:05 +02:00
|
|
|
Q_FOREACH (const BitcoinUnits::Unit unit, units)
|
2014-12-27 20:19:51 +01:00
|
|
|
{
|
|
|
|
max_width = qMax(max_width, fm.width(BitcoinUnits::name(unit)));
|
|
|
|
}
|
|
|
|
setMinimumSize(max_width, 0);
|
|
|
|
setAlignment(Qt::AlignRight | Qt::AlignVCenter);
|
2015-07-28 15:20:14 +02:00
|
|
|
setStyleSheet(QString("QLabel { color : %1 }").arg(platformStyle->SingleColor().name()));
|
2014-06-07 08:20:22 +02:00
|
|
|
}
|
|
|
|
|
2014-07-13 08:14:29 +02:00
|
|
|
/** So that it responds to button clicks */
|
2014-06-07 08:20:22 +02:00
|
|
|
void UnitDisplayStatusBarControl::mousePressEvent(QMouseEvent *event)
|
|
|
|
{
|
|
|
|
onDisplayUnitsClicked(event->pos());
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Creates context menu, its actions, and wires up all the relevant signals for mouse events. */
|
|
|
|
void UnitDisplayStatusBarControl::createContextMenu()
|
|
|
|
{
|
|
|
|
menu = new QMenu();
|
2015-07-14 13:59:05 +02:00
|
|
|
Q_FOREACH(BitcoinUnits::Unit u, BitcoinUnits::availableUnits())
|
2014-06-07 08:20:22 +02:00
|
|
|
{
|
|
|
|
QAction *menuAction = new QAction(QString(BitcoinUnits::name(u)), this);
|
|
|
|
menuAction->setData(QVariant(u));
|
|
|
|
menu->addAction(menuAction);
|
|
|
|
}
|
|
|
|
connect(menu,SIGNAL(triggered(QAction*)),this,SLOT(onMenuSelection(QAction*)));
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Lets the control know about the Options Model (and its signals) */
|
|
|
|
void UnitDisplayStatusBarControl::setOptionsModel(OptionsModel *optionsModel)
|
|
|
|
{
|
|
|
|
if (optionsModel)
|
|
|
|
{
|
|
|
|
this->optionsModel = optionsModel;
|
|
|
|
|
|
|
|
// be aware of a display unit change reported by the OptionsModel object.
|
|
|
|
connect(optionsModel,SIGNAL(displayUnitChanged(int)),this,SLOT(updateDisplayUnit(int)));
|
|
|
|
|
|
|
|
// initialize the display units label with the current value in the model.
|
|
|
|
updateDisplayUnit(optionsModel->getDisplayUnit());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/** When Display Units are changed on OptionsModel it will refresh the display text of the control on the status bar */
|
|
|
|
void UnitDisplayStatusBarControl::updateDisplayUnit(int newUnits)
|
|
|
|
{
|
2014-12-27 20:19:51 +01:00
|
|
|
setText(BitcoinUnits::name(newUnits));
|
2014-06-07 08:20:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Shows context menu with Display Unit options by the mouse coordinates */
|
|
|
|
void UnitDisplayStatusBarControl::onDisplayUnitsClicked(const QPoint& point)
|
|
|
|
{
|
|
|
|
QPoint globalPos = mapToGlobal(point);
|
|
|
|
menu->exec(globalPos);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Tells underlying optionsModel to update its current display unit. */
|
|
|
|
void UnitDisplayStatusBarControl::onMenuSelection(QAction* action)
|
|
|
|
{
|
|
|
|
if (action)
|
|
|
|
{
|
|
|
|
optionsModel->setDisplayUnit(action->data());
|
|
|
|
}
|
|
|
|
}
|