From 56bb697d0681bf1b9628f39123c64c66f613f0b0 Mon Sep 17 00:00:00 2001 From: David Sansome Date: Mon, 19 Apr 2010 14:10:31 +0000 Subject: [PATCH] Remember maximized state between calls to hide() and show() on window managers that don't do it for us. Fixes issue #215 --- src/mainwindow.cpp | 14 ++++++++++++-- src/mainwindow.h | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 2791e7d3d..e6b2f1858 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -101,7 +101,8 @@ MainWindow::MainWindow(QNetworkAccessManager* network, Engine::Type engine, QWid equalizer_(new Equalizer), playlist_menu_(new QMenu(this)), library_sort_model_(new QSortFilterProxyModel(this)), - track_position_timer_(new QTimer(this)) + track_position_timer_(new QTimer(this)), + was_maximized_(false) { ui_.setupUi(this); #ifndef Q_OS_DARWIN @@ -625,7 +626,16 @@ void MainWindow::closeEvent(QCloseEvent* event) { void MainWindow::SetHiddenInTray(bool hidden) { settings_.setValue("hidden", hidden); - setVisible(!hidden); + + if (hidden) { + was_maximized_ = isMaximized(); + hide(); + } else { + if (was_maximized_) + showMaximized(); + else + show(); + } } void MainWindow::ClearLibraryFilter() { diff --git a/src/mainwindow.h b/src/mainwindow.h index 9911304e4..9c4c5bd58 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -168,6 +168,8 @@ class MainWindow : public QMainWindow { QTimer* track_position_timer_; QSettings settings_; + + bool was_maximized_; }; #endif // MAINWINDOW_H