Skip to content

Commit

Permalink
Always enable Live Update in layer styling dock
Browse files Browse the repository at this point in the history
Remove "Live Update" and "Apply" buttons, and just always enable
live updates
  • Loading branch information
nyalldawson committed Aug 30, 2024
1 parent c875172 commit 9e08187
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 56 deletions.
16 changes: 1 addition & 15 deletions src/app/qgslayerstylingwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@ 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 @@ -104,9 +100,7 @@ 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 @@ -397,7 +391,7 @@ void QgsLayerStylingWidget::apply()

void QgsLayerStylingWidget::autoApply()
{
if ( mLiveApplyCheck->isChecked() && !mBlockAutoApply )
if ( !mBlockAutoApply )
{
mAutoApplyTimer->start( 100 );
}
Expand Down Expand Up @@ -852,14 +846,6 @@ 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: 0 additions & 1 deletion src/app/qgslayerstylingwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ 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: 10 additions & 40 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::AlignCenter</set>
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</item>
Expand Down Expand Up @@ -76,7 +76,7 @@
</sizepolicy>
</property>
<property name="sizeAdjustPolicy">
<enum>QComboBox::AdjustToMinimumContentsLengthWithIcon</enum>
<enum>QComboBox::SizeAdjustPolicy::AdjustToMinimumContentsLengthWithIcon</enum>
</property>
</widget>
</item>
Expand Down Expand Up @@ -121,7 +121,7 @@
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand All @@ -131,44 +131,15 @@
</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::NoFrame</enum>
<enum>QFrame::Shape::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<enum>QFrame::Shadow::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
Expand Down Expand Up @@ -201,19 +172,19 @@
</size>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
<enum>QFrame::Shape::NoFrame</enum>
</property>
<property name="horizontalScrollBarPolicy">
<enum>Qt::ScrollBarAlwaysOff</enum>
<enum>Qt::ScrollBarPolicy::ScrollBarAlwaysOff</enum>
</property>
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
<set>QAbstractItemView::EditTrigger::NoEditTriggers</set>
</property>
<property name="textElideMode">
<enum>Qt::ElideNone</enum>
<enum>Qt::TextElideMode::ElideNone</enum>
</property>
<property name="resizeMode">
<enum>QListView::Adjust</enum>
<enum>QListView::ResizeMode::Adjust</enum>
</property>
<property name="wordWrap">
<bool>true</bool>
Expand Down Expand Up @@ -246,7 +217,6 @@
<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 9e08187

Please sign in to comment.