Skip to content
Permalink
Browse files

Port a few file related actions to layouts

  • Loading branch information
nyalldawson committed Dec 6, 2017
1 parent a9896ea commit 9c4a98f0292a605bc62fcd1b2fb5bfb3325451dc
@@ -157,6 +157,9 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla
mVerticalRuler->setContextMenu( rulerMenu );

connect( mActionRefreshView, &QAction::triggered, this, &QgsLayoutDesignerDialog::refreshLayout );
connect( mActionSaveProject, &QAction::triggered, this, &QgsLayoutDesignerDialog::saveProject );
connect( mActionNewLayout, &QAction::triggered, this, &QgsLayoutDesignerDialog::newLayout );
connect( mActionLayoutManager, &QAction::triggered, this, &QgsLayoutDesignerDialog::showManager );

connect( mActionShowGrid, &QAction::triggered, this, &QgsLayoutDesignerDialog::showGrid );
connect( mActionSnapGrid, &QAction::triggered, this, &QgsLayoutDesignerDialog::snapToGrid );
@@ -1348,6 +1351,29 @@ void QgsLayoutDesignerDialog::duplicate()
}
}

void QgsLayoutDesignerDialog::saveProject()
{
QgisApp::instance()->actionSaveProject()->trigger();
}

void QgsLayoutDesignerDialog::newLayout()
{
QString title;
if ( !QgisApp::instance()->uniqueLayoutTitle( this, title, true ) )
{
return;
}
QgisApp::instance()->createNewLayout( title );
}

void QgsLayoutDesignerDialog::showManager()
{
// NOTE: Avoid crash where composer that spawned modal manager from toolbar ends up
// being deleted by user, but event loop tries to return to layout on manager close
// (does not seem to be an issue for menu action)
QTimer::singleShot( 0, QgisApp::instance()->actionShowComposerManager(), SLOT( trigger() ) );
}

void QgsLayoutDesignerDialog::paste()
{
QPointF pt = mView->mapFromGlobal( QCursor::pos() );
@@ -269,6 +269,9 @@ class QgsLayoutDesignerDialog: public QMainWindow, private Ui::QgsLayoutDesigner
void saveAsTemplate();
void addItemsFromTemplate();
void duplicate();
void saveProject();
void newLayout();
void showManager();

private:

@@ -7445,6 +7445,19 @@ QgsComposer *QgisApp::openComposer( QgsComposition *composition )
return newComposerObject;
}

QgsLayoutDesignerDialog *QgisApp::createNewLayout( QString title )
{
if ( title.isEmpty() )
{
title = QgsProject::instance()->layoutManager()->generateUniqueTitle();
}
//create new layout object
QgsLayout *layout = new QgsLayout( QgsProject::instance() );
layout->setName( title );
QgsProject::instance()->layoutManager()->addLayout( layout );
return openLayoutDesignerDialog( layout );
}

QgsLayoutDesignerDialog *QgisApp::openLayoutDesignerDialog( QgsLayout *layout )
{
// maybe a designer already open for this layout
@@ -7474,7 +7487,9 @@ QgsLayoutDesignerDialog *QgisApp::openLayoutDesignerDialog( QgsLayout *layout )

newDesigner->open();
emit layoutDesignerOpened( newDesigner->iface() );
//connect( newDesigner, &QgsLayoutDesignerDialog::atlasPreviewFeatureChanged, this, &QgisApp::refreshMapCanvas );
#if 0 //TODO
connect( newDesigner, &QgsLayoutDesignerDialog::atlasPreviewFeatureChanged, this, &QgisApp::refreshMapCanvas );
#endif

return newDesigner;
}
@@ -384,6 +384,9 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
*/
QgsComposer *openComposer( QgsComposition *composition );

//! Creates a new layout and returns a pointer to it
QgsLayoutDesignerDialog *createNewLayout( QString title = QString() );

/**
* Opens a layout designer dialog for an existing \a layout.
* If a designer already exists for this layout then it will be activated.
@@ -62,7 +62,11 @@
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="mActionSaveProject"/>
<addaction name="separator"/>
<addaction name="mActionNewLayout"/>
<addaction name="mActionDuplicateLayout"/>
<addaction name="mActionLayoutManager"/>
<addaction name="mActionLoadFromTemplate"/>
<addaction name="mActionSaveAsTemplate"/>
</widget>
@@ -95,7 +99,11 @@
<property name="title">
<string>&amp;Layout</string>
</property>
<addaction name="mActionSaveProject"/>
<addaction name="separator"/>
<addaction name="mActionNewLayout"/>
<addaction name="mActionDuplicateLayout"/>
<addaction name="mActionLayoutManager"/>
<addaction name="separator"/>
<addaction name="mActionLayoutProperties"/>
<addaction name="mActionAddPages"/>
@@ -1101,6 +1109,48 @@
<string>Duplicate layout</string>
</property>
</action>
<action name="mActionSaveProject">
<property name="icon">
<iconset resource="../../../images/images.qrc">
<normaloff>:/images/themes/default/mActionFileSave.svg</normaloff>:/images/themes/default/mActionFileSave.svg</iconset>
</property>
<property name="text">
<string>&amp;Save Project</string>
</property>
<property name="toolTip">
<string>Save project</string>
</property>
<property name="shortcut">
<string>Ctrl+S</string>
</property>
</action>
<action name="mActionNewLayout">
<property name="icon">
<iconset resource="../../../images/images.qrc">
<normaloff>:/images/themes/default/mActionNewComposer.svg</normaloff>:/images/themes/default/mActionNewComposer.svg</iconset>
</property>
<property name="text">
<string>&amp;New Layout…</string>
</property>
<property name="toolTip">
<string>New layout</string>
</property>
<property name="shortcut">
<string>Ctrl+N</string>
</property>
</action>
<action name="mActionLayoutManager">
<property name="icon">
<iconset resource="../../../images/images.qrc">
<normaloff>:/images/themes/default/mActionComposerManager.svg</normaloff>:/images/themes/default/mActionComposerManager.svg</iconset>
</property>
<property name="text">
<string>Layout &amp;Manager...</string>
</property>
<property name="toolTip">
<string>Layout manager</string>
</property>
</action>
</widget>
<resources>
<include location="../../../images/images.qrc"/>

0 comments on commit 9c4a98f

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