18#include "moc_qgslegendpatchshapewidget.cpp"
22#include <QDialogButtonBox>
61void QgsLegendPatchShapeWidget::setShapeFromStyle(
const QString &name,
QgsStyle::StyleEntity,
const QString &stylePath )
78void QgsLegendPatchShapeWidget::saveShape()
81 saveDlg.setDefaultTags( mStyleItemsListWidget->currentTagFilter() );
82 if ( !saveDlg.exec() )
85 if ( saveDlg.name().isEmpty() )
88 QgsStyle *style = saveDlg.destinationStyle();
95 const int res = QMessageBox::warning(
this, tr(
"Save Legend Patch Shape" ),
96 tr(
"A legend patch shape with the name '%1' already exists. Overwrite?" )
97 .arg( saveDlg.name() ),
98 QMessageBox::Yes | QMessageBox::No );
99 if ( res != QMessageBox::Yes )
106 const QStringList symbolTags = saveDlg.tags().split(
',' );
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.
Q_INVOKABLE 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.
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 dialog for setting properties of a newly saved style.
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.