mirror of
https://github.com/dashpay/dash.git
synced 2024-12-30 14:25:53 +01:00
Merge pull request #826 from laanwj/2012_02_fixminimizetotray
Fix Minimize to the tray instead of the taskbar (rework)
This commit is contained in:
commit
2aa3429899
@ -56,6 +56,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
|
|||||||
QMainWindow(parent),
|
QMainWindow(parent),
|
||||||
clientModel(0),
|
clientModel(0),
|
||||||
walletModel(0),
|
walletModel(0),
|
||||||
|
dummyWidget(0),
|
||||||
encryptWalletAction(0),
|
encryptWalletAction(0),
|
||||||
changePassphraseAction(0),
|
changePassphraseAction(0),
|
||||||
aboutQtAction(0),
|
aboutQtAction(0),
|
||||||
@ -85,6 +86,9 @@ BitcoinGUI::BitcoinGUI(QWidget *parent):
|
|||||||
// Create the tray icon (or setup the dock icon)
|
// Create the tray icon (or setup the dock icon)
|
||||||
createTrayIcon();
|
createTrayIcon();
|
||||||
|
|
||||||
|
// Dummy widget used when restoring window state after minimization
|
||||||
|
dummyWidget = new QWidget();
|
||||||
|
|
||||||
// Create tabs
|
// Create tabs
|
||||||
overviewPage = new OverviewPage();
|
overviewPage = new OverviewPage();
|
||||||
|
|
||||||
@ -162,6 +166,7 @@ BitcoinGUI::~BitcoinGUI()
|
|||||||
#ifdef Q_WS_MAC
|
#ifdef Q_WS_MAC
|
||||||
delete appMenuBar;
|
delete appMenuBar;
|
||||||
#endif
|
#endif
|
||||||
|
delete dummyWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinGUI::createActions()
|
void BitcoinGUI::createActions()
|
||||||
@ -205,17 +210,17 @@ void BitcoinGUI::createActions()
|
|||||||
#endif
|
#endif
|
||||||
tabGroup->addAction(messageAction);
|
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(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(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(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(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(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()));
|
connect(messageAction, SIGNAL(triggered()), this, SLOT(gotoMessagePage()));
|
||||||
|
|
||||||
quitAction = new QAction(QIcon(":/icons/quit"), tr("E&xit"), this);
|
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"
|
// Click on system tray icon triggers "open bitcoin"
|
||||||
openBitcoinAction->trigger();
|
openBitcoinAction->trigger();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#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()
|
void BitcoinGUI::optionsClicked()
|
||||||
{
|
{
|
||||||
if(!clientModel || !clientModel->getOptionsModel())
|
if(!clientModel || !clientModel->getOptionsModel())
|
||||||
@ -550,13 +562,13 @@ void BitcoinGUI::changeEvent(QEvent *e)
|
|||||||
{
|
{
|
||||||
if(isMinimized())
|
if(isMinimized())
|
||||||
{
|
{
|
||||||
hide();
|
// Hiding the window from taskbar
|
||||||
e->ignore();
|
setParent(dummyWidget, Qt::SubWindow);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
show();
|
showNormal();
|
||||||
e->accept();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,8 @@ private:
|
|||||||
|
|
||||||
QStackedWidget *centralWidget;
|
QStackedWidget *centralWidget;
|
||||||
|
|
||||||
|
QWidget *dummyWidget;
|
||||||
|
|
||||||
OverviewPage *overviewPage;
|
OverviewPage *overviewPage;
|
||||||
QWidget *transactionsPage;
|
QWidget *transactionsPage;
|
||||||
AddressBookPage *addressBookPage;
|
AddressBookPage *addressBookPage;
|
||||||
@ -131,6 +133,8 @@ public slots:
|
|||||||
void gotoMessagePage();
|
void gotoMessagePage();
|
||||||
void gotoMessagePage(QString);
|
void gotoMessagePage(QString);
|
||||||
|
|
||||||
|
void showNormal();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
/** Switch to overview (home) page */
|
/** Switch to overview (home) page */
|
||||||
void gotoOverviewPage();
|
void gotoOverviewPage();
|
||||||
|
Loading…
Reference in New Issue
Block a user