Skip to content

Commit e8ad0ba

Browse files
committed
Move "sync extent" canvas view option to map settings menu
This means all the settings are collected together, and the dock toolbar just contains navigation actions. (followup feedback from hackfest demo)
1 parent 2d441a8 commit e8ad0ba

File tree

3 files changed

+54
-36
lines changed

3 files changed

+54
-36
lines changed

src/app/qgsmapcanvasdockwidget.cpp

+25-20
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa
6767

6868
mMainWidget->layout()->addWidget( mMapCanvas );
6969

70-
connect( mActionSyncView, &QAction::toggled, this, [ = ]
71-
{
72-
syncViewCenter( mMainCanvas );
73-
} );
74-
7570
mMenu = new QMenu();
7671
connect( mMenu, &QMenu::aboutToShow, this, &QgsMapCanvasDockWidget::menuAboutToShow );
7772

@@ -124,12 +119,18 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa
124119
mActionShowLabels->setChecked( true );
125120
connect( mActionShowLabels, &QAction::toggled, this, &QgsMapCanvasDockWidget::showLabels );
126121

122+
mSyncExtentCheckBox = settingsAction->syncExtentCheckBox();
127123
mScaleCombo = settingsAction->scaleCombo();
128124
mRotationEdit = settingsAction->rotationSpinBox();
129125
mMagnificationEdit = settingsAction->magnifierSpinBox();
130126
mSyncScaleCheckBox = settingsAction->syncScaleCheckBox();
131127
mScaleFactorWidget = settingsAction->scaleFactorSpinBox();
132128

129+
connect( mSyncExtentCheckBox, &QCheckBox::toggled, this, [ = ]
130+
{
131+
syncViewCenter( mMainCanvas );
132+
} );
133+
133134
connect( mScaleCombo, &QgsScaleComboBox::scaleChanged, this, [ = ]( double scale )
134135
{
135136
if ( !mBlockScaleUpdate )
@@ -203,7 +204,7 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa
203204
connect( &mResizeTimer, &QTimer::timeout, this, [ = ]
204205
{
205206
mBlockExtentSync = false;
206-
if ( mActionSyncView->isChecked() )
207+
if ( mSyncExtentCheckBox->isChecked() )
207208
syncViewCenter( mMainCanvas );
208209
} );
209210
}
@@ -236,12 +237,12 @@ QgsMapCanvas *QgsMapCanvasDockWidget::mapCanvas()
236237

237238
void QgsMapCanvasDockWidget::setViewCenterSynchronized( bool enabled )
238239
{
239-
mActionSyncView->setChecked( enabled );
240+
mSyncExtentCheckBox->setChecked( enabled );
240241
}
241242

242243
bool QgsMapCanvasDockWidget::isViewCenterSynchronized() const
243244
{
244-
return mActionSyncView->isChecked();
245+
return mSyncExtentCheckBox->isChecked();
245246
}
246247

247248
void QgsMapCanvasDockWidget::setCursorMarkerVisible( bool visible )
@@ -350,7 +351,7 @@ void QgsMapCanvasDockWidget::mapExtentChanged()
350351
mScaleFactorWidget->setValue( newScaleFactor );
351352
}
352353

353-
if ( mActionSyncView->isChecked() )
354+
if ( mSyncExtentCheckBox->isChecked() )
354355
syncViewCenter( sourceCanvas );
355356
}
356357

@@ -477,11 +478,15 @@ QgsMapSettingsAction::QgsMapSettingsAction( QWidget *parent )
477478
{
478479
QGridLayout *gLayout = new QGridLayout();
479480
gLayout->setContentsMargins( 3, 2, 3, 2 );
481+
482+
mSyncExtentCheckBox = new QCheckBox( tr( "Synchronize View Center with Main Map" ) );
483+
gLayout->addWidget( mSyncExtentCheckBox, 0, 0, 1, 2 );
484+
480485
QLabel *label = new QLabel( tr( "Scale" ) );
481-
gLayout->addWidget( label, 0, 0 );
486+
gLayout->addWidget( label, 1, 0 );
482487

483488
mScaleCombo = new QgsScaleComboBox();
484-
gLayout->addWidget( mScaleCombo, 0, 1 );
489+
gLayout->addWidget( mScaleCombo, 1, 1 );
485490

486491
mRotationWidget = new QgsDoubleSpinBox();
487492
mRotationWidget->setClearValue( 0.0 );
@@ -495,8 +500,8 @@ QgsMapSettingsAction::QgsMapSettingsAction( QWidget *parent )
495500
mRotationWidget->setToolTip( tr( "Current clockwise map rotation in degrees" ) );
496501

497502
label = new QLabel( tr( "Rotation" ) );
498-
gLayout->addWidget( label, 1, 0 );
499-
gLayout->addWidget( mRotationWidget, 1, 1 );
503+
gLayout->addWidget( label, 2, 0 );
504+
gLayout->addWidget( mRotationWidget, 2, 1 );
500505

501506
QgsSettings settings;
502507
int minimumFactor = 100 * QgsGuiUtils::CANVAS_MAGNIFICATION_MIN;
@@ -516,11 +521,11 @@ QgsMapSettingsAction::QgsMapSettingsAction( QWidget *parent )
516521
mMagnifierWidget->setValue( defaultFactor );
517522

518523
label = new QLabel( tr( "Magnification" ) );
519-
gLayout->addWidget( label, 2, 0 );
520-
gLayout->addWidget( mMagnifierWidget, 2, 1 );
524+
gLayout->addWidget( label, 3, 0 );
525+
gLayout->addWidget( mMagnifierWidget, 3, 1 );
521526

522-
mSyncScaleCheckBox = new QCheckBox( tr( "Synchronize scale" ) );
523-
gLayout->addWidget( mSyncScaleCheckBox, 3, 0, 1, 2 );
527+
mSyncScaleCheckBox = new QCheckBox( tr( "Synchronize Scale" ) );
528+
gLayout->addWidget( mSyncScaleCheckBox, 4, 0, 1, 2 );
524529

525530
mScaleFactorWidget = new QgsDoubleSpinBox();
526531
mScaleFactorWidget->setSuffix( trUtf8( "×" ) );
@@ -536,9 +541,9 @@ QgsMapSettingsAction::QgsMapSettingsAction( QWidget *parent )
536541

537542
connect( mSyncScaleCheckBox, &QCheckBox::toggled, mScaleFactorWidget, &QgsDoubleSpinBox::setEnabled );
538543

539-
label = new QLabel( tr( "Scale factor" ) );
540-
gLayout->addWidget( label, 4, 0 );
541-
gLayout->addWidget( mScaleFactorWidget, 4, 1 );
544+
label = new QLabel( tr( "Scale Factor" ) );
545+
gLayout->addWidget( label, 5, 0 );
546+
gLayout->addWidget( mScaleFactorWidget, 5, 1 );
542547

543548
QWidget *w = new QWidget();
544549
w->setLayout( gLayout );

src/app/qgsmapcanvasdockwidget.h

+3
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ class APP_EXPORT QgsMapCanvasDockWidget : public QgsDockWidget, private Ui::QgsM
157157
QgsMapCanvas *mMainCanvas = nullptr;
158158
QMenu *mMenu = nullptr;
159159
QList<QAction *> mMenuPresetActions;
160+
QCheckBox *mSyncExtentCheckBox = nullptr;
160161
QgsScaleComboBox *mScaleCombo = nullptr;
161162
QgsDoubleSpinBox *mRotationEdit = nullptr;
162163
QgsDoubleSpinBox *mMagnificationEdit = nullptr;
@@ -187,13 +188,15 @@ class QgsMapSettingsAction: public QWidgetAction
187188

188189
QgsMapSettingsAction( QWidget *parent = nullptr );
189190

191+
QCheckBox *syncExtentCheckBox() { return mSyncExtentCheckBox; }
190192
QgsScaleComboBox *scaleCombo() { return mScaleCombo; }
191193
QgsDoubleSpinBox *rotationSpinBox() { return mRotationWidget; }
192194
QgsDoubleSpinBox *magnifierSpinBox() { return mMagnifierWidget; }
193195
QgsDoubleSpinBox *scaleFactorSpinBox() { return mScaleFactorWidget; }
194196
QCheckBox *syncScaleCheckBox() { return mSyncScaleCheckBox; }
195197

196198
private:
199+
QCheckBox *mSyncExtentCheckBox = nullptr;
197200
QgsScaleComboBox *mScaleCombo = nullptr;
198201
QgsDoubleSpinBox *mRotationWidget = nullptr;
199202
QgsDoubleSpinBox *mMagnifierWidget = nullptr;

src/ui/qgsmapcanvasdockwidgetbase.ui

+26-16
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
<property name="floatable">
4242
<bool>false</bool>
4343
</property>
44-
<addaction name="mActionSyncView"/>
4544
<addaction name="mActionZoomFullExtent"/>
4645
<addaction name="mActionZoomToSelected"/>
4746
<addaction name="mActionZoomToLayer"/>
@@ -82,21 +81,6 @@
8281
<string>Set Map CRS</string>
8382
</property>
8483
</action>
85-
<action name="mActionSyncView">
86-
<property name="checkable">
87-
<bool>true</bool>
88-
</property>
89-
<property name="icon">
90-
<iconset resource="../../images/images.qrc">
91-
<normaloff>:/images/themes/default/mActionLockExtent.svg</normaloff>:/images/themes/default/mActionLockExtent.svg</iconset>
92-
</property>
93-
<property name="text">
94-
<string>Synchronize View</string>
95-
</property>
96-
<property name="toolTip">
97-
<string>Synchronize View Center with Main Map</string>
98-
</property>
99-
</action>
10084
<action name="mActionRename">
10185
<property name="text">
10286
<string>Rename View…</string>
@@ -178,6 +162,32 @@
178162
</customwidgets>
179163
<resources>
180164
<include location="../../images/images.qrc"/>
165+
<include location="../../images/images.qrc"/>
166+
<include location="../../images/images.qrc"/>
167+
<include location="../../images/images.qrc"/>
168+
<include location="../../images/images.qrc"/>
169+
<include location="../../images/images.qrc"/>
170+
<include location="../../images/images.qrc"/>
171+
<include location="../../images/images.qrc"/>
172+
<include location="../../images/images.qrc"/>
173+
<include location="../../images/images.qrc"/>
174+
<include location="../../images/images.qrc"/>
175+
<include location="../../images/images.qrc"/>
176+
<include location="../../images/images.qrc"/>
177+
<include location="../../images/images.qrc"/>
178+
<include location="../../images/images.qrc"/>
179+
<include location="../../images/images.qrc"/>
180+
<include location="../../images/images.qrc"/>
181+
<include location="../../images/images.qrc"/>
182+
<include location="../../images/images.qrc"/>
183+
<include location="../../images/images.qrc"/>
184+
<include location="../../images/images.qrc"/>
185+
<include location="../../images/images.qrc"/>
186+
<include location="../../images/images.qrc"/>
187+
<include location="../../images/images.qrc"/>
188+
<include location="../../images/images.qrc"/>
189+
<include location="../../images/images.qrc"/>
190+
<include location="../../images/images.qrc"/>
181191
</resources>
182192
<connections/>
183193
</ui>

0 commit comments

Comments
 (0)