diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2012-02-12 01:49:18 -0800 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2012-02-12 01:49:18 -0800 |
commit | 2aa34298998fe1ecff76f006d7a95fc06b5aae6b (patch) | |
tree | fb6c2dda74961a229cb0b1285fc850f1da31ff14 | |
parent | 9f3de58d83f54536076be44fe945f56670ef9b60 (diff) | |
parent | 6af93ee2ea58fe513647a6fdf007561d196a0e72 (diff) |
Merge pull request #826 from laanwj/2012_02_fixminimizetotray
Fix Minimize to the tray instead of the taskbar (rework)
-rw-r--r-- | src/qt/bitcoingui.cpp | 34 | ||||
-rw-r--r-- | src/qt/bitcoingui.h | 4 |
2 files changed, 27 insertions, 11 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index f67a5d6b56..815d872857 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -56,6 +56,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): QMainWindow(parent), clientModel(0), walletModel(0), + dummyWidget(0), encryptWalletAction(0), changePassphraseAction(0), aboutQtAction(0), @@ -85,6 +86,9 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): // Create the tray icon (or setup the dock icon) createTrayIcon(); + // Dummy widget used when restoring window state after minimization + dummyWidget = new QWidget(); + // Create tabs overviewPage = new OverviewPage(); @@ -162,6 +166,7 @@ BitcoinGUI::~BitcoinGUI() #ifdef Q_WS_MAC delete appMenuBar; #endif + delete dummyWidget; } void BitcoinGUI::createActions() @@ -205,17 +210,17 @@ void BitcoinGUI::createActions() #endif tabGroup->addAction(messageAction); - connect(overviewAction, SIGNAL(triggered()), this, SLOT(show())); + connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormal())); connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage())); - connect(historyAction, SIGNAL(triggered()), this, SLOT(show())); + connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormal())); connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage())); - connect(addressBookAction, SIGNAL(triggered()), this, SLOT(show())); + connect(addressBookAction, SIGNAL(triggered()), this, SLOT(showNormal())); connect(addressBookAction, SIGNAL(triggered()), this, SLOT(gotoAddressBookPage())); - connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(show())); + connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(showNormal())); connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage())); - connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(show())); + connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(showNormal())); connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage())); - connect(messageAction, SIGNAL(triggered()), this, SLOT(show())); + connect(messageAction, SIGNAL(triggered()), this, SLOT(showNormal())); connect(messageAction, SIGNAL(triggered()), this, SLOT(gotoMessagePage())); quitAction = new QAction(QIcon(":/icons/quit"), tr("E&xit"), this); @@ -405,10 +410,17 @@ void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason) // Click on system tray icon triggers "open bitcoin" openBitcoinAction->trigger(); } - } #endif +void BitcoinGUI::showNormal() +{ + // Reparent window to the desktop (in case it was hidden on minimize) + if(parent() != NULL) + setParent(NULL, Qt::Window); + QMainWindow::showNormal(); +} + void BitcoinGUI::optionsClicked() { if(!clientModel || !clientModel->getOptionsModel()) @@ -550,13 +562,13 @@ void BitcoinGUI::changeEvent(QEvent *e) { if(isMinimized()) { - hide(); - e->ignore(); + // Hiding the window from taskbar + setParent(dummyWidget, Qt::SubWindow); + return; } else { - show(); - e->accept(); + showNormal(); } } } diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index 09ad89a894..37ab12577c 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -58,6 +58,8 @@ private: QStackedWidget *centralWidget; + QWidget *dummyWidget; + OverviewPage *overviewPage; QWidget *transactionsPage; AddressBookPage *addressBookPage; @@ -131,6 +133,8 @@ public slots: void gotoMessagePage(); void gotoMessagePage(QString); + void showNormal(); + private slots: /** Switch to overview (home) page */ void gotoOverviewPage(); |