From 8ca6a1617687ce613b0426c2627ba79e710a695f Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Thu, 7 Aug 2014 09:34:31 +0200 Subject: [Qt] ensure all class attributes are init to 0 - in BitcoinGUI and UnitDisplayStatusBarControl --- src/qt/bitcoingui.cpp | 30 +++++++++++++++++++++++++++--- src/qt/bitcoingui.h | 1 + 2 files changed, 28 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index e3257e859c..429b9a9fb3 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -61,9 +61,33 @@ BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) : QMainWindow(parent), clientModel(0), walletFrame(0), + unitDisplayControl(0), + labelEncryptionIcon(0), + labelConnectionsIcon(0), + labelBlocksIcon(0), + progressBarLabel(0), + progressBar(0), + progressDialog(0), + appMenuBar(0), + overviewAction(0), + historyAction(0), + quitAction(0), + sendCoinsAction(0), + usedSendingAddressesAction(0), + usedReceivingAddressesAction(0), + signMessageAction(0), + verifyMessageAction(0), + aboutAction(0), + receiveCoinsAction(0), + optionsAction(0), + toggleHideAction(0), encryptWalletAction(0), + backupWalletAction(0), changePassphraseAction(0), aboutQtAction(0), + openRPCConsoleAction(0), + openAction(0), + showHelpMessageAction(0), trayIcon(0), notificator(0), rpcConsole(0), @@ -1006,9 +1030,10 @@ void BitcoinGUI::unsubscribeFromCoreSignals() uiInterface.ThreadSafeMessageBox.disconnect(boost::bind(ThreadSafeMessageBox, this, _1, _2, _3)); } -UnitDisplayStatusBarControl::UnitDisplayStatusBarControl():QLabel() +UnitDisplayStatusBarControl::UnitDisplayStatusBarControl() : + optionsModel(0), + menu(0) { - optionsModel = 0; createContextMenu(); setToolTip(tr("Unit to show amounts in. Click to select another unit.")); } @@ -1068,4 +1093,3 @@ void UnitDisplayStatusBarControl::onMenuSelection(QAction* action) optionsModel->setDisplayUnit(action->data()); } } - diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 30dd7ae317..7e45240f05 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -219,6 +219,7 @@ protected: private: OptionsModel *optionsModel; QMenu* menu; + /** Shows context menu with Display Unit options by the mouse coordinates */ void onDisplayUnitsClicked(const QPoint& point); /** Creates context menu, its actions, and wires up all the relevant signals for mouse events. */ -- cgit v1.2.3 From 314fbd9ac7713e812e85960499474dcf453b563e Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Thu, 7 Aug 2014 09:36:02 +0200 Subject: [Qt] use BitcoinGUI::DEFAULT_WALLET constant in bitcoin.cpp --- src/qt/bitcoin.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index a43e7cb756..c0dee66931 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -414,8 +414,8 @@ void BitcoinApplication::initializeResult(int retval) { walletModel = new WalletModel(pwalletMain, optionsModel); - window->addWallet("~Default", walletModel); - window->setCurrentWallet("~Default"); + window->addWallet(BitcoinGUI::DEFAULT_WALLET, walletModel); + window->setCurrentWallet(BitcoinGUI::DEFAULT_WALLET); connect(walletModel, SIGNAL(coinsSent(CWallet*,SendCoinsRecipient,QByteArray)), paymentServer, SLOT(fetchPaymentACK(CWallet*,const SendCoinsRecipient&,QByteArray))); -- cgit v1.2.3 From b197bf3270490068319d87e4b977b08f754a1307 Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Thu, 7 Aug 2014 09:37:21 +0200 Subject: [Qt] disable tray interactions when client model set to 0 - this prevents the ability to fiddle around with the system tray when already shutting down (e.g. on slow shutdowns because of a proxy delay) - extends solution for #4360 --- src/qt/bitcoingui.cpp | 13 +++++++++---- src/qt/bitcoingui.h | 1 + 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 429b9a9fb3..e3665dfe6e 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -89,6 +89,7 @@ BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) : openAction(0), showHelpMessageAction(0), trayIcon(0), + trayIconMenu(0), notificator(0), rpcConsole(0), prevBlocks(0), @@ -449,8 +450,12 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel) walletFrame->setClientModel(clientModel); } #endif - - this->unitDisplayControl->setOptionsModel(clientModel->getOptionsModel()); + unitDisplayControl->setOptionsModel(clientModel->getOptionsModel()); + } else { + // Disable possibility to show main window via action + toggleHideAction->setEnabled(false); + // Disable context menu on tray icon + trayIconMenu->clear(); } } @@ -519,7 +524,6 @@ void BitcoinGUI::createTrayIcon(bool fIsTestnet) void BitcoinGUI::createTrayIconMenu() { - QMenu *trayIconMenu; #ifndef Q_OS_MAC // return if trayIcon is unset (only on non-Mac OSes) if (!trayIcon) @@ -560,7 +564,7 @@ void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason) if(reason == QSystemTrayIcon::Trigger) { // Click on system tray icon triggers show/hide of the main window - toggleHideAction->trigger(); + toggleHidden(); } } #endif @@ -946,6 +950,7 @@ void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden) { if(!clientModel) return; + // activateWindow() (sometimes) helps with keyboard focus on Windows if (isHidden()) { diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 7e45240f05..30b05cb7d9 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -103,6 +103,7 @@ private: QAction *showHelpMessageAction; QSystemTrayIcon *trayIcon; + QMenu *trayIconMenu; Notificator *notificator; RPCConsole *rpcConsole; -- cgit v1.2.3