Skip to content

Commit

Permalink
GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Jan 11, 2023
1 parent 0ddee0b commit bf1c4f8
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 14 deletions.
6 changes: 5 additions & 1 deletion src/gui/vector/qgsvectorlayerproperties.cpp
Expand Up @@ -21,6 +21,7 @@

#include "qgsactionmanager.h"
#include "qgsjoindialog.h"
#include "qgssldexportcontext.h"
#include "qgswmsdimensiondialog.h"
#include "qgsapplication.h"
#include "qgsattributeactiondialog.h"
Expand Down Expand Up @@ -1230,7 +1231,10 @@ void QgsVectorLayerProperties::saveStyleAs()
if ( type == QML )
errorMessage = mLayer->saveNamedStyle( filePath, defaultLoadedFlag, dlg.styleCategories() );
else
errorMessage = mLayer->saveSldStyle( filePath, defaultLoadedFlag );
{
const QgsSldExportContext sldContext { dlg.sldExportOptions(), Qgis::SldExportVendorExtension::NoVendorExtension, filePath };
errorMessage = mLayer->saveSldStyleV2( defaultLoadedFlag, sldContext );
}

//reset if the default style was loaded OK only
if ( defaultLoadedFlag )
Expand Down
11 changes: 11 additions & 0 deletions src/gui/vector/qgsvectorlayersavestyledialog.cpp
Expand Up @@ -41,6 +41,7 @@ QgsVectorLayerSaveStyleDialog::QgsVectorLayerSaveStyleDialog( QgsVectorLayer *la
mFileLabel->setVisible( type != QgsVectorLayerProperties::DB && type != QgsVectorLayerProperties::Local );
mFileWidget->setVisible( type != QgsVectorLayerProperties::DB && type != QgsVectorLayerProperties::Local );
mSaveToDbWidget->setVisible( type == QgsVectorLayerProperties::DB );
mSaveToSldWidget->setVisible( type == QgsVectorLayerProperties::SLD && layer->geometryType() == QgsWkbTypes::GeometryType::PolygonGeometry );
mStyleCategoriesListView->setEnabled( type != QgsVectorLayerProperties::SLD );
mFileWidget->setFilter( type == QgsVectorLayerProperties::QML ? tr( "QGIS Layer Style File (*.qml)" ) : tr( "SLD File (*.sld)" ) );
updateSaveButtonState();
Expand Down Expand Up @@ -246,6 +247,16 @@ const QListWidget *QgsVectorLayerSaveStyleDialog::stylesWidget()
return mStylesWidget;
}

Qgis::SldExportOptions QgsVectorLayerSaveStyleDialog::sldExportOptions() const
{
Qgis::SldExportOptions options;

if ( mStyleTypeComboBox->currentData( ) == QgsVectorLayerProperties::SLD )
{
options.setFlag( Qgis::SldExportOption::Png );
}
return options;
}

void QgsVectorLayerSaveStyleDialog::showHelp()
{
Expand Down
6 changes: 6 additions & 0 deletions src/gui/vector/qgsvectorlayersavestyledialog.h
Expand Up @@ -63,6 +63,12 @@ class GUI_EXPORT QgsVectorLayerSaveStyleDialog : public QDialog, private Ui::Qgs

const QListWidget *stylesWidget( );

/**
* Returns the SLD export options.
* \since QGIS 3.30
*/
Qgis::SldExportOptions sldExportOptions( ) const;

public slots:
void accept() override;

Expand Down
47 changes: 38 additions & 9 deletions src/ui/qgsvectorlayersavestyledialog.ui
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>491</width>
<height>614</height>
<height>728</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -41,17 +41,46 @@
<item row="1" column="1">
<widget class="QListWidget" name="mStylesWidget"/>
</item>
<item row="2" column="0">
<item row="2" column="0" colspan="2">
<widget class="QWidget" name="mSaveToSldWidget" native="true">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1">
<widget class="QCheckBox" name="mSldExportPng">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Complex and rotated polygon fills are generally not supported by SLD. &lt;/p&gt;&lt;p&gt;By checking this option supported symbols will be exported as PNG tiles in the same directory of the SLD document and the SLD document will refer to the PNG images as external graphic symbols.&lt;/p&gt;&lt;p&gt;Note that not all symbols can be exported to PNG, if the symbol cannot be exported the default SLD export implementation will be used.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Export polygon fills as PNG tiles</string>
</property>
</widget>
</item>
<item row="0" column="0">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="mFileLabel">
<property name="text">
<string>File</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QgsFileWidget" name="mFileWidget"/>
<item row="3" column="1">
<widget class="QgsFileWidget" name="mFileWidget" native="true"/>
</item>
<item row="3" column="0" colspan="2">
<item row="4" column="0" colspan="2">
<widget class="QWidget" name="mSaveToDbWidget" native="true">
<layout class="QGridLayout" name="gridLayout_3">
<property name="leftMargin">
Expand All @@ -67,7 +96,7 @@
<number>0</number>
</property>
<item row="2" column="1">
<widget class="QgsFileWidget" name="mDbStyleUIFileWidget">
<widget class="QgsFileWidget" name="mDbStyleUIFileWidget" native="true">
<property name="toolTip">
<string>Optionally pick an input form for attribute editing (QT Designer UI format), it will be stored in the database</string>
</property>
Expand Down Expand Up @@ -116,14 +145,14 @@
</layout>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Categories</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<widget class="QListView" name="mStyleCategoriesListView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
Expand All @@ -133,7 +162,7 @@
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<item row="6" column="0" colspan="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand Down
8 changes: 4 additions & 4 deletions tests/src/python/test_qgssymbollayerutils.py
Expand Up @@ -672,22 +672,22 @@ def testTileSize(self):
[10, 10, math.pi / 4, 10 * math.sqrt(2), 10 * math.sqrt(2), math.pi / 4],
[10, 20, math.pi / 2, 20, 10, math.pi / 2],
[10, 20, math.pi / 4, 20 * math.sqrt(2), 20 * math.sqrt(2), math.pi / 4],
[10, 20, math.pi / 6, 36, 72, 0.5880031703261417], # Angle approx
[10, 20, math.pi / 6, 36, 72, 0.5880031703261417], # Angle approx

# Second quadrant
[10, 20, math.pi / 2 + math.pi / 6, 72, 36, math.pi / 2 + 0.5880031703261417], # Angle approx
[10, 20, math.pi / 2 + math.pi / 6, 72, 36, math.pi / 2 + 0.5880031703261417], # Angle approx
[10, 10, math.pi / 2 + math.pi / 4, 10 * math.sqrt(2), 10 * math.sqrt(2), math.pi / 2 + math.pi / 4],
[10, 20, math.pi / 2 + math.pi / 2, 10, 20, math.pi / 2 + math.pi / 2],
[10, 20, math.pi / 2 + math.pi / 4, 20 * math.sqrt(2), 20 * math.sqrt(2), math.pi / 2 + math.pi / 4],

# Third quadrant
[10, 20, math.pi + math.pi / 6, 36, 72, math.pi + 0.5880031703261417], # Angle approx
[10, 20, math.pi + math.pi / 6, 36, 72, math.pi + 0.5880031703261417], # Angle approx
[10, 10, math.pi + math.pi / 4, 10 * math.sqrt(2), 10 * math.sqrt(2), math.pi + math.pi / 4],
[10, 20, math.pi + math.pi / 2, 20, 10, math.pi + math.pi / 2],
[10, 20, math.pi + math.pi / 4, 20 * math.sqrt(2), 20 * math.sqrt(2), math.pi + math.pi / 4],

# Fourth quadrant
[10, 20, math.pi + math.pi / 2 + math.pi / 6, 72, 36, math.pi + math.pi / 2 + 0.5880031703261417], # Angle approx
[10, 20, math.pi + math.pi / 2 + math.pi / 6, 72, 36, math.pi + math.pi / 2 + 0.5880031703261417], # Angle approx
[10, 10, math.pi + math.pi / 2 + math.pi / 4, 10 * math.sqrt(2), 10 * math.sqrt(2), math.pi + math.pi / 2 + math.pi / 4],
[10, 20, math.pi + math.pi / 2 + math.pi / 4, 20 * math.sqrt(2), 20 * math.sqrt(2), math.pi + math.pi / 2 + math.pi / 4],
]
Expand Down

0 comments on commit bf1c4f8

Please sign in to comment.