Skip to content

Commit

Permalink
Merge pull request #941 from laanwj/2012_03_newminimizetray
Browse files Browse the repository at this point in the history
Yet another attempt of a "minimize to tray" that works on all OSes
  • Loading branch information
laanwj committed Mar 16, 2012
2 parents 3670252 + 3f5b8ec commit 18edd23
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include <QMovie>
#include <QFileDialog>
#include <QDesktopServices>
#include <QTimer>

#include <QDragEnterEvent>
#include <QUrl>
Expand Down Expand Up @@ -558,29 +559,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)
{
// Minimized, hide the window from taskbar
setWindowFlags(windowFlags() | Qt::Tool);
return;
}
else if(wasMinimized && !isMinimized)
if(!(wsevt->oldState() & Qt::WindowMinimized) && 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)
Expand Down

0 comments on commit 18edd23

Please sign in to comment.