23#include <QDialogButtonBox>
26#include "moc_qgslegendpatchshapewidget.cpp"
36 mStyleItemsListWidget->setSymbolType(
shape.symbolType() );
55 if (
shape.geometry().asWkt() == mShapeEdit->toPlainText() &&
shape.preserveAspectRatio() == mPreserveRatioCheckBox->isChecked() &&
shape.symbolType() == mType )
58 mType =
shape.symbolType();
64void QgsLegendPatchShapeWidget::setShapeFromStyle(
const QString &name,
QgsStyle::StyleEntity,
const QString &stylePath )
81void QgsLegendPatchShapeWidget::saveShape()
84 saveDlg.setDefaultTags( mStyleItemsListWidget->currentTagFilter() );
85 if ( !saveDlg.exec() )
88 if ( saveDlg.name().isEmpty() )
91 QgsStyle *style = saveDlg.destinationStyle();
98 const int res = QMessageBox::warning(
this, tr(
"Save Legend Patch Shape" ), tr(
"A legend patch shape with the name '%1' already exists. Overwrite?" ).arg( saveDlg.name() ), QMessageBox::Yes | QMessageBox::No );
99 if ( res != QMessageBox::Yes )
106 const QStringList symbolTags = saveDlg.
tags().split(
',' );
108 const QgsLegendPatchShape newShape =
shape();
120 QVBoxLayout *vLayout =
new QVBoxLayout();
122 vLayout->addWidget( mWidget );
125 mButtonBox =
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok, Qt::Horizontal );
126 connect( mButtonBox, &QDialogButtonBox::accepted,
this, &QDialog::accept );
127 connect( mButtonBox, &QDialogButtonBox::rejected,
this, &QDialog::reject );
128 vLayout->addWidget( mButtonBox );
129 setLayout( vLayout );
130 setWindowTitle( tr(
"Legend Patch Shape" ) );
static Q_INVOKABLE QgsGeometry fromWkt(const QString &wkt)
Creates a new geometry from a WKT string.
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.
QgsStyle * styleAtPath(const QString &path)
Returns a reference to the style database associated with the project with matching file path.
static QgsProject * instance()
Returns the QgsProject singleton instance.
const QgsProjectStyleSettings * styleSettings() const
Returns the project's style settings, which contains settings and properties relating to how a QgsPro...
A database of saved style entities, including symbols, color ramps, text formats and others.
QStringList tags() const
Returns a list of all tags in the style database.
StyleEntity
Enum for Entities involved in a style.
@ LegendPatchShapeEntity
Legend patch shape.
QStringList legendPatchShapeNames() const
Returns a list of names of legend patch shapes in the 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.
static QgsStyle * defaultStyle(bool initialize=true)
Returns the default application-wide 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.