Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[needs-docs] Make the Digitize with Curve and Streaming Digitize acti…
…ons sit in the same drop down group
  • Loading branch information
nyalldawson committed Mar 11, 2021
1 parent 5260105 commit c5a0d1d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/app/maptools/qgsappmaptools.cpp
Expand Up @@ -92,7 +92,7 @@ QgsStreamDigitizingSettingsAction::QgsStreamDigitizingSettingsAction( QWidget *p
mStreamToleranceSpinBox->setClearValue( 2 );
mStreamToleranceSpinBox->setValue( defaultTolerance );

QLabel *label = new QLabel( tr( "Tolerance" ) );
QLabel *label = new QLabel( tr( "Streaming Tolerance" ) );
gLayout->addWidget( label, 1, 0 );
gLayout->addWidget( mStreamToleranceSpinBox, 1, 1 );
connect( mStreamToleranceSpinBox, qgis::overload<int>::of( &QgsSpinBox::valueChanged ), this, [ = ]( int value )
Expand Down
39 changes: 32 additions & 7 deletions src/app/qgisapp.cpp
Expand Up @@ -3209,12 +3209,25 @@ void QgisApp::createToolBars()
static_cast< void ( QgsDoubleSpinBox::* )( double ) >( &QgsDoubleSpinBox::valueChanged ),
this, [ = ]( double v ) { mTracer->setOffset( v ); } );

QToolButton *bt = new QToolButton();
bt->setPopupMode( QToolButton::MenuButtonPopup );
bt->addAction( mActionStreamDigitize );
bt->addAction( mMapTools->streamDigitizingSettingsAction() );
bt->setDefaultAction( mActionStreamDigitize );
mAdvancedDigitizeToolBar->insertWidget( mAdvancedDigitizeToolBar->actions().at( 0 ), bt );
mDigitizeModeToolButton = new QToolButton();
mDigitizeModeToolButton->setPopupMode( QToolButton::MenuButtonPopup );
QMenu *digitizeMenu = new QMenu();
digitizeMenu->addAction( mActionDigitizeWithCurve );
digitizeMenu->addAction( mActionStreamDigitize );
digitizeMenu->addSeparator();
digitizeMenu->addAction( mMapTools->streamDigitizingSettingsAction() );
mDigitizeModeToolButton->setMenu( digitizeMenu );

switch ( settings.value( QStringLiteral( "UI/digitizeTechnique" ), 0 ).toInt() )
{
case 0:
mDigitizeModeToolButton->setDefaultAction( mActionDigitizeWithCurve );
break;
case 1:
mDigitizeModeToolButton->setDefaultAction( mActionStreamDigitize );
break;
}
mAdvancedDigitizeToolBar->insertWidget( mAdvancedDigitizeToolBar->actions().at( 0 ), mDigitizeModeToolButton );

QList<QAction *> toolbarMenuActions;
// Set action names so that they can be used in customization
Expand All @@ -3231,7 +3244,7 @@ void QgisApp::createToolBars()
mToolbarMenu->addActions( toolbarMenuActions );

// advanced selection tool button
bt = new QToolButton( mSelectionToolBar );
QToolButton *bt = new QToolButton( mSelectionToolBar );
bt->setPopupMode( QToolButton::MenuButtonPopup );
bt->addAction( mActionSelectByForm );
bt->addAction( mActionSelectByExpression );
Expand Down Expand Up @@ -10130,6 +10143,12 @@ void QgisApp::enableDigitizeWithCurve( bool enable )
enableStreamDigitizing( false );
}

if ( enable )
{
mDigitizeModeToolButton->setDefaultAction( mActionDigitizeWithCurve );
QgsSettings().setValue( QStringLiteral( "UI/digitizeTechnique" ), 0 );
}

const QList< QgsMapToolCapture * > captureTools = mMapTools->captureTools();
for ( QgsMapToolCapture *tool : captureTools )
{
Expand All @@ -10148,6 +10167,12 @@ void QgisApp::enableStreamDigitizing( bool enable )
enableDigitizeWithCurve( false );
}

if ( enable )
{
mDigitizeModeToolButton->setDefaultAction( mActionStreamDigitize );
QgsSettings().setValue( QStringLiteral( "UI/digitizeTechnique" ), 1 );
}

const QList< QgsMapToolCapture * > captureTools = mMapTools->captureTools();
for ( QgsMapToolCapture *tool : captureTools )
{
Expand Down
2 changes: 2 additions & 0 deletions src/app/qgisapp.h
Expand Up @@ -2531,6 +2531,8 @@ class APP_EXPORT QgisApp : public QMainWindow, private Ui::MainWindow
QgsDockWidget *mDevToolsDock = nullptr;
QgsDevToolsPanelWidget *mDevToolsWidget = nullptr;

QToolButton *mDigitizeModeToolButton = nullptr;

//! Persistent tile scale slider
QgsTileScaleWidget *mpTileScaleWidget = nullptr;

Expand Down
3 changes: 1 addition & 2 deletions src/ui/qgisapp.ui
Expand Up @@ -521,7 +521,6 @@
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="mActionDigitizeWithCurve"/>
<addaction name="mActionRotateFeature"/>
<addaction name="mActionScaleFeature"/>
<addaction name="mActionSimplifyFeature"/>
Expand Down Expand Up @@ -3468,7 +3467,7 @@ Shows placeholders for labels which could not be placed, e.g. due to overlaps wi
<normaloff>:/images/themes/default/mActionDigitizeWithCurve.svg</normaloff>:/images/themes/default/mActionDigitizeWithCurve.svg</iconset>
</property>
<property name="text">
<string>Digitize with curve</string>
<string>Digitize with Curve</string>
</property>
<property name="toolTip">
<string>Digitize with curve</string>
Expand Down

0 comments on commit c5a0d1d

Please sign in to comment.