Skip to content

Commit

Permalink
[needs-docs] Double clicking a layout in the layout manager opens
Browse files Browse the repository at this point in the history
the layout, instead of renaming it

Because there's already a dedicated rename button, and opening
is a far more common operation than renaming.

Signed off by @nirvn
  • Loading branch information
nyalldawson committed Dec 12, 2017
1 parent c0f4d0f commit 253b9d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/app/layout/qgslayoutmanagerdialog.cpp
Expand Up @@ -68,6 +68,7 @@ QgsLayoutManagerDialog::QgsLayoutManagerDialog( QWidget *parent, Qt::WindowFlags
connect( mButtonBox, &QDialogButtonBox::rejected, this, &QWidget::close );
connect( mLayoutListView->selectionModel(), &QItemSelectionModel::selectionChanged,
this, &QgsLayoutManagerDialog::toggleButtons );
connect( mLayoutListView, &QListView::doubleClicked, this, &QgsLayoutManagerDialog::itemDoubleClicked );

mShowButton = mButtonBox->addButton( tr( "&Show" ), QDialogButtonBox::ActionRole );
connect( mShowButton, &QAbstractButton::clicked, this, &QgsLayoutManagerDialog::showClicked );
Expand Down Expand Up @@ -435,6 +436,14 @@ void QgsLayoutManagerDialog::renameClicked()
currentLayout->setName( newTitle );
}

void QgsLayoutManagerDialog::itemDoubleClicked( const QModelIndex &index )
{
if ( QgsLayout *l = mModel->layoutFromIndex( index ) )
{
QgisApp::instance()->openLayoutDesignerDialog( l );
}
}

//
// QgsLayoutManagerModel
//
Expand Down Expand Up @@ -520,7 +529,7 @@ bool QgsLayoutManagerModel::setData( const QModelIndex &index, const QVariant &v
Qt::ItemFlags QgsLayoutManagerModel::flags( const QModelIndex &index ) const
{
Qt::ItemFlags flags = QAbstractListModel::flags( index );

#if 0 // double click is now used for opening the layout
if ( index.isValid() )
{
return flags | Qt::ItemIsEditable;
Expand All @@ -529,6 +538,8 @@ Qt::ItemFlags QgsLayoutManagerModel::flags( const QModelIndex &index ) const
{
return flags;
}
#endif
return flags;
}

QgsLayout *QgsLayoutManagerModel::layoutFromIndex( const QModelIndex &index ) const
Expand Down
1 change: 1 addition & 0 deletions src/app/layout/qgslayoutmanagerdialog.h
Expand Up @@ -117,6 +117,7 @@ class QgsLayoutManagerDialog: public QDialog, private Ui::QgsLayoutManagerBase
//! Duplicate layout
void duplicateClicked();
void renameClicked();
void itemDoubleClicked( const QModelIndex &index );
};

#endif // QGSLAYOUTMANAGERDIALOG_H

0 comments on commit 253b9d9

Please sign in to comment.