52#include <QDesktopServices>
55#include <QInputDialog>
60#include <QStandardItemModel>
64#include "moc_qgsstylemanagerdialog.cpp"
66using namespace Qt::StringLiterals;
75QgsCheckableStyleModel::QgsCheckableStyleModel(
QgsStyleModel *sourceModel, QObject *parent,
bool readOnly )
77 , mStyle( sourceModel->style() )
78 , mReadOnly( readOnly )
82QgsCheckableStyleModel::QgsCheckableStyleModel(
QgsStyle *style, QObject *parent,
bool readOnly )
85 , mReadOnly( readOnly )
89void QgsCheckableStyleModel::setCheckable(
bool checkable )
91 if ( checkable == mCheckable )
94 mCheckable = checkable;
95 emit dataChanged( index( 0, 0 ), index( rowCount() - 1, 0 ), QVector<int>() << Qt::CheckStateRole );
98void QgsCheckableStyleModel::setCheckTag(
const QString &tag )
100 if ( tag == mCheckTag )
104 emit dataChanged( index( 0, 0 ), index( rowCount() - 1, 0 ), QVector<int>() << Qt::CheckStateRole );
107Qt::ItemFlags QgsCheckableStyleModel::flags(
const QModelIndex &index )
const
109 Qt::ItemFlags f = QgsStyleProxyModel::flags( index );
110 if ( !mReadOnly && mCheckable && index.column() == 0 )
111 f |= Qt::ItemIsUserCheckable;
114 f &= ~Qt::ItemIsEditable;
119QVariant QgsCheckableStyleModel::data(
const QModelIndex &index,
int role )
const
126 QFont f = QgsStyleProxyModel::data( index, role ).value<QFont>();
131 case Qt::CheckStateRole:
133 if ( !mCheckable || index.column() != 0 )
137 return tags.contains( mCheckTag ) ? Qt::Checked : Qt::Unchecked;
143 return QgsStyleProxyModel::data( index, role );
146bool QgsCheckableStyleModel::setData(
const QModelIndex &i,
const QVariant &value,
int role )
148 if ( i.row() < 0 || i.row() >= rowCount( QModelIndex() ) || ( role != Qt::EditRole && role != Qt::CheckStateRole ) )
154 if ( role == Qt::CheckStateRole )
156 if ( !mCheckable || mCheckTag.isEmpty() )
159 const QString name = data( index( i.row(),
QgsStyleModel::Name ), Qt::DisplayRole ).toString();
162 if ( value.toInt() == Qt::Checked )
163 return mStyle->tagSymbol( entity, name, QStringList() << mCheckTag );
165 return mStyle->detagSymbol( entity, name, QStringList() << mCheckTag );
167 return QgsStyleProxyModel::setData( i, value, role );
177QString QgsStyleManagerDialog::sPreviousTag;
180 : QDialog( parent, flags )
181 , mReadOnly( readOnly )
184 setCurrentStyle( style );
185 mStyleDatabaseWidget->hide();
189 : QDialog( parent, flags )
194 mProjectStyleModel->setShowDefaultStyle(
true );
195 mComboBoxStyleDatabase->setModel( mProjectStyleModel );
199 connect( mComboBoxStyleDatabase, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this]() {
200 if ( mBlockStyleDatabaseChanges )
203 const QModelIndex index = mProjectStyleModel->index( mComboBoxStyleDatabase->currentIndex(), 0, QModelIndex() );
204 setCurrentStyle( mProjectStyleModel->styleFromIndex( index ) );
207 connect( mButtonAddStyleDatabase, &QAbstractButton::clicked,
this, [
this] { addStyleDatabase(
false ); } );
208 connect( mButtonNewStyleDatabase, &QAbstractButton::clicked,
this, [
this] { addStyleDatabase(
true ); } );
211void QgsStyleManagerDialog::init()
215 connect( tabItemType, &QTabWidget::currentChanged,
this, &QgsStyleManagerDialog::tabItemType_currentChanged );
219 QPushButton *downloadButton = buttonBox->addButton( tr(
"Browse Online Styles" ), QDialogButtonBox::ResetRole );
220 downloadButton->setToolTip( tr(
"Download new styles from the online QGIS style repository" ) );
222 connect( downloadButton, &QPushButton::clicked,
this, [] {
223 QDesktopServices::openUrl( QUrl( u
"https://hub.qgis.org/styles/"_s ) );
226 mMessageBar =
new QgsMessageBar();
227 mMessageBar->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
228 mVerticalLayout->insertWidget( 0, mMessageBar );
231 setWindowModality( Qt::WindowModal );
234 QgsSettings settings;
236 mSplitter->setSizes( QList<int>() << 170 << 540 );
237 mSplitter->restoreState( settings.
value( u
"Windows/StyleV2Manager/splitter"_s ).toByteArray() );
239 tabItemType->setDocumentMode(
true );
240 searchBox->setShowSearchIcon(
true );
241 searchBox->setPlaceholderText( tr(
"Filter symbols…" ) );
245 connect( btnEditItem, &QPushButton::clicked,
this, [
this](
bool ) {
editItem(); } );
246 connect( actnEditItem, &QAction::triggered,
this, [
this](
bool ) {
editItem(); } );
249 connect( btnAddItem, &QPushButton::clicked,
this, [
this](
bool ) {
251 if ( !btnAddItem->menu() )
257 connect( btnRemoveItem, &QPushButton::clicked,
this, [
this](
bool ) {
removeItem(); } );
258 connect( actnRemoveItem, &QAction::triggered,
this, [
this](
bool ) {
removeItem(); } );
260 mShareMenu =
new QMenu( tr(
"Share Menu" ),
this );
261 mExportAction =
new QAction( tr(
"Export Item(s)…" ),
this );
263 mShareMenu->addAction( mExportAction );
265 connect( mCopyToDefaultButton, &QPushButton::clicked,
this, &QgsStyleManagerDialog::copyItemsToDefault );
267 mActionCopyItem =
new QAction( tr(
"Copy Item" ),
this );
268 connect( mActionCopyItem, &QAction::triggered,
this, &QgsStyleManagerDialog::copyItem );
269 mActionPasteItem =
new QAction( tr(
"Paste Item…" ),
this );
270 connect( mActionPasteItem, &QAction::triggered,
this, &QgsStyleManagerDialog::pasteItem );
272 QShortcut *copyShortcut =
new QShortcut( QKeySequence( QKeySequence::StandardKey::Copy ),
this );
273 connect( copyShortcut, &QShortcut::activated,
this, &QgsStyleManagerDialog::copyItem );
274 QShortcut *pasteShortcut =
new QShortcut( QKeySequence( QKeySequence::StandardKey::Paste ),
this );
275 connect( pasteShortcut, &QShortcut::activated,
this, &QgsStyleManagerDialog::pasteItem );
276 QShortcut *removeShortcut =
new QShortcut( QKeySequence( QKeySequence::StandardKey::Delete ),
this );
278 QShortcut *editShortcut =
new QShortcut( QKeySequence( Qt::Key_Return ),
this );
281 mShareMenu->addSeparator();
282 mShareMenu->addAction( actnExportAsPNG );
283 mShareMenu->addAction( actnExportAsSVG );
288 btnShare->setMenu( mShareMenu );
290 listItems->setTextElideMode( Qt::TextElideMode::ElideRight );
292 mSymbolTreeView->setIconSize( QSize(
static_cast<int>( treeIconSize ),
static_cast<int>( treeIconSize ) ) );
294 listItems->setSelectionBehavior( QAbstractItemView::SelectRows );
295 listItems->setSelectionMode( QAbstractItemView::ExtendedSelection );
296 mSymbolTreeView->setSelectionMode( listItems->selectionMode() );
298 QStandardItemModel *groupModel =
new QStandardItemModel( groupTree );
299 groupTree->setModel( groupModel );
300 groupTree->setHeaderHidden(
true );
305 QMenu *groupMenu =
new QMenu( tr(
"Group Actions" ),
this );
307 groupMenu->addAction( actnTagSymbols );
309 actnFinishTagging->setVisible(
false );
310 groupMenu->addAction( actnFinishTagging );
311 groupMenu->addAction( actnEditSmartGroup );
312 btnManageGroups->setMenu( groupMenu );
317 groupTree->setContextMenuPolicy( Qt::CustomContextMenu );
321 listItems->setContextMenuPolicy( Qt::CustomContextMenu );
323 mSymbolTreeView->setContextMenuPolicy( Qt::CustomContextMenu );
326 mMenuBtnAddItemAll =
new QMenu(
this );
327 mMenuBtnAddItemColorRamp =
new QMenu(
this );
328 mMenuBtnAddItemLabelSettings =
new QMenu(
this );
329 mMenuBtnAddItemLegendPatchShape =
new QMenu(
this );
330 mMenuBtnAddItemSymbol3D =
new QMenu(
this );
334 mMenuBtnAddItemAll->addAction( item );
337 mMenuBtnAddItemAll->addAction( item );
340 mMenuBtnAddItemAll->addAction( item );
341 mMenuBtnAddItemAll->addSeparator();
344 for (
const QPair<QString, QString> &rampType : rampTypes )
347 connect( item, &QAction::triggered,
this, [
this, rampType](
bool ) {
addColorRamp( rampType.first ); } );
348 mMenuBtnAddItemAll->addAction( item );
349 mMenuBtnAddItemColorRamp->addAction( item );
351 mMenuBtnAddItemAll->addSeparator();
353 connect( item, &QAction::triggered,
this, [
this](
bool ) { addTextFormat(); } );
354 mMenuBtnAddItemAll->addAction( item );
355 mMenuBtnAddItemAll->addSeparator();
358 mMenuBtnAddItemAll->addAction( item );
359 mMenuBtnAddItemLabelSettings->addAction( item );
362 mMenuBtnAddItemAll->addAction( item );
363 mMenuBtnAddItemLabelSettings->addAction( item );
366 mMenuBtnAddItemAll->addAction( item );
367 mMenuBtnAddItemLabelSettings->addAction( item );
369 mMenuBtnAddItemAll->addSeparator();
372 mMenuBtnAddItemAll->addAction( item );
373 mMenuBtnAddItemLegendPatchShape->addAction( item );
375 connect( item, &QAction::triggered,
this, [
this](
bool ) { addLegendPatchShape(
Qgis::SymbolType::Line ); } );
376 mMenuBtnAddItemAll->addAction( item );
377 mMenuBtnAddItemLegendPatchShape->addAction( item );
379 connect( item, &QAction::triggered,
this, [
this](
bool ) { addLegendPatchShape(
Qgis::SymbolType::Fill ); } );
380 mMenuBtnAddItemAll->addAction( item );
381 mMenuBtnAddItemLegendPatchShape->addAction( item );
383 mMenuBtnAddItemAll->addSeparator();
385 connect( item, &QAction::triggered,
this, [
this](
bool ) { addSymbol3D( u
"point"_s ); } );
386 mMenuBtnAddItemAll->addAction( item );
387 mMenuBtnAddItemSymbol3D->addAction( item );
389 connect( item, &QAction::triggered,
this, [
this](
bool ) { addSymbol3D( u
"line"_s ); } );
390 mMenuBtnAddItemAll->addAction( item );
391 mMenuBtnAddItemSymbol3D->addAction( item );
393 connect( item, &QAction::triggered,
this, [
this](
bool ) { addSymbol3D( u
"polygon"_s ); } );
394 mMenuBtnAddItemAll->addAction( item );
395 mMenuBtnAddItemSymbol3D->addAction( item );
398 mGroupMenu =
new QMenu(
this );
399 mGroupListMenu =
new QMenu( mGroupMenu );
400 mGroupListMenu->setTitle( tr(
"Add to Tag" ) );
401 mGroupListMenu->setEnabled(
false );
408 mGroupTreeContextMenu =
new QMenu(
this );
410 connect( actnAddTag, &QAction::triggered,
this, [
this](
bool ) {
addTag(); } );
411 connect( actnAddSmartgroup, &QAction::triggered,
this, [
this](
bool ) {
addSmartgroup(); } );
414 tabItemType_currentChanged( 0 );
416 connect( mButtonIconView, &QToolButton::toggled,
this, [
this](
bool active ) {
419 mSymbolViewStackedWidget->setCurrentIndex( 0 );
421 QgsSettings().setValue( u
"Windows/StyleV2Manager/lastIconView"_s, 0,
QgsSettings::Gui );
424 connect( mButtonListView, &QToolButton::toggled,
this, [
this](
bool active ) {
427 QgsSettings().setValue( u
"Windows/StyleV2Manager/lastIconView"_s, 1,
QgsSettings::Gui );
428 mSymbolViewStackedWidget->setCurrentIndex( 1 );
432 const int currentView = settings.
value( u
"Windows/StyleV2Manager/lastIconView"_s, 0,
QgsSettings::Gui ).toInt();
433 if ( currentView == 0 )
434 mButtonIconView->setChecked(
true );
436 mButtonListView->setChecked(
true );
438 mSymbolTreeView->header()->restoreState( settings.
value( u
"Windows/StyleV2Manager/treeState"_s, QByteArray(),
QgsSettings::Gui ).toByteArray() );
439 connect( mSymbolTreeView->header(), &QHeaderView::sectionResized,
this, [
this] {
441 QgsSettings().setValue( u
"Windows/StyleV2Manager/treeState"_s, mSymbolTreeView->header()->saveState(), QgsSettings::Gui );
444 const int thumbnailSize = settings.
value( u
"Windows/StyleV2Manager/thumbnailSize"_s, 0,
QgsSettings::Gui ).toInt();
445 mSliderIconSize->setValue( thumbnailSize );
446 connect( mSliderIconSize, &QSlider::valueChanged,
this, &QgsStyleManagerDialog::setThumbnailSize );
447 setThumbnailSize( thumbnailSize );
450void QgsStyleManagerDialog::setCurrentStyle(
QgsStyle *style )
452 if ( mStyle == style )
462 QgsCheckableStyleModel *oldModel = mModel;
465 const bool readOnly = isReadOnly();
468 if ( !mActionCopyToDefault )
470 mActionCopyToDefault =
new QAction( tr(
"Copy Selection to Default Style…" ),
this );
471 mShareMenu->insertAction( mActionCopyItem, mActionCopyToDefault );
472 connect( mActionCopyToDefault, &QAction::triggered,
this, &QgsStyleManagerDialog::copyItemsToDefault );
474 mCopyToDefaultButton->show();
475 mModel =
new QgsCheckableStyleModel( mStyle,
this, readOnly );
479 mCopyToDefaultButton->hide();
480 if ( mActionCopyToDefault )
482 mActionCopyToDefault->deleteLater();
483 mActionCopyToDefault =
nullptr;
487 mModel->addDesiredIconSize( mSymbolTreeView->iconSize() );
488 mModel->addDesiredIconSize( listItems->iconSize() );
489 mModel->addTargetScreenProperties( QgsScreenProperties( screen() ) );
491 mModel->setFilterString( searchBox->text() );
493 listItems->setModel( mModel );
494 mSymbolTreeView->setModel( mModel );
496 mSymbolTreeView->setSelectionModel( listItems->selectionModel() );
503 oldModel->deleteLater();
511 if ( mProjectStyleModel )
513 const QModelIndex styleIndex = mProjectStyleModel->indexFromStyle( mStyle );
514 mBlockStyleDatabaseChanges++;
515 mComboBoxStyleDatabase->setCurrentIndex( styleIndex.row() );
516 mBlockStyleDatabaseChanges--;
521 btnAddTag->setEnabled(
false );
522 btnAddSmartgroup->setEnabled(
false );
523 btnManageGroups->setEnabled(
false );
525 btnAddItem->setVisible(
false );
526 btnRemoveItem->setVisible(
false );
527 btnEditItem->setVisible(
false );
528 btnAddSmartgroup->setVisible(
false );
529 btnAddTag->setVisible(
false );
530 btnManageGroups->setVisible(
false );
532 delete mImportAction;
533 mImportAction =
nullptr;
535 mGroupTreeContextMenu->clear();
537 mGroupMenu->addAction( mActionCopyItem );
541 btnAddTag->setEnabled(
true );
542 btnAddSmartgroup->setEnabled(
true );
543 btnManageGroups->setEnabled(
true );
545 btnAddItem->setVisible(
true );
546 btnRemoveItem->setVisible(
true );
547 btnEditItem->setVisible(
true );
548 btnAddSmartgroup->setVisible(
true );
549 btnAddTag->setVisible(
true );
550 btnManageGroups->setVisible(
true );
552 if ( !mImportAction )
554 mImportAction =
new QAction( tr(
"Import Item(s)…" ),
this );
556 mShareMenu->insertAction( mShareMenu->actions().at( mShareMenu->actions().indexOf( mExportAction ) + 1 ), mImportAction );
560 mGroupTreeContextMenu->clear();
561 mGroupTreeContextMenu->addAction( actnEditSmartGroup );
562 mGroupTreeContextMenu->addAction( actnAddTag );
563 mGroupTreeContextMenu->addAction( actnAddSmartgroup );
564 mGroupTreeContextMenu->addAction( actnRemoveGroup );
567 mGroupMenu->addAction( actnAddFavorite );
568 mGroupMenu->addAction( actnRemoveFavorite );
569 mGroupMenu->addSeparator()->setParent(
this );
570 mGroupMenu->addMenu( mGroupListMenu );
571 mGroupMenu->addAction( actnDetag );
572 mGroupMenu->addSeparator()->setParent(
this );
573 mGroupMenu->addAction( actnRemoveItem );
574 mGroupMenu->addAction( actnEditItem );
575 mGroupMenu->addAction( mActionCopyItem );
576 mGroupMenu->addAction( mActionPasteItem );
577 mGroupMenu->addSeparator()->setParent(
this );
580 if ( mActionCopyToDefault )
582 mGroupMenu->addAction( mActionCopyToDefault );
584 mGroupMenu->addAction( actnExportAsPNG );
585 mGroupMenu->addAction( actnExportAsSVG );
588 const QModelIndexList prevIndex = groupTree->model()->match( groupTree->model()->index( 0, 0 ), Qt::UserRole + 1, sPreviousTag, 1, Qt::MatchFixedString | Qt::MatchCaseSensitive | Qt::MatchRecursive );
589 groupTree->setCurrentIndex( !prevIndex.empty() ? prevIndex.at( 0 ) : groupTree->model()->index( 0, 0 ) );
592 tabItemType_currentChanged( tabItemType->currentIndex() );
598void QgsStyleManagerDialog::currentStyleAboutToBeDestroyed()
609 settings.
setValue( u
"Windows/StyleV2Manager/splitter"_s, mSplitter->saveState() );
616void QgsStyleManagerDialog::tabItemType_currentChanged(
int )
625 searchBox->setPlaceholderText( isSymbol ? tr(
"Filter symbols…" ) : isColorRamp ? tr(
"Filter color ramps…" )
626 : isTextFormat ? tr(
"Filter text symbols…" )
627 : isLabelSettings ? tr(
"Filter label settings…" )
628 : isLegendPatchShape ? tr(
"Filter legend patch shapes…" )
629 : tr(
"Filter 3D symbols…" ) );
631 const bool readOnly = isReadOnly();
632 if ( !readOnly && isColorRamp )
634 btnAddItem->setMenu( mMenuBtnAddItemColorRamp );
636 else if ( !readOnly && isLegendPatchShape )
638 btnAddItem->setMenu( mMenuBtnAddItemLegendPatchShape );
640 else if ( !readOnly && isSymbol3D )
642 btnAddItem->setMenu( mMenuBtnAddItemSymbol3D );
644 else if ( !readOnly && isLabelSettings )
646 btnAddItem->setMenu( mMenuBtnAddItemLabelSettings );
648 else if ( !readOnly && !isSymbol && !isColorRamp )
650 btnAddItem->setMenu(
nullptr );
652 else if ( !readOnly && tabItemType->currentIndex() == 0 )
654 btnAddItem->setMenu( mMenuBtnAddItemAll );
658 btnAddItem->setMenu(
nullptr );
661 actnExportAsPNG->setVisible( isSymbol );
662 actnExportAsSVG->setVisible( isSymbol );
670 mModel->setEntityFilterEnabled( !allTypesSelected() );
671 mModel->setSymbolTypeFilterEnabled( isSymbol && !allTypesSelected() );
672 if ( isSymbol && !allTypesSelected() )
679void QgsStyleManagerDialog::copyItemsToDefault()
681 const QList<ItemDetails> items = selectedItems();
682 if ( !items.empty() )
686 if ( !mBaseName.isEmpty() )
687 options.append( mBaseName );
690 defaultTags.sort( Qt::CaseInsensitive );
691 options.append( defaultTags );
692 const QString tags = QInputDialog::getItem(
this, tr(
"Import Items" ), tr(
"Additional tags to add (comma separated)" ), options, mBaseName.isEmpty() ? -1 : 0,
true, &ok );
696 const QStringList parts = tags.split(
',', Qt::SkipEmptyParts );
697 QStringList additionalTags;
698 additionalTags.reserve( parts.count() );
699 for (
const QString &tag : parts )
700 additionalTags << tag.trimmed();
702 auto cursorOverride = std::make_unique<QgsTemporaryCursorOverride>( Qt::WaitCursor );
703 const int count = copyItems( items, mStyle,
QgsStyle::defaultStyle(),
this, cursorOverride,
true, additionalTags,
false,
false );
704 cursorOverride.reset();
707 mMessageBar->pushSuccess( tr(
"Import Items" ), count > 1 ? tr(
"Successfully imported %n item(s).",
nullptr, count ) : tr(
"Successfully imported item." ) );
712void QgsStyleManagerDialog::copyItem()
714 const QList<ItemDetails> items = selectedItems();
718 ItemDetails details = items.at( 0 );
719 switch ( details.entityType )
723 std::unique_ptr<QgsSymbol> symbol( mStyle->symbol( details.name ) );
732 const QgsTextFormat format( mStyle->textFormat( details.name ) );
733 QApplication::clipboard()->setMimeData( format.toMimeData() );
739 const QgsPalLayerSettings labelSettings( mStyle->labelSettings( details.name ) );
740 QApplication::clipboard()->setMimeData( labelSettings.toMimeData() );
753void QgsStyleManagerDialog::pasteItem()
755 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
759 QgsStyleSaveDialog saveDlg(
this );
760 saveDlg.setWindowTitle( tr(
"Paste Symbol" ) );
761 saveDlg.setDefaultTags( defaultTag );
762 if ( !saveDlg.exec() || saveDlg.name().isEmpty() )
765 if ( mStyle->symbolNames().contains( saveDlg.name() ) )
767 int res = QMessageBox::warning(
this, tr(
"Paste Symbol" ), tr(
"A symbol with the name '%1' already exists. Overwrite?" ).arg( saveDlg.name() ), QMessageBox::Yes | QMessageBox::No );
768 if ( res != QMessageBox::Yes )
772 mStyle->removeSymbol( saveDlg.name() );
775 QStringList symbolTags = saveDlg.tags().split(
',' );
776 QgsSymbol *newSymbol = tempSymbol.get();
777 mStyle->addSymbol( saveDlg.name(), tempSymbol.release() );
779 mStyle->saveSymbol( saveDlg.name(), newSymbol, saveDlg.isFavorite(), symbolTags );
789 saveDlg.setDefaultTags( defaultTag );
790 saveDlg.setWindowTitle( tr(
"Paste Label Settings" ) );
791 if ( !saveDlg.exec() || saveDlg.name().isEmpty() )
794 if ( mStyle->labelSettingsNames().contains( saveDlg.name() ) )
796 int res = QMessageBox::warning(
this, tr(
"Paste Label Settings" ), tr(
"A label setting with the name '%1' already exists. Overwrite?" ).arg( saveDlg.name() ), QMessageBox::Yes | QMessageBox::No );
797 if ( res != QMessageBox::Yes )
801 mStyle->removeLabelSettings( saveDlg.name() );
804 QStringList symbolTags = saveDlg.tags().split(
',' );
805 mStyle->addLabelSettings( saveDlg.name(), labelSettings );
807 mStyle->saveLabelSettings( saveDlg.name(), labelSettings, saveDlg.isFavorite(), symbolTags );
816 saveDlg.setDefaultTags( defaultTag );
817 saveDlg.setWindowTitle( tr(
"Paste Text Format" ) );
818 if ( !saveDlg.exec() || saveDlg.name().isEmpty() )
821 if ( mStyle->textFormatNames().contains( saveDlg.name() ) )
823 int res = QMessageBox::warning(
this, tr(
"Paste Text Format" ), tr(
"A format with the name '%1' already exists. Overwrite?" ).arg( saveDlg.name() ), QMessageBox::Yes | QMessageBox::No );
824 if ( res != QMessageBox::Yes )
828 mStyle->removeTextFormat( saveDlg.name() );
831 QStringList symbolTags = saveDlg.tags().split(
',' );
832 mStyle->addTextFormat( saveDlg.name(), format );
834 mStyle->saveTextFormat( saveDlg.name(), format, saveDlg.isFavorite(), symbolTags );
839void QgsStyleManagerDialog::setThumbnailSize(
int value )
844 const double spacing =
Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance(
'X' ) * ( value * 2.2 + 14 );
847 listItems->setIconSize( QSize(
static_cast<int>( iconSize ),
static_cast<int>( iconSize * 0.9 ) ) );
848 listItems->setGridSize( QSize(
static_cast<int>( spacing ),
static_cast<int>( verticalSpacing ) ) );
851 mModel->addDesiredIconSize( listItems->iconSize() );
854 QgsSettings().setValue( u
"Windows/StyleV2Manager/thumbnailSize"_s, value,
QgsSettings::Gui );
857int QgsStyleManagerDialog::selectedItemType()
859 QModelIndex index = listItems->selectionModel()->currentIndex();
860 if ( !index.isValid() )
878bool QgsStyleManagerDialog::allTypesSelected()
const
880 return tabItemType->currentIndex() == 0;
883bool QgsStyleManagerDialog::isReadOnly()
const
885 return mReadOnly || ( mStyle && mStyle->isReadOnly() );
888QList<QgsStyleManagerDialog::ItemDetails> QgsStyleManagerDialog::selectedItems()
890 QList<QgsStyleManagerDialog::ItemDetails> res;
891 QModelIndexList indices = listItems->selectionModel()->selectedRows();
892 for (
const QModelIndex &index : indices )
894 if ( !index.isValid() )
901 details.name = mModel->data( mModel->index( index.row(),
QgsStyleModel::Name, index.parent() ), Qt::DisplayRole ).toString();
908int QgsStyleManagerDialog::copyItems(
const QList<QgsStyleManagerDialog::ItemDetails> &items,
QgsStyle *src,
QgsStyle *dst, QWidget *parentWidget, std::unique_ptr<QgsTemporaryCursorOverride> &cursorOverride,
bool isImport,
const QStringList &importTags,
bool addToFavorites,
bool ignoreSourceTags )
911 bool overwriteAll =
true;
921 for (
auto &details : items )
923 QStringList symbolTags;
924 if ( !ignoreSourceTags )
926 symbolTags = src->
tagsOfSymbol( details.entityType, details.name );
929 bool addItemToFavorites =
false;
932 symbolTags << importTags;
933 addItemToFavorites = addToFavorites;
936 switch ( details.entityType )
940 std::unique_ptr<QgsSymbol> symbol( src->
symbol( details.name ) );
944 const bool hasDuplicateName = dst->
symbolNames().contains( details.name );
945 bool overwriteThis =
false;
947 addItemToFavorites = favoriteSymbols.contains( details.name );
949 if ( hasDuplicateName && prompt )
951 cursorOverride.reset();
952 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Symbol" ) : tr(
"Export Symbol" ), tr(
"A symbol with the name “%1” already exists.\nOverwrite?" ).arg( details.name ), QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
953 cursorOverride = std::make_unique<QgsTemporaryCursorOverride>( Qt::WaitCursor );
956 case QMessageBox::Cancel:
959 case QMessageBox::No:
962 case QMessageBox::Yes:
963 overwriteThis =
true;
966 case QMessageBox::YesToAll:
971 case QMessageBox::NoToAll:
973 overwriteAll =
false;
978 if ( !hasDuplicateName || overwriteAll || overwriteThis )
980 QgsSymbol *newSymbol = symbol.get();
981 dst->
addSymbol( details.name, symbol.release() );
982 dst->
saveSymbol( details.name, newSymbol, addItemToFavorites, symbolTags );
990 std::unique_ptr<QgsColorRamp> ramp( src->
colorRamp( details.name ) );
994 const bool hasDuplicateName = dst->
colorRampNames().contains( details.name );
995 bool overwriteThis =
false;
997 addItemToFavorites = favoriteColorramps.contains( details.name );
999 if ( hasDuplicateName && prompt )
1001 cursorOverride.reset();
1002 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Color Ramp" ) : tr(
"Export Color Ramp" ), tr(
"A color ramp with the name “%1” already exists.\nOverwrite?" ).arg( details.name ), QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1003 cursorOverride = std::make_unique<QgsTemporaryCursorOverride>( Qt::WaitCursor );
1006 case QMessageBox::Cancel:
1009 case QMessageBox::No:
1012 case QMessageBox::Yes:
1013 overwriteThis =
true;
1016 case QMessageBox::YesToAll:
1018 overwriteAll =
true;
1021 case QMessageBox::NoToAll:
1023 overwriteAll =
false;
1028 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1030 QgsColorRamp *newRamp = ramp.get();
1032 dst->
saveColorRamp( details.name, newRamp, addItemToFavorites, symbolTags );
1040 const QgsTextFormat format( src->
textFormat( details.name ) );
1042 const bool hasDuplicateName = dst->
textFormatNames().contains( details.name );
1043 bool overwriteThis =
false;
1045 addItemToFavorites = favoriteTextFormats.contains( details.name );
1047 if ( hasDuplicateName && prompt )
1049 cursorOverride.reset();
1050 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Text Format" ) : tr(
"Export Text Format" ), tr(
"A text format with the name “%1” already exists.\nOverwrite?" ).arg( details.name ), QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1051 cursorOverride = std::make_unique<QgsTemporaryCursorOverride>( Qt::WaitCursor );
1054 case QMessageBox::Cancel:
1057 case QMessageBox::No:
1060 case QMessageBox::Yes:
1061 overwriteThis =
true;
1064 case QMessageBox::YesToAll:
1066 overwriteAll =
true;
1069 case QMessageBox::NoToAll:
1071 overwriteAll =
false;
1076 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1079 dst->
saveTextFormat( details.name, format, addItemToFavorites, symbolTags );
1087 const QgsPalLayerSettings settings( src->
labelSettings( details.name ) );
1090 bool overwriteThis =
false;
1092 addItemToFavorites = favoriteLabelSettings.contains( details.name );
1094 if ( hasDuplicateName && prompt )
1096 cursorOverride.reset();
1097 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Label Settings" ) : tr(
"Export Label Settings" ), tr(
"Label settings with the name “%1” already exist.\nOverwrite?" ).arg( details.name ), QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1098 cursorOverride = std::make_unique<QgsTemporaryCursorOverride>( Qt::WaitCursor );
1101 case QMessageBox::Cancel:
1104 case QMessageBox::No:
1107 case QMessageBox::Yes:
1108 overwriteThis =
true;
1111 case QMessageBox::YesToAll:
1113 overwriteAll =
true;
1116 case QMessageBox::NoToAll:
1118 overwriteAll =
false;
1123 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1126 dst->
saveLabelSettings( details.name, settings, addItemToFavorites, symbolTags );
1137 bool overwriteThis =
false;
1139 addItemToFavorites = favoriteLegendPatchShapes.contains( details.name );
1141 if ( hasDuplicateName && prompt )
1143 cursorOverride.reset();
1144 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import Legend Patch Shape" ) : tr(
"Export Legend Patch Shape" ), tr(
"Legend patch shape with the name “%1” already exist.\nOverwrite?" ).arg( details.name ), QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1145 cursorOverride = std::make_unique<QgsTemporaryCursorOverride>( Qt::WaitCursor );
1148 case QMessageBox::Cancel:
1151 case QMessageBox::No:
1154 case QMessageBox::Yes:
1155 overwriteThis =
true;
1158 case QMessageBox::YesToAll:
1160 overwriteAll =
true;
1163 case QMessageBox::NoToAll:
1165 overwriteAll =
false;
1170 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1181 std::unique_ptr<QgsAbstract3DSymbol> symbol( src->
symbol3D( details.name ) );
1185 const bool hasDuplicateName = dst->
symbol3DNames().contains( details.name );
1186 bool overwriteThis =
false;
1188 addItemToFavorites = favorite3dSymbols.contains( details.name );
1190 if ( hasDuplicateName && prompt )
1192 cursorOverride.reset();
1193 int res = QMessageBox::warning( parentWidget, isImport ? tr(
"Import 3D Symbol" ) : tr(
"Export 3D Symbol" ), tr(
"A 3D symbol with the name “%1” already exists.\nOverwrite?" ).arg( details.name ), QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel );
1194 cursorOverride = std::make_unique<QgsTemporaryCursorOverride>( Qt::WaitCursor );
1197 case QMessageBox::Cancel:
1200 case QMessageBox::No:
1203 case QMessageBox::Yes:
1204 overwriteThis =
true;
1207 case QMessageBox::YesToAll:
1209 overwriteAll =
true;
1212 case QMessageBox::NoToAll:
1214 overwriteAll =
false;
1219 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1221 QgsAbstract3DSymbol *newSymbol = symbol.get();
1222 dst->
addSymbol3D( details.name, symbol.release() );
1223 dst->
saveSymbol3D( details.name, newSymbol, addItemToFavorites, symbolTags );
1237bool QgsStyleManagerDialog::addTextFormat()
1239 QgsTextFormat format;
1240 QgsTextFormatDialog formatDlg( format,
nullptr,
this );
1241 formatDlg.setWindowTitle( tr(
"New Text Format" ) );
1242 if ( !formatDlg.exec() )
1244 format = formatDlg.format();
1247 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
1248 saveDlg.setDefaultTags( defaultTag );
1249 if ( !saveDlg.exec() )
1251 QString name = saveDlg.name();
1254 bool nameInvalid =
true;
1255 while ( nameInvalid )
1258 if ( name.isEmpty() )
1260 QMessageBox::warning(
this, tr(
"Save Text Format" ), tr(
"Cannot save text format without name. Enter a name." ) );
1262 else if ( mStyle->textFormatNames().contains( name ) )
1264 int res = QMessageBox::warning(
this, tr(
"Save Text Format" ), tr(
"Text format with name '%1' already exists. Overwrite?" ).arg( name ), QMessageBox::Yes | QMessageBox::No );
1265 if ( res == QMessageBox::Yes )
1267 mStyle->removeTextFormat( name );
1268 nameInvalid =
false;
1274 nameInvalid =
false;
1279 name = QInputDialog::getText(
this, tr(
"Text Format Name" ), tr(
"Please enter a name for new text format:" ), QLineEdit::Normal, name, &ok );
1287 QStringList symbolTags = saveDlg.tags().split(
',' );
1290 mStyle->addTextFormat( name, format );
1291 mStyle->saveTextFormat( name, format, saveDlg.isFavorite(), symbolTags );
1299 groupChanged( groupTree->selectionModel()->currentIndex() );
1312 switch ( tabItemType->currentIndex() )
1337 QModelIndex index = listItems->selectionModel()->currentIndex();
1338 if ( !index.isValid() )
1341 return mModel->data( mModel->index( index.row(),
QgsStyleModel::Name, index.parent() ), Qt::DisplayRole ).toString();
1346 bool changed =
false;
1357 changed = addTextFormat();
1376 Q_ASSERT(
false &&
"not implemented" );
1389 QString name = tr(
"new symbol" );
1390 QString dialogTitle;
1395 name = tr(
"new marker" );
1396 dialogTitle = tr(
"New Marker Symbol" );
1400 name = tr(
"new line" );
1401 dialogTitle = tr(
"New Line Symbol" );
1405 name = tr(
"new fill symbol" );
1406 dialogTitle = tr(
"New Fill Symbol" );
1409 Q_ASSERT(
false &&
"unknown symbol type" );
1419 dlg.setWindowTitle( dialogTitle );
1420 if ( dlg.exec() == 0 )
1427 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
1429 if ( !saveDlg.exec() )
1435 name = saveDlg.
name();
1438 bool nameInvalid =
true;
1439 while ( nameInvalid )
1442 if ( name.isEmpty() )
1444 QMessageBox::warning(
this, tr(
"Save Symbol" ), tr(
"Cannot save symbol without name. Enter a name." ) );
1446 else if ( mStyle->symbolNames().contains( name ) )
1448 int res = QMessageBox::warning(
this, tr(
"Save Symbol" ), tr(
"Symbol with name '%1' already exists. Overwrite?" ).arg( name ), QMessageBox::Yes | QMessageBox::No );
1449 if ( res == QMessageBox::Yes )
1451 mStyle->removeSymbol( name );
1452 nameInvalid =
false;
1458 nameInvalid =
false;
1463 name = QInputDialog::getText(
this, tr(
"Symbol Name" ), tr(
"Please enter a name for new symbol:" ), QLineEdit::Normal, name, &ok );
1472 QStringList symbolTags = saveDlg.
tags().split(
',' );
1475 mStyle->addSymbol( name, symbol );
1476 mStyle->saveSymbol( name, symbol, saveDlg.
isFavorite(), symbolTags );
1485 QString rampType = type;
1487 if ( rampType.isEmpty() )
1492 QStringList rampTypeNames;
1493 rampTypeNames.reserve( rampTypes.size() );
1494 for (
const QPair<QString, QString> &type : rampTypes )
1495 rampTypeNames << type.second;
1496 const QString selectedRampTypeName = QInputDialog::getItem( parent, tr(
"Color Ramp Type" ), tr(
"Please select color ramp type:" ), rampTypeNames, 0,
false, &ok );
1497 if ( !ok || selectedRampTypeName.isEmpty() )
1500 rampType = rampTypes.value( rampTypeNames.indexOf( selectedRampTypeName ) ).first;
1503 QString name = tr(
"new ramp" );
1505 std::unique_ptr<QgsColorRamp> ramp;
1509 dlg.setWindowTitle( tr(
"New Gradient Color Ramp" ) );
1515 name = tr(
"new gradient ramp" );
1520 dlg.setWindowTitle( tr(
"New Random Color Ramp" ) );
1526 name = tr(
"new random ramp" );
1531 dlg.setWindowTitle( tr(
"New ColorBrewer Ramp" ) );
1542 dlg.setWindowTitle( tr(
"New Preset Color Ramp" ) );
1548 name = tr(
"new preset ramp" );
1553 dlg.setWindowTitle( tr(
"New cpt-city Color Ramp" ) );
1578 if ( !saveDlg.exec() )
1583 name = saveDlg.
name();
1586 bool nameInvalid =
true;
1587 while ( nameInvalid )
1590 if ( name.isEmpty() )
1592 QMessageBox::warning( parent, tr(
"Save Color Ramp" ), tr(
"Cannot save color ramp without name. Enter a name." ) );
1596 int res = QMessageBox::warning( parent, tr(
"Save Color Ramp" ), tr(
"Color ramp with name '%1' already exists. Overwrite?" ).arg( name ), QMessageBox::Yes | QMessageBox::No );
1597 if ( res == QMessageBox::Yes )
1599 nameInvalid =
false;
1605 nameInvalid =
false;
1610 name = QInputDialog::getText( parent, tr(
"Color Ramp Name" ), tr(
"Please enter a name for new color ramp:" ), QLineEdit::Normal, name, &ok );
1618 QStringList colorRampTags = saveDlg.
tags().split(
',' );
1630 mFavoritesGroupVisible = show;
1636 mSmartGroupVisible = show;
1648 setWindowState( windowState() & ~Qt::WindowMinimized );
1656 if ( !rampName.isEmpty() )
1668 if ( selectedItemType() < 3 )
1672 else if ( selectedItemType() == 3 )
1676 else if ( selectedItemType() == 4 )
1680 else if ( selectedItemType() == 5 )
1682 editLabelSettings();
1684 else if ( selectedItemType() == 6 )
1686 editLegendPatchShape();
1688 else if ( selectedItemType() == 7 )
1694 Q_ASSERT(
false &&
"not implemented" );
1701 if ( symbolName.isEmpty() )
1704 std::unique_ptr<QgsSymbol> symbol( mStyle->symbol( symbolName ) );
1708 dlg.setWindowTitle( symbolName );
1710 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1716 mStyle->addSymbol( symbolName, symbol.release(),
true );
1724 if ( name.isEmpty() )
1727 std::unique_ptr<QgsColorRamp> ramp( mStyle->colorRamp( name ) );
1733 dlg.setWindowTitle( name );
1735 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1747 dlg.setWindowTitle( name );
1749 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1761 dlg.setWindowTitle( name );
1763 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1775 dlg.setWindowTitle( name );
1777 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1789 dlg.setWindowTitle( name );
1791 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1808 Q_ASSERT(
false &&
"invalid ramp type" );
1811 mStyle->addColorRamp( name, ramp.release(),
true );
1816bool QgsStyleManagerDialog::editTextFormat()
1819 if ( formatName.isEmpty() )
1826 dlg.setWindowTitle( formatName );
1828 dlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1841 QgsPalLayerSettings settings;
1842 QgsLabelSettingsDialog settingsDlg( settings,
nullptr,
nullptr,
this, type );
1843 settingsDlg.setWindowTitle( tr(
"New Label Settings" ) );
1845 settingsDlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1847 if ( !settingsDlg.exec() )
1850 settings = settingsDlg.settings();
1854 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
1855 saveDlg.setDefaultTags( defaultTag );
1856 if ( !saveDlg.exec() )
1858 QString name = saveDlg.name();
1861 bool nameInvalid =
true;
1862 while ( nameInvalid )
1865 if ( name.isEmpty() )
1867 QMessageBox::warning(
this, tr(
"Save Label Settings" ), tr(
"Cannot save label settings without a name. Enter a name." ) );
1869 else if ( mStyle->labelSettingsNames().contains( name ) )
1871 int res = QMessageBox::warning(
this, tr(
"Save Label Settings" ), tr(
"Label settings with the name '%1' already exist. Overwrite?" ).arg( name ), QMessageBox::Yes | QMessageBox::No );
1872 if ( res == QMessageBox::Yes )
1874 mStyle->removeLabelSettings( name );
1875 nameInvalid =
false;
1881 nameInvalid =
false;
1886 name = QInputDialog::getText(
this, tr(
"Label Settings Name" ), tr(
"Please enter a name for the new label settings:" ), QLineEdit::Normal, name, &ok );
1894 QStringList symbolTags = saveDlg.tags().split(
',' );
1897 mStyle->addLabelSettings( name, settings );
1898 mStyle->saveLabelSettings( name, settings, saveDlg.isFavorite(), symbolTags );
1904bool QgsStyleManagerDialog::editLabelSettings()
1907 if ( formatName.isEmpty() )
1910 QgsPalLayerSettings settings = mStyle->labelSettings( formatName );
1914 QgsLabelSettingsDialog dlg( settings,
nullptr,
nullptr,
this, geomType );
1915 dlg.setWindowTitle( formatName );
1919 settings = dlg.settings();
1923 mStyle->addLabelSettings( formatName, settings,
true );
1930 QgsLegendPatchShape shape = mStyle->defaultPatch( type, QSizeF( 10, 5 ) );
1931 QgsLegendPatchShapeDialog dialog( shape,
this );
1932 dialog.setWindowTitle( tr(
"New Legend Patch Shape" ) );
1934 dialog.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1936 if ( !dialog.exec() )
1939 shape = dialog.shape();
1942 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
1943 saveDlg.setDefaultTags( defaultTag );
1944 if ( !saveDlg.exec() )
1946 QString name = saveDlg.name();
1949 bool nameInvalid =
true;
1950 while ( nameInvalid )
1953 if ( name.isEmpty() )
1955 QMessageBox::warning(
this, tr(
"Save Legend Patch Shape" ), tr(
"Cannot save legend patch shapes without a name. Enter a name." ) );
1957 else if ( mStyle->legendPatchShapeNames().contains( name ) )
1959 int res = QMessageBox::warning(
this, tr(
"Save Legend Patch Shape" ), tr(
"A legend patch shape with the name '%1' already exists. Overwrite?" ).arg( name ), QMessageBox::Yes | QMessageBox::No );
1960 if ( res == QMessageBox::Yes )
1963 nameInvalid =
false;
1969 nameInvalid =
false;
1974 name = QInputDialog::getText(
this, tr(
"Legend Patch Shape Name" ), tr(
"Please enter a name for the new legend patch shape:" ), QLineEdit::Normal, name, &ok );
1982 QStringList symbolTags = saveDlg.tags().split(
',' );
1985 mStyle->addLegendPatchShape( name, shape );
1986 mStyle->saveLegendPatchShape( name, shape, saveDlg.isFavorite(), symbolTags );
1992bool QgsStyleManagerDialog::editLegendPatchShape()
1995 if ( shapeName.isEmpty() )
1998 QgsLegendPatchShape shape = mStyle->legendPatchShape( shapeName );
2003 QgsLegendPatchShapeDialog dlg( shape,
this );
2004 dlg.setWindowTitle( shapeName );
2008 shape = dlg.shape();
2011 mStyle->addLegendPatchShape( shapeName, shape,
true );
2016bool QgsStyleManagerDialog::addSymbol3D(
const QString &type )
2022 Qgs3DSymbolDialog dialog( symbol.get(),
this );
2023 dialog.setWindowTitle( tr(
"New 3D Symbol" ) );
2025 dialog.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
2027 if ( !dialog.exec() )
2030 symbol.reset( dialog.symbol() );
2035 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
2036 saveDlg.setDefaultTags( defaultTag );
2037 if ( !saveDlg.exec() )
2039 QString name = saveDlg.name();
2042 bool nameInvalid =
true;
2043 while ( nameInvalid )
2046 if ( name.isEmpty() )
2048 QMessageBox::warning(
this, tr(
"Save 3D Symbol" ), tr(
"Cannot save 3D symbols without a name. Enter a name." ) );
2050 else if ( mStyle->symbol3DNames().contains( name ) )
2052 int res = QMessageBox::warning(
this, tr(
"Save 3D Symbol" ), tr(
"A 3D symbol with the name '%1' already exists. Overwrite?" ).arg( name ), QMessageBox::Yes | QMessageBox::No );
2053 if ( res == QMessageBox::Yes )
2056 nameInvalid =
false;
2062 nameInvalid =
false;
2067 name = QInputDialog::getText(
this, tr(
"3D Symbol Name" ), tr(
"Please enter a name for the new 3D symbol:" ), QLineEdit::Normal, name, &ok );
2075 QStringList symbolTags = saveDlg.tags().split(
',' );
2078 QgsAbstract3DSymbol *newSymbol = symbol.get();
2079 mStyle->addSymbol3D( name, symbol.release() );
2080 mStyle->saveSymbol3D( name, newSymbol, saveDlg.isFavorite(), symbolTags );
2086bool QgsStyleManagerDialog::editSymbol3D()
2089 if ( symbolName.isEmpty() )
2092 std::unique_ptr<QgsAbstract3DSymbol> symbol( mStyle->symbol3D( symbolName ) );
2097 Qgs3DSymbolDialog dlg( symbol.get(),
this );
2098 dlg.setWindowTitle( symbolName );
2102 symbol.reset( dlg.symbol() );
2107 mStyle->addSymbol3D( symbolName, symbol.release(),
true );
2112void QgsStyleManagerDialog::addStyleDatabase(
bool createNew )
2115 if ( initialFolder.isEmpty() )
2116 initialFolder = QDir::homePath();
2118 QString databasePath = createNew
2119 ? QFileDialog::getSaveFileName(
2121 tr(
"Create Style Database" ),
2123 tr(
"Style databases" ) +
" (*.db)"
2125 : QFileDialog::getOpenFileName(
2127 tr(
"Add Style Database" ),
2129 tr(
"Style databases" ) +
" (*.db *.xml)"
2134 if ( !databasePath.isEmpty() )
2141 if ( QFile::exists( databasePath ) )
2143 QFile::remove( databasePath );
2148 QMessageBox::warning(
this, tr(
"Create Style Database" ), tr(
"The style database could not be created" ) );
2160 const QList<ItemDetails> items = selectedItems();
2162 if ( allTypesSelected() )
2164 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Items" ), QString( tr(
"Do you really want to remove %n item(s)?",
nullptr, items.count() ) ), QMessageBox::Yes, QMessageBox::No ) )
2171 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Symbol" ), QString( tr(
"Do you really want to remove %n symbol(s)?",
nullptr, items.count() ) ), QMessageBox::Yes, QMessageBox::No ) )
2176 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Color Ramp" ), QString( tr(
"Do you really want to remove %n ramp(s)?",
nullptr, items.count() ) ), QMessageBox::Yes, QMessageBox::No ) )
2181 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Text Formats" ), QString( tr(
"Do you really want to remove %n text format(s)?",
nullptr, items.count() ) ), QMessageBox::Yes, QMessageBox::No ) )
2186 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Label Settings" ), QString( tr(
"Do you really want to remove %n label setting(s)?",
nullptr, items.count() ) ), QMessageBox::Yes, QMessageBox::No ) )
2191 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove Legend Patch Shapes" ), QString( tr(
"Do you really want to remove %n legend patch shape(s)?",
nullptr, items.count() ) ), QMessageBox::Yes, QMessageBox::No ) )
2196 if ( QMessageBox::Yes != QMessageBox::question(
this, tr(
"Remove 3D Symbols" ), QString( tr(
"Do you really want to remove %n 3D symbol(s)?",
nullptr, items.count() ) ), QMessageBox::Yes, QMessageBox::No ) )
2203 for (
const ItemDetails &details : items )
2205 if ( details.name.isEmpty() )
2208 mStyle->removeEntityByName( details.entityType, details.name );
2230 QString dir = QFileDialog::getExistingDirectory(
this, tr(
"Export Selected Symbols as PNG" ), QDir::home().absolutePath(), QFileDialog::DontResolveSymlinks );
2236 QString dir = QFileDialog::getExistingDirectory(
this, tr(
"Export Selected Symbols as SVG" ), QDir::home().absolutePath(), QFileDialog::DontResolveSymlinks );
2243 if ( dir.isEmpty() )
2246 const QList<ItemDetails> items = selectedItems();
2247 for (
const ItemDetails &details : items )
2252 QString path = dir +
'/' + details.name +
'.' + format;
2253 std::unique_ptr<QgsSymbol> sym( mStyle->symbol( details.name ) );
2255 sym->exportImage( path, format, size );
2275 QFont font = item->font();
2276 font.setBold(
true );
2277 item->setFont( font );
2282 if ( mBlockGroupUpdates )
2285 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2288 const bool readOnly = isReadOnly();
2290 if ( mFavoritesGroupVisible )
2292 QStandardItem *favoriteSymbols =
new QStandardItem( tr(
"Favorites" ) );
2293 favoriteSymbols->setData(
"favorite" );
2294 favoriteSymbols->setEditable(
false );
2296 model->appendRow( favoriteSymbols );
2299 QStandardItem *allSymbols =
new QStandardItem( tr(
"All" ) );
2300 allSymbols->setData(
"all" );
2301 allSymbols->setEditable(
false );
2303 model->appendRow( allSymbols );
2305 QStandardItem *taggroup =
new QStandardItem( QString() );
2306 taggroup->setData(
"tags" );
2307 taggroup->setEditable(
false );
2308 QStringList tags = mStyle->tags();
2310 for (
const QString &tag : std::as_const( tags ) )
2312 QStandardItem *item =
new QStandardItem( tag );
2313 item->setData( mStyle->tagId( tag ) );
2314 item->setData( tag, GroupModelRoles::TagName );
2315 item->setEditable( !readOnly );
2316 taggroup->appendRow( item );
2318 taggroup->setText( tr(
"Tags" ) );
2320 model->appendRow( taggroup );
2322 if ( mSmartGroupVisible )
2324 QStandardItem *smart =
new QStandardItem( tr(
"Smart Groups" ) );
2325 smart->setData(
"smartgroups" );
2326 smart->setEditable(
false );
2329 QgsSymbolGroupMap::const_iterator i = sgMap.constBegin();
2330 while ( i != sgMap.constEnd() )
2332 QStandardItem *item =
new QStandardItem( i.value() );
2333 item->setData( i.key() );
2334 item->setEditable( !readOnly );
2335 smart->appendRow( item );
2338 model->appendRow( smart );
2342 int rows = model->rowCount( model->indexFromItem( model->invisibleRootItem() ) );
2343 for (
int i = 0; i < rows; i++ )
2345 groupTree->setExpanded( model->indexFromItem( model->item( i ) ),
true );
2351 const QString category = index.data( Qt::UserRole + 1 ).toString();
2352 sPreviousTag = category;
2354 const bool readOnly = isReadOnly();
2356 if ( mGroupingMode && mModel )
2358 mModel->setTagId( -1 );
2359 mModel->setSmartGroupId( -1 );
2360 mModel->setFavoritesOnly(
false );
2361 mModel->setCheckTag( index.data( Qt::DisplayRole ).toString() );
2363 else if ( category ==
"all"_L1 || category ==
"tags"_L1 || category ==
"smartgroups"_L1 )
2366 if ( category ==
"tags"_L1 )
2368 actnAddTag->setEnabled( !readOnly );
2369 actnAddSmartgroup->setEnabled(
false );
2371 else if ( category ==
"smartgroups"_L1 )
2373 actnAddTag->setEnabled(
false );
2374 actnAddSmartgroup->setEnabled( !readOnly );
2379 mModel->setTagId( -1 );
2380 mModel->setSmartGroupId( -1 );
2381 mModel->setFavoritesOnly(
false );
2384 else if ( category ==
"favorite"_L1 )
2389 mModel->setTagId( -1 );
2390 mModel->setSmartGroupId( -1 );
2391 mModel->setFavoritesOnly(
true );
2394 else if ( index.parent().data( Qt::UserRole + 1 ) ==
"smartgroups" )
2396 actnRemoveGroup->setEnabled( !readOnly );
2397 btnManageGroups->setEnabled( !readOnly );
2398 const int groupId = index.data( Qt::UserRole + 1 ).toInt();
2401 mModel->setTagId( -1 );
2402 mModel->setSmartGroupId( groupId );
2403 mModel->setFavoritesOnly(
false );
2409 int tagId = index.data( Qt::UserRole + 1 ).toInt();
2412 mModel->setTagId( tagId );
2413 mModel->setSmartGroupId( -1 );
2414 mModel->setFavoritesOnly(
false );
2418 actnEditSmartGroup->setVisible(
false );
2419 actnAddTag->setVisible(
false );
2420 actnAddSmartgroup->setVisible(
false );
2421 actnRemoveGroup->setVisible(
false );
2422 actnTagSymbols->setVisible(
false );
2423 actnFinishTagging->setVisible(
false );
2425 if ( index.parent().isValid() )
2427 if ( index.parent().data( Qt::UserRole + 1 ).toString() ==
"smartgroups"_L1 )
2429 actnEditSmartGroup->setVisible( !mGroupingMode && !readOnly );
2431 else if ( index.parent().data( Qt::UserRole + 1 ).toString() ==
"tags"_L1 )
2433 actnAddTag->setVisible( !mGroupingMode && !readOnly );
2434 actnTagSymbols->setVisible( !mGroupingMode && !readOnly );
2435 actnFinishTagging->setVisible( mGroupingMode && !readOnly );
2437 actnRemoveGroup->setVisible( !readOnly );
2439 else if ( index.data( Qt::UserRole + 1 ) ==
"smartgroups" )
2441 actnAddSmartgroup->setVisible( !mGroupingMode && !readOnly );
2443 else if ( index.data( Qt::UserRole + 1 ) ==
"tags" )
2445 actnAddTag->setVisible( !mGroupingMode && !readOnly );
2454 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2456 for (
int i = 0; i < groupTree->model()->rowCount(); i++ )
2458 index = groupTree->model()->index( i, 0 );
2459 QString data = index.data( Qt::UserRole + 1 ).toString();
2460 if ( data ==
"tags"_L1 )
2469 itemName = QInputDialog::getText(
this, tr(
"Add Tag" ), tr(
"Please enter name for the new tag:" ), QLineEdit::Normal, tr(
"New tag" ), &ok ).trimmed();
2470 if ( !ok || itemName.isEmpty() )
2473 int check = mStyle->tagId( itemName );
2476 mMessageBar->pushCritical( tr(
"Add Tag" ), tr(
"The tag “%1” already exists." ).arg( itemName ) );
2482 mBlockGroupUpdates++;
2483 id = mStyle->addTag( itemName );
2484 mBlockGroupUpdates--;
2488 mMessageBar->pushCritical( tr(
"Add Tag" ), tr(
"New tag could not be created — There was a problem with the symbol database." ) );
2492 QStandardItem *parentItem = model->itemFromIndex( index );
2493 QStandardItem *childItem =
new QStandardItem( itemName );
2494 childItem->setData(
id );
2495 childItem->setData( itemName, GroupModelRoles::TagName );
2496 parentItem->appendRow( childItem );
2506 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2508 for (
int i = 0; i < groupTree->model()->rowCount(); i++ )
2510 index = groupTree->model()->index( i, 0 );
2511 QString data = index.data( Qt::UserRole + 1 ).toString();
2512 if ( data ==
"smartgroups"_L1 )
2521 if ( dlg.exec() == QDialog::Rejected )
2526 mBlockGroupUpdates++;
2528 mBlockGroupUpdates--;
2534 QStandardItem *parentItem = model->itemFromIndex( index );
2535 QStandardItem *childItem =
new QStandardItem( itemName );
2536 childItem->setData(
id );
2537 parentItem->appendRow( childItem );
2547 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2548 QModelIndex index = groupTree->currentIndex();
2551 QString data = index.data( Qt::UserRole + 1 ).toString();
2552 if ( data ==
"all"_L1 || data ==
"favorite"_L1 || data ==
"tags"_L1 || index.data() ==
"smartgroups" )
2555 int err = QMessageBox::critical(
this, tr(
"Remove Group" ), tr(
"Invalid selection. Cannot delete system defined categories.\n"
2556 "Kindly select a group or smart group you might want to delete." ) );
2561 QStandardItem *parentItem = model->itemFromIndex( index.parent() );
2565 mBlockGroupUpdates++;
2567 if ( parentItem->data( Qt::UserRole + 1 ).toString() ==
"smartgroups"_L1 )
2576 mBlockGroupUpdates--;
2577 parentItem->removeRow( index.row() );
2585 QgsDebugMsgLevel( u
"Symbol group edited: data=%1 text=%2"_s.arg( item->data( Qt::UserRole + 1 ).toString(), item->text() ), 2 );
2586 int id = item->data( Qt::UserRole + 1 ).toInt();
2587 QString name = item->text();
2588 mBlockGroupUpdates++;
2589 if ( item->parent()->data( Qt::UserRole + 1 ) ==
"smartgroups" )
2597 mBlockGroupUpdates--;
2605 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2607 if ( mGroupingMode )
2609 mGroupingMode =
false;
2610 mModel->setCheckable(
false );
2611 actnTagSymbols->setVisible(
true );
2612 actnFinishTagging->setVisible(
false );
2623 listItems->setSelectionMode( QAbstractItemView::ExtendedSelection );
2624 mSymbolTreeView->setSelectionMode( QAbstractItemView::ExtendedSelection );
2628 bool validGroup =
false;
2630 QModelIndex present = groupTree->currentIndex();
2631 while ( present.parent().isValid() )
2633 if ( present.parent().data() ==
"Tags" )
2638 present = present.parent();
2643 mGroupingMode =
true;
2645 actnTagSymbols->setVisible(
false );
2646 actnFinishTagging->setVisible(
true );
2653 btnManageGroups->setEnabled(
true );
2655 mModel->setCheckable(
true );
2658 listItems->setSelectionMode( QAbstractItemView::NoSelection );
2659 mSymbolTreeView->setSelectionMode( QAbstractItemView::NoSelection );
2673 mModel->setFilterString( qword );
2678 actnEditItem->setEnabled( index.isValid() && !mGroupingMode && !isReadOnly() );
2683 Q_UNUSED( selected )
2684 Q_UNUSED( deselected )
2685 const bool nothingSelected = listItems->selectionModel()->selectedIndexes().empty();
2686 const bool readOnly = isReadOnly();
2687 actnRemoveItem->setDisabled( nothingSelected || readOnly );
2688 actnAddFavorite->setDisabled( nothingSelected || readOnly );
2689 actnRemoveFavorite->setDisabled( nothingSelected || readOnly );
2690 mGroupListMenu->setDisabled( nothingSelected || readOnly );
2691 actnDetag->setDisabled( nothingSelected || readOnly );
2692 actnExportAsPNG->setDisabled( nothingSelected );
2693 actnExportAsSVG->setDisabled( nothingSelected );
2694 if ( mActionCopyToDefault )
2695 mActionCopyToDefault->setDisabled( nothingSelected );
2696 mCopyToDefaultButton->setDisabled( nothingSelected );
2697 actnEditItem->setDisabled( nothingSelected || readOnly );
2702 const bool readOnly = isReadOnly();
2703 groupTree->setEnabled( enable );
2704 btnAddTag->setEnabled( enable && !readOnly );
2705 btnAddSmartgroup->setEnabled( enable && !readOnly );
2706 actnAddTag->setEnabled( enable && !readOnly );
2707 actnAddSmartgroup->setEnabled( enable && !readOnly );
2708 actnRemoveGroup->setEnabled( enable && !readOnly );
2709 btnManageGroups->setEnabled( !readOnly && ( enable || mGroupingMode ) );
2710 searchBox->setEnabled( enable );
2715 const bool readOnly = isReadOnly();
2716 actnRemoveGroup->setEnabled( enable && !readOnly );
2717 btnManageGroups->setEnabled( !readOnly && ( enable || mGroupingMode ) );
2722 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2723 for (
int i = 0; i < treeModel->rowCount(); i++ )
2725 treeModel->item( i )->setEnabled( enable );
2727 if ( treeModel->item( i )->data() ==
"smartgroups" )
2729 for (
int j = 0; j < treeModel->item( i )->rowCount(); j++ )
2731 treeModel->item( i )->child( j )->setEnabled( enable );
2738 for (
int i = 0; i < symbolBtnsLayout->count(); i++ )
2740 QWidget *w = symbolBtnsLayout->itemAt( i )->widget();
2742 w->setEnabled( enable );
2746 actnRemoveItem->setEnabled( enable );
2747 actnEditItem->setEnabled( enable );
2748 mActionCopyItem->setEnabled( enable );
2749 mActionPasteItem->setEnabled( enable );
2754 QPoint globalPos = groupTree->viewport()->mapToGlobal( point );
2756 QModelIndex index = groupTree->indexAt( point );
2757 if ( index.isValid() && !mGroupingMode )
2758 mGroupTreeContextMenu->popup( globalPos );
2763 QPoint globalPos = mSymbolViewStackedWidget->currentIndex() == 0
2764 ? listItems->viewport()->mapToGlobal( point )
2765 : mSymbolTreeView->viewport()->mapToGlobal( point );
2768 mGroupListMenu->clear();
2770 const QModelIndexList indices = listItems->selectionModel()->selectedRows();
2772 if ( !isReadOnly() )
2774 const QStringList currentTags = indices.count() == 1 ? indices.at( 0 ).data(
static_cast<int>(
QgsStyleModel::CustomRole::Tag ) ).toStringList() : QStringList();
2775 QAction *a =
nullptr;
2776 QStringList tags = mStyle->tags();
2778 for (
const QString &tag : std::as_const( tags ) )
2780 a =
new QAction( tag, mGroupListMenu );
2782 if ( indices.count() == 1 )
2784 a->setCheckable(
true );
2785 a->setChecked( currentTags.contains( tag ) );
2788 mGroupListMenu->addAction( a );
2791 if ( tags.count() > 0 )
2793 mGroupListMenu->addSeparator();
2795 a =
new QAction( tr(
"Create New Tag…" ), mGroupListMenu );
2796 connect( a, &QAction::triggered,
this, [
this](
bool ) {
tagSelectedSymbols(
true ); } );
2797 mGroupListMenu->addAction( a );
2800 const QList<ItemDetails> items = selectedItems();
2803 bool enablePaste =
false;
2809 const QMimeData *mimeData = QApplication::clipboard()->mimeData();
2810 if ( mimeData->hasFormat(
"application/qgis.labelsettings"_L1 ) )
2819 mActionPasteItem->setEnabled( enablePaste );
2821 mGroupMenu->popup( globalPos );
2829 const QList<ItemDetails> items = selectedItems();
2830 for (
const ItemDetails &details : items )
2832 mStyle->addFavorite( details.entityType, details.name );
2841 const QList<ItemDetails> items = selectedItems();
2842 for (
const ItemDetails &details : items )
2844 mStyle->removeFavorite( details.entityType, details.name );
2850 QAction *selectedItem = qobject_cast<QAction *>( sender() );
2853 const QList<ItemDetails> items = selectedItems();
2863 tag = mStyle->tag(
id );
2867 tag = selectedItem->data().toString();
2870 for (
const ItemDetails &details : items )
2872 mStyle->tagSymbol( details.entityType, details.name, QStringList( tag ) );
2882 QAction *selectedItem = qobject_cast<QAction *>( sender() );
2886 const QList<ItemDetails> items = selectedItems();
2887 for (
const ItemDetails &details : items )
2889 mStyle->detagSymbol( details.entityType, details.name );
2899 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2902 QModelIndex present = groupTree->currentIndex();
2903 if ( present.parent().data( Qt::UserRole + 1 ) !=
"smartgroups" )
2906 QMessageBox::critical(
this, tr(
"Edit Smart Group" ), tr(
"You have not selected a Smart Group. Kindly select a Smart Group to edit." ) );
2909 QStandardItem *item = treeModel->itemFromIndex( present );
2914 dlg.
setOperator( mStyle->smartgroupOperator( item->data().toInt() ) );
2917 if ( dlg.exec() == QDialog::Rejected )
2920 mBlockGroupUpdates++;
2923 mBlockGroupUpdates--;
2926 mMessageBar->pushCritical( tr(
"Edit Smart Group" ), tr(
"There was an error while editing the smart group." ) );
2930 item->setData(
id );
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
static const double UI_SCALE_FACTOR
UI scaling factor.
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QgsStyleModel * defaultStyleModel()
Returns a shared QgsStyleModel containing the default style library (see QgsStyle::defaultStyle()).
static Qgs3DSymbolRegistry * symbol3DRegistry()
Returns registry of available 3D symbols.
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
A dialog which allows users to modify the properties of a QgsColorBrewerColorRamp.
QgsColorBrewerColorRamp ramp
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
Color ramp utilising "Color Brewer" preset color schemes.
QgsColorBrewerColorRamp * clone() const override
Creates a clone of the color ramp.
static QString typeString()
Returns the string identifier for QgsColorBrewerColorRamp.
QString schemeName() const
Returns the name of the color brewer color scheme.
int colors() const
Returns the number of colors in the ramp.
Abstract base class for color ramps.
static QList< QPair< QString, QString > > rampTypes()
Returns a list of available ramp types, where the first value in each item is the QgsColorRamp::type(...
A dialog which allows users to modify the properties of a QgsCptCityColorRamp.
bool saveAsGradientRamp() const
Returns true if the ramp should be converted to a QgsGradientColorRamp.
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
A color ramp from the CPT City collection.
QgsCptCityColorRamp * clone() const override
Creates a clone of the color ramp.
static QString typeString()
Returns the string identifier for QgsCptCityColorRamp.
QgsGradientColorRamp * cloneGradientRamp() const
QString schemeName() const
QString variantName() const
static QString ensureFileNameHasExtension(const QString &fileName, const QStringList &extensions)
Ensures that a fileName ends with an extension from the provided list of extensions.
A fill symbol type, for rendering Polygon and MultiPolygon geometries.
A dialog which allows users to modify the properties of a QgsGradientColorRamp.
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
QgsGradientColorRamp ramp
Gradient color ramp, which smoothly interpolates between two colors and also supports optional extra ...
static QString typeString()
Returns the string identifier for QgsGradientColorRamp.
QgsGradientColorRamp * clone() const override
Creates a clone of the color ramp.
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
static QIcon iconLine()
Returns an icon representing line geometries.
static QIcon iconPolygon()
Returns an icon representing polygon geometries.
static QIcon iconPoint()
Returns an icon representing point geometries.
bool isNull() const
Returns true if the patch shape is a null QgsLegendPatchShape, which indicates that the default legen...
A dialog which allows users to modify the properties of a QgsLimitedRandomColorRamp.
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
QgsLimitedRandomColorRamp ramp
Constrained random color ramp, which returns random colors based on preset parameters.
static QString typeString()
Returns the string identifier for QgsLimitedRandomColorRamp.
QgsLimitedRandomColorRamp * clone() const override
Creates a clone of the color ramp.
A line symbol type, for rendering LineString and MultiLineString geometries.
A marker symbol type, for rendering Point and MultiPoint geometries.
static QgsPalLayerSettings fromMimeData(const QMimeData *data, bool *ok=nullptr)
Attempts to parse the provided mime data as a QgsPalLayerSettings.
Qgis::GeometryType layerType
Geometry type of layers associated with these settings.
A dialog which allows users to modify the properties of a QgsPresetSchemeColorRamp.
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
QgsPresetSchemeColorRamp ramp
A scheme based color ramp consisting of a list of predefined colors.
static QString typeString()
Returns the string identifier for QgsPresetSchemeColorRamp.
QgsPresetSchemeColorRamp * clone() const override
Creates a clone of the color ramp.
List model representing the style databases associated with a QgsProject.
void addStyleDatabasePath(const QString &path)
Adds a style database path to the project.
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...
T value(const QString &dynamicKeyPart=QString()) const
Returns settings value.
bool setValue(const T &value, const QString &dynamicKeyPart=QString()) const
Set settings value.
Stores settings for use within QGIS.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.
A dialog for configuring a style smart group.
void setConditionMap(const QgsSmartConditionMap &)
sets up the GUI for the given conditionmap
QgsSmartConditionMap conditionMap()
returns the condition map
QString smartgroupName()
returns the value from mNameLineEdit
void setSmartgroupName(const QString &)
sets the smart group Name
void setOperator(const QString &)
sets the operator AND/OR
QString conditionOperator()
returns the AND/OR condition
@ Export
Export existing symbols mode.
@ Import
Import xml file mode.
Q_DECL_DEPRECATED bool removeSymbol()
void onClose()
Closes the dialog.
void groupRenamed(QStandardItem *item)
Triggered when a group item is renamed.
static const QgsSettingsEntryString * settingLastStyleDatabaseFolder
Last used folder for generic style database actions.
void addFavoriteSelectedSymbols()
Add selected symbols to favorites.
void selectedSymbolsChanged(const QItemSelection &selected, const QItemSelection &deselected)
Perform tasks when the selected symbols change.
void removeGroup()
Removes the selected tag or smartgroup.
void exportItems()
Triggers the dialog to export items.
friend class QgsStyleExportImportDialog
void setFavoritesGroupVisible(bool show)
Sets whether the favorites group should be shown.
void grouptreeContextMenu(QPoint)
Context menu for the groupTree.
void setBold(QStandardItem *)
sets the text of the item with bold font
void filterSymbols(const QString &filter)
Sets the filter string to filter symbols by.
void addItem()
Triggers the dialog for adding a new item, based on the currently selected item type tab.
void tagSymbolsAction()
Toggles the interactive item tagging mode.
void editSmartgroupAction()
Triggers the dialog for editing the selected smart group.
void showHelp()
Opens the associated help.
void detagSelectedSymbols()
Remove all tags from selected symbols.
void enableSymbolInputs(bool)
Enables or disbables the symbol specific inputs.
bool addSymbol(int symbolType=-1)
add a new symbol to style
Q_DECL_DEPRECATED void populateTypes()
Populate combo box with known style items (symbols, color ramps).
void populateList()
Refreshes the list of items.
void removeItem()
Removes the current selected item.
void groupChanged(const QModelIndex &)
Triggered when the current group (or tag) is changed.
QgsStyleManagerDialog(QgsStyle *style, QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::WindowFlags(), bool readOnly=false)
Constructor for QgsStyleManagerDialog, with the specified parent widget and window flags.
void enableGroupInputs(bool)
Enables or disables the groupTree specific inputs.
int addTag()
Triggers the dialog to add a new tag.
void exportItemsSVG()
Triggers the dialog to export selected items as SVG files.
Q_DECL_DEPRECATED void populateSymbols(const QStringList &symbolNames, bool checkable=false)
Populates the list view with symbols of the current type with the given names.
void populateGroups()
populate the groups
Q_DECL_DEPRECATED bool removeColorRamp()
void importItems()
Triggers the dialog to import items.
void setBaseStyleName(const QString &name)
Sets the base name for the style, which is used by the dialog to reflect the original style/XML file ...
Q_DECL_DEPRECATED void regrouped(QStandardItem *)
Q_DECL_DEPRECATED void itemChanged(QStandardItem *item)
void exportItemsPNG()
Triggers the dialog to export selected items as PNG files.
void activate()
Raises, unminimizes and activates this window.
bool addColorRamp(const QString &type=QString())
Triggers adding a new color ramp.
void exportSelectedItemsImages(const QString &dir, const QString &format, QSize size)
Triggers the dialog to export selected items as images of the specified format and size.
void enableItemsForGroupingMode(bool)
Enables or disables the groupTree items for grouping mode.
Q_DECL_DEPRECATED void setSymbolsChecked(const QStringList &)
void onFinished()
Called when the dialog is going to be closed.
void listitemsContextMenu(QPoint)
Context menu for the listItems ( symbols list ).
void setSmartGroupsVisible(bool show)
Sets whether smart groups should be shown.
static QString addColorRampStatic(QWidget *parent, QgsStyle *style, const QString &RampType=QString())
Opens the add color ramp dialog, returning the new color ramp's name if the ramp has been added.
void symbolSelected(const QModelIndex &)
Perform symbol specific tasks when selected.
void editItem()
Triggers the dialog for editing the current item.
void removeFavoriteSelectedSymbols()
Remove selected symbols from favorites.
int addSmartgroup()
Triggers the dialog to add a new smart group.
void tagSelectedSymbols(bool newTag=false)
Tag selected symbols using menu item selection.
QString currentItemName()
Q_DECL_DEPRECATED void populateColorRamps(const QStringList &colorRamps, bool checkable=false)
Populates the list view with color ramps of the current type with the given names.
A QAbstractItemModel subclass for showing symbol and color ramp entities contained within a QgsStyle ...
@ SymbolType
Symbol type (for symbol or legend patch shape entities).
@ Type
Style entity type, see QgsStyle::StyleEntity.
@ Tag
String list of tags.
A QSortFilterProxyModel subclass for showing filtered symbol and color ramps entries from a QgsStyle ...
A dialog for setting properties of a newly saved style.
bool isFavorite() const
Returns true if the favorite is checked for the symbol.
QString name() const
Returns the entered name for the new symbol.
void setDefaultTags(const QString &tags)
Sets the default tags for the newly created item.
QString tags() const
Returns any tags entered for the new symbol (as a comma separated value list).
A database of saved style entities, including symbols, color ramps, text formats and others.
QgsTextFormat textFormat(const QString &name) const
Returns the text format with the specified name.
QStringList tags() const
Returns a list of all tags in the style database.
QStringList symbol3DNames() const
Returns a list of names of 3d symbols in the style.
bool saveLabelSettings(const QString &name, const QgsPalLayerSettings &settings, bool favorite, const QStringList &tags)
Adds label settings to the database.
void aboutToBeDestroyed()
Emitted just before the style object is destroyed.
bool createDatabase(const QString &filename)
Creates an on-disk database.
QStringList textFormatNames() const
Returns a list of names of text formats in the style.
bool addColorRamp(const QString &name, QgsColorRamp *colorRamp, bool update=false)
Adds a color ramp to the style.
QgsSymbol * symbol(const QString &name)
Returns a NEW copy of symbol.
StyleEntity
Enum for Entities involved in a style.
@ LabelSettingsEntity
Label settings.
@ TextFormatEntity
Text formats.
@ SmartgroupEntity
Smart groups.
@ Symbol3DEntity
3D symbol entity
@ ColorrampEntity
Color ramps.
@ LegendPatchShapeEntity
Legend patch shape.
QStringList tagsOfSymbol(StyleEntity type, const QString &symbol)
Returns the tags associated with the symbol.
void groupsModified()
Emitted every time a tag or smartgroup has been added, removed, or renamed.
QStringList colorRampNames() const
Returns a list of names of color ramps.
bool addSymbol3D(const QString &name, QgsAbstract3DSymbol *symbol, bool update=false)
Adds a 3d symbol with the specified name to the style.
QStringList legendPatchShapeNames() const
Returns a list of names of legend patch shapes in the style.
void symbolSaved(const QString &name, const QgsSymbol *symbol)
Emitted every time a new symbol has been added to 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.
QgsColorRamp * colorRamp(const QString &name) const
Returns a new copy of the specified color ramp.
static QgsStyle * defaultStyle(bool initialize=true)
Returns the default application-wide style.
bool saveSymbol(const QString &name, const QgsSymbol *symbol, bool favorite, const QStringList &tags)
Adds the symbol to the database with tags.
QStringList labelSettingsNames() const
Returns a list of names of label settings in the style.
bool saveLegendPatchShape(const QString &name, const QgsLegendPatchShape &shape, bool favorite, const QStringList &tags)
Adds a legend patch shape to the database.
bool addTextFormat(const QString &name, const QgsTextFormat &format, bool update=false)
Adds a text format with the specified name to the style.
bool saveColorRamp(const QString &name, const QgsColorRamp *ramp, bool favorite, const QStringList &tags)
Adds the colorramp to the database.
QStringList symbolsOfFavorite(StyleEntity type) const
Returns the symbol names which are flagged as favorite.
bool saveSymbol3D(const QString &name, QgsAbstract3DSymbol *symbol, bool favorite, const QStringList &tags)
Adds a 3d symbol to the database.
QgsPalLayerSettings labelSettings(const QString &name) const
Returns the label settings with the specified name.
QgsAbstract3DSymbol * symbol3D(const QString &name) const
Returns a new copy of the 3D symbol with the specified name.
bool addSymbol(const QString &name, QgsSymbol *symbol, bool update=false)
Adds a symbol to style and takes symbol's ownership.
QgsLegendPatchShape legendPatchShape(const QString &name) const
Returns the legend patch shape with the specified name.
QStringList symbolNames() const
Returns a list of names of symbols.
bool saveTextFormat(const QString &name, const QgsTextFormat &format, bool favorite, const QStringList &tags)
Adds a text format to the database.
bool addLabelSettings(const QString &name, const QgsPalLayerSettings &settings, bool update=false)
Adds label settings with the specified name to the style.
static std::unique_ptr< QgsSymbol > symbolFromMimeData(const QMimeData *data)
Attempts to parse mime data as a symbol.
static QMimeData * symbolToMimeData(const QgsSymbol *symbol)
Creates new mime data from a symbol.
A dialog that can be used to select and build a symbol.
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
Abstract base class for all rendered symbols.
Temporarily sets a cursor override for the QApplication for the lifetime of the object.
A simple dialog for customizing text formatting settings.
Container for all settings relating to text rendering.
static QgsTextFormat fromMimeData(const QMimeData *data, bool *ok=nullptr)
Attempts to parse the provided mime data as a QgsTextFormat.
QMultiMap< QString, QString > QgsSmartConditionMap
A multimap to hold the smart group conditions as constraint and parameter pairs.
QSize iconSize(bool dockableToolbar)
Returns the user-preferred size of a window's toolbar icons.
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)
QMap< int, QString > QgsSymbolGroupMap