Skip to content

Commit

Permalink
Revert "Always enable Live Update in layer styling dock"
Browse files Browse the repository at this point in the history
This reverts commit 5d11440.
  • Loading branch information
nyalldawson committed Aug 30, 2024
1 parent 9e08187 commit 2215a8c
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 11 deletions.
16 changes: 15 additions & 1 deletion src/app/qgslayerstylingwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Expand All @@ -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
Expand Down Expand Up @@ -391,7 +397,7 @@ void QgsLayerStylingWidget::apply()

void QgsLayerStylingWidget::autoApply()
{
if ( !mBlockAutoApply )
if ( mLiveApplyCheck->isChecked() && !mBlockAutoApply )
{
mAutoApplyTimer->start( 100 );
}
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/app/qgslayerstylingwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
50 changes: 40 additions & 10 deletions src/ui/qgsmapstylingwidgetbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<string>Not supported or no layer</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
<set>Qt::AlignCenter</set>
</property>
</widget>
</item>
Expand Down Expand Up @@ -76,7 +76,7 @@
</sizepolicy>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon</enum>
<enum>QComboBox::AdjustToMinimumContentsLengthWithIcon</enum>
</property>
</widget>
</item>
Expand Down Expand Up @@ -121,7 +121,7 @@
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand All @@ -131,15 +131,44 @@
</property>
</spacer>
</item>
<item>
<widget class="QCheckBox" name="mLiveApplyCheck">
<property name="toolTip">
<string>If checked, the map canvas will automatically update whenever an option has been changed without the requirement to click Apply</string>
</property>
<property name="text">
<string>Live update</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<property name="autoRepeat">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="mButtonBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Apply</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0" rowspan="2">
<widget class="QFrame" name="mOptionsListFrame">
<property name="frameShape">
<enum>QFrame::Shape::NoFrame</enum>
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Shadow::Raised</enum>
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
Expand Down Expand Up @@ -172,19 +201,19 @@
</size>
</property>
<property name="frameShape">
<enum>QFrame::Shape::NoFrame</enum>
<enum>QFrame::NoFrame</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarPolicy::ScrollBarAlwaysOff</enum>
<enum>Qt::ScrollBarAlwaysOff</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::EditTrigger::NoEditTriggers</set>
<set>QAbstractItemView::NoEditTriggers</set>
</property>
<property name="textElideMode">
<enum>Qt::TextElideMode::ElideNone</enum>
<enum>Qt::ElideNone</enum>
</property>
<property name="resizeMode">
<enum>QListView::ResizeMode::Adjust</enum>
<enum>QListView::Adjust</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
Expand Down Expand Up @@ -217,6 +246,7 @@
<tabstop>mLayerCombo</tabstop>
<tabstop>mUndoButton</tabstop>
<tabstop>mRedoButton</tabstop>
<tabstop>mLiveApplyCheck</tabstop>
</tabstops>
<resources>
<include location="../../images/images.qrc"/>
Expand Down

0 comments on commit 2215a8c

Please sign in to comment.