@@ -805,24 +805,38 @@ void QgsComposer::activate()
805
805
}
806
806
}
807
807
808
- #ifdef Q_OS_MAC
809
808
void QgsComposer::changeEvent ( QEvent* event )
810
809
{
811
810
QMainWindow::changeEvent ( event );
812
811
switch ( event->type () )
813
812
{
813
+ #ifdef Q_OS_MAC
814
814
case QEvent::ActivationChange:
815
+ {
815
816
if ( QApplication::activeWindow () == this )
816
817
{
817
818
mWindowAction ->setChecked ( true );
818
819
}
819
820
break ;
820
-
821
+ }
822
+ #endif
823
+ case QEvent::WindowStateChange:
824
+ {
825
+ /* Listen out for window un-minimisation and restore composer map states.
826
+ * We can't use showEvent to detect this due to QT Bug 36675 (see #6085).
827
+ */
828
+ QWindowStateChangeEvent* changeEv = static_cast < QWindowStateChangeEvent* >( event );
829
+ if ( changeEv->oldState () & Qt::WindowMinimized )
830
+ {
831
+ // Window restored, restore composers
832
+ restoreComposerMapStates ();
833
+ }
834
+ break ;
835
+ }
821
836
default :
822
837
break ;
823
838
}
824
839
}
825
- #endif
826
840
827
841
void QgsComposer::setTitle ( const QString& title )
828
842
{
@@ -3005,21 +3019,16 @@ void QgsComposer::resizeEvent( QResizeEvent *e )
3005
3019
saveWindowState ();
3006
3020
}
3007
3021
3022
+ #ifdef Q_OS_MAC
3008
3023
void QgsComposer::showEvent ( QShowEvent* event )
3009
3024
{
3010
- if ( event->spontaneous () ) // event from the window system
3011
- {
3012
- restoreComposerMapStates ();
3013
- }
3014
-
3015
- #ifdef Q_OS_MAC
3016
3025
// add to menu if (re)opening window (event not due to unminimize)
3017
3026
if ( !event->spontaneous () )
3018
3027
{
3019
3028
mQgis ->addWindow ( mWindowAction );
3020
3029
}
3021
- #endif
3022
3030
}
3031
+ #endif
3023
3032
3024
3033
void QgsComposer::saveWindowState ()
3025
3034
{
@@ -3564,15 +3573,18 @@ void QgsComposer::on_mActionPageSetup_triggered()
3564
3573
3565
3574
void QgsComposer::restoreComposerMapStates ()
3566
3575
{
3567
- // go through maps and restore original preview modes (show on demand after loading from project file)
3568
- QMap< QgsComposerMap*, int >::iterator mapIt = mMapsToRestore .begin ();
3569
- for ( ; mapIt != mMapsToRestore .end (); ++mapIt )
3576
+ if ( !mMapsToRestore .isEmpty () )
3570
3577
{
3571
- mapIt.key ()->setPreviewMode (( QgsComposerMap::PreviewMode )( mapIt.value () ) );
3572
- mapIt.key ()->cache ();
3573
- mapIt.key ()->update ();
3578
+ // go through maps and restore original preview modes (show on demand after loading from project file)
3579
+ QMap< QgsComposerMap*, int >::iterator mapIt = mMapsToRestore .begin ();
3580
+ for ( ; mapIt != mMapsToRestore .end (); ++mapIt )
3581
+ {
3582
+ mapIt.key ()->setPreviewMode (( QgsComposerMap::PreviewMode )( mapIt.value () ) );
3583
+ mapIt.key ()->cache ();
3584
+ mapIt.key ()->update ();
3585
+ }
3586
+ mMapsToRestore .clear ();
3574
3587
}
3575
- mMapsToRestore .clear ();
3576
3588
}
3577
3589
3578
3590
void QgsComposer::populatePrintComposersMenu ()
0 commit comments