Skip to content

Commit a3e99ca

Browse files
authored
Merge pull request #8732 from m-kuhn/ux_geometry_validation_configuration
Make geometry constraint configuration size fit the contents
2 parents 868254d + db77b45 commit a3e99ca

3 files changed

+59
-21
lines changed

src/app/qgsvectorlayerproperties.cpp

+22-1
Original file line numberDiff line numberDiff line change
@@ -408,14 +408,33 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
408408
mGeometryPrecisionLineEdit->setEnabled( true );
409409
mGeometryPrecisionLineEdit->setValidator( new QDoubleValidator( mGeometryPrecisionLineEdit ) );
410410

411-
mRemoveDuplicateNodesCheckbox->setChecked( mLayer->geometryOptions()->removeDuplicateNodes() );
412411
double precision( mLayer->geometryOptions()->geometryPrecision() );
413412
bool ok = true;
414413
QString precisionStr( QLocale().toString( precision, ok ) );
415414
if ( precision == 0.0 || ! ok )
416415
precisionStr = QString();
417416
mGeometryPrecisionLineEdit->setText( precisionStr );
418417

418+
mRemoveDuplicateNodesManuallyActivated = mLayer->geometryOptions()->removeDuplicateNodes();
419+
mRemoveDuplicateNodesCheckbox->setChecked( mRemoveDuplicateNodesManuallyActivated );
420+
if ( !precisionStr.isNull() )
421+
mRemoveDuplicateNodesCheckbox->setEnabled( false );
422+
connect( mGeometryPrecisionLineEdit, &QLineEdit::textChanged, this, [this]
423+
{
424+
if ( !mGeometryPrecisionLineEdit->text().isEmpty() )
425+
{
426+
if ( mRemoveDuplicateNodesCheckbox->isEnabled() )
427+
mRemoveDuplicateNodesManuallyActivated = mRemoveDuplicateNodesCheckbox->isChecked();
428+
mRemoveDuplicateNodesCheckbox->setEnabled( false );
429+
mRemoveDuplicateNodesCheckbox->setChecked( true );
430+
}
431+
else
432+
{
433+
mRemoveDuplicateNodesCheckbox->setEnabled( true );
434+
mRemoveDuplicateNodesCheckbox->setChecked( mRemoveDuplicateNodesManuallyActivated );
435+
}
436+
} );
437+
419438
mPrecisionUnitsLabel->setText( QStringLiteral( "[%1]" ).arg( QgsUnitTypes::toAbbreviatedString( mLayer->crs().mapUnits() ) ) );
420439

421440
QLayout *geometryCheckLayout = new QVBoxLayout();
@@ -429,6 +448,7 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
429448
geometryCheckLayout->addWidget( cb );
430449
}
431450
mGeometryValidationGroupBox->setLayout( geometryCheckLayout );
451+
mGeometryValidationGroupBox->setVisible( !geometryCheckFactories.isEmpty() );
432452

433453
QLayout *topologyCheckLayout = new QVBoxLayout();
434454
const QList<QgsGeometryCheckFactory *> topologyCheckFactories = QgsAnalysis::instance()->geometryCheckRegistry()->geometryCheckFactories( mLayer, QgsGeometryCheck::LayerCheck, QgsGeometryCheck::Flag::AvailableInValidation );
@@ -441,6 +461,7 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
441461
topologyCheckLayout->addWidget( cb );
442462
}
443463
mTopologyChecksGroupBox->setLayout( topologyCheckLayout );
464+
mTopologyChecksGroupBox->setVisible( !topologyCheckFactories.isEmpty() );
444465
}
445466
else
446467
{

src/app/qgsvectorlayerproperties.h

+2
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private
245245

246246
QHash<QCheckBox *, QString> mGeometryCheckFactoriesGroupBoxes;
247247

248+
bool mRemoveDuplicateNodesManuallyActivated = false;
249+
248250
private slots:
249251
void openPanel( QgsPanelWidget *panel );
250252

src/ui/qgsvectorlayerpropertiesbase.ui

+35-20
Original file line numberDiff line numberDiff line change
@@ -433,8 +433,8 @@
433433
<rect>
434434
<x>0</x>
435435
<y>0</y>
436-
<width>325</width>
437-
<height>389</height>
436+
<width>315</width>
437+
<height>403</height>
438438
</rect>
439439
</property>
440440
<layout class="QVBoxLayout" name="verticalLayout_9">
@@ -907,8 +907,8 @@ border-radius: 2px;</string>
907907
<rect>
908908
<x>0</x>
909909
<y>0</y>
910-
<width>104</width>
911-
<height>102</height>
910+
<width>185</width>
911+
<height>112</height>
912912
</rect>
913913
</property>
914914
<layout class="QVBoxLayout" name="verticalLayout_23">
@@ -1504,8 +1504,8 @@ border-radius: 2px;</string>
15041504
<rect>
15051505
<x>0</x>
15061506
<y>0</y>
1507-
<width>685</width>
1508-
<height>346</height>
1507+
<width>734</width>
1508+
<height>372</height>
15091509
</rect>
15101510
</property>
15111511
<layout class="QVBoxLayout" name="verticalLayout_32">
@@ -1961,8 +1961,8 @@ border-radius: 2px;</string>
19611961
<rect>
19621962
<x>0</x>
19631963
<y>0</y>
1964-
<width>340</width>
1965-
<height>630</height>
1964+
<width>378</width>
1965+
<height>678</height>
19661966
</rect>
19671967
</property>
19681968
<layout class="QVBoxLayout" name="verticalLayout_13">
@@ -2367,8 +2367,8 @@ border-radius: 2px;</string>
23672367
<rect>
23682368
<x>0</x>
23692369
<y>0</y>
2370-
<width>651</width>
2371-
<height>804</height>
2370+
<width>658</width>
2371+
<height>800</height>
23722372
</rect>
23732373
</property>
23742374
<layout class="QVBoxLayout" name="verticalLayout_20">
@@ -2377,8 +2377,15 @@ border-radius: 2px;</string>
23772377
<property name="title">
23782378
<string>Automatic Fixes</string>
23792379
</property>
2380-
<layout class="QFormLayout" name="formLayout">
2381-
<item row="2" column="0">
2380+
<layout class="QGridLayout" name="gridLayout">
2381+
<item row="0" column="0" colspan="2">
2382+
<widget class="QCheckBox" name="mRemoveDuplicateNodesCheckbox">
2383+
<property name="text">
2384+
<string>Remove duplicate nodes</string>
2385+
</property>
2386+
</widget>
2387+
</item>
2388+
<item row="1" column="0">
23822389
<widget class="QLabel" name="label">
23832390
<property name="toolTip">
23842391
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The geometry precision defines the maximum precision to of geometry coordinates that should be stored on this layer. A snap to grid algorithm will be applied on every geometry entering this layer, resulting in coordinates being rounded to multiples of this value. The operation is applied in this layer's coordinate reference system.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
@@ -2388,14 +2395,7 @@ border-radius: 2px;</string>
23882395
</property>
23892396
</widget>
23902397
</item>
2391-
<item row="0" column="0" colspan="2">
2392-
<widget class="QCheckBox" name="mRemoveDuplicateNodesCheckbox">
2393-
<property name="text">
2394-
<string>Remove duplicate nodes</string>
2395-
</property>
2396-
</widget>
2397-
</item>
2398-
<item row="2" column="1">
2398+
<item row="1" column="1">
23992399
<layout class="QHBoxLayout" name="horizontalLayout_11" stretch="0,0">
24002400
<item>
24012401
<widget class="QLabel" name="mPrecisionUnitsLabel">
@@ -2436,6 +2436,19 @@ border-radius: 2px;</string>
24362436
</property>
24372437
</widget>
24382438
</item>
2439+
<item>
2440+
<spacer name="verticalSpacer_4">
2441+
<property name="orientation">
2442+
<enum>Qt::Vertical</enum>
2443+
</property>
2444+
<property name="sizeHint" stdset="0">
2445+
<size>
2446+
<width>20</width>
2447+
<height>40</height>
2448+
</size>
2449+
</property>
2450+
</spacer>
2451+
</item>
24392452
</layout>
24402453
</widget>
24412454
</widget>
@@ -2653,6 +2666,8 @@ border-radius: 2px;</string>
26532666
<include location="../../images/images.qrc"/>
26542667
<include location="../../images/images.qrc"/>
26552668
<include location="../../images/images.qrc"/>
2669+
<include location="../../images/images.qrc"/>
2670+
<include location="../../images/images.qrc"/>
26562671
</resources>
26572672
<connections>
26582673
<connection>

0 commit comments

Comments
 (0)