Skip to content
Permalink
Browse files

Swap composers menu to show layouts instead

  • Loading branch information
nyalldawson committed Jan 7, 2018
1 parent 4f825f8 commit 3edab4feef50dac83b89988c003e4a770af8bd54
@@ -3570,7 +3570,7 @@ void QgsComposer::mActionPageSetup_triggered()

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

void QgsComposer::populateWindowMenu()
@@ -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
@@ -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() );
@@ -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;
@@ -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 );
}

@@ -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;
}
@@ -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;
@@ -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 );
@@ -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
@@ -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();
@@ -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
@@ -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
@@ -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"/>
@@ -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"/>
@@ -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">
@@ -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>

0 comments on commit 3edab4f

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