Skip to content
Permalink
Browse files
[needs-docs] Add rename layout action to layout designer dialog
Fixes #10435
  • Loading branch information
nyalldawson committed Dec 6, 2017
1 parent 61c57bc commit 88682b2c7defa1b4a7c06e071e40b729668e7b72
@@ -316,6 +316,7 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla
connect( mActionSaveAsTemplate, &QAction::triggered, this, &QgsLayoutDesignerDialog::saveAsTemplate );
connect( mActionLoadFromTemplate, &QAction::triggered, this, &QgsLayoutDesignerDialog::addItemsFromTemplate );
connect( mActionDuplicateLayout, &QAction::triggered, this, &QgsLayoutDesignerDialog::duplicate );
connect( mActionRenameLayout, &QAction::triggered, this, &QgsLayoutDesignerDialog::renameLayout );

connect( mActionZoomIn, &QAction::triggered, mView, &QgsLayoutView::zoomIn );
connect( mActionZoomOut, &QAction::triggered, mView, &QgsLayoutView::zoomOut );
@@ -1380,6 +1381,17 @@ void QgsLayoutDesignerDialog::showManager()
} );
}

void QgsLayoutDesignerDialog::renameLayout()
{
QString currentTitle = currentLayout()->name();
QString newTitle;
if ( !QgisApp::instance()->uniqueLayoutTitle( this, newTitle, false, currentTitle ) )
{
return;
}
currentLayout()->setName( newTitle );
}

void QgsLayoutDesignerDialog::paste()
{
QPointF pt = mView->mapFromGlobal( QCursor::pos() );
@@ -272,6 +272,7 @@ class QgsLayoutDesignerDialog: public QMainWindow, private Ui::QgsLayoutDesigner
void saveProject();
void newLayout();
void showManager();
void renameLayout();

private:

@@ -7351,14 +7351,13 @@ bool QgisApp::uniqueLayoutTitle( QWidget *parent, QString &title, bool acceptEmp
}
QString titleMsg = chooseMsg;

QStringList cNames;
cNames << newTitle;
#if 0 //TODO
Q_FOREACH ( QgsComposition *c, QgsProject::instance()->layoutManager()->compositions() )
QStringList layoutNames;
layoutNames << newTitle;
const QList< QgsLayout * > layouts = QgsProject::instance()->layoutManager()->layouts();
for ( QgsLayout *l : layouts )
{
cNames << c->name();
layoutNames << l->name();
}
#endif
while ( !titleValid )
{
newTitle = QInputDialog::getText( parent,
@@ -7384,9 +7383,9 @@ bool QgisApp::uniqueLayoutTitle( QWidget *parent, QString &title, bool acceptEmp
newTitle = QgsProject::instance()->layoutManager()->generateUniqueTitle();
}
}
else if ( cNames.indexOf( newTitle, 1 ) >= 0 )
else if ( layoutNames.indexOf( newTitle, 1 ) >= 0 )
{
cNames[0] = QString(); // clear non-unique name
layoutNames[0] = QString(); // clear non-unique name
titleMsg = chooseMsg + "\n\n" + tr( "Title already exists!" );
}
else
@@ -106,6 +106,7 @@
<addaction name="mActionLayoutManager"/>
<addaction name="separator"/>
<addaction name="mActionLayoutProperties"/>
<addaction name="mActionRenameLayout"/>
<addaction name="mActionAddPages"/>
<addaction name="separator"/>
<addaction name="mActionLoadFromTemplate"/>
@@ -1151,6 +1152,14 @@
<string>Layout manager</string>
</property>
</action>
<action name="mActionRenameLayout">
<property name="text">
<string>Rename Layout…</string>
</property>
<property name="toolTip">
<string>Rename layout</string>
</property>
</action>
</widget>
<resources>
<include location="../../../images/images.qrc"/>

0 comments on commit 88682b2

Please sign in to comment.