[needs-docs] Add "delete layout" action to layout designer menu

Fixes #10436
This commit is contained in:
Nyall Dawson 2017-12-05 12:37:12 +10:00
parent 88682b2c7d
commit b6dab6ff48
3 changed files with 26 additions and 0 deletions

View File

@ -23,6 +23,7 @@
#include "qgslayout.h"
#include "qgslayoutappmenuprovider.h"
#include "qgslayoutcustomdrophandler.h"
#include "qgslayoutmanager.h"
#include "qgslayoutview.h"
#include "qgslayoutviewtooladditem.h"
#include "qgslayoutviewtooladdnodeitem.h"
@ -160,6 +161,7 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla
connect( mActionSaveProject, &QAction::triggered, this, &QgsLayoutDesignerDialog::saveProject );
connect( mActionNewLayout, &QAction::triggered, this, &QgsLayoutDesignerDialog::newLayout );
connect( mActionLayoutManager, &QAction::triggered, this, &QgsLayoutDesignerDialog::showManager );
connect( mActionRemoveLayout, &QAction::triggered, this, &QgsLayoutDesignerDialog::deleteLayout );
connect( mActionShowGrid, &QAction::triggered, this, &QgsLayoutDesignerDialog::showGrid );
connect( mActionSnapGrid, &QAction::triggered, this, &QgsLayoutDesignerDialog::snapToGrid );
@ -1392,6 +1394,16 @@ void QgsLayoutDesignerDialog::renameLayout()
currentLayout()->setName( newTitle );
}
void QgsLayoutDesignerDialog::deleteLayout()
{
if ( QMessageBox::question( this, tr( "Delete Layout" ), tr( "Are you sure you want to delete the layout “%1”?" ).arg( currentLayout()->name() ),
QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes )
return;
currentLayout()->project()->layoutManager()->removeLayout( currentLayout() );
close();
}
void QgsLayoutDesignerDialog::paste()
{
QPointF pt = mView->mapFromGlobal( QCursor::pos() );

View File

@ -273,6 +273,7 @@ class QgsLayoutDesignerDialog: public QMainWindow, private Ui::QgsLayoutDesigner
void newLayout();
void showManager();
void renameLayout();
void deleteLayout();
private:

View File

@ -103,6 +103,7 @@
<addaction name="separator"/>
<addaction name="mActionNewLayout"/>
<addaction name="mActionDuplicateLayout"/>
<addaction name="mActionRemoveLayout"/>
<addaction name="mActionLayoutManager"/>
<addaction name="separator"/>
<addaction name="mActionLayoutProperties"/>
@ -1160,6 +1161,18 @@
<string>Rename layout</string>
</property>
</action>
<action name="mActionRemoveLayout">
<property name="icon">
<iconset resource="../../../images/images.qrc">
<normaloff>:/images/themes/default/mActionDeleteSelected.svg</normaloff>:/images/themes/default/mActionDeleteSelected.svg</iconset>
</property>
<property name="text">
<string>Delete Layout…</string>
</property>
<property name="toolTip">
<string>Delete layout</string>
</property>
</action>
</widget>
<resources>
<include location="../../../images/images.qrc"/>