Skip to content
Permalink
Browse files

Don't open multiple composer manager windows, don't hide the composer…

… manager when showing/duplicating a composer
  • Loading branch information
manisandro committed Apr 14, 2014
1 parent c8575e0 commit ae341586b0e94cab0901f0c621b8efd4dddda1a3
Showing with 36 additions and 11 deletions.
  1. +12 −6 src/app/composer/qgscomposermanager.cpp
  2. +18 −5 src/app/qgisapp.cpp
  3. +6 −0 src/app/qgisapp.h
@@ -101,6 +101,8 @@ QgsComposerManager::~QgsComposerManager()

void QgsComposerManager::refreshComposers()
{
QString selName = mComposerListWidget->currentItem() ? mComposerListWidget->currentItem()->text() : "";

mItemComposerMap.clear();
mComposerListWidget->clear();

@@ -113,6 +115,16 @@ void QgsComposerManager::refreshComposers()
mItemComposerMap.insert( item, *it );
}
mComposerListWidget->sortItems();

// Restore selection
if ( !selName.isEmpty() )
{
QList<QListWidgetItem*> items = mComposerListWidget->findItems( selName, Qt::MatchExactly );
if ( !items.isEmpty() )
{
mComposerListWidget->setCurrentItem( items.first() );
}
}
}

QMap<QString, QString> QgsComposerManager::defaultTemplates( bool fromUser ) const
@@ -299,7 +311,6 @@ void QgsComposerManager::show_clicked()
{
// extra activation steps for Windows
bool shown = c->isVisible();
hide();

c->activate();

@@ -344,7 +355,6 @@ void QgsComposerManager::show_clicked()
c->activate();
}
#endif //0
close();
}

void QgsComposerManager::duplicate_clicked()
@@ -388,11 +398,7 @@ void QgsComposerManager::duplicate_clicked()
if ( newComposer )
{
// extra activation steps for Windows
hide();
newComposer->activate();

// no need to add new composer to list widget, if just closing this->exec();
close();
}
else
{
@@ -452,6 +452,7 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
#ifdef Q_OS_WIN
, mSkipNextContextMenuEvent( 0 )
#endif
, mComposerManager( 0 )
, mpGpsWidget( 0 )
{
if ( smInstance )
@@ -776,6 +777,7 @@ QgisApp::QgisApp( )
, mInternalClipboard( 0 )
, mpMaptip( 0 )
, mPythonUtils( 0 )
, mComposerManager( 0 )
, mpGpsWidget( 0 )
{
smInstance = this;
@@ -845,6 +847,8 @@ QgisApp::~QgisApp()

delete mOverviewMapCursor;

delete mComposerManager;

deletePrintComposers();
removeAnnotationItems();

@@ -3919,11 +3923,20 @@ void QgisApp::newPrintComposer()

void QgisApp::showComposerManager()
{
QgsComposerManager* m = new QgsComposerManager( this, Qt::Window );
connect( m, SIGNAL( finished( int ) ), m, SLOT( deleteLater() ) );
m->show();
m->raise();
m->activateWindow();
if ( !mComposerManager )
{
mComposerManager = new QgsComposerManager( this, Qt::Window );
connect( mComposerManager, SIGNAL( finished( int ) ), this, SLOT( deleteComposerManager() ) );
}
mComposerManager->show();
mComposerManager->raise();
mComposerManager->activateWindow();
}

void QgisApp::deleteComposerManager()
{
delete mComposerManager;
mComposerManager = 0;
}

void QgisApp::saveMapAsImage()
@@ -42,6 +42,7 @@ class QgsAnnotationItem;
class QgsClipboard;
class QgsComposer;
class QgsComposerView;
class QgsComposerManager;
class QgsContrastEnhancement;
class QgsGeometry;
class QgsFeature;
@@ -1172,6 +1173,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
//! catch MapCanvas keyPress event so we can check if selected feature collection must be deleted
void mapCanvas_keyPressed( QKeyEvent *e );

//! Deletes the active QgsComposerManager instance
void deleteComposerManager();

signals:
/** emitted when a key is pressed and we want non widget sublasses to be able
to pick up on this (e.g. maplayer) */
@@ -1513,6 +1517,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow

QgsPluginManager* mPluginManager;

QgsComposerManager* mComposerManager;

//! Persistent tile scale slider
QgsTileScaleWidget * mpTileScaleWidget;

0 comments on commit ae34158

Please sign in to comment.
You can’t perform that action at this time.