QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
qgsvectortilelayerproperties.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsvectortilelayerproperties.cpp
3 --------------------------------------
4 Date : May 2020
5 Copyright : (C) 2020 by Martin Dobias
6 Email : wonder dot sk at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
17
18#include "qgsfileutils.h"
19#include "qgshelp.h"
25#include "qgsvectortilelayer.h"
26#include "qgsvectortileutils.h"
27#include "qgsgui.h"
28#include "qgsnative.h"
29#include "qgsapplication.h"
30#include "qgsjsonutils.h"
31#include "qgsmetadatawidget.h"
36#include <QFileDialog>
37#include <QMenu>
38#include <QMessageBox>
39#include <QDesktopServices>
40#include <QTextStream>
41
42QgsVectorTileLayerProperties::QgsVectorTileLayerProperties( QgsVectorTileLayer *lyr, QgsMapCanvas *canvas, QgsMessageBar *messageBar, QWidget *parent, Qt::WindowFlags flags )
43 : QgsOptionsDialogBase( QStringLiteral( "VectorTileLayerProperties" ), parent, flags )
44 , mLayer( lyr )
45 , mMapCanvas( canvas )
46{
47 setupUi( this );
48
49 mRendererWidget = new QgsVectorTileBasicRendererWidget( nullptr, canvas, messageBar, this );
50 mOptsPage_Style->layout()->addWidget( mRendererWidget );
51 mOptsPage_Style->layout()->setContentsMargins( 0, 0, 0, 0 );
52
53 mLabelingWidget = new QgsVectorTileBasicLabelingWidget( nullptr, canvas, messageBar, this );
54 mOptsPage_Labeling->layout()->addWidget( mLabelingWidget );
55 mOptsPage_Labeling->layout()->setContentsMargins( 0, 0, 0, 0 );
56
57 connect( this, &QDialog::accepted, this, &QgsVectorTileLayerProperties::apply );
58 connect( this, &QDialog::rejected, this, &QgsVectorTileLayerProperties::onCancel );
59 connect( buttonBox->button( QDialogButtonBox::Apply ), &QAbstractButton::clicked, this, &QgsVectorTileLayerProperties::apply );
60 connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsVectorTileLayerProperties::showHelp );
61
62 connect( mCrsSelector, &QgsProjectionSelectionWidget::crsChanged, this, &QgsVectorTileLayerProperties::crsChanged );
63
64 // scale based layer visibility related widgets
65 mScaleRangeWidget->setMapCanvas( mMapCanvas );
66
67 // QgsOptionsDialogBase handles saving/restoring of geometry, splitter and current tab states,
68 // switching vertical tabs between icon/text to icon-only modes (splitter collapsed to left),
69 // and connecting QDialogButtonBox's accepted/rejected signals to dialog's accept/reject slots
70 initOptionsBase( false );
71
72 mSourceGroupBox->hide();
73
74#ifdef WITH_QTWEBKIT
75 // Setup information tab
76
77 const int horizontalDpi = logicalDpiX();
78
79 // Adjust zoom: text is ok, but HTML seems rather big at least on Linux/KDE
80 if ( horizontalDpi > 96 )
81 {
82 mMetadataViewer->setZoomFactor( mMetadataViewer->zoomFactor() * 0.9 );
83 }
84 mMetadataViewer->page()->setLinkDelegationPolicy( QWebPage::LinkDelegationPolicy::DelegateAllLinks );
85 connect( mMetadataViewer->page(), &QWebPage::linkClicked, this, &QgsVectorTileLayerProperties::urlClicked );
86 mMetadataViewer->page()->settings()->setAttribute( QWebSettings::DeveloperExtrasEnabled, true );
87 mMetadataViewer->page()->settings()->setAttribute( QWebSettings::JavascriptEnabled, true );
88
89#endif
90 mOptsPage_Information->setContentsMargins( 0, 0, 0, 0 );
91
92 QVBoxLayout *layout = new QVBoxLayout( metadataFrame );
93 layout->setContentsMargins( 0, 0, 0, 0 );
94 metadataFrame->setContentsMargins( 0, 0, 0, 0 );
95 mMetadataWidget = new QgsMetadataWidget( this, mLayer );
96 mMetadataWidget->layout()->setContentsMargins( 0, 0, 0, 0 );
97 mMetadataWidget->setMapCanvas( mMapCanvas );
98 layout->addWidget( mMetadataWidget );
99 metadataFrame->setLayout( layout );
100 mOptsPage_Metadata->setContentsMargins( 0, 0, 0, 0 );
101
102 // update based on lyr's current state
103 syncToLayer();
104
105 QgsSettings settings;
106 // if dialog hasn't been opened/closed yet, default to Styles tab, which is used most often
107 // this will be read by restoreOptionsBaseUi()
108 if ( !settings.contains( QStringLiteral( "/Windows/VectorTileLayerProperties/tab" ) ) )
109 {
110 settings.setValue( QStringLiteral( "Windows/VectorTileLayerProperties/tab" ),
111 mOptStackedWidget->indexOf( mOptsPage_Style ) );
112 }
113
114 QString title = tr( "Layer Properties - %1" ).arg( mLayer->name() );
115
116 mBtnStyle = new QPushButton( tr( "Style" ) );
117 QMenu *menuStyle = new QMenu( this );
118 menuStyle->addAction( tr( "Load Style…" ), this, &QgsVectorTileLayerProperties::loadStyle );
119 menuStyle->addAction( tr( "Save Style…" ), this, &QgsVectorTileLayerProperties::saveStyleAs );
120 menuStyle->addSeparator();
121 menuStyle->addAction( tr( "Save as Default" ), this, &QgsVectorTileLayerProperties::saveDefaultStyle );
122 menuStyle->addAction( tr( "Restore Default" ), this, &QgsVectorTileLayerProperties::loadDefaultStyle );
123 mBtnStyle->setMenu( menuStyle );
124 connect( menuStyle, &QMenu::aboutToShow, this, &QgsVectorTileLayerProperties::aboutToShowStyleMenu );
125
126 buttonBox->addButton( mBtnStyle, QDialogButtonBox::ResetRole );
127
128 mBtnMetadata = new QPushButton( tr( "Metadata" ), this );
129 QMenu *menuMetadata = new QMenu( this );
130 mActionLoadMetadata = menuMetadata->addAction( tr( "Load Metadata…" ), this, &QgsVectorTileLayerProperties::loadMetadata );
131 mActionSaveMetadataAs = menuMetadata->addAction( tr( "Save Metadata…" ), this, &QgsVectorTileLayerProperties::saveMetadataAs );
132 mBtnMetadata->setMenu( menuMetadata );
133 buttonBox->addButton( mBtnMetadata, QDialogButtonBox::ResetRole );
134
135 if ( !mLayer->styleManager()->isDefault( mLayer->styleManager()->currentStyle() ) )
136 title += QStringLiteral( " (%1)" ).arg( mLayer->styleManager()->currentStyle() );
137 restoreOptionsBaseUi( title );
138}
139
140void QgsVectorTileLayerProperties::apply()
141{
142 if ( mSourceWidget )
143 {
144 const QString newSource = mSourceWidget->sourceUri();
145 if ( newSource != mLayer->source() )
146 {
147 mLayer->setDataSource( newSource, mLayer->name(), mLayer->providerType(), QgsDataProvider::ProviderOptions() );
148 }
149 }
150
151 mLayer->setName( mLayerOrigNameLineEd->text() );
152 mLayer->setCrs( mCrsSelector->crs() );
153
154 mRendererWidget->apply();
155 mLabelingWidget->apply();
156 mMetadataWidget->acceptMetadata();
157
158 mLayer->setScaleBasedVisibility( chkUseScaleDependentRendering->isChecked() );
159 mLayer->setMinimumScale( mScaleRangeWidget->minimumScale() );
160 mLayer->setMaximumScale( mScaleRangeWidget->maximumScale() );
161}
162
163void QgsVectorTileLayerProperties::onCancel()
164{
165 if ( mOldStyle.xmlData() != mLayer->styleManager()->style( mLayer->styleManager()->currentStyle() ).xmlData() )
166 {
167 // need to reset style to previous - style applied directly to the layer (not in apply())
168 QString myMessage;
169 QDomDocument doc( QStringLiteral( "qgis" ) );
170 int errorLine, errorColumn;
171 doc.setContent( mOldStyle.xmlData(), false, &myMessage, &errorLine, &errorColumn );
172 mLayer->importNamedStyle( doc, myMessage );
173 syncToLayer();
174 }
175}
176
177void QgsVectorTileLayerProperties::syncToLayer()
178{
179 /*
180 * Information Tab
181 */
182 const QString myStyle = QgsApplication::reportStyleSheet( QgsApplication::StyleSheetType::WebBrowser );
183 // Inject the stylesheet
184 const QString html { mLayer->htmlMetadata().replace( QLatin1String( "<head>" ), QStringLiteral( R"raw(<head><style type="text/css">%1</style>)raw" ) ).arg( myStyle ) };
185 mMetadataViewer->setHtml( html );
186
187 /*
188 * Source
189 */
190
191 mLayerOrigNameLineEd->setText( mLayer->name() );
192 mCrsSelector->setCrs( mLayer->crs() );
193
194 if ( !mSourceWidget )
195 {
196 mSourceWidget = QgsGui::sourceWidgetProviderRegistry()->createWidget( mLayer );
197 if ( mSourceWidget )
198 {
199 QHBoxLayout *layout = new QHBoxLayout();
200 layout->addWidget( mSourceWidget );
201 mSourceGroupBox->setLayout( layout );
202 mSourceGroupBox->show();
203
204 connect( mSourceWidget, &QgsProviderSourceWidget::validChanged, this, [ = ]( bool isValid )
205 {
206 buttonBox->button( QDialogButtonBox::Apply )->setEnabled( isValid );
207 buttonBox->button( QDialogButtonBox::Ok )->setEnabled( isValid );
208 } );
209 }
210 }
211
212 if ( mSourceWidget )
213 {
214 mSourceWidget->setMapCanvas( mMapCanvas );
215 mSourceWidget->setSourceUri( mLayer->source() );
216 }
217
218 /*
219 * Symbology Tab
220 */
221 mRendererWidget->syncToLayer( mLayer );
222
223 /*
224 * Labels Tab
225 */
226 mLabelingWidget->setLayer( mLayer );
227
228 /*
229 * Rendering
230 */
231 chkUseScaleDependentRendering->setChecked( mLayer->hasScaleBasedVisibility() );
232 mScaleRangeWidget->setScaleRange( mLayer->minimumScale(), mLayer->maximumScale() );
233}
234
235
237{
238 bool defaultLoadedFlag = false;
239 const QString myMessage = mLayer->loadDefaultStyle( defaultLoadedFlag );
240 // reset if the default style was loaded OK only
241 if ( defaultLoadedFlag )
242 {
243 syncToLayer();
244 }
245 else
246 {
247 // otherwise let the user know what went wrong
248 QMessageBox::information( this,
249 tr( "Default Style" ),
250 myMessage
251 );
252 }
253}
254
256{
257 apply(); // make sure the style to save is up-to-date
258
259 // a flag passed by reference
260 bool defaultSavedFlag = false;
261 // TODO Once the deprecated `saveDefaultStyle()` method is gone, just
262 // remove the NOWARN_DEPRECATED tags
264 // after calling this the above flag will be set true for success
265 // or false if the save operation failed
266 const QString myMessage = mLayer->saveDefaultStyle( defaultSavedFlag );
268 if ( !defaultSavedFlag )
269 {
270 // let the user know what went wrong
271 QMessageBox::information( this,
272 tr( "Default Style" ),
273 myMessage
274 );
275 }
276}
277
279{
280 const QgsSettings settings; // where we keep last used filter in persistent state
281
282 QgsMapLayerLoadStyleDialog dlg( mLayer );
283
284 if ( dlg.exec() )
285 {
286 mOldStyle = mLayer->styleManager()->style( mLayer->styleManager()->currentStyle() );
287 const QgsMapLayer::StyleCategories categories = dlg.styleCategories();
288 const QString type = dlg.fileExtension();
289 if ( type.compare( QLatin1String( "qml" ), Qt::CaseInsensitive ) == 0 )
290 {
291 QString message;
292 bool defaultLoadedFlag = false;
293 const QString filePath = dlg.filePath();
294 message = mLayer->loadNamedStyle( filePath, defaultLoadedFlag, categories );
295
296 //reset if the default style was loaded OK only
297 if ( defaultLoadedFlag )
298 {
299 syncToLayer();
300 }
301 else
302 {
303 //let the user know what went wrong
304 QMessageBox::warning( this, tr( "Load Style" ), message );
305 }
306 }
307 else if ( type.compare( QLatin1String( "json" ), Qt::CaseInsensitive ) == 0 )
308 {
309 QFile file( dlg.filePath() );
310 if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
311 {
312 QMessageBox::warning( this, tr( "Load Style" ), tr( "Could not read %1" ).arg( QDir::toNativeSeparators( dlg.filePath() ) ) );
313 }
314 else
315 {
316 QTextStream in( &file );
317#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
318 in.setCodec( "UTF-8" );
319#endif
320 const QString content = in.readAll();
321
323 // convert automatically from pixel sizes to millimeters, because pixel sizes
324 // are a VERY edge case in QGIS and don't play nice with hidpi map renders or print layouts
325 context.setTargetUnit( Qgis::RenderUnit::Millimeters );
326 //assume source uses 96 dpi
327 context.setPixelSizeConversionFactor( 25.4 / 96.0 );
328
329 //load sprites
330 QVariantMap styleDefinition = QgsJsonUtils::parseJson( content ).toMap();
331
332 QFileInfo fi( dlg.filePath() );
333 QgsVectorTileUtils::loadSprites( styleDefinition, context, QStringLiteral( "file://" ) + fi.absolutePath() );
334
336
337 if ( converter.convert( content, &context ) != QgsMapBoxGlStyleConverter::Success )
338 {
339 QMessageBox::warning( this, tr( "Load Style" ), converter.errorMessage() );
340 }
341 else
342 {
343 if ( dlg.styleCategories().testFlag( QgsMapLayer::StyleCategory::Symbology ) )
344 {
345 mLayer->setRenderer( converter.renderer() );
346 }
347 if ( dlg.styleCategories().testFlag( QgsMapLayer::StyleCategory::Labeling ) )
348 {
349 mLayer->setLabeling( converter.labeling() );
350 }
351 syncToLayer();
352 }
353 }
354 }
355 activateWindow(); // set focus back to properties dialog
356 }
357}
358
360{
361 QgsSettings settings;
362 const QString lastUsedDir = settings.value( QStringLiteral( "style/lastStyleDir" ), QDir::homePath() ).toString();
363
364 QString outputFileName = QFileDialog::getSaveFileName(
365 this,
366 tr( "Save layer properties as style file" ),
367 lastUsedDir,
368 tr( "QGIS Layer Style File" ) + " (*.qml)" );
369 if ( outputFileName.isEmpty() )
370 return;
371
372 // ensure the user never omits the extension from the file name
373 outputFileName = QgsFileUtils::ensureFileNameHasExtension( outputFileName, QStringList() << QStringLiteral( "qml" ) );
374
375 apply(); // make sure the style to save is up-to-date
376
377 // then export style
378 bool defaultLoadedFlag = false;
379 QString message;
380 message = mLayer->saveNamedStyle( outputFileName, defaultLoadedFlag );
381
382 if ( defaultLoadedFlag )
383 {
384 settings.setValue( QStringLiteral( "style/lastStyleDir" ), QFileInfo( outputFileName ).absolutePath() );
385 }
386 else
387 QMessageBox::information( this, tr( "Save Style" ), message );
388}
389
390void QgsVectorTileLayerProperties::aboutToShowStyleMenu()
391{
392 QMenu *m = qobject_cast<QMenu *>( sender() );
393
395 // re-add style manager actions!
396 m->addSeparator();
398}
399
400void QgsVectorTileLayerProperties::loadMetadata()
401{
402 QgsSettings myQSettings; // where we keep last used filter in persistent state
403 const QString myLastUsedDir = myQSettings.value( QStringLiteral( "style/lastStyleDir" ), QDir::homePath() ).toString();
404
405 const QString myFileName = QFileDialog::getOpenFileName( this, tr( "Load layer metadata from metadata file" ), myLastUsedDir,
406 tr( "QGIS Layer Metadata File" ) + " (*.qmd)" );
407 if ( myFileName.isNull() )
408 {
409 return;
410 }
411
412 QString myMessage;
413 bool defaultLoadedFlag = false;
414 myMessage = mLayer->loadNamedMetadata( myFileName, defaultLoadedFlag );
415
416 //reset if the default style was loaded OK only
417 if ( defaultLoadedFlag )
418 {
419 mMetadataWidget->setMetadata( &mLayer->metadata() );
420 }
421 else
422 {
423 //let the user know what went wrong
424 QMessageBox::warning( this, tr( "Load Metadata" ), myMessage );
425 }
426
427 const QFileInfo myFI( myFileName );
428 const QString myPath = myFI.path();
429 myQSettings.setValue( QStringLiteral( "style/lastStyleDir" ), myPath );
430
431 activateWindow(); // set focus back to properties dialog
432}
433
434void QgsVectorTileLayerProperties::saveMetadataAs()
435{
436 QgsSettings myQSettings; // where we keep last used filter in persistent state
437 const QString myLastUsedDir = myQSettings.value( QStringLiteral( "style/lastStyleDir" ), QDir::homePath() ).toString();
438
439 QString myOutputFileName = QFileDialog::getSaveFileName( this, tr( "Save Layer Metadata as QMD" ),
440 myLastUsedDir, tr( "QMD File" ) + " (*.qmd)" );
441 if ( myOutputFileName.isNull() ) //dialog canceled
442 {
443 return;
444 }
445
446 mMetadataWidget->acceptMetadata();
447
448 //ensure the user never omitted the extension from the file name
449 if ( !myOutputFileName.endsWith( QgsMapLayer::extensionPropertyType( QgsMapLayer::Metadata ), Qt::CaseInsensitive ) )
450 {
452 }
453
454 bool defaultLoadedFlag = false;
455 const QString message = mLayer->saveNamedMetadata( myOutputFileName, defaultLoadedFlag );
456 if ( defaultLoadedFlag )
457 myQSettings.setValue( QStringLiteral( "style/lastStyleDir" ), QFileInfo( myOutputFileName ).absolutePath() );
458 else
459 QMessageBox::information( this, tr( "Save Metadata" ), message );
460}
461
462void QgsVectorTileLayerProperties::showHelp()
463{
464 const QVariant helpPage = mOptionsStackedWidget->currentWidget()->property( "helpPage" );
465
466 if ( helpPage.isValid() )
467 {
468 QgsHelp::openHelp( helpPage.toString() );
469 }
470 else
471 {
472 QgsHelp::openHelp( QStringLiteral( "working_with_vector_tiles/vector_tiles_properties.html" ) );
473 }
474}
475
476void QgsVectorTileLayerProperties::urlClicked( const QUrl &url )
477{
478 const QFileInfo file( url.toLocalFile() );
479 if ( file.exists() && !file.isDir() )
480 QgsGui::nativePlatformInterface()->openFileExplorerAndSelectFile( url.toLocalFile() );
481 else
482 QDesktopServices::openUrl( url );
483}
484
485void QgsVectorTileLayerProperties::crsChanged( const QgsCoordinateReferenceSystem &crs )
486{
487 QgsDatumTransformDialog::run( crs, QgsProject::instance()->crs(), this, mMapCanvas, tr( "Select Transformation" ) );
488 mLayer->setCrs( crs );
489 mMetadataWidget->crsChanged();
490}
491
493{
495
496 const bool isMetadataPanel = ( index == mOptStackedWidget->indexOf( mOptsPage_Metadata ) );
497 mBtnStyle->setVisible( ! isMetadataPanel );
498 mBtnMetadata->setVisible( isMetadataPanel );
499}
static QString reportStyleSheet(QgsApplication::StyleSheetType styleSheetType=QgsApplication::StyleSheetType::Qt)
Returns a css style sheet for reports, the styleSheetType argument determines what type of stylesheet...
This class represents a coordinate reference system (CRS).
static bool run(const QgsCoordinateReferenceSystem &sourceCrs=QgsCoordinateReferenceSystem(), const QgsCoordinateReferenceSystem &destinationCrs=QgsCoordinateReferenceSystem(), QWidget *parent=nullptr, QgsMapCanvas *mapCanvas=nullptr, const QString &windowTitle=QString())
Runs the dialog (if required) prompting for the desired transform to use from sourceCrs to destinatio...
static QString ensureFileNameHasExtension(const QString &fileName, const QStringList &extensions)
Ensures that a fileName ends with an extension from the provided list of extensions.
static QgsProviderSourceWidgetProviderRegistry * sourceWidgetProviderRegistry()
Returns the registry of provider source widget providers.
Definition: qgsgui.cpp:113
static QgsNative * nativePlatformInterface()
Returns the global native interface, which offers abstraction to the host OS's underlying public inte...
Definition: qgsgui.cpp:78
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
Definition: qgshelp.cpp:38
static QVariant parseJson(const std::string &jsonString)
Converts JSON jsonString to a QVariant, in case of parsing error an invalid QVariant is returned and ...
Context for a MapBox GL style conversion operation.
void setTargetUnit(Qgis::RenderUnit targetUnit)
Sets the target unit type.
void setPixelSizeConversionFactor(double sizeConversionFactor)
Sets the pixel size conversion factor, used to scale the original pixel sizes when converting styles.
Handles conversion of MapBox GL styles to QGIS vector tile renderers and labeling settings.
QgsVectorTileRenderer * renderer() const
Returns a new instance of a vector tile renderer representing the converted style,...
QgsVectorTileLabeling * labeling() const
Returns a new instance of a vector tile labeling representing the converted style,...
Result convert(const QVariantMap &style, QgsMapBoxGlStyleConversionContext *context=nullptr)
Converts a JSON style map, and returns the resultant status of the conversion.
@ Success
Conversion was successful.
QString errorMessage() const
Returns a descriptive error message if an error was encountered during the style conversion,...
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:90
A reusable dialog which allows users to select stored layer styles and categories to load for a map l...
QgsMapLayer::StyleCategories styleCategories() const
Returns the list of selected style categories the user has opted to load.
QString filePath() const
Returns the full path to the selected layer style source file.
QString fileExtension() const
Returns the file extension for the selected layer style source file.
void removesExtraMenuSeparators(QMenu *m)
removes extra separators from the menu
void addStyleManagerActions(QMenu *m, QgsMapLayer *layer)
adds actions to the menu in accordance to the layer
static QgsMapLayerStyleGuiUtils * instance()
returns a singleton instance of this class
QString currentStyle() const
Returns name of the current style.
static bool isDefault(const QString &styleName)
Returns true if this is the default style.
QgsMapLayerStyle style(const QString &name) const
Returns data of a stored style - accessed by its unique name.
QString xmlData() const
Returns XML content of the style.
QString name
Definition: qgsmaplayer.h:76
virtual bool importNamedStyle(QDomDocument &doc, QString &errorMsg, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories)
Import the properties of this layer from a QDomDocument.
QString source() const
Returns the source for the layer.
QString providerType() const
Returns the provider type (provider key) for this layer.
void setMinimumScale(double scale)
Sets the minimum map scale (i.e.
QgsCoordinateReferenceSystem crs
Definition: qgsmaplayer.h:79
virtual QString loadNamedMetadata(const QString &uri, bool &resultFlag)
Retrieve a named metadata for this layer if one exists (either as a .qmd file on disk or as a record ...
void setMaximumScale(double scale)
Sets the maximum map scale (i.e.
QgsLayerMetadata metadata
Definition: qgsmaplayer.h:78
void setScaleBasedVisibility(bool enabled)
Sets whether scale based visibility is enabled for the layer.
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
virtual QString loadNamedStyle(const QString &uri, bool &resultFlag, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories)
Retrieve a named style for this layer if one exists (either as a .qml file on disk or as a record in ...
static QString extensionPropertyType(PropertyType type)
Returns the extension of a Property.
Definition: qgsmaplayer.cpp:69
void setName(const QString &name)
Set the display name of the layer.
QString saveNamedMetadata(const QString &uri, bool &resultFlag)
Save the current metadata of this layer as a named metadata (either as a .qmd file on disk or as a re...
void setDataSource(const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag=false)
Updates the data source of the layer.
double minimumScale() const
Returns the minimum map scale (i.e.
QgsMapLayerStyleManager * styleManager() const
Gets access to the layer's style manager.
virtual QString saveNamedStyle(const QString &uri, bool &resultFlag, StyleCategories categories=AllStyleCategories)
Save the properties of this layer as a named style (either as a .qml file on disk or as a record in t...
virtual QString saveDefaultStyle(bool &resultFlag, StyleCategories categories)
Save the properties of this layer as the default style (either as a .qml file on disk or as a record ...
double maximumScale() const
Returns the maximum map scale (i.e.
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system.
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:61
A wizard to edit metadata on a map layer.
void acceptMetadata()
Saves the metadata to the layer.
void crsChanged()
If the CRS is updated.
void setMapCanvas(QgsMapCanvas *canvas)
Sets a map canvas associated with the widget.
void setMetadata(const QgsAbstractMetadataBase *metadata)
Sets the metadata to display in the widget.
A base dialog for options and properties dialogs that offers vertical tabs.
virtual void optionsStackedWidget_CurrentChanged(int index)
Select relevant tab on current page change.
void restoreOptionsBaseUi(const QString &title=QString())
Restore the base ui.
QStackedWidget * mOptStackedWidget
void initOptionsBase(bool restoreUi=true, const QString &title=QString())
Set up the base ui connections for vertical tabs.
static QgsProject * instance()
Returns the QgsProject singleton instance.
Definition: qgsproject.cpp:484
void crsChanged(const QgsCoordinateReferenceSystem &)
Emitted when the selected CRS is changed.
QgsProviderSourceWidget * createWidget(QgsMapLayer *layer, QWidget *parent=nullptr)
Creates a new widget to configure the source of the specified layer.
void validChanged(bool isValid)
Emitted whenever the validation status of the widget changes.
virtual QString sourceUri() const =0
Returns the source URI as currently defined by the widget.
virtual void setMapCanvas(QgsMapCanvas *mapCanvas)
Sets a map canvas associated with the widget.
virtual void setSourceUri(const QString &uri)=0
Sets the source uri to show in the widget.
This class is a composition of two QSettings instances:
Definition: qgssettings.h:63
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
bool contains(const QString &key, QgsSettings::Section section=QgsSettings::NoSection) const
Returns true if there exists a setting called key; returns false otherwise.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
void saveDefaultStyle()
Saves the default style when appropriate button is pressed.
void optionsStackedWidget_CurrentChanged(int index) override
void saveStyleAs()
Saves a style when appriate button is pressed.
void loadDefaultStyle()
Loads the default style when appropriate button is pressed.
void loadStyle()
Loads a saved style when appropriate button is pressed.
QgsVectorTileLayerProperties(QgsVectorTileLayer *lyr, QgsMapCanvas *canvas, QgsMessageBar *messageBar, QWidget *parent=nullptr, Qt::WindowFlags=QgsGuiUtils::ModalDialogFlags)
Constructor.
Implements a map layer that is dedicated to rendering of vector tiles.
void setRenderer(QgsVectorTileRenderer *r)
Sets renderer for the map layer.
void setLabeling(QgsVectorTileLabeling *labeling)
Sets labeling for the map layer.
QString loadDefaultStyle(bool &resultFlag) override
Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record...
QString htmlMetadata() const override
Obtain a formatted HTML string containing assorted metadata for this layer.
static void loadSprites(const QVariantMap &styleDefinition, QgsMapBoxGlStyleConversionContext &context, const QString &styleUrl=QString())
Downloads the sprite image and sets it to the conversion context.
#define Q_NOWARN_DEPRECATED_POP
Definition: qgis.h:4572
#define Q_NOWARN_DEPRECATED_PUSH
Definition: qgis.h:4571
const QgsCoordinateReferenceSystem & crs
Setting options for creating vector data providers.