Skip to content

Commit b6dab6f

Browse files
committedDec 6, 2017
[needs-docs] Add "delete layout" action to layout designer menu
Fixes #10436
1 parent 88682b2 commit b6dab6f

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed
 

‎src/app/layout/qgslayoutdesignerdialog.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "qgslayout.h"
2424
#include "qgslayoutappmenuprovider.h"
2525
#include "qgslayoutcustomdrophandler.h"
26+
#include "qgslayoutmanager.h"
2627
#include "qgslayoutview.h"
2728
#include "qgslayoutviewtooladditem.h"
2829
#include "qgslayoutviewtooladdnodeitem.h"
@@ -160,6 +161,7 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla
160161
connect( mActionSaveProject, &QAction::triggered, this, &QgsLayoutDesignerDialog::saveProject );
161162
connect( mActionNewLayout, &QAction::triggered, this, &QgsLayoutDesignerDialog::newLayout );
162163
connect( mActionLayoutManager, &QAction::triggered, this, &QgsLayoutDesignerDialog::showManager );
164+
connect( mActionRemoveLayout, &QAction::triggered, this, &QgsLayoutDesignerDialog::deleteLayout );
163165

164166
connect( mActionShowGrid, &QAction::triggered, this, &QgsLayoutDesignerDialog::showGrid );
165167
connect( mActionSnapGrid, &QAction::triggered, this, &QgsLayoutDesignerDialog::snapToGrid );
@@ -1392,6 +1394,16 @@ void QgsLayoutDesignerDialog::renameLayout()
13921394
currentLayout()->setName( newTitle );
13931395
}
13941396

1397+
void QgsLayoutDesignerDialog::deleteLayout()
1398+
{
1399+
if ( QMessageBox::question( this, tr( "Delete Layout" ), tr( "Are you sure you want to delete the layout “%1”?" ).arg( currentLayout()->name() ),
1400+
QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) != QMessageBox::Yes )
1401+
return;
1402+
1403+
currentLayout()->project()->layoutManager()->removeLayout( currentLayout() );
1404+
close();
1405+
}
1406+
13951407
void QgsLayoutDesignerDialog::paste()
13961408
{
13971409
QPointF pt = mView->mapFromGlobal( QCursor::pos() );

‎src/app/layout/qgslayoutdesignerdialog.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ class QgsLayoutDesignerDialog: public QMainWindow, private Ui::QgsLayoutDesigner
273273
void newLayout();
274274
void showManager();
275275
void renameLayout();
276+
void deleteLayout();
276277

277278
private:
278279

‎src/ui/layout/qgslayoutdesignerbase.ui

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
<addaction name="separator"/>
104104
<addaction name="mActionNewLayout"/>
105105
<addaction name="mActionDuplicateLayout"/>
106+
<addaction name="mActionRemoveLayout"/>
106107
<addaction name="mActionLayoutManager"/>
107108
<addaction name="separator"/>
108109
<addaction name="mActionLayoutProperties"/>
@@ -1160,6 +1161,18 @@
11601161
<string>Rename layout</string>
11611162
</property>
11621163
</action>
1164+
<action name="mActionRemoveLayout">
1165+
<property name="icon">
1166+
<iconset resource="../../../images/images.qrc">
1167+
<normaloff>:/images/themes/default/mActionDeleteSelected.svg</normaloff>:/images/themes/default/mActionDeleteSelected.svg</iconset>
1168+
</property>
1169+
<property name="text">
1170+
<string>Delete Layout…</string>
1171+
</property>
1172+
<property name="toolTip">
1173+
<string>Delete layout</string>
1174+
</property>
1175+
</action>
11631176
</widget>
11641177
<resources>
11651178
<include location="../../../images/images.qrc"/>

0 commit comments

Comments
 (0)
Please sign in to comment.