Properly restore main window maximized state when it activated through tray icon

This commit is contained in:
Abs62 2013-01-24 00:36:53 +04:00
parent 08ca79c272
commit c23e09b57b
2 changed files with 15 additions and 1 deletions

View file

@ -74,6 +74,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
wordFinder( this ),
newReleaseCheckTimer( this ),
wordListSelChanged( false )
, wasMaximized( false )
#ifdef Q_OS_WIN32
, gdAskMessage( 0xFFFFFFFF )
#endif
@ -682,6 +683,8 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
updateStatusLine();
wasMaximized = isMaximized();
#ifdef Q_OS_MAC
LionSupport::addFullscreen(this);
#endif
@ -2000,6 +2003,12 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev )
}
}
if ( obj == this && ev->type() == QEvent::WindowStateChange )
{
QWindowStateChangeEvent *stev = static_cast< QWindowStateChangeEvent *>( ev );
wasMaximized = ( stev->oldState() == Qt::WindowMaximized && isMinimized() );
}
if ( ev->type() == QEvent::MouseButtonPress ) {
QMouseEvent * event = static_cast< QMouseEvent * >( ev );
@ -2389,6 +2398,9 @@ void MainWindow::toggleMainWindow( bool onlyShow )
else
if ( isMinimized() )
{
if( wasMaximized )
showMaximized();
else
showNormal();
activateWindow();
raise();

View file

@ -149,6 +149,8 @@ private:
bool wordListSelChanged;
bool wasMaximized; // Window state before minimization
QPrinter & getPrinter(); // Creates a printer if it's not there and returns it
/// Applies the qt's stylesheet, given the style's name.