Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Call QgsComposer::restoreComposerMapStates in QgsComposer:changeEvent,
not in showEvent (latter does not work reliably with some window
managers, such as openbox) (fix #6085)
- Loading branch information
Showing
with
32 additions
and
21 deletions.
-
+29
−17
src/app/composer/qgscomposer.cpp
-
+3
−4
src/app/composer/qgscomposer.h
|
@@ -803,24 +803,38 @@ void QgsComposer::activate() |
|
|
} |
|
|
} |
|
|
|
|
|
#ifdef Q_OS_MAC |
|
|
void QgsComposer::changeEvent( QEvent* event ) |
|
|
{ |
|
|
QMainWindow::changeEvent( event ); |
|
|
switch ( event->type() ) |
|
|
{ |
|
|
#ifdef Q_OS_MAC |
|
|
case QEvent::ActivationChange: |
|
|
{ |
|
|
if ( QApplication::activeWindow() == this ) |
|
|
{ |
|
|
mWindowAction->setChecked( true ); |
|
|
} |
|
|
break; |
|
|
|
|
|
} |
|
|
#endif |
|
|
case QEvent::WindowStateChange: |
|
|
{ |
|
|
/* Listen out for window un-minimisation and restore composer map states. |
|
|
* We can't use showEvent to detect this due to QT Bug 36675 (see #6085). |
|
|
*/ |
|
|
QWindowStateChangeEvent* changeEv = static_cast< QWindowStateChangeEvent* >( event ); |
|
|
if ( changeEv->oldState() & Qt::WindowMinimized ) |
|
|
{ |
|
|
// Window restored, restore composers |
|
|
restoreComposerMapStates(); |
|
|
} |
|
|
break; |
|
|
} |
|
|
default: |
|
|
break; |
|
|
} |
|
|
} |
|
|
#endif |
|
|
|
|
|
void QgsComposer::setTitle( const QString& title ) |
|
|
{ |
|
@@ -3003,21 +3017,16 @@ void QgsComposer::resizeEvent( QResizeEvent *e ) |
|
|
saveWindowState(); |
|
|
} |
|
|
|
|
|
#ifdef Q_OS_MAC |
|
|
void QgsComposer::showEvent( QShowEvent* event ) |
|
|
{ |
|
|
if ( event->spontaneous() ) //event from the window system |
|
|
{ |
|
|
restoreComposerMapStates(); |
|
|
} |
|
|
|
|
|
#ifdef Q_OS_MAC |
|
|
// add to menu if (re)opening window (event not due to unminimize) |
|
|
if ( !event->spontaneous() ) |
|
|
{ |
|
|
mQgis->addWindow( mWindowAction ); |
|
|
} |
|
|
#endif |
|
|
} |
|
|
#endif |
|
|
|
|
|
void QgsComposer::saveWindowState() |
|
|
{ |
|
@@ -3562,15 +3571,18 @@ void QgsComposer::on_mActionPageSetup_triggered() |
|
|
|
|
|
void QgsComposer::restoreComposerMapStates() |
|
|
{ |
|
|
//go through maps and restore original preview modes (show on demand after loading from project file) |
|
|
QMap< QgsComposerMap*, int >::iterator mapIt = mMapsToRestore.begin(); |
|
|
for ( ; mapIt != mMapsToRestore.end(); ++mapIt ) |
|
|
if ( !mMapsToRestore.isEmpty() ) |
|
|
{ |
|
|
mapIt.key()->setPreviewMode(( QgsComposerMap::PreviewMode )( mapIt.value() ) ); |
|
|
mapIt.key()->cache(); |
|
|
mapIt.key()->update(); |
|
|
//go through maps and restore original preview modes (show on demand after loading from project file) |
|
|
QMap< QgsComposerMap*, int >::iterator mapIt = mMapsToRestore.begin(); |
|
|
for ( ; mapIt != mMapsToRestore.end(); ++mapIt ) |
|
|
{ |
|
|
mapIt.key()->setPreviewMode(( QgsComposerMap::PreviewMode )( mapIt.value() ) ); |
|
|
mapIt.key()->cache(); |
|
|
mapIt.key()->update(); |
|
|
} |
|
|
mMapsToRestore.clear(); |
|
|
} |
|
|
mMapsToRestore.clear(); |
|
|
} |
|
|
|
|
|
void QgsComposer::populatePrintComposersMenu() |
|
|
|
@@ -112,13 +112,12 @@ class QgsComposer: public QMainWindow, private Ui::QgsComposerBase |
|
|
//! Resize event |
|
|
virtual void resizeEvent( QResizeEvent * ) override; |
|
|
|
|
|
virtual void showEvent( QShowEvent* event ) override; |
|
|
|
|
|
#ifdef Q_OS_MAC |
|
|
//! Change event (update window menu on ActivationChange) |
|
|
virtual void changeEvent( QEvent * ); |
|
|
virtual void showEvent( QShowEvent* event ) override; |
|
|
#endif |
|
|
|
|
|
virtual void changeEvent( QEvent *ev ) override; |
|
|
|
|
|
signals: |
|
|
//! Is emitted every time the view zoom has changed |
|
|
void zoomLevelChanged(); |
|
|