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 ), wordFinder( this ),
newReleaseCheckTimer( this ), newReleaseCheckTimer( this ),
wordListSelChanged( false ) wordListSelChanged( false )
, wasMaximized( false )
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
, gdAskMessage( 0xFFFFFFFF ) , gdAskMessage( 0xFFFFFFFF )
#endif #endif
@ -682,6 +683,8 @@ MainWindow::MainWindow( Config::Class & cfg_ ):
updateStatusLine(); updateStatusLine();
wasMaximized = isMaximized();
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
LionSupport::addFullscreen(this); LionSupport::addFullscreen(this);
#endif #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 ) { if ( ev->type() == QEvent::MouseButtonPress ) {
QMouseEvent * event = static_cast< QMouseEvent * >( ev ); QMouseEvent * event = static_cast< QMouseEvent * >( ev );
@ -2389,6 +2398,9 @@ void MainWindow::toggleMainWindow( bool onlyShow )
else else
if ( isMinimized() ) if ( isMinimized() )
{ {
if( wasMaximized )
showMaximized();
else
showNormal(); showNormal();
activateWindow(); activateWindow();
raise(); raise();

View file

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