From 0b9662090378ac5fb12d9d560157c1018cf6ced5 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Wed, 2 Oct 2024 09:41:26 +1000 Subject: [PATCH] Make "Page Properties" action set properties for visible page And reflect which page it refers to in the action text --- src/app/layout/qgslayoutdesignerdialog.cpp | 18 ++++++++++++++++-- src/app/layout/qgslayoutdesignerdialog.h | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/app/layout/qgslayoutdesignerdialog.cpp b/src/app/layout/qgslayoutdesignerdialog.cpp index 381f0d6fc3dd..a7945a00d18b 100644 --- a/src/app/layout/qgslayoutdesignerdialog.cpp +++ b/src/app/layout/qgslayoutdesignerdialog.cpp @@ -373,6 +373,7 @@ QgsLayoutDesignerDialog::QgsLayoutDesignerDialog( QWidget *parent, Qt::WindowFla mHorizontalRuler->setContextMenu( rulerMenu ); mVerticalRuler->setContextMenu( rulerMenu ); + connect( mLayoutMenu, &QMenu::aboutToShow, this, &QgsLayoutDesignerDialog::layoutMenuAboutToShow ); connect( mActionRefreshView, &QAction::triggered, this, &QgsLayoutDesignerDialog::refreshLayout ); connect( mActionSaveProject, &QAction::triggered, this, &QgsLayoutDesignerDialog::saveProject ); connect( mActionNewLayout, &QAction::triggered, this, &QgsLayoutDesignerDialog::newLayout ); @@ -1924,9 +1925,10 @@ void QgsLayoutDesignerDialog::addPages() void QgsLayoutDesignerDialog::showPageProperties() { - QgsLayoutItemPage *page = mLayout->pageCollection()->page( 0 ); + if ( !mLayout ) + return; - if ( page ) + if ( QgsLayoutItemPage *page = mLayout->pageCollection()->page( mView->currentPage() ) ) { showItemOptions( page, true ); } @@ -5138,3 +5140,15 @@ void QgsLayoutDesignerDialog::onItemDestroyed( QObject *item ) delete mItemPropertiesStack->takeMainPanel(); } } + +void QgsLayoutDesignerDialog::layoutMenuAboutToShow() +{ + if ( mLayout && mLayout->pageCollection()->pageCount() > 1 ) + { + mActionPageProperties->setText( tr( "Page %1 Properties…" ).arg( mView->currentPage() + 1 ) ); + } + else + { + mActionPageProperties->setText( tr( "Page Properties…" ) ); + } +} diff --git a/src/app/layout/qgslayoutdesignerdialog.h b/src/app/layout/qgslayoutdesignerdialog.h index 97325944062d..ec6a7715ec11 100644 --- a/src/app/layout/qgslayoutdesignerdialog.h +++ b/src/app/layout/qgslayoutdesignerdialog.h @@ -427,6 +427,7 @@ class QgsLayoutDesignerDialog: public QMainWindow, public Ui::QgsLayoutDesignerB void onMapPreviewRefreshed(); void onItemAdded( QgsLayoutItem *item ); void onItemDestroyed( QObject *item ); + void layoutMenuAboutToShow(); private: