mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 19:24:08 +00:00
Properly restore main window maximized state when it activated through tray icon
This commit is contained in:
parent
08ca79c272
commit
c23e09b57b
|
@ -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,7 +2398,10 @@ void MainWindow::toggleMainWindow( bool onlyShow )
|
|||
else
|
||||
if ( isMinimized() )
|
||||
{
|
||||
showNormal();
|
||||
if( wasMaximized )
|
||||
showMaximized();
|
||||
else
|
||||
showNormal();
|
||||
activateWindow();
|
||||
raise();
|
||||
shown = true;
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue