25 #endif // ENABLE_WALLET 41 #include <QApplication> 44 #include <QDesktopWidget> 45 #include <QDragEnterEvent> 46 #include <QListWidget> 48 #include <QMessageBox> 50 #include <QProgressDialog> 53 #include <QStackedWidget> 59 #include <QVBoxLayout> 61 #include <boost/bind.hpp> 66 #elif defined(Q_OS_WIN) 76 platformStyle(_platformStyle)
79 if (!restoreGeometry(settings.value(
"MainWindowGeometry").toByteArray())) {
81 move(QApplication::desktop()->availableGeometry().center() - frameGeometry().center());
87 #endif // ENABLE_WALLET 90 windowTitle += tr(
"Wallet");
92 windowTitle += tr(
"Node");
101 setWindowTitle(windowTitle);
112 #endif // ENABLE_WALLET 121 setAcceptDrops(
true);
140 statusBar()->setSizeGripEnabled(
false);
143 QFrame *frameBlocks =
new QFrame();
144 frameBlocks->setContentsMargins(0,0,0,0);
145 frameBlocks->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
146 QHBoxLayout *frameBlocksLayout =
new QHBoxLayout(frameBlocks);
147 frameBlocksLayout->setContentsMargins(3,0,3,0);
148 frameBlocksLayout->setSpacing(3);
157 frameBlocksLayout->addStretch();
159 frameBlocksLayout->addStretch();
164 frameBlocksLayout->addStretch();
166 frameBlocksLayout->addStretch();
168 frameBlocksLayout->addStretch();
180 QString curStyle = QApplication::style()->metaObject()->className();
181 if(curStyle ==
"QWindowsStyle" || curStyle ==
"QWindowsXPStyle")
183 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; }");
188 statusBar()->addPermanentWidget(frameBlocks);
191 this->installEventFilter(
this);
222 settings.setValue(
"MainWindowGeometry", saveGeometry());
235 QActionGroup *tabGroup =
new QActionGroup(
this);
238 overviewAction->setStatusTip(tr(
"Show general overview of wallet"));
256 receiveCoinsAction->setStatusTip(tr(
"Request payments (generates QR codes and bitcoin: URIs)"));
267 historyAction->setStatusTip(tr(
"Browse transaction history"));
270 historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
277 connect(
overviewAction, &QAction::triggered,
this, &BitcoinGUI::gotoOverviewPage);
279 connect(
sendCoinsAction, &QAction::triggered, [
this]{ gotoSendCoinsPage(); });
283 connect(
receiveCoinsAction, &QAction::triggered,
this, &BitcoinGUI::gotoReceiveCoinsPage);
287 connect(
historyAction, &QAction::triggered,
this, &BitcoinGUI::gotoHistoryPage);
288 #endif // ENABLE_WALLET 291 quitAction->setStatusTip(tr(
"Quit application"));
292 quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
299 aboutQtAction->setStatusTip(tr(
"Show information about Qt"));
309 encryptWalletAction->setStatusTip(tr(
"Encrypt the private keys that belong to your wallet"));
316 signMessageAction->setStatusTip(tr(
"Sign messages with your BSHA3 addresses to prove you own them"));
318 verifyMessageAction->setStatusTip(tr(
"Verify messages to ensure they were signed with specified BSHA3 addresses"));
331 openAction->setStatusTip(tr(
"Open a bitcoin: URI or payment request"));
337 connect(
quitAction, &QAction::triggered, qApp, QApplication::quit);
339 connect(
aboutQtAction, &QAction::triggered, qApp, QApplication::aboutQt);
353 connect(
signMessageAction, &QAction::triggered, [
this]{ gotoSignMessageTab(); });
357 connect(
openAction, &QAction::triggered,
this, &BitcoinGUI::openClicked);
359 #endif // ENABLE_WALLET 362 connect(
new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_D),
this), &QShortcut::activated,
this, &
BitcoinGUI::showDebugWindow);
376 QMenu *file =
appMenuBar->addMenu(tr(
"&File"));
383 file->addSeparator();
386 file->addSeparator();
390 QMenu *settings =
appMenuBar->addMenu(tr(
"&Settings"));
395 settings->addSeparator();
405 help->addSeparator();
414 QToolBar *toolbar = addToolBar(tr(
"Tabs toolbar"));
416 toolbar->setContextMenuPolicy(Qt::PreventContextMenu);
417 toolbar->setMovable(
false);
418 toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
426 QWidget *spacer =
new QWidget();
427 spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
428 toolbar->addWidget(spacer);
431 connect(
m_wallet_selector,
static_cast<void (QComboBox::*)(
int)
>(&QComboBox::currentIndexChanged),
this, &BitcoinGUI::setCurrentWalletBySelectorIndex);
481 #endif // ENABLE_WALLET 508 #endif // ENABLE_WALLET 514 bool BitcoinGUI::addWallet(
WalletModel *walletModel)
519 QString display_name =
name.isEmpty() ?
"["+tr(
"default wallet")+
"]" :
name;
530 bool BitcoinGUI::removeWallet(
WalletModel* walletModel)
546 bool BitcoinGUI::setCurrentWallet(
const QString&
name)
553 bool BitcoinGUI::setCurrentWalletBySelectorIndex(
int index)
556 return setCurrentWallet(internal_name);
559 void BitcoinGUI::removeAllWallets()
566 #endif // ENABLE_WALLET 589 trayIcon =
new QSystemTrayIcon(
this);
613 dockIconHandler->
setMainWindow(static_cast<QMainWindow*>(
this));
633 #ifndef Q_OS_MAC // This is built-in on Mac 642 if(reason == QSystemTrayIcon::Trigger)
684 void BitcoinGUI::openClicked()
693 void BitcoinGUI::gotoOverviewPage()
699 void BitcoinGUI::gotoHistoryPage()
705 void BitcoinGUI::gotoReceiveCoinsPage()
711 void BitcoinGUI::gotoSendCoinsPage(QString addr)
717 void BitcoinGUI::gotoSignMessageTab(QString addr)
722 void BitcoinGUI::gotoVerifyMessageTab(QString addr)
726 #endif // ENABLE_WALLET 734 case 0: icon =
":/icons/connect_0";
break;
735 case 1:
case 2:
case 3: icon =
":/icons/connect_1";
break;
736 case 4:
case 5:
case 6: icon =
":/icons/connect_2";
break;
737 case 7:
case 8:
case 9: icon =
":/icons/connect_3";
break;
738 default: icon =
":/icons/connect_4";
break;
744 tooltip = tr(
"%n active connection(s) to Bitcoin network",
"", count) + QString(
".<br>") + tr(
"Click to disable network activity.");
746 tooltip = tr(
"Network activity disabled.") + QString(
"<br>") + tr(
"Click to enable network activity again.");
747 icon =
":/icons/network_disabled";
751 tooltip = QString(
"<nobr>") + tooltip + QString(
"</nobr>");
772 if (estHeadersLeft > HEADER_HEIGHT_DELTA_SYNC)
773 progressBarLabel->setText(tr(
"Syncing Headers (%1%)...").arg(QString::number(100.0 / (headersTipHeight+estHeadersLeft)*headersTipHeight,
'f', 1)));
800 statusBar()->clearMessage();
804 switch (blockSource) {
833 QDateTime currentDate = QDateTime::currentDateTime();
834 qint64 secs = blockDate.secsTo(currentDate);
836 tooltip = tr(
"Processed %n block(s) of transaction history.",
"", count);
841 tooltip = tr(
"Up to date") + QString(
".<br>") + tooltip;
850 #endif // ENABLE_WALLET 860 progressBar->setFormat(tr(
"%1 behind").arg(timeBehindText));
862 progressBar->setValue(nVerificationProgress * 1000000000.0 + 0.5);
865 tooltip = tr(
"Catching up...") + QString(
"<br>") + tooltip;
869 ":/movies/spinner-%1").arg(
spinnerFrame, 3, 10, QChar(
'0')))
870 .pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
881 #endif // ENABLE_WALLET 883 tooltip += QString(
"<br>");
884 tooltip += tr(
"Last received block was generated %1 ago.").arg(timeBehindText);
885 tooltip += QString(
"<br>");
886 tooltip += tr(
"Transactions after this will not yet be visible.");
890 tooltip = QString(
"<nobr>") + tooltip + QString(
"</nobr>");
899 QString strTitle = tr(
"BSHA3");
901 int nMBoxIcon = QMessageBox::Information;
907 if (!title.isEmpty()) {
913 msgType = tr(
"Error");
916 msgType = tr(
"Warning");
919 msgType = tr(
"Information");
926 if (!msgType.isEmpty())
927 strTitle +=
" - " + msgType;
931 nMBoxIcon = QMessageBox::Critical;
935 nMBoxIcon = QMessageBox::Warning;
942 QMessageBox::StandardButton buttons;
944 buttons = QMessageBox::Ok;
947 QMessageBox mBox(static_cast<QMessageBox::Icon>(nMBoxIcon), strTitle,
message, buttons,
this);
948 mBox.setTextFormat(Qt::PlainText);
951 *
ret = r == QMessageBox::Ok;
959 QMainWindow::changeEvent(e);
960 #ifndef Q_OS_MAC // Ignored on Mac 961 if(e->type() == QEvent::WindowStateChange)
965 QWindowStateChangeEvent *wsevt =
static_cast<QWindowStateChangeEvent*
>(e);
966 if(!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized())
968 QTimer::singleShot(0,
this, &BitcoinGUI::hide);
971 else if((wsevt->oldState() & Qt::WindowMinimized) && !isMinimized())
973 QTimer::singleShot(0,
this, &BitcoinGUI::show);
983 #ifndef Q_OS_MAC // Ignored on Mac 991 QApplication::quit();
995 QMainWindow::showMinimized();
1000 QMainWindow::closeEvent(event);
1012 #ifdef ENABLE_WALLET 1013 void BitcoinGUI::incomingTransaction(
const QString& date,
int unit,
const CAmount& amount,
const QString& type,
const QString& address,
const QString& label,
const QString& walletName)
1016 QString msg = tr(
"Date: %1\n").arg(date) +
1019 msg += tr(
"Wallet: %1\n").arg(walletName);
1021 msg += tr(
"Type: %1\n").arg(type);
1022 if (!label.isEmpty())
1023 msg += tr(
"Label: %1\n").arg(label);
1024 else if (!address.isEmpty())
1025 msg += tr(
"Address: %1\n").arg(address);
1026 message((amount)<0 ? tr(
"Sent transaction") : tr(
"Incoming transaction"),
1029 #endif // ENABLE_WALLET 1034 if(event->mimeData()->hasUrls())
1035 event->acceptProposedAction();
1040 if(event->mimeData()->hasUrls())
1042 for (
const QUrl &uri : event->mimeData()->urls())
1047 event->acceptProposedAction();
1053 if (event->type() == QEvent::StatusTip)
1059 return QMainWindow::eventFilter(
object, event);
1062 #ifdef ENABLE_WALLET 1069 gotoSendCoinsPage();
1075 void BitcoinGUI::setHDStatus(
int hdEnabled)
1078 labelWalletHDStatusIcon->setToolTip(hdEnabled ? tr(
"HD key generation is <b>enabled</b>") : tr(
"HD key generation is <b>disabled</b>"));
1084 void BitcoinGUI::setEncryptionStatus(
int status)
1113 void BitcoinGUI::updateWalletStatus()
1126 #endif // ENABLE_WALLET 1130 std::string ip_port;
1133 if (proxy_enabled) {
1135 QString ip_port_q = QString::fromStdString(ip_port);
1137 labelProxyIcon->setToolTip(tr(
"Proxy is <b>enabled</b>: %1").arg(ip_port_q));
1157 else if (isMinimized())
1167 else if(fToggleHidden)
1197 else if (nProgress == 100)
1213 trayIcon->setVisible(!fHideTrayIcon);
1223 static bool ThreadSafeMessageBox(
BitcoinGUI* gui,
const std::string& message,
const std::string& caption,
unsigned int style)
1234 QMetaObject::invokeMethod(gui,
"message",
1236 Q_ARG(QString, QString::fromStdString(caption)),
1237 Q_ARG(QString, QString::fromStdString(message)),
1238 Q_ARG(
unsigned int, style),
1239 Q_ARG(
bool*, &
ret));
1262 setToolTip(tr(
"Unit to show amounts in. Click to select another unit."));
1265 const QFontMetrics fm(font());
1270 setMinimumSize(max_width, 0);
1271 setAlignment(Qt::AlignRight | Qt::AlignVCenter);
1272 setStyleSheet(QString(
"QLabel { color : %1 }").arg(platformStyle->
SingleColor().name()));
1284 menu =
new QMenu(
this);
1288 menuAction->setData(QVariant(u));
1289 menu->addAction(menuAction);
1318 QPoint globalPos = mapToGlobal(point);
1319 menu->exec(globalPos);
void subscribeToCoreSignals()
Connect core signals to GUI client.
void unsubscribeFromCoreSignals()
Disconnect core signals from GUI client.
bool handlePaymentRequest(const SendCoinsRecipient &recipient)
bool setCurrentWallet(const QString &name)
void message(const QString &title, const QString &message, unsigned int style)
Fired when a message should be reported to the user.
void setNetworkActive(bool networkActive)
Set network state shown in the UI.
void addWallet(WalletModel *const walletModel)
QAction * receiveCoinsAction
UnitDisplayStatusBarControl * unitDisplayControl
Local Bitcoin RPC console.
void message(const QString &title, const QString &message, unsigned int style, bool *ret=nullptr)
Notify the user of an event from the core network or transaction handling code.
interfaces::Wallet & wallet() const
QAction * signMessageAction
void receivedURI(const QString &uri)
Signal raised when a URI was entered or dragged to the GUI.
virtual bool getNetworkActive()=0
Get network active.
void updateNetworkState()
Update UI with latest network info from model.
QLabel * labelWalletHDStatusIcon
void mousePressEvent(QMouseEvent *event)
So that it responds to left-button clicks.
void showNormalIfMinimized()
Show window if hidden, unminimize when minimized, rise when obscured or show if hidden and fToggleHid...
UnitDisplayStatusBarControl(const PlatformStyle *platformStyle)
QProgressDialog * progressDialog
static bool isWalletEnabled()
void hideTrayIconChanged(bool)
void showDebugWindow()
Show debug window.
GUIUtil::ClickableLabel * labelProxyIcon
virtual double getVerificationProgress()=0
Get verification progress.
ClientModel * clientModel
WalletView * currentWalletView()
void createToolBars()
Create the toolbars.
ModalOverlay * modalOverlay
void createTrayIconMenu()
Create system tray menu (or setup the dock menu)
QAction * m_wallet_selector_action
UniValue ret(UniValue::VARR)
QAction * verifyMessageAction
void dropEvent(QDropEvent *event)
void usedReceivingAddresses()
Show used receiving addresses.
void tipUpdate(int count, const QDateTime &blockDate, double nVerificationProgress)
Qt::ConnectionType blockingGUIThreadConnection()
Get connection type to call object slot in GUI thread with invokeMethod.
void setWalletActionsEnabled(bool enabled)
Enable or disable all wallet-related actions.
const QIcon & getAppIcon() const
void networkActiveChanged(bool networkActive)
OptionsModel * getOptionsModel()
void encryptWallet(bool status)
Encrypt the wallet.
Macintosh-specific dock icon handler.
Mask of all available buttons in CClientUIInterface::MessageBoxFlags This needs to be updated...
bool isLayerVisible() const
HelpMessageDialog * helpMessageDialog
QLabel * progressBarLabel
QSystemTrayIcon * trayIcon
virtual std::vector< std::unique_ptr< Wallet > > getWallets()=0
Return interfaces for accessing wallets (if any).
QAction * showHelpMessageAction
Notify user of potential problem.
Modal overlay to display information about the chain-sync state.
const QString & getTitleAddText() const
static QString longName(int unit)
Long name.
void numConnectionsChanged(int count)
Signals for UI communication.
GUIUtil::ClickableLabel * connectionsControl
QAction * backupWalletAction
void setOptionsModel(OptionsModel *optionsModel)
Lets the control know about the Options Model (and its signals)
void openOptionsDialogWithTab(OptionsDialog::Tab tab)
Open the OptionsDialog on the specified tab index.
EncryptionStatus getEncryptionStatus() const
int getDisplayUnit() const
virtual std::unique_ptr< Handler > handleMessageBox(MessageBoxFn fn)=0
Force blocking, modal message box dialog (not just OS notification)
void showOutOfSyncWarning(bool fShow)
void setIcon(const QIcon &icon)
void setClientModel(ClientModel *model)
void gotoHistoryPage()
Switch to history (transactions) page.
QAction * usedReceivingAddressesAction
int64_t CAmount
Amount in satoshis (Can be negative)
BitcoinGUI(interfaces::Node &node, const PlatformStyle *platformStyle, const NetworkStyle *networkStyle, QWidget *parent=0)
void setClientModel(ClientModel *clientModel)
Set the client model.
WalletModel * getWalletModel()
void gotoOverviewPage()
Switch to overview (home) page.
const PlatformStyle * platformStyle
QAction * toggleHideAction
virtual bool hdEnabled()=0
void showProgress(const QString &title, int nProgress)
Show progress dialog e.g.
static MacDockIconHandler * instance()
void setDisplayUnit(const QVariant &value)
Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal.
void setClientModel(ClientModel *clientModel)
void setMainWindow(QMainWindow *window)
bool isObscured(QWidget *w)
QAction * m_wallet_selector_label_action
int getNumConnections(unsigned int flags=CONNECTIONS_ALL) const
Return number of connections, default is in- and outbound (total)
OptionsModel * optionsModel
QLabel * m_wallet_selector_label
enum BlockSource getBlockSource() const
Returns enum BlockSource of the current importing/syncing state.
void setKnownBestHeight(int count, const QDateTime &blockDate)
void optionsClicked()
Show configuration dialog.
void gotoVerifyMessageTab(QString addr="")
Show Sign/Verify Message dialog and switch to verify message tab.
void notify(Class cls, const QString &title, const QString &text, const QIcon &icon=QIcon(), int millisTimeout=10000)
Show notification message.
bool eventFilter(QObject *object, QEvent *event)
WalletFrame * walletFrame
void updateDisplayUnit(int newUnits)
When Display Units are changed on OptionsModel it will refresh the display text of the control on the...
QAction * usedSendingAddressesAction
void setTabFocus(enum TabTypes tabType)
set which tab has the focus (is visible)
int64_t nPowTargetSpacing
void setTrayIconVisible(bool)
When hideTrayIcon setting is changed in OptionsModel hide or show the icon accordingly.
void setModel(OptionsModel *model)
QAction * openRPCConsoleAction
void detectShutdown()
called by a timer to check if ShutdownRequested() has been set
Cross-platform desktop notification client.
void clicked(const QPoint &point)
Emitted when the label is clicked.
QLabel * labelWalletEncryptionIcon
GUIUtil::ClickableLabel * labelBlocksIcon
void setCurrentTab(OptionsDialog::Tab tab)
GUIUtil::ClickableProgressBar * progressBar
void numBlocksChanged(int count, const QDateTime &blockDate, double nVerificationProgress, bool header)
UniValue help(const JSONRPCRequest &jsonRequest)
void showHelpMessageClicked()
Show help message dialog.
QString getWalletName() const
void dragEnterEvent(QDragEnterEvent *event)
Notificator * notificator
void displayUnitChanged(int unit)
void changePassphrase()
Change encrypted wallet passphrase.
Model for Bitcoin network client.
const QIcon & getTrayAndWindowIcon() const
QAction * receiveCoinsMenuAction
ClickableProgressBar ProgressBar
void gotoSignMessageTab(QString addr="")
Show Sign/Verify Message dialog and switch to sign message tab.
virtual bool shutdownRequested()=0
Return whether shutdown was requested.
QAction * sendCoinsAction
void showHide(bool hide=false, bool userRequested=false)
void requestedSyncWarningInfo()
Notify that the user has requested more information about the out-of-sync warning.
static QList< Unit > availableUnits()
Get list of units, for drop-down box.
void trayIconActivated(QSystemTrayIcon::ActivationReason reason)
Handle tray icon clicked.
bool getMinimizeOnClose() const
void updateProxyIcon()
Set the proxy-enabled icon as shown in the UI.
QAction * changePassphraseAction
virtual int64_t getLastBlockTime()=0
Get last block time.
void gotoSendCoinsPage(QString addr="")
Switch to send coins page.
virtual std::unique_ptr< Handler > handleQuestion(QuestionFn fn)=0
void gotoReceiveCoinsPage()
Switch to receive coins page.
void closeEvent(QCloseEvent *event)
Interface from Qt to configuration data structure for Bitcoin client.
std::unique_ptr< interfaces::Handler > m_handler_question
const CChainParams & Params()
Return the currently selected parameters.
bool getMinimizeToTray() const
Interface to Bitcoin wallet from Qt view code.
QAction * sendCoinsMenuAction
void changeEvent(QEvent *e)
int prevBlocks
Keep track of previous number of blocks, to detect progress.
void toggleHidden()
Simply calls showNormalIfMinimized(true) for use in SLOT() macro.
interfaces::Node & m_node
bool removeWallet(const QString &name)
void removeWallet(WalletModel *const walletModel)
void showEvent(QShowEvent *event)
bool addWallet(WalletModel *walletModel)
void setNumConnections(int count)
Set number of connections shown in the UI.
"Help message" dialog box
void backupWallet()
Backup the wallet.
bool noui_ThreadSafeMessageBox(const std::string &message, const std::string &caption, unsigned int style)
Non-GUI handler, which logs and prints messages.
QComboBox * m_wallet_selector
void clicked(const QPoint &point)
Emitted when the progressbar is clicked.
virtual int getNumBlocks()=0
Get num blocks.
QString formatNiceTimeOffset(qint64 secs)
static QString formatWithUnit(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as string (with unit)
void createContextMenu()
Creates context menu, its actions, and wires up all the relevant signals for mouse events...
void showDebugWindowActivateConsole()
Show debug window and set focus to the console.
void createActions()
Create the main UI actions.
int64_t GetTime()
GetTimeMicros() and GetTimeMillis() both return the system time, but in different units...
QAction * encryptWalletAction
void aboutClicked()
Show about dialog.
const Consensus::Params & GetConsensus() const
int getHeaderTipHeight() const
void updateHeadersSyncProgressLabel()
static const std::string DEFAULT_UIPLATFORM
virtual void setNetworkActive(bool active)=0
Set network active.
int64_t getHeaderTipTime() const
Top-level interface for a bitcoin node (bsha3d process).
A container for embedding all wallet-related controls into BitcoinGUI.
void showProgress(const QString &title, int nProgress)
void usedSendingAddresses()
Show used sending addresses.
void setNumBlocks(int count, const QDateTime &blockDate, double nVerificationProgress, bool headers)
Set number of blocks and last block date shown in the UI.
bool getHideTrayIcon() const
void onDisplayUnitsClicked(const QPoint &point)
Shows context menu with Display Unit options by the mouse coordinates.
void createTrayIcon(const NetworkStyle *networkStyle)
Create system tray icon and notification.
void createMenuBar()
Create the menu bar and sub-menus.
void onMenuSelection(QAction *action)
Tells underlying optionsModel to update its current display unit.
std::unique_ptr< interfaces::Handler > m_handler_message_box
Predefined combinations for certain default usage cases.
bool getProxyInfo(std::string &ip_port) const