Skip to content

Commit

Permalink
[needs-docs] Add "delete layout" action to layout designer menu
Browse files Browse the repository at this point in the history
Fixes #10436
  • Loading branch information
nyalldawson committed Dec 6, 2017
1 parent 88682b2 commit b6dab6f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/app/layout/qgslayoutdesignerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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() );
Expand Down
1 change: 1 addition & 0 deletions src/app/layout/qgslayoutdesignerdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ class QgsLayoutDesignerDialog: public QMainWindow, private Ui::QgsLayoutDesigner
void newLayout();
void showManager();
void renameLayout();
void deleteLayout();

private:

Expand Down
13 changes: 13 additions & 0 deletions src/ui/layout/qgslayoutdesignerbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand Down Expand Up @@ -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"/>
Expand Down

0 comments on commit b6dab6f

Please sign in to comment.