19 #include <QDialogButtonBox>
20 #include <QMessageBox>
67 void QgsLegendPatchShapeWidget::saveShape()
74 saveDlg.setDefaultTags( mStyleItemsListWidget->currentTagFilter() );
75 if ( !saveDlg.exec() )
78 if ( saveDlg.name().isEmpty() )
84 const int res = QMessageBox::warning(
this, tr(
"Save Legend Patch Shape" ),
85 tr(
"A legend patch shape with the name '%1' already exists. Overwrite?" )
86 .arg( saveDlg.name() ),
87 QMessageBox::Yes | QMessageBox::No );
88 if ( res != QMessageBox::Yes )
95 const QStringList symbolTags = saveDlg.tags().split(
',' );
109 QVBoxLayout *vLayout =
new QVBoxLayout();
111 vLayout->addWidget( mWidget );
114 mButtonBox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok, Qt::Horizontal );
115 connect( mButtonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept );
116 connect( mButtonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
117 vLayout->addWidget( mButtonBox );
118 setLayout( vLayout );
119 setWindowTitle( tr(
"Legend Patch Shape" ) );
static QgsGeometry fromWkt(const QString &wkt)
Creates a new geometry from a WKT string.
QString asWkt(int precision=17) const
Exports the geometry to WKT.
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
QgsLegendPatchShape shape() const
Returns the legend patch shape defined by the dialog.
QgsLegendPatchShapeDialog(const QgsLegendPatchShape &shape, QWidget *parent=nullptr)
Constructor for QgsLegendPatchShapeDialog, initially showing the specified shape.
Represents a patch shape for use in map legends.
bool preserveAspectRatio() const
Returns true if the patch shape should preserve its aspect ratio when it is resized to fit a desired ...
QgsGeometry geometry() const
Returns the geometry for the patch shape.
Qgis::SymbolType symbolType() const
Returns the symbol type associated with this patch.
a dialog for setting properties of a newly saved style.
StyleEntity
Enum for Entities involved in a style.
@ LegendPatchShapeEntity
Legend patch shape (since QGIS 3.14)
QStringList legendPatchShapeNames() const
Returns a list of names of legend patch shapes in the style.
static QgsStyle * defaultStyle()
Returns default application-wide style.
bool removeEntityByName(StyleEntity type, const QString &name)
Removes the entry of the specified type with matching name from the database.
bool addLegendPatchShape(const QString &name, const QgsLegendPatchShape &shape, bool update=false)
Adds a legend patch shape with the specified name to the style.
bool saveLegendPatchShape(const QString &name, const QgsLegendPatchShape &shape, bool favorite, const QStringList &tags)
Adds a legend patch shape to the database.
QgsLegendPatchShape legendPatchShape(const QString &name) const
Returns the legend patch shape with the specified name.
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.