Skip to content
Permalink
Browse files
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)
  • 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.
@@ -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 );

@@ -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 )
@@ -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 );
} );
}
@@ -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 )
@@ -350,7 +351,7 @@ void QgsMapCanvasDockWidget::mapExtentChanged()
mScaleFactorWidget->setValue( newScaleFactor );
}

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

@@ -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 );
@@ -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;
@@ -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( "×" ) );
@@ -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 );
@@ -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;
@@ -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;
@@ -41,7 +41,6 @@
<property name="floatable">
<bool>false</bool>
</property>
<addaction name="mActionSyncView"/>
<addaction name="mActionZoomFullExtent"/>
<addaction name="mActionZoomToSelected"/>
<addaction name="mActionZoomToLayer"/>
@@ -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>
@@ -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.