Skip to content

Commit

Permalink
Swap composers menu to show layouts instead
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jan 7, 2018
1 parent 4f825f8 commit 3edab4f
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/app/composer/qgscomposer.cpp
Expand Up @@ -3570,7 +3570,7 @@ void QgsComposer::mActionPageSetup_triggered()

void QgsComposer::populatePrintComposersMenu()
{
mQgis->populateComposerMenu( mPrintComposersMenu );
mQgis->populateLayoutsMenu( mPrintComposersMenu );
}

void QgsComposer::populateWindowMenu()
Expand Down
8 changes: 8 additions & 0 deletions src/app/layout/qgslayoutdesignerdialog.cpp
Expand Up @@ -709,6 +709,9 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla
mActionExportAtlasAsSVG->setEnabled( false );
mActionExportAtlasAsPDF->setEnabled( false );

mLayoutsMenu->setObjectName( QStringLiteral( "mLayoutsMenu" ) );
connect( mLayoutsMenu, &QMenu::aboutToShow, this, &QgsLayoutDesignerDialog::populateLayoutsMenu );

restoreWindowState();

//listen out to status bar updates from the view
Expand Down Expand Up @@ -3312,6 +3315,11 @@ void QgsLayoutDesignerDialog::pageOrientationChanged()
mSetPageOrientation = false;
}

void QgsLayoutDesignerDialog::populateLayoutsMenu()
{
QgisApp::instance()->populateLayoutsMenu( mLayoutsMenu );
}

void QgsLayoutDesignerDialog::paste()
{
QPointF pt = mView->mapFromGlobal( QCursor::pos() );
Expand Down
3 changes: 3 additions & 0 deletions src/app/layout/qgslayoutdesignerdialog.h
Expand Up @@ -340,6 +340,9 @@ class QgsLayoutDesignerDialog: public QMainWindow, private Ui::QgsLayoutDesigner
//! Sets the printer page orientation when the page orientation changes
void pageOrientationChanged();

//! Populate layouts menu from main app's
void populateLayoutsMenu();

private:

static bool sInitializedRegistry;
Expand Down
17 changes: 9 additions & 8 deletions src/app/qgisapp.cpp
Expand Up @@ -3244,7 +3244,7 @@ void QgisApp::setupConnections()
// setup undo/redo actions
connect( mUndoWidget, &QgsUndoWidget::undoStackChanged, this, &QgisApp::updateUndoActions );

connect( mPrintComposersMenu, &QMenu::aboutToShow, this, &QgisApp::composerMenuAboutToShow );
connect( mLayoutsMenu, &QMenu::aboutToShow, this, &QgisApp::layoutsMenuAboutToShow );
connect( QgsProject::instance()->layoutManager(), &QgsLayoutManager::compositionAboutToBeRemoved, this, &QgisApp::compositionAboutToBeRemoved );
}

Expand Down Expand Up @@ -7535,21 +7535,22 @@ void QgisApp::setLayoutAtlasFeature( QgsPrintLayout *layout, QgsMapLayer *layer,
designer->setAtlasFeature( layer, feat );
}

void QgisApp::composerMenuAboutToShow()
void QgisApp::layoutsMenuAboutToShow()
{
populateComposerMenu( mPrintComposersMenu );
populateLayoutsMenu( mLayoutsMenu );
}

void QgisApp::populateComposerMenu( QMenu *menu )
void QgisApp::populateLayoutsMenu( QMenu *menu )
{
menu->clear();
QList<QAction *> acts;
Q_FOREACH ( QgsComposition *c, QgsProject::instance()->layoutManager()->compositions() )
const QList< QgsMasterLayoutInterface * > layouts = QgsProject::instance()->layoutManager()->layouts();
for ( QgsMasterLayoutInterface *layout : layouts )
{
QAction *a = new QAction( c->name(), menu );
connect( a, &QAction::triggered, this, [this, c]
QAction *a = new QAction( layout->name(), menu );
connect( a, &QAction::triggered, this, [this, layout]
{
openComposer( c );
openLayoutDesignerDialog( layout );
} );
acts << a;
}
Expand Down
12 changes: 5 additions & 7 deletions src/app/qgisapp.h
Expand Up @@ -46,10 +46,8 @@ class QgsAuthManager;
class QgsBookmarks;
class QgsClipboard;
class QgsComposer;
class QgsComposerInterface;
class QgsComposition;
class QgsComposerManager;
class QgsComposerView;
class QgsContrastEnhancement;
class QgsCoordinateReferenceSystem;
class QgsCustomDropHandler;
Expand Down Expand Up @@ -302,7 +300,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
QgisAppStyleSheet *styleSheetBuilder();

//! Populates a menu with actions for opening layout designers
void populateComposerMenu( QMenu *menu );
void populateLayoutsMenu( QMenu *menu );

//! Setup the toolbar popup menus for a given theme
void setupToolbarPopups( QString themeName );
Expand Down Expand Up @@ -574,7 +572,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
QMenu *firstRightStandardMenu() { return mHelpMenu; }
QMenu *windowMenu() { return nullptr; }
#endif
QMenu *printComposersMenu() {return mPrintComposersMenu;}
QMenu *helpMenu() { return mHelpMenu; }

//! Toolbars
Expand Down Expand Up @@ -1260,6 +1257,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
//! Create a new print layout
void newPrintLayout();

//! Slot to handle display of layouts menu, e.g. sorting
void layoutsMenuAboutToShow();

void showComposerManager();
//! Add all loaded layers into the overview - overrides qgisappbase method
void addAllToOverview();
Expand Down Expand Up @@ -1528,8 +1528,6 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow

void showStyleManager();

//! Slot to handle display of composers menu, e.g. sorting
void composerMenuAboutToShow();
void compositionAboutToBeRemoved( const QString &name );

//! Toggles whether to show pinned labels
Expand Down Expand Up @@ -2037,7 +2035,7 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
//! Print composers of this project, accessible by id string
QSet<QgsComposer *> mPrintComposers;

//! Print composers of this project, accessible by id string
//! Currently open layout designer dialogs
QSet<QgsLayoutDesignerDialog *> mLayoutDesignerDialogs;

//! QGIS-internal vector feature clipboard
Expand Down
11 changes: 11 additions & 0 deletions src/ui/layout/qgslayoutdesignerbase.ui
Expand Up @@ -106,12 +106,18 @@
<property name="title">
<string>&amp;Layout</string>
</property>
<widget class="QMenu" name="mLayoutsMenu">
<property name="title">
<string>Layouts</string>
</property>
</widget>
<addaction name="mActionSaveProject"/>
<addaction name="separator"/>
<addaction name="mActionNewLayout"/>
<addaction name="mActionDuplicateLayout"/>
<addaction name="mActionRemoveLayout"/>
<addaction name="mActionLayoutManager"/>
<addaction name="mLayoutsMenu"/>
<addaction name="separator"/>
<addaction name="mActionLayoutProperties"/>
<addaction name="mActionRenameLayout"/>
Expand Down Expand Up @@ -1487,6 +1493,11 @@
<string>Ctrl+Shift+P</string>
</property>
</action>
<action name="actiondsfg">
<property name="text">
<string>dsfg</string>
</property>
</action>
</widget>
<resources>
<include location="../../../images/images.qrc"/>
Expand Down
6 changes: 3 additions & 3 deletions src/ui/qgisapp.ui
Expand Up @@ -32,9 +32,9 @@
<string>Open &amp;Recent</string>
</property>
</widget>
<widget class="QMenu" name="mPrintComposersMenu">
<widget class="QMenu" name="mLayoutsMenu">
<property name="title">
<string>Print Composers</string>
<string>Layouts</string>
</property>
</widget>
<widget class="QMenu" name="mProjectFromTemplateMenu">
Expand All @@ -59,7 +59,7 @@
<addaction name="mActionProjectProperties"/>
<addaction name="separator"/>
<addaction name="mActionShowComposerManager"/>
<addaction name="mPrintComposersMenu"/>
<addaction name="mLayoutsMenu"/>
<addaction name="separator"/>
<addaction name="mActionExit"/>
</widget>
Expand Down

0 comments on commit 3edab4f

Please sign in to comment.