3030#include " qgsstyle.h"
3131#include " qgslayoutundostack.h"
3232#include " qgslayoutatlas.h"
33+ #include " qgslayoutdesignerinterface.h"
3334#include < QMenu>
3435#include < QMessageBox>
3536
@@ -41,9 +42,9 @@ QgsLayoutMapWidget::QgsLayoutMapWidget( QgsLayoutItemMap *item )
4142
4243 setupUi ( this );
4344 connect ( mScaleLineEdit , &QLineEdit::editingFinished, this , &QgsLayoutMapWidget::mScaleLineEdit_editingFinished );
44- connect ( mSetToMapCanvasExtentButton , &QPushButton::clicked , this , &QgsLayoutMapWidget::mSetToMapCanvasExtentButton_clicked );
45- connect ( mViewExtentInCanvasButton , &QPushButton::clicked , this , &QgsLayoutMapWidget::mViewExtentInCanvasButton_clicked );
46- connect ( mUpdatePreviewButton , &QPushButton::clicked , this , &QgsLayoutMapWidget::mUpdatePreviewButton_clicked );
45+ connect ( mActionSetToCanvasExtent , &QAction::triggered , this , &QgsLayoutMapWidget::setToMapCanvasExtent );
46+ connect ( mActionViewExtentInCanvas , &QAction::triggered , this , &QgsLayoutMapWidget::viewExtentInCanvas );
47+ connect ( mActionUpdatePreview , &QAction::triggered , this , &QgsLayoutMapWidget::updatePreview );
4748 connect ( mFollowVisibilityPresetCheckBox , &QCheckBox::stateChanged, this , &QgsLayoutMapWidget::mFollowVisibilityPresetCheckBox_stateChanged );
4849 connect ( mKeepLayerListCheckBox , &QCheckBox::stateChanged, this , &QgsLayoutMapWidget::mKeepLayerListCheckBox_stateChanged );
4950 connect ( mKeepLayerStylesCheckBox , &QCheckBox::stateChanged, this , &QgsLayoutMapWidget::mKeepLayerStylesCheckBox_stateChanged );
@@ -77,9 +78,12 @@ QgsLayoutMapWidget::QgsLayoutMapWidget( QgsLayoutItemMap *item )
7778 connect ( mOverviewListWidget , &QListWidget::itemChanged, this , &QgsLayoutMapWidget::mOverviewListWidget_itemChanged );
7879 connect ( mLabelSettingsButton , &QPushButton::clicked, this , &QgsLayoutMapWidget::showLabelSettings );
7980
81+ connect ( mActionMoveContent , &QAction::triggered, this , &QgsLayoutMapWidget::switchToMoveContentTool );
8082 setPanelTitle ( tr ( " Map Properties" ) );
8183 mMapRotationSpinBox ->setClearValue ( 0 );
8284
85+ mDockToolbar ->setIconSize ( QgisApp::instance ()->iconSize ( true ) );
86+
8387 // add widget for general composer item properties
8488 mItemPropertiesWidget = new QgsLayoutItemPropertiesWidget ( this , item );
8589 mainLayout->addWidget ( mItemPropertiesWidget );
@@ -163,6 +167,11 @@ void QgsLayoutMapWidget::setReportTypeString( const QString &string )
163167 mAtlasPredefinedScaleRadio ->setToolTip ( tr ( " Use one of the predefined scales of the project where the %1 feature best fits." ).arg ( string ) );
164168}
165169
170+ void QgsLayoutMapWidget::setDesignerInterface ( QgsLayoutDesignerInterface *iface )
171+ {
172+ mInterface = iface;
173+ }
174+
166175bool QgsLayoutMapWidget::setNewItem ( QgsLayoutItem *item )
167176{
168177 if ( item->type () != QgsLayoutItemRegistry::LayoutMap )
@@ -352,6 +361,12 @@ void QgsLayoutMapWidget::showLabelSettings()
352361 openPanel ( w );
353362}
354363
364+ void QgsLayoutMapWidget::switchToMoveContentTool ()
365+ {
366+ if ( mInterface )
367+ mInterface ->activateTool ( QgsLayoutDesignerInterface::ToolMoveItemContent );
368+ }
369+
355370void QgsLayoutMapWidget::mAtlasCheckBox_toggled ( bool checked )
356371{
357372 if ( !mMapItem )
@@ -512,7 +527,7 @@ void QgsLayoutMapWidget::rotationChanged( double value )
512527 mMapItem ->invalidateCache ();
513528}
514529
515- void QgsLayoutMapWidget::mSetToMapCanvasExtentButton_clicked ()
530+ void QgsLayoutMapWidget::setToMapCanvasExtent ()
516531{
517532 if ( !mMapItem )
518533 {
@@ -543,7 +558,7 @@ void QgsLayoutMapWidget::mSetToMapCanvasExtentButton_clicked()
543558 mMapItem ->layout ()->undoStack ()->endCommand ();
544559}
545560
546- void QgsLayoutMapWidget::mViewExtentInCanvasButton_clicked ()
561+ void QgsLayoutMapWidget::viewExtentInCanvas ()
547562{
548563 if ( !mMapItem )
549564 {
@@ -779,8 +794,8 @@ void QgsLayoutMapWidget::blockAllSignals( bool b )
779794 mFollowVisibilityPresetCombo ->blockSignals ( b );
780795 mKeepLayerListCheckBox ->blockSignals ( b );
781796 mKeepLayerStylesCheckBox ->blockSignals ( b );
782- mSetToMapCanvasExtentButton ->blockSignals ( b );
783- mUpdatePreviewButton ->blockSignals ( b );
797+ mActionSetToCanvasExtent ->blockSignals ( b );
798+ mActionUpdatePreview ->blockSignals ( b );
784799
785800 blockOverviewItemsSignals ( b );
786801}
@@ -830,7 +845,7 @@ void QgsLayoutMapWidget::handleChangedAnnotationDisplay( QgsLayoutItemMapGrid::B
830845 mMapItem ->layout ()->undoStack ()->endCommand ();
831846}
832847
833- void QgsLayoutMapWidget::mUpdatePreviewButton_clicked ()
848+ void QgsLayoutMapWidget::updatePreview ()
834849{
835850 if ( !mMapItem )
836851 {
0 commit comments