5 #if defined(HAVE_CONFIG_H)
6 #include "config/bitcoin-config.h"
42 #include <QApplication>
44 #include <QDesktopWidget>
45 #include <QDragEnterEvent>
46 #include <QFontDatabase>
47 #include <QListWidget>
49 #include <QMessageBox>
51 #include <QProgressDialog>
54 #include <QStackedWidget>
59 #include <QVBoxLayout>
61 #if QT_VERSION < 0x050000
62 #include <QTextDocument>
71 #elif defined(Q_OS_WIN)
78 #include <boost/bind/bind.hpp>
89 unitDisplayControl(0),
90 labelWalletEncryptionIcon(0),
91 labelWalletHDStatusIcon(0),
92 connectionsControl(0),
102 sendCoinsMenuAction(0),
103 usedSendingAddressesAction(0),
104 usedReceivingAddressesAction(0),
105 signMessageAction(0),
106 verifyMessageAction(0),
108 receiveCoinsAction(0),
109 receiveCoinsMenuAction(0),
112 encryptWalletAction(0),
113 backupWalletAction(0),
114 changePassphraseAction(0),
116 openRPCConsoleAction(0),
118 showHelpMessageAction(0),
123 helpMessageDialog(0),
127 platformStyle(_platformStyle)
131 QString windowTitle = tr(PACKAGE_NAME) +
" - ";
137 windowTitle += tr(
"Wallet");
139 windowTitle += tr(
"Node");
148 setWindowTitle(windowTitle);
150 #if defined(Q_OS_MAC) && QT_VERSION < 0x050000
153 setUnifiedTitleAndToolBarOnMac(
true);
174 QFontDatabase::addApplicationFont(
":fonts/ComicNeue-Bold");
175 QFontDatabase::addApplicationFont(
":fonts/ComicNeue-Bold-Oblique");
176 QFontDatabase::addApplicationFont(
":fonts/ComicNeue-Light");
177 QFontDatabase::addApplicationFont(
":fonts/ComicNeue-Light-Oblique");
178 QFontDatabase::addApplicationFont(
":fonts/ComicNeue-Regular");
179 QFontDatabase::addApplicationFont(
":fonts/ComicNeue-Regular-Oblique");
180 QFont::insertSubstitution(
"Comic Sans MS",
"Comic Neue");
183 QFont newFont(
"Comic Sans MS", 10);
186 QApplication::setFont(newFont);
189 setAcceptDrops(
true);
208 statusBar()->setSizeGripEnabled(
false);
211 QFrame *frameBlocks =
new QFrame();
212 frameBlocks->setContentsMargins(0,0,0,0);
213 frameBlocks->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
214 QHBoxLayout *frameBlocksLayout =
new QHBoxLayout(frameBlocks);
215 frameBlocksLayout->setContentsMargins(3,0,3,0);
216 frameBlocksLayout->setSpacing(3);
224 frameBlocksLayout->addStretch();
226 frameBlocksLayout->addStretch();
230 frameBlocksLayout->addStretch();
232 frameBlocksLayout->addStretch();
234 frameBlocksLayout->addStretch();
246 QString curStyle = QApplication::style()->metaObject()->className();
247 if(curStyle ==
"QWindowsStyle" || curStyle ==
"QWindowsXPStyle")
249 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; }");
254 statusBar()->addPermanentWidget(frameBlocks);
257 this->installEventFilter(
this);
295 QActionGroup *tabGroup =
new QActionGroup(
this);
298 overviewAction->setStatusTip(tr(
"Show general overview of wallet"));
316 receiveCoinsAction->setStatusTip(tr(
"Request payments (generates QR codes and dogecoin: URIs)"));
327 historyAction->setStatusTip(tr(
"Browse transaction history"));
330 historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
337 connect(
overviewAction, SIGNAL(triggered()),
this, SLOT(gotoOverviewPage()));
339 connect(
sendCoinsAction, SIGNAL(triggered()),
this, SLOT(gotoSendCoinsPage()));
347 connect(
historyAction, SIGNAL(triggered()),
this, SLOT(gotoHistoryPage()));
351 quitAction->setStatusTip(tr(
"Quit application"));
352 quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
355 aboutAction->setStatusTip(tr(
"Show information about %1").arg(tr(PACKAGE_NAME)));
359 aboutQtAction->setStatusTip(tr(
"Show information about Qt"));
362 optionsAction->setStatusTip(tr(
"Modify configuration options for %1").arg(tr(PACKAGE_NAME)));
369 encryptWalletAction->setStatusTip(tr(
"Encrypt the private keys that belong to your wallet"));
376 signMessageAction->setStatusTip(tr(
"Sign messages with your Dogecoin addresses to prove you own them"));
378 verifyMessageAction->setStatusTip(tr(
"Verify messages to ensure they were signed with specified Dogecoin addresses"));
379 paperWalletAction =
new QAction(QIcon(
":/icons/print"), tr(
"&Print paper wallets"),
this);
393 openAction->setStatusTip(tr(
"Open a dogecoin: URI or payment request"));
397 showHelpMessageAction->setStatusTip(tr(
"Show the %1 help message to get a list with possible Dogecoin command-line options").arg(tr(PACKAGE_NAME)));
399 connect(
quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
401 connect(
aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
415 connect(
signMessageAction, SIGNAL(triggered()),
this, SLOT(gotoSignMessageTab()));
419 connect(
openAction, SIGNAL(triggered()),
this, SLOT(openClicked()));
425 new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_D),
this, SLOT(
showDebugWindow()));
439 QMenu *file =
appMenuBar->addMenu(tr(
"&File"));
447 file->addSeparator();
450 file->addSeparator();
454 QMenu *settings =
appMenuBar->addMenu(tr(
"&Settings"));
459 settings->addSeparator();
469 help->addSeparator();
478 QToolBar *toolbar = addToolBar(tr(
"Tabs toolbar"));
479 toolbar->setMovable(
false);
480 toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
500 connect(_clientModel, SIGNAL(numConnectionsChanged(
int)),
this, SLOT(
setNumConnections(
int)));
501 connect(_clientModel, SIGNAL(networkActiveChanged(
bool)),
this, SLOT(
setNetworkActive(
bool)));
505 connect(_clientModel, SIGNAL(numBlocksChanged(
int,QDateTime,
double,
bool)),
this, SLOT(
setNumBlocks(
int,QDateTime,
double,
bool)));
508 connect(_clientModel, SIGNAL(
message(QString,QString,
unsigned int)),
this, SLOT(
message(QString,QString,
unsigned int)));
526 connect(optionsModel,SIGNAL(hideTrayIconChanged(
bool)),
this,SLOT(
setTrayIconVisible(
bool)));
552 bool BitcoinGUI::addWallet(
const QString& name,
WalletModel *walletModel)
560 bool BitcoinGUI::setCurrentWallet(
const QString& name)
567 void BitcoinGUI::removeAllWallets()
598 trayIcon =
new QSystemTrayIcon(
this);
599 QString toolTip = tr(
"%1 client").arg(tr(PACKAGE_NAME)) +
" " + networkStyle->
getTitleAddText();
618 connect(
trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
647 if(reason == QSystemTrayIcon::Trigger)
694 void BitcoinGUI::openClicked()
703 void BitcoinGUI::gotoOverviewPage()
709 void BitcoinGUI::gotoHistoryPage()
715 void BitcoinGUI::gotoReceiveCoinsPage()
721 void BitcoinGUI::gotoSendCoinsPage(QString addr)
727 void BitcoinGUI::gotoSignMessageTab(QString addr)
732 void BitcoinGUI::gotoVerifyMessageTab(QString addr)
744 case 0: icon =
":/icons/connect_0";
break;
745 case 1:
case 2:
case 3: icon =
":/icons/connect_1";
break;
746 case 4:
case 5:
case 6: icon =
":/icons/connect_2";
break;
747 case 7:
case 8:
case 9: icon =
":/icons/connect_3";
break;
748 default: icon =
":/icons/connect_4";
break;
754 tooltip = tr(
"%n active connection(s) to Dogecoin network",
"", count) + QString(
".<br>") + tr(
"Click to disable network activity.");
756 tooltip = tr(
"Network activity disabled.") + QString(
"<br>") + tr(
"Click to enable network activity again.");
757 icon =
":/icons/network_disabled";
761 tooltip = QString(
"<nobr>") + tooltip + QString(
"</nobr>");
782 if (estHeadersLeft > HEADER_HEIGHT_DELTA_SYNC)
783 progressBarLabel->setText(tr(
"Syncing Headers (%1%)...").arg(QString::number(100.0 / (headersTipHeight+estHeadersLeft)*headersTipHeight,
'f', 1)));
799 statusBar()->clearMessage();
803 switch (blockSource) {
832 QDateTime currentDate = QDateTime::currentDateTime();
833 qint64 secs = blockDate.secsTo(currentDate);
835 tooltip = tr(
"Processed %n block(s) of transaction history.",
"", count);
840 tooltip = tr(
"Up to date") + QString(
".<br>") + tooltip;
859 progressBar->setFormat(tr(
"%1 behind").arg(timeBehindText));
861 progressBar->setValue(nVerificationProgress * 1000000000.0 + 0.5);
864 tooltip = tr(
"Catching up...") + QString(
"<br>") + tooltip;
868 ":/movies/spinner-%1").arg(
spinnerFrame, 3, 10, QChar(
'0')))
869 .pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
882 tooltip += QString(
"<br>");
883 tooltip += tr(
"Last received block was generated %1 ago.").arg(timeBehindText);
884 tooltip += QString(
"<br>");
885 tooltip += tr(
"Transactions after this will not yet be visible.");
889 tooltip = QString(
"<nobr>") + tooltip + QString(
"</nobr>");
898 QString strTitle = tr(
"Dogecoin");
900 int nMBoxIcon = QMessageBox::Information;
906 if (!title.isEmpty()) {
912 msgType = tr(
"Error");
915 msgType = tr(
"Warning");
918 msgType = tr(
"Information");
925 if (!msgType.isEmpty())
926 strTitle +=
" - " + msgType;
930 nMBoxIcon = QMessageBox::Critical;
934 nMBoxIcon = QMessageBox::Warning;
941 QMessageBox::StandardButton buttons;
943 buttons = QMessageBox::Ok;
946 QMessageBox mBox((QMessageBox::Icon)nMBoxIcon, strTitle,
message, buttons,
this);
949 *ret = r == QMessageBox::Ok;
957 QMainWindow::changeEvent(e);
959 if(e->type() == QEvent::WindowStateChange)
963 QWindowStateChangeEvent *wsevt =
static_cast<QWindowStateChangeEvent*
>(e);
964 if(!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized())
966 QTimer::singleShot(0,
this, SLOT(hide()));
984 QApplication::quit();
988 QMainWindow::showMinimized();
993 QMainWindow::closeEvent(event);
1005 #ifdef ENABLE_WALLET
1006 void BitcoinGUI::incomingTransaction(
const QString& date,
int unit,
const CAmount& amount,
const QString& type,
const QString& address,
const QString& label)
1009 QString msg = tr(
"Date: %1\n").arg(date) +
1011 tr(
"Type: %1\n").arg(type);
1012 if (!label.isEmpty())
1013 msg += tr(
"Label: %1\n").arg(label);
1014 else if (!address.isEmpty())
1015 msg += tr(
"Address: %1\n").arg(address);
1016 message((amount)<0 ? tr(
"Sent transaction") : tr(
"Incoming transaction"),
1024 if(event->mimeData()->hasUrls())
1025 event->acceptProposedAction();
1030 if(event->mimeData()->hasUrls())
1032 Q_FOREACH(
const QUrl &uri, event->mimeData()->urls())
1037 event->acceptProposedAction();
1043 if (event->type() == QEvent::StatusTip)
1049 return QMainWindow::eventFilter(
object, event);
1052 #ifdef ENABLE_WALLET
1059 gotoSendCoinsPage();
1065 void BitcoinGUI::setHDStatus(
int hdEnabled)
1068 labelWalletHDStatusIcon->setToolTip(hdEnabled ? tr(
"HD key generation is <b>enabled</b>") : tr(
"HD key generation is <b>disabled</b>"));
1074 void BitcoinGUI::setEncryptionStatus(
int status)
1115 else if (isMinimized())
1125 else if(fToggleHidden)
1155 else if (nProgress == 100)
1171 trayIcon->setVisible(!fHideTrayIcon);
1181 static bool ThreadSafeMessageBox(
BitcoinGUI *gui,
const std::string& message,
const std::string& caption,
unsigned int style)
1189 QMetaObject::invokeMethod(gui,
"message",
1191 Q_ARG(QString, QString::fromStdString(caption)),
1192 Q_ARG(QString, QString::fromStdString(message)),
1193 Q_ARG(
unsigned int, style),
1194 Q_ARG(
bool*, &ret));
1202 boost::placeholders::_1,
1203 boost::placeholders::_2,
1204 boost::placeholders::_3));
1206 boost::placeholders::_1,
1207 boost::placeholders::_3,
1208 boost::placeholders::_4));
1215 boost::placeholders::_1,
1216 boost::placeholders::_2,
1217 boost::placeholders::_3));
1219 boost::placeholders::_1,
1220 boost::placeholders::_3,
1221 boost::placeholders::_4));
1236 setToolTip(tr(
"Unit to show amounts in. Click to select another unit."));
1239 const QFontMetrics fm(font());
1244 setMinimumSize(max_width, 0);
1245 setAlignment(Qt::AlignRight | Qt::AlignVCenter);
1246 setStyleSheet(QString(
"QLabel { color : %1 }").arg(platformStyle->
SingleColor().name()));
1258 menu =
new QMenu(
this);
1262 menuAction->setData(QVariant(u));
1263 menu->addAction(menuAction);
1276 connect(_optionsModel,SIGNAL(displayUnitChanged(
int)),
this,SLOT(
updateDisplayUnit(
int)));
1292 QPoint globalPos = mapToGlobal(point);
1293 menu->exec(globalPos);
int64_t CAmount
Amount in satoshis (Can be negative)
const CChainParams & Params()
Return the currently selected parameters.
QLabel * progressBarLabel
void showNormalIfMinimized(bool fToggleHidden=false)
Show window if hidden, unminimize when minimized, rise when obscured or show if hidden and fToggleHid...
static const std::string DEFAULT_UIPLATFORM
void createTrayIcon(const NetworkStyle *networkStyle)
Create system tray icon and notification.
void changeEvent(QEvent *e)
void receivedURI(const QString &uri)
Signal raised when a URI was entered or dragged to the GUI.
ModalOverlay * modalOverlay
QAction * paperWalletAction
QAction * changePassphraseAction
void dropEvent(QDropEvent *event)
QAction * receiveCoinsMenuAction
int prevBlocks
Keep track of previous number of blocks, to detect progress.
QAction * openRPCConsoleAction
void optionsClicked()
Show configuration dialog.
QAction * toggleHideAction
void toggleNetworkActive()
Toggle networking.
QProgressBar * progressBar
QProgressDialog * progressDialog
WalletFrame * walletFrame
QAction * receiveCoinsAction
QAction * usedSendingAddressesAction
void unsubscribeFromCoreSignals()
Disconnect core signals from GUI client.
QAction * verifyMessageAction
void createTrayIconMenu()
Create system tray menu (or setup the dock menu)
HelpMessageDialog * helpMessageDialog
BitcoinGUI(const PlatformStyle *platformStyle, const NetworkStyle *networkStyle, QWidget *parent=0)
void aboutClicked()
Show about dialog.
void toggleHidden()
Simply calls showNormalIfMinimized(true) for use in SLOT() macro.
void setNumBlocks(int count, const QDateTime &blockDate, double nVerificationProgress, bool headers)
Set number of blocks and last block date shown in the UI.
QAction * encryptWalletAction
void updateNetworkState()
Update UI with latest network info from model.
void createActions()
Create the main UI actions.
void showDebugWindow()
Show debug window.
void showDebugWindowActivateConsole()
Show debug window and set focus to the console.
void showProgress(const QString &title, int nProgress)
Show progress dialog e.g.
void dragEnterEvent(QDragEnterEvent *event)
QAction * usedReceivingAddressesAction
void subscribeToCoreSignals()
Connect core signals to GUI client.
void createToolBars()
Create the toolbars.
QLabel * connectionsControl
void showEvent(QShowEvent *event)
UnitDisplayStatusBarControl * unitDisplayControl
void setClientModel(ClientModel *clientModel)
Set the client model.
void setWalletActionsEnabled(bool enabled)
Enable or disable all wallet-related actions.
const PlatformStyle * platformStyle
QLabel * labelWalletEncryptionIcon
void detectShutdown()
called by a timer to check if fRequestShutdown has been set
QAction * backupWalletAction
void message(const QString &title, const QString &message, unsigned int style, bool *ret=NULL)
Notify the user of an event from the core network or transaction handling code.
QAction * sendCoinsMenuAction
QAction * showHelpMessageAction
void closeEvent(QCloseEvent *event)
ClientModel * clientModel
void updateHeadersSyncProgressLabel()
void setTrayIconVisible(bool)
When hideTrayIcon setting is changed in OptionsModel hide or show the icon accordingly.
void createMenuBar()
Create the menu bar and sub-menus.
QSystemTrayIcon * trayIcon
static const QString DEFAULT_WALLET
Display name for default wallet name.
void showHelpMessageClicked()
Show help message dialog.
QAction * sendCoinsAction
QLabel * labelWalletHDStatusIcon
void setNumConnections(int count)
Set number of connections shown in the UI.
void trayIconActivated(QSystemTrayIcon::ActivationReason reason)
Handle tray icon clicked.
QAction * signMessageAction
bool eventFilter(QObject *object, QEvent *event)
Notificator * notificator
void setNetworkActive(bool networkActive)
Set network state shown in the UI.
static QString name(int unit)
Short name.
static QList< Unit > availableUnits()
Get list of units, for drop-down box.
static QString formatWithUnit(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as string (with unit)
const Consensus::Params & GetConsensus(uint32_t nTargetHeight) const
Signals for UI communication.
@ BTN_MASK
Mask of all available buttons in CClientUIInterface::MessageBoxFlags This needs to be updated,...
@ MSG_INFORMATION
Predefined combinations for certain default usage cases.
@ MODAL
Force blocking, modal message box dialog (not just OS notification)
boost::signals2::signal< bool(const std::string &message, const std::string &caption, unsigned int style), boost::signals2::last_value< bool > > ThreadSafeMessageBox
Show message box.
boost::signals2::signal< bool(const std::string &message, const std::string &noninteractive_message, const std::string &caption, unsigned int style), boost::signals2::last_value< bool > > ThreadSafeQuestion
If possible, ask the user a question.
Model for Bitcoin network client.
void setNetworkActive(bool active)
Toggle network activity state in core.
int getHeaderTipHeight() const
QDateTime getLastBlockDate() const
int64_t getHeaderTipTime() const
double getVerificationProgress(const CBlockIndex *tip) const
bool getNetworkActive() const
Return true if network activity in core is enabled.
int getNumConnections(unsigned int flags=CONNECTIONS_ALL) const
Return number of connections, default is in- and outbound (total)
enum BlockSource getBlockSource() const
Returns enum BlockSource of the current importing/syncing state.
OptionsModel * getOptionsModel()
"Help message" dialog box
Macintosh-specific dock icon handler.
void setMainWindow(QMainWindow *window)
void setIcon(const QIcon &icon)
static MacDockIconHandler * instance()
Modal overlay to display information about the chain-sync state.
void showHide(bool hide=false, bool userRequested=false)
void setKnownBestHeight(int count, const QDateTime &blockDate)
void tipUpdate(int count, const QDateTime &blockDate, double nVerificationProgress)
const QString & getTitleAddText() const
const QIcon & getAppIcon() const
const QIcon & getTrayAndWindowIcon() const
Cross-platform desktop notification client.
@ Information
Informational message.
@ Critical
An error occurred.
@ Warning
Notify user of potential problem.
void notify(Class cls, const QString &title, const QString &text, const QIcon &icon=QIcon(), int millisTimeout=10000)
Show notification message.
void setModel(OptionsModel *model)
Interface from Qt to configuration data structure for Bitcoin client.
void setDisplayUnit(const QVariant &value)
Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal.
bool getMinimizeOnClose()
Local Bitcoin RPC console.
void setClientModel(ClientModel *model)
void setTabFocus(enum TabTypes tabType)
set which tab has the focus (is visible)
void updateDisplayUnit(int newUnits)
When Display Units are changed on OptionsModel it will refresh the display text of the control on the...
void createContextMenu()
Creates context menu, its actions, and wires up all the relevant signals for mouse events.
OptionsModel * optionsModel
void mousePressEvent(QMouseEvent *event)
So that it responds to left-button clicks.
UnitDisplayStatusBarControl(const PlatformStyle *platformStyle)
void onMenuSelection(QAction *action)
Tells underlying optionsModel to update its current display unit.
void setOptionsModel(OptionsModel *optionsModel)
Lets the control know about the Options Model (and its signals)
void onDisplayUnitsClicked(const QPoint &point)
Shows context menu with Display Unit options by the mouse coordinates.
A container for embedding all wallet-related controls into BitcoinGUI.
void gotoHistoryPage()
Switch to history (transactions) page.
void gotoSignMessageTab(QString addr="")
Show Sign/Verify Message dialog and switch to sign message tab.
void gotoOverviewPage()
Switch to overview (home) page.
void gotoSendCoinsPage(QString addr="")
Switch to send coins page.
void setClientModel(ClientModel *clientModel)
bool addWallet(const QString &name, WalletModel *walletModel)
bool handlePaymentRequest(const SendCoinsRecipient &recipient)
bool setCurrentWallet(const QString &name)
void showOutOfSyncWarning(bool fShow)
void gotoReceiveCoinsPage()
Switch to receive coins page.
void gotoVerifyMessageTab(QString addr="")
Show Sign/Verify Message dialog and switch to verify message tab.
Interface to Bitcoin wallet from Qt view code.
static bool isWalletEnabled()
bool isObscured(QWidget *w)
Qt::ConnectionType blockingGUIThreadConnection()
Get connection type to call object slot in GUI thread with invokeMethod.
void saveWindowGeometry(const QString &strSetting, QWidget *parent)
Save window size and position.
ClickableProgressBar ProgressBar
void restoreWindowGeometry(const QString &strSetting, const QSize &defaultSize, QWidget *parent)
Restore window size and position.
QString formatNiceTimeOffset(qint64 secs)
UniValue help(const JSONRPCRequest &jsonRequest)
int64_t nPowTargetSpacing
CClientUIInterface uiInterface
int64_t GetTime()
GetTimeMicros() and GetTimeMillis() both return the system time, but in different units.