diff --git a/src/app/qgslayerstylingwidget.cpp b/src/app/qgslayerstylingwidget.cpp
index f87358c5a808..ed18fd191873 100644
--- a/src/app/qgslayerstylingwidget.cpp
+++ b/src/app/qgslayerstylingwidget.cpp
@@ -81,6 +81,10 @@ QgsLayerStylingWidget::QgsLayerStylingWidget( QgsMapCanvas *canvas, QgsMessageBa
connect( QgsProject::instance(), static_cast < void ( QgsProject::* )( QgsMapLayer * ) > ( &QgsProject::layerWillBeRemoved ), this, &QgsLayerStylingWidget::layerAboutToBeRemoved );
+ QgsSettings settings;
+ mLiveApplyCheck->setChecked( settings.value( QStringLiteral( "UI/autoApplyStyling" ), true ).toBool() );
+ mButtonBox->button( QDialogButtonBox::Apply )->setEnabled( !mLiveApplyCheck->isChecked() );
+
mAutoApplyTimer = new QTimer( this );
mAutoApplyTimer->setSingleShot( true );
@@ -100,7 +104,9 @@ QgsLayerStylingWidget::QgsLayerStylingWidget( QgsMapCanvas *canvas, QgsMessageBa
connect( mAutoApplyTimer, &QTimer::timeout, this, &QgsLayerStylingWidget::apply );
connect( mOptionsListWidget, &QListWidget::currentRowChanged, this, &QgsLayerStylingWidget::updateCurrentWidgetLayer );
+ connect( mButtonBox->button( QDialogButtonBox::Apply ), &QAbstractButton::clicked, this, &QgsLayerStylingWidget::apply );
connect( mLayerCombo, &QgsMapLayerComboBox::layerChanged, this, &QgsLayerStylingWidget::setLayer );
+ connect( mLiveApplyCheck, &QAbstractButton::toggled, this, &QgsLayerStylingWidget::liveApplyToggled );
mLayerCombo->setFilters( Qgis::LayerFilter::HasGeometry
| Qgis::LayerFilter::RasterLayer
@@ -391,7 +397,7 @@ void QgsLayerStylingWidget::apply()
void QgsLayerStylingWidget::autoApply()
{
- if ( !mBlockAutoApply )
+ if ( mLiveApplyCheck->isChecked() && !mBlockAutoApply )
{
mAutoApplyTimer->start( 100 );
}
@@ -846,6 +852,14 @@ void QgsLayerStylingWidget::layerAboutToBeRemoved( QgsMapLayer *layer )
}
}
+void QgsLayerStylingWidget::liveApplyToggled( bool liveUpdateEnabled )
+{
+ QgsSettings settings;
+ settings.setValue( QStringLiteral( "UI/autoApplyStyling" ), liveUpdateEnabled );
+
+ mButtonBox->button( QDialogButtonBox::Apply )->setEnabled( !liveUpdateEnabled );
+}
+
void QgsLayerStylingWidget::pushUndoItem( const QString &name, bool triggerRepaint )
{
QString errorMsg;
diff --git a/src/app/qgslayerstylingwidget.h b/src/app/qgslayerstylingwidget.h
index b41d2f66da98..32f06ffa1f21 100644
--- a/src/app/qgslayerstylingwidget.h
+++ b/src/app/qgslayerstylingwidget.h
@@ -153,6 +153,7 @@ class APP_EXPORT QgsLayerStylingWidget : public QWidget, private Ui::QgsLayerSty
private slots:
void layerAboutToBeRemoved( QgsMapLayer *layer );
+ void liveApplyToggled( bool liveUpdateEnabled );
private:
void pushUndoItem( const QString &name, bool triggerRepaint = true );
diff --git a/src/ui/qgsmapstylingwidgetbase.ui b/src/ui/qgsmapstylingwidgetbase.ui
index 08cfa36efd96..4b2fcd0e219a 100644
--- a/src/ui/qgsmapstylingwidgetbase.ui
+++ b/src/ui/qgsmapstylingwidgetbase.ui
@@ -39,7 +39,7 @@
Not supported or no layer
- Qt::AlignmentFlag::AlignCenter
+ Qt::AlignCenter
@@ -76,7 +76,7 @@
- QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon
+ QComboBox::AdjustToMinimumContentsLengthWithIcon
@@ -121,7 +121,7 @@
-
- Qt::Orientation::Horizontal
+ Qt::Horizontal
@@ -131,15 +131,44 @@
+ -
+
+
+ If checked, the map canvas will automatically update whenever an option has been changed without the requirement to click Apply
+
+
+ Live update
+
+
+ true
+
+
+ false
+
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ QDialogButtonBox::Apply
+
+
+
-
- QFrame::Shape::NoFrame
+ QFrame::NoFrame
- QFrame::Shadow::Raised
+ QFrame::Raised
@@ -172,19 +201,19 @@
- QFrame::Shape::NoFrame
+ QFrame::NoFrame
- Qt::ScrollBarPolicy::ScrollBarAlwaysOff
+ Qt::ScrollBarAlwaysOff
- QAbstractItemView::EditTrigger::NoEditTriggers
+ QAbstractItemView::NoEditTriggers
- Qt::TextElideMode::ElideNone
+ Qt::ElideNone
- QListView::ResizeMode::Adjust
+ QListView::Adjust
true
@@ -217,6 +246,7 @@
mLayerCombo
mUndoButton
mRedoButton
+ mLiveApplyCheck