| 
    QGIS API Documentation
    3.26.3-Buenos Aires (65e4edfdad)
    
   | 
 
 
 
 
Go to the documentation of this file.
   21 #include <QDialogButtonBox> 
   22 #include <QMessageBox> 
   60 void QgsLegendPatchShapeWidget::setShapeFromStyle( 
const QString &name, 
QgsStyle::StyleEntity, 
const QString &stylePath )
 
   66 #if QT_VERSION >= QT_VERSION_CHECK(5, 13, 0) 
   82 void QgsLegendPatchShapeWidget::saveShape()
 
   85   saveDlg.setDefaultTags( mStyleItemsListWidget->currentTagFilter() );
 
   86   if ( !saveDlg.exec() )
 
   89   if ( saveDlg.name().isEmpty() )
 
   92   QgsStyle *style = saveDlg.destinationStyle();
 
   99     const int res = QMessageBox::warning( 
this, tr( 
"Save Legend Patch Shape" ),
 
  100                                           tr( 
"A legend patch shape with the name '%1' already exists. Overwrite?" )
 
  101                                           .arg( saveDlg.name() ),
 
  102                                           QMessageBox::Yes | QMessageBox::No );
 
  103     if ( res != QMessageBox::Yes )
 
  110   const QStringList symbolTags = saveDlg.tags().split( 
',' );
 
  124   QVBoxLayout *vLayout = 
new QVBoxLayout();
 
  126   vLayout->addWidget( mWidget );
 
  129   mButtonBox = 
new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok, Qt::Horizontal );
 
  130   connect( mButtonBox, &QDialogButtonBox::accepted, 
this, &QDialog::accept );
 
  131   connect( mButtonBox, &QDialogButtonBox::rejected, 
this, &QDialog::reject );
 
  132   vLayout->addWidget( mButtonBox );
 
  133   setLayout( vLayout );
 
  134   setWindowTitle( tr( 
"Legend Patch Shape" ) );
 
  
QgsGeometry geometry() const
Returns the geometry for the patch shape.
 
bool removeEntityByName(StyleEntity type, const QString &name)
Removes the entry of the specified type with matching name from the database.
 
static QgsGeometry fromWkt(const QString &wkt)
Creates a new geometry from a WKT string.
 
static QgsProject * instance()
Returns the QgsProject singleton instance.
 
QgsLegendPatchShape shape() const
Returns the legend patch shape defined by the dialog.
 
@ LegendPatchShapeEntity
Legend patch shape (since QGIS 3.14)
 
const QgsProjectStyleSettings * styleSettings() const
Returns the project's style settings, which contains settings and properties relating to how a QgsPro...
 
Represents a patch shape for use in map legends.
 
static QgsStyle * defaultStyle()
Returns default application-wide style.
 
bool preserveAspectRatio() const
Returns true if the patch shape should preserve its aspect ratio when it is resized to fit a desired ...
 
bool addLegendPatchShape(const QString &name, const QgsLegendPatchShape &shape, bool update=false)
Adds a legend patch shape with the specified name to the style.
 
QgsSignalBlocker< Object > whileBlocking(Object *object)
Temporarily blocks signals from a QObject while calling a single method from the object.
 
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
 
QString asWkt(int precision=17) const
Exports the geometry to WKT.
 
QgsLegendPatchShape legendPatchShape(const QString &name) const
Returns the legend patch shape with the specified name.
 
Qgis::SymbolType symbolType() const
Returns the symbol type associated with this patch.
 
QgsLegendPatchShapeDialog(const QgsLegendPatchShape &shape, QWidget *parent=nullptr)
Constructor for QgsLegendPatchShapeDialog, initially showing the specified shape.
 
QgsStyle * styleAtPath(const QString &path)
Returns a reference to the style database associated with the project with matching file path.
 
bool saveLegendPatchShape(const QString &name, const QgsLegendPatchShape &shape, bool favorite, const QStringList &tags)
Adds a legend patch shape to the database.
 
QStringList legendPatchShapeNames() const
Returns a list of names of legend patch shapes in the style.
 
StyleEntity
Enum for Entities involved in a style.