Skip to content

Commit

Permalink
Move "sync extent" canvas view option to map settings menu
Browse files Browse the repository at this point in the history
This means all the settings are collected together, and the
dock toolbar just contains navigation actions.

(followup feedback from hackfest demo)
  • Loading branch information
nyalldawson committed Aug 17, 2017
1 parent 2d441a8 commit e8ad0ba
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 36 deletions.
45 changes: 25 additions & 20 deletions src/app/qgsmapcanvasdockwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,6 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa

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

connect( mActionSyncView, &QAction::toggled, this, [ = ]
{
syncViewCenter( mMainCanvas );
} );

mMenu = new QMenu();
connect( mMenu, &QMenu::aboutToShow, this, &QgsMapCanvasDockWidget::menuAboutToShow );

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

mSyncExtentCheckBox = settingsAction->syncExtentCheckBox();
mScaleCombo = settingsAction->scaleCombo();
mRotationEdit = settingsAction->rotationSpinBox();
mMagnificationEdit = settingsAction->magnifierSpinBox();
mSyncScaleCheckBox = settingsAction->syncScaleCheckBox();
mScaleFactorWidget = settingsAction->scaleFactorSpinBox();

connect( mSyncExtentCheckBox, &QCheckBox::toggled, this, [ = ]
{
syncViewCenter( mMainCanvas );
} );

connect( mScaleCombo, &QgsScaleComboBox::scaleChanged, this, [ = ]( double scale )
{
if ( !mBlockScaleUpdate )
Expand Down Expand Up @@ -203,7 +204,7 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa
connect( &mResizeTimer, &QTimer::timeout, this, [ = ]
{
mBlockExtentSync = false;
if ( mActionSyncView->isChecked() )
if ( mSyncExtentCheckBox->isChecked() )
syncViewCenter( mMainCanvas );
} );
}
Expand Down Expand Up @@ -236,12 +237,12 @@ QgsMapCanvas *QgsMapCanvasDockWidget::mapCanvas()

void QgsMapCanvasDockWidget::setViewCenterSynchronized( bool enabled )
{
mActionSyncView->setChecked( enabled );
mSyncExtentCheckBox->setChecked( enabled );
}

bool QgsMapCanvasDockWidget::isViewCenterSynchronized() const
{
return mActionSyncView->isChecked();
return mSyncExtentCheckBox->isChecked();
}

void QgsMapCanvasDockWidget::setCursorMarkerVisible( bool visible )
Expand Down Expand Up @@ -350,7 +351,7 @@ void QgsMapCanvasDockWidget::mapExtentChanged()
mScaleFactorWidget->setValue( newScaleFactor );
}

if ( mActionSyncView->isChecked() )
if ( mSyncExtentCheckBox->isChecked() )
syncViewCenter( sourceCanvas );
}

Expand Down Expand Up @@ -477,11 +478,15 @@ QgsMapSettingsAction::QgsMapSettingsAction( QWidget *parent )
{
QGridLayout *gLayout = new QGridLayout();
gLayout->setContentsMargins( 3, 2, 3, 2 );

mSyncExtentCheckBox = new QCheckBox( tr( "Synchronize View Center with Main Map" ) );
gLayout->addWidget( mSyncExtentCheckBox, 0, 0, 1, 2 );

QLabel *label = new QLabel( tr( "Scale" ) );
gLayout->addWidget( label, 0, 0 );
gLayout->addWidget( label, 1, 0 );

mScaleCombo = new QgsScaleComboBox();
gLayout->addWidget( mScaleCombo, 0, 1 );
gLayout->addWidget( mScaleCombo, 1, 1 );

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

label = new QLabel( tr( "Rotation" ) );
gLayout->addWidget( label, 1, 0 );
gLayout->addWidget( mRotationWidget, 1, 1 );
gLayout->addWidget( label, 2, 0 );
gLayout->addWidget( mRotationWidget, 2, 1 );

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

label = new QLabel( tr( "Magnification" ) );
gLayout->addWidget( label, 2, 0 );
gLayout->addWidget( mMagnifierWidget, 2, 1 );
gLayout->addWidget( label, 3, 0 );
gLayout->addWidget( mMagnifierWidget, 3, 1 );

mSyncScaleCheckBox = new QCheckBox( tr( "Synchronize scale" ) );
gLayout->addWidget( mSyncScaleCheckBox, 3, 0, 1, 2 );
mSyncScaleCheckBox = new QCheckBox( tr( "Synchronize Scale" ) );
gLayout->addWidget( mSyncScaleCheckBox, 4, 0, 1, 2 );

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

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

label = new QLabel( tr( "Scale factor" ) );
gLayout->addWidget( label, 4, 0 );
gLayout->addWidget( mScaleFactorWidget, 4, 1 );
label = new QLabel( tr( "Scale Factor" ) );
gLayout->addWidget( label, 5, 0 );
gLayout->addWidget( mScaleFactorWidget, 5, 1 );

QWidget *w = new QWidget();
w->setLayout( gLayout );
Expand Down
3 changes: 3 additions & 0 deletions src/app/qgsmapcanvasdockwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ class APP_EXPORT QgsMapCanvasDockWidget : public QgsDockWidget, private Ui::QgsM
QgsMapCanvas *mMainCanvas = nullptr;
QMenu *mMenu = nullptr;
QList<QAction *> mMenuPresetActions;
QCheckBox *mSyncExtentCheckBox = nullptr;
QgsScaleComboBox *mScaleCombo = nullptr;
QgsDoubleSpinBox *mRotationEdit = nullptr;
QgsDoubleSpinBox *mMagnificationEdit = nullptr;
Expand Down Expand Up @@ -187,13 +188,15 @@ class QgsMapSettingsAction: public QWidgetAction

QgsMapSettingsAction( QWidget *parent = nullptr );

QCheckBox *syncExtentCheckBox() { return mSyncExtentCheckBox; }
QgsScaleComboBox *scaleCombo() { return mScaleCombo; }
QgsDoubleSpinBox *rotationSpinBox() { return mRotationWidget; }
QgsDoubleSpinBox *magnifierSpinBox() { return mMagnifierWidget; }
QgsDoubleSpinBox *scaleFactorSpinBox() { return mScaleFactorWidget; }
QCheckBox *syncScaleCheckBox() { return mSyncScaleCheckBox; }

private:
QCheckBox *mSyncExtentCheckBox = nullptr;
QgsScaleComboBox *mScaleCombo = nullptr;
QgsDoubleSpinBox *mRotationWidget = nullptr;
QgsDoubleSpinBox *mMagnifierWidget = nullptr;
Expand Down
42 changes: 26 additions & 16 deletions src/ui/qgsmapcanvasdockwidgetbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
<property name="floatable">
<bool>false</bool>
</property>
<addaction name="mActionSyncView"/>
<addaction name="mActionZoomFullExtent"/>
<addaction name="mActionZoomToSelected"/>
<addaction name="mActionZoomToLayer"/>
Expand Down Expand Up @@ -82,21 +81,6 @@
<string>Set Map CRS</string>
</property>
</action>
<action name="mActionSyncView">
<property name="checkable">
<bool>true</bool>
</property>
<property name="icon">
<iconset resource="../../images/images.qrc">
<normaloff>:/images/themes/default/mActionLockExtent.svg</normaloff>:/images/themes/default/mActionLockExtent.svg</iconset>
</property>
<property name="text">
<string>Synchronize View</string>
</property>
<property name="toolTip">
<string>Synchronize View Center with Main Map</string>
</property>
</action>
<action name="mActionRename">
<property name="text">
<string>Rename View…</string>
Expand Down Expand Up @@ -178,6 +162,32 @@
</customwidgets>
<resources>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
<include location="../../images/images.qrc"/>
</resources>
<connections/>
</ui>

0 comments on commit e8ad0ba

Please sign in to comment.