Skip to content
Permalink
Browse files

Merge pull request #5038 from nyalldawson/canvas_dock_tweaks

Canvas dock tweaks
  • Loading branch information
nyalldawson committed Aug 18, 2017
2 parents c188578 + e8ad0ba commit 0c46ac4030730593794e0c64c36adf6747622042
Showing with 56 additions and 36 deletions.
  1. +27 −20 src/app/qgsmapcanvasdockwidget.cpp
  2. +3 −0 src/app/qgsmapcanvasdockwidget.h
  3. +26 −16 src/ui/qgsmapcanvasdockwidgetbase.ui
@@ -44,6 +44,8 @@ QgsMapCanvasDockWidget::QgsMapCanvasDockWidget( const QString &name, QWidget *pa
static_cast< QVBoxLayout * >( mContents->layout() )->setSpacing( 0 );

setWindowTitle( name );
mToolbar->setIconSize( QgisApp::instance()->iconSize( true ) );

mMapCanvas = new QgsMapCanvas( this );
mXyMarker = new QgsVertexMarker( mMapCanvas );
mXyMarker->setIconType( QgsVertexMarker::ICON_CIRCLE );
@@ -65,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 );

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

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

@@ -475,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 );
@@ -493,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;
@@ -514,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( "×" ) );
@@ -534,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 0c46ac4

Please sign in to comment.
You can’t perform that action at this time.