mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-04 06:12:07 +01:00
Yet another attempt at implementing "minimize to tray" that works on all OSes
This commit is contained in:
committed by
Luke Dashjr
parent
e20417c333
commit
b4c7b6a384
@@ -45,6 +45,7 @@
|
||||
#include <QStackedWidget>
|
||||
#include <QDateTime>
|
||||
#include <QMovie>
|
||||
#include <QTimer>
|
||||
|
||||
#include <QDragEnterEvent>
|
||||
#include <QUrl>
|
||||
@@ -523,29 +524,21 @@ void BitcoinGUI::error(const QString &title, const QString &message)
|
||||
|
||||
void BitcoinGUI::changeEvent(QEvent *e)
|
||||
{
|
||||
QMainWindow::changeEvent(e);
|
||||
#ifndef Q_WS_MAC // Ignored on Mac
|
||||
if(e->type() == QEvent::WindowStateChange)
|
||||
{
|
||||
if(clientModel && clientModel->getOptionsModel()->getMinimizeToTray())
|
||||
{
|
||||
QWindowStateChangeEvent *wsevt = static_cast<QWindowStateChangeEvent*>(e);
|
||||
bool wasMinimized = wsevt->oldState() & Qt::WindowMinimized;
|
||||
bool isMinimized = windowState() & Qt::WindowMinimized;
|
||||
if(!wasMinimized && isMinimized)
|
||||
if(!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized())
|
||||
{
|
||||
// Minimized, hide the window from taskbar
|
||||
setWindowFlags(windowFlags() | Qt::Tool);
|
||||
return;
|
||||
}
|
||||
else if(wasMinimized && !isMinimized)
|
||||
{
|
||||
// Unminimized, show the window in taskbar
|
||||
setWindowFlags(windowFlags() &~ Qt::Tool);
|
||||
QTimer::singleShot(0, this, SLOT(hide()));
|
||||
e->ignore();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
QMainWindow::changeEvent(e);
|
||||
}
|
||||
|
||||
void BitcoinGUI::closeEvent(QCloseEvent *event)
|
||||
|
||||
Reference in New Issue
Block a user