52#include <QDesktopServices>
55#include <QInputDialog>
60#include <QStandardItemModel>
64#include "moc_qgsstylemanagerdialog.cpp"
66using namespace Qt::StringLiterals;
69 =
new QgsSettingsEntryString( u
"last-style-database-folder"_s, sTtreeStyleManager, QString(), u
"Last used folder for style databases"_s );
76QgsCheckableStyleModel::QgsCheckableStyleModel(
QgsStyleModel *sourceModel, QObject *parent,
bool readOnly )
78 , mStyle( sourceModel->style() )
79 , mReadOnly( readOnly )
82QgsCheckableStyleModel::QgsCheckableStyleModel(
QgsStyle *style, QObject *parent,
bool readOnly )
85 , mReadOnly( readOnly )
88void QgsCheckableStyleModel::setCheckable(
bool checkable )
90 if ( checkable == mCheckable )
93 mCheckable = checkable;
94 emit dataChanged( index( 0, 0 ), index( rowCount() - 1, 0 ), QVector<int>() << Qt::CheckStateRole );
97void QgsCheckableStyleModel::setCheckTag(
const QString &tag )
99 if ( tag == mCheckTag )
103 emit dataChanged( index( 0, 0 ), index( rowCount() - 1, 0 ), QVector<int>() << Qt::CheckStateRole );
106Qt::ItemFlags QgsCheckableStyleModel::flags(
const QModelIndex &index )
const
108 Qt::ItemFlags f = QgsStyleProxyModel::flags( index );
109 if ( !mReadOnly && mCheckable && index.column() == 0 )
110 f |= Qt::ItemIsUserCheckable;
113 f &= ~Qt::ItemIsEditable;
118QVariant QgsCheckableStyleModel::data(
const QModelIndex &index,
int role )
const
125 QFont f = QgsStyleProxyModel::data( index, role ).value<QFont>();
130 case Qt::CheckStateRole:
132 if ( !mCheckable || index.column() != 0 )
136 return tags.contains( mCheckTag ) ? Qt::Checked : Qt::Unchecked;
142 return QgsStyleProxyModel::data( index, role );
145bool QgsCheckableStyleModel::setData(
const QModelIndex &i,
const QVariant &value,
int role )
147 if ( i.row() < 0 || i.row() >= rowCount( QModelIndex() ) || ( role != Qt::EditRole && role != Qt::CheckStateRole ) )
153 if ( role == Qt::CheckStateRole )
155 if ( !mCheckable || mCheckTag.isEmpty() )
158 const QString name = data( index( i.row(),
QgsStyleModel::Name ), Qt::DisplayRole ).toString();
161 if ( value.toInt() == Qt::Checked )
162 return mStyle->tagSymbol( entity, name, QStringList() << mCheckTag );
164 return mStyle->detagSymbol( entity, name, QStringList() << mCheckTag );
166 return QgsStyleProxyModel::setData( i, value, role );
176QString QgsStyleManagerDialog::sPreviousTag;
179 : QDialog( parent, flags )
180 , mReadOnly( readOnly )
183 setCurrentStyle( style );
184 mStyleDatabaseWidget->hide();
188 : QDialog( parent, flags )
193 mProjectStyleModel->setShowDefaultStyle(
true );
194 mComboBoxStyleDatabase->setModel( mProjectStyleModel );
198 connect( mComboBoxStyleDatabase, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this]() {
199 if ( mBlockStyleDatabaseChanges )
202 const QModelIndex index = mProjectStyleModel->index( mComboBoxStyleDatabase->currentIndex(), 0, QModelIndex() );
203 setCurrentStyle( mProjectStyleModel->styleFromIndex( index ) );
206 connect( mButtonAddStyleDatabase, &QAbstractButton::clicked,
this, [
this] { addStyleDatabase(
false ); } );
207 connect( mButtonNewStyleDatabase, &QAbstractButton::clicked,
this, [
this] { addStyleDatabase(
true ); } );
210void QgsStyleManagerDialog::init()
214 connect( tabItemType, &QTabWidget::currentChanged,
this, &QgsStyleManagerDialog::tabItemType_currentChanged );
218 QPushButton *downloadButton = buttonBox->addButton( tr(
"Browse Online Styles" ), QDialogButtonBox::ResetRole );
219 downloadButton->setToolTip( tr(
"Download new styles from the online QGIS style repository" ) );
221 connect( downloadButton, &QPushButton::clicked,
this, [] { QDesktopServices::openUrl( QUrl( u
"https://hub.qgis.org/styles/"_s ) ); } );
223 mMessageBar =
new QgsMessageBar();
224 mMessageBar->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed );
225 mVerticalLayout->insertWidget( 0, mMessageBar );
228 setWindowModality( Qt::WindowModal );
231 QgsSettings settings;
233 mSplitter->setSizes( QList<int>() << 170 << 540 );
234 mSplitter->restoreState( settings.
value( u
"Windows/StyleV2Manager/splitter"_s ).toByteArray() );
236 tabItemType->setDocumentMode(
true );
237 searchBox->setShowSearchIcon(
true );
238 searchBox->setPlaceholderText( tr(
"Filter symbols…" ) );
242 connect( btnEditItem, &QPushButton::clicked,
this, [
this](
bool ) {
editItem(); } );
243 connect( actnEditItem, &QAction::triggered,
this, [
this](
bool ) {
editItem(); } );
246 connect( btnAddItem, &QPushButton::clicked,
this, [
this](
bool ) {
248 if ( !btnAddItem->menu() )
254 connect( btnRemoveItem, &QPushButton::clicked,
this, [
this](
bool ) {
removeItem(); } );
255 connect( actnRemoveItem, &QAction::triggered,
this, [
this](
bool ) {
removeItem(); } );
257 mShareMenu =
new QMenu( tr(
"Share Menu" ),
this );
258 mExportAction =
new QAction( tr(
"Export Item(s)…" ),
this );
260 mShareMenu->addAction( mExportAction );
262 connect( mCopyToDefaultButton, &QPushButton::clicked,
this, &QgsStyleManagerDialog::copyItemsToDefault );
264 mActionCopyItem =
new QAction( tr(
"Copy Item" ),
this );
265 connect( mActionCopyItem, &QAction::triggered,
this, &QgsStyleManagerDialog::copyItem );
266 mActionPasteItem =
new QAction( tr(
"Paste Item…" ),
this );
267 connect( mActionPasteItem, &QAction::triggered,
this, &QgsStyleManagerDialog::pasteItem );
269 QShortcut *copyShortcut =
new QShortcut( QKeySequence( QKeySequence::StandardKey::Copy ),
this );
270 connect( copyShortcut, &QShortcut::activated,
this, &QgsStyleManagerDialog::copyItem );
271 QShortcut *pasteShortcut =
new QShortcut( QKeySequence( QKeySequence::StandardKey::Paste ),
this );
272 connect( pasteShortcut, &QShortcut::activated,
this, &QgsStyleManagerDialog::pasteItem );
273 QShortcut *removeShortcut =
new QShortcut( QKeySequence( QKeySequence::StandardKey::Delete ),
this );
275 QShortcut *editShortcut =
new QShortcut( QKeySequence( Qt::Key_Return ),
this );
278 mShareMenu->addSeparator();
279 mShareMenu->addAction( actnExportAsPNG );
280 mShareMenu->addAction( actnExportAsSVG );
285 btnShare->setMenu( mShareMenu );
287 listItems->setTextElideMode( Qt::TextElideMode::ElideRight );
289 mSymbolTreeView->setIconSize( QSize(
static_cast<int>( treeIconSize ),
static_cast<int>( treeIconSize ) ) );
291 listItems->setSelectionBehavior( QAbstractItemView::SelectRows );
292 listItems->setSelectionMode( QAbstractItemView::ExtendedSelection );
293 mSymbolTreeView->setSelectionMode( listItems->selectionMode() );
295 QStandardItemModel *groupModel =
new QStandardItemModel( groupTree );
296 groupTree->setModel( groupModel );
297 groupTree->setHeaderHidden(
true );
302 QMenu *groupMenu =
new QMenu( tr(
"Group Actions" ),
this );
304 groupMenu->addAction( actnTagSymbols );
306 actnFinishTagging->setVisible(
false );
307 groupMenu->addAction( actnFinishTagging );
308 groupMenu->addAction( actnEditSmartGroup );
309 btnManageGroups->setMenu( groupMenu );
314 groupTree->setContextMenuPolicy( Qt::CustomContextMenu );
318 listItems->setContextMenuPolicy( Qt::CustomContextMenu );
320 mSymbolTreeView->setContextMenuPolicy( Qt::CustomContextMenu );
323 mMenuBtnAddItemAll =
new QMenu(
this );
324 mMenuBtnAddItemColorRamp =
new QMenu(
this );
325 mMenuBtnAddItemLabelSettings =
new QMenu(
this );
326 mMenuBtnAddItemLegendPatchShape =
new QMenu(
this );
327 mMenuBtnAddItemSymbol3D =
new QMenu(
this );
331 mMenuBtnAddItemAll->addAction( item );
334 mMenuBtnAddItemAll->addAction( item );
337 mMenuBtnAddItemAll->addAction( item );
338 mMenuBtnAddItemAll->addSeparator();
341 for (
const QPair<QString, QString> &rampType : rampTypes )
344 connect( item, &QAction::triggered,
this, [
this, rampType](
bool ) {
addColorRamp( rampType.first ); } );
345 mMenuBtnAddItemAll->addAction( item );
346 mMenuBtnAddItemColorRamp->addAction( item );
348 mMenuBtnAddItemAll->addSeparator();
350 connect( item, &QAction::triggered,
this, [
this](
bool ) { addTextFormat(); } );
351 mMenuBtnAddItemAll->addAction( item );
352 mMenuBtnAddItemAll->addSeparator();
355 mMenuBtnAddItemAll->addAction( item );
356 mMenuBtnAddItemLabelSettings->addAction( item );
359 mMenuBtnAddItemAll->addAction( item );
360 mMenuBtnAddItemLabelSettings->addAction( item );
363 mMenuBtnAddItemAll->addAction( item );
364 mMenuBtnAddItemLabelSettings->addAction( item );
366 mMenuBtnAddItemAll->addSeparator();
369 mMenuBtnAddItemAll->addAction( item );
370 mMenuBtnAddItemLegendPatchShape->addAction( item );
372 connect( item, &QAction::triggered,
this, [
this](
bool ) { addLegendPatchShape(
Qgis::SymbolType::Line ); } );
373 mMenuBtnAddItemAll->addAction( item );
374 mMenuBtnAddItemLegendPatchShape->addAction( item );
376 connect( item, &QAction::triggered,
this, [
this](
bool ) { addLegendPatchShape(
Qgis::SymbolType::Fill ); } );
377 mMenuBtnAddItemAll->addAction( item );
378 mMenuBtnAddItemLegendPatchShape->addAction( item );
380 mMenuBtnAddItemAll->addSeparator();
382 connect( item, &QAction::triggered,
this, [
this](
bool ) { addSymbol3D( u
"point"_s ); } );
383 mMenuBtnAddItemAll->addAction( item );
384 mMenuBtnAddItemSymbol3D->addAction( item );
386 connect( item, &QAction::triggered,
this, [
this](
bool ) { addSymbol3D( u
"line"_s ); } );
387 mMenuBtnAddItemAll->addAction( item );
388 mMenuBtnAddItemSymbol3D->addAction( item );
390 connect( item, &QAction::triggered,
this, [
this](
bool ) { addSymbol3D( u
"polygon"_s ); } );
391 mMenuBtnAddItemAll->addAction( item );
392 mMenuBtnAddItemSymbol3D->addAction( item );
395 mGroupMenu =
new QMenu(
this );
396 mGroupListMenu =
new QMenu( mGroupMenu );
397 mGroupListMenu->setTitle( tr(
"Add to Tag" ) );
398 mGroupListMenu->setEnabled(
false );
405 mGroupTreeContextMenu =
new QMenu(
this );
407 connect( actnAddTag, &QAction::triggered,
this, [
this](
bool ) {
addTag(); } );
408 connect( actnAddSmartgroup, &QAction::triggered,
this, [
this](
bool ) {
addSmartgroup(); } );
411 tabItemType_currentChanged( 0 );
413 connect( mButtonIconView, &QToolButton::toggled,
this, [
this](
bool active ) {
416 mSymbolViewStackedWidget->setCurrentIndex( 0 );
418 QgsSettings().setValue( u
"Windows/StyleV2Manager/lastIconView"_s, 0,
QgsSettings::Gui );
421 connect( mButtonListView, &QToolButton::toggled,
this, [
this](
bool active ) {
424 QgsSettings().setValue( u
"Windows/StyleV2Manager/lastIconView"_s, 1,
QgsSettings::Gui );
425 mSymbolViewStackedWidget->setCurrentIndex( 1 );
429 const int currentView = settings.
value( u
"Windows/StyleV2Manager/lastIconView"_s, 0,
QgsSettings::Gui ).toInt();
430 if ( currentView == 0 )
431 mButtonIconView->setChecked(
true );
433 mButtonListView->setChecked(
true );
435 mSymbolTreeView->header()->restoreState( settings.
value( u
"Windows/StyleV2Manager/treeState"_s, QByteArray(),
QgsSettings::Gui ).toByteArray() );
436 connect( mSymbolTreeView->header(), &QHeaderView::sectionResized,
this, [
this] {
438 QgsSettings().setValue( u
"Windows/StyleV2Manager/treeState"_s, mSymbolTreeView->header()->saveState(), QgsSettings::Gui );
441 const int thumbnailSize = settings.
value( u
"Windows/StyleV2Manager/thumbnailSize"_s, 0,
QgsSettings::Gui ).toInt();
442 mSliderIconSize->setValue( thumbnailSize );
443 connect( mSliderIconSize, &QSlider::valueChanged,
this, &QgsStyleManagerDialog::setThumbnailSize );
444 setThumbnailSize( thumbnailSize );
447void QgsStyleManagerDialog::setCurrentStyle(
QgsStyle *style )
449 if ( mStyle == style )
459 QgsCheckableStyleModel *oldModel = mModel;
462 const bool readOnly = isReadOnly();
465 if ( !mActionCopyToDefault )
467 mActionCopyToDefault =
new QAction( tr(
"Copy Selection to Default Style…" ),
this );
468 mShareMenu->insertAction( mActionCopyItem, mActionCopyToDefault );
469 connect( mActionCopyToDefault, &QAction::triggered,
this, &QgsStyleManagerDialog::copyItemsToDefault );
471 mCopyToDefaultButton->show();
472 mModel =
new QgsCheckableStyleModel( mStyle,
this, readOnly );
476 mCopyToDefaultButton->hide();
477 if ( mActionCopyToDefault )
479 mActionCopyToDefault->deleteLater();
480 mActionCopyToDefault =
nullptr;
484 mModel->addDesiredIconSize( mSymbolTreeView->iconSize() );
485 mModel->addDesiredIconSize( listItems->iconSize() );
486 mModel->addTargetScreenProperties( QgsScreenProperties( screen() ) );
488 mModel->setFilterString( searchBox->text() );
490 listItems->setModel( mModel );
491 mSymbolTreeView->setModel( mModel );
493 mSymbolTreeView->setSelectionModel( listItems->selectionModel() );
500 oldModel->deleteLater();
508 if ( mProjectStyleModel )
510 const QModelIndex styleIndex = mProjectStyleModel->indexFromStyle( mStyle );
511 mBlockStyleDatabaseChanges++;
512 mComboBoxStyleDatabase->setCurrentIndex( styleIndex.row() );
513 mBlockStyleDatabaseChanges--;
518 btnAddTag->setEnabled(
false );
519 btnAddSmartgroup->setEnabled(
false );
520 btnManageGroups->setEnabled(
false );
522 btnAddItem->setVisible(
false );
523 btnRemoveItem->setVisible(
false );
524 btnEditItem->setVisible(
false );
525 btnAddSmartgroup->setVisible(
false );
526 btnAddTag->setVisible(
false );
527 btnManageGroups->setVisible(
false );
529 delete mImportAction;
530 mImportAction =
nullptr;
532 mGroupTreeContextMenu->clear();
534 mGroupMenu->addAction( mActionCopyItem );
538 btnAddTag->setEnabled(
true );
539 btnAddSmartgroup->setEnabled(
true );
540 btnManageGroups->setEnabled(
true );
542 btnAddItem->setVisible(
true );
543 btnRemoveItem->setVisible(
true );
544 btnEditItem->setVisible(
true );
545 btnAddSmartgroup->setVisible(
true );
546 btnAddTag->setVisible(
true );
547 btnManageGroups->setVisible(
true );
549 if ( !mImportAction )
551 mImportAction =
new QAction( tr(
"Import Item(s)…" ),
this );
553 mShareMenu->insertAction( mShareMenu->actions().at( mShareMenu->actions().indexOf( mExportAction ) + 1 ), mImportAction );
557 mGroupTreeContextMenu->clear();
558 mGroupTreeContextMenu->addAction( actnEditSmartGroup );
559 mGroupTreeContextMenu->addAction( actnAddTag );
560 mGroupTreeContextMenu->addAction( actnAddSmartgroup );
561 mGroupTreeContextMenu->addAction( actnRemoveGroup );
564 mGroupMenu->addAction( actnAddFavorite );
565 mGroupMenu->addAction( actnRemoveFavorite );
566 mGroupMenu->addSeparator()->setParent(
this );
567 mGroupMenu->addMenu( mGroupListMenu );
568 mGroupMenu->addAction( actnDetag );
569 mGroupMenu->addSeparator()->setParent(
this );
570 mGroupMenu->addAction( actnRemoveItem );
571 mGroupMenu->addAction( actnEditItem );
572 mGroupMenu->addAction( mActionCopyItem );
573 mGroupMenu->addAction( mActionPasteItem );
574 mGroupMenu->addSeparator()->setParent(
this );
577 if ( mActionCopyToDefault )
579 mGroupMenu->addAction( mActionCopyToDefault );
581 mGroupMenu->addAction( actnExportAsPNG );
582 mGroupMenu->addAction( actnExportAsSVG );
585 const QModelIndexList prevIndex = groupTree->model()->match( groupTree->model()->index( 0, 0 ), Qt::UserRole + 1, sPreviousTag, 1, Qt::MatchFixedString | Qt::MatchCaseSensitive | Qt::MatchRecursive );
586 groupTree->setCurrentIndex( !prevIndex.empty() ? prevIndex.at( 0 ) : groupTree->model()->index( 0, 0 ) );
589 tabItemType_currentChanged( tabItemType->currentIndex() );
595void QgsStyleManagerDialog::currentStyleAboutToBeDestroyed()
606 settings.
setValue( u
"Windows/StyleV2Manager/splitter"_s, mSplitter->saveState() );
612void QgsStyleManagerDialog::tabItemType_currentChanged(
int )
621 searchBox->setPlaceholderText(
622 isSymbol ? tr(
"Filter symbols…" )
623 : isColorRamp ? tr(
"Filter color ramps…" )
624 : isTextFormat ? tr(
"Filter text symbols…" )
625 : isLabelSettings ? tr(
"Filter label settings…" )
626 : isLegendPatchShape ? tr(
"Filter legend patch shapes…" )
627 : tr(
"Filter 3D symbols…" )
630 const bool readOnly = isReadOnly();
631 if ( !readOnly && isColorRamp )
633 btnAddItem->setMenu( mMenuBtnAddItemColorRamp );
635 else if ( !readOnly && isLegendPatchShape )
637 btnAddItem->setMenu( mMenuBtnAddItemLegendPatchShape );
639 else if ( !readOnly && isSymbol3D )
641 btnAddItem->setMenu( mMenuBtnAddItemSymbol3D );
643 else if ( !readOnly && isLabelSettings )
645 btnAddItem->setMenu( mMenuBtnAddItemLabelSettings );
647 else if ( !readOnly && !isSymbol && !isColorRamp )
649 btnAddItem->setMenu(
nullptr );
651 else if ( !readOnly && tabItemType->currentIndex() == 0 )
653 btnAddItem->setMenu( mMenuBtnAddItemAll );
657 btnAddItem->setMenu(
nullptr );
660 actnExportAsPNG->setVisible( isSymbol );
661 actnExportAsSVG->setVisible( isSymbol );
665 mModel->setEntityFilter(
673 mModel->setEntityFilterEnabled( !allTypesSelected() );
674 mModel->setSymbolTypeFilterEnabled( isSymbol && !allTypesSelected() );
675 if ( isSymbol && !allTypesSelected() )
682void QgsStyleManagerDialog::copyItemsToDefault()
684 const QList<ItemDetails> items = selectedItems();
685 if ( !items.empty() )
689 if ( !mBaseName.isEmpty() )
690 options.append( mBaseName );
693 defaultTags.sort( Qt::CaseInsensitive );
694 options.append( defaultTags );
695 const QString tags = QInputDialog::getItem(
this, tr(
"Import Items" ), tr(
"Additional tags to add (comma separated)" ), options, mBaseName.isEmpty() ? -1 : 0,
true, &ok );
699 const QStringList parts = tags.split(
',', Qt::SkipEmptyParts );
700 QStringList additionalTags;
701 additionalTags.reserve( parts.count() );
702 for (
const QString &tag : parts )
703 additionalTags << tag.trimmed();
705 auto cursorOverride = std::make_unique<QgsTemporaryCursorOverride>( Qt::WaitCursor );
706 const int count = copyItems( items, mStyle,
QgsStyle::defaultStyle(),
this, cursorOverride,
true, additionalTags,
false,
false );
707 cursorOverride.reset();
710 mMessageBar->pushSuccess( tr(
"Import Items" ), count > 1 ? tr(
"Successfully imported %n item(s).",
nullptr, count ) : tr(
"Successfully imported item." ) );
715void QgsStyleManagerDialog::copyItem()
717 const QList<ItemDetails> items = selectedItems();
721 ItemDetails details = items.at( 0 );
722 switch ( details.entityType )
726 std::unique_ptr<QgsSymbol> symbol( mStyle->symbol( details.name ) );
735 const QgsTextFormat format( mStyle->textFormat( details.name ) );
736 QApplication::clipboard()->setMimeData( format.toMimeData() );
742 const QgsPalLayerSettings labelSettings( mStyle->labelSettings( details.name ) );
743 QApplication::clipboard()->setMimeData( labelSettings.toMimeData() );
756void QgsStyleManagerDialog::pasteItem()
758 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
762 QgsStyleSaveDialog saveDlg(
this );
763 saveDlg.setWindowTitle( tr(
"Paste Symbol" ) );
764 saveDlg.setDefaultTags( defaultTag );
765 if ( !saveDlg.exec() || saveDlg.name().isEmpty() )
768 if ( mStyle->symbolNames().contains( saveDlg.name() ) )
770 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 );
771 if ( res != QMessageBox::Yes )
775 mStyle->removeSymbol( saveDlg.name() );
778 QStringList symbolTags = saveDlg.tags().split(
',' );
779 QgsSymbol *newSymbol = tempSymbol.get();
780 mStyle->addSymbol( saveDlg.name(), tempSymbol.release() );
782 mStyle->saveSymbol( saveDlg.name(), newSymbol, saveDlg.isFavorite(), symbolTags );
792 saveDlg.setDefaultTags( defaultTag );
793 saveDlg.setWindowTitle( tr(
"Paste Label Settings" ) );
794 if ( !saveDlg.exec() || saveDlg.name().isEmpty() )
797 if ( mStyle->labelSettingsNames().contains( saveDlg.name() ) )
799 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 );
800 if ( res != QMessageBox::Yes )
804 mStyle->removeLabelSettings( saveDlg.name() );
807 QStringList symbolTags = saveDlg.tags().split(
',' );
808 mStyle->addLabelSettings( saveDlg.name(), labelSettings );
810 mStyle->saveLabelSettings( saveDlg.name(), labelSettings, saveDlg.isFavorite(), symbolTags );
819 saveDlg.setDefaultTags( defaultTag );
820 saveDlg.setWindowTitle( tr(
"Paste Text Format" ) );
821 if ( !saveDlg.exec() || saveDlg.name().isEmpty() )
824 if ( mStyle->textFormatNames().contains( saveDlg.name() ) )
826 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 );
827 if ( res != QMessageBox::Yes )
831 mStyle->removeTextFormat( saveDlg.name() );
834 QStringList symbolTags = saveDlg.tags().split(
',' );
835 mStyle->addTextFormat( saveDlg.name(), format );
837 mStyle->saveTextFormat( saveDlg.name(), format, saveDlg.isFavorite(), symbolTags );
842void QgsStyleManagerDialog::setThumbnailSize(
int value )
847 const double spacing =
Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance(
'X' ) * ( value * 2.2 + 14 );
849 listItems->setIconSize( QSize(
static_cast<int>( iconSize ),
static_cast<int>( iconSize * 0.9 ) ) );
850 listItems->setGridSize( QSize(
static_cast<int>( spacing ),
static_cast<int>( verticalSpacing ) ) );
853 mModel->addDesiredIconSize( listItems->iconSize() );
856 QgsSettings().setValue( u
"Windows/StyleV2Manager/thumbnailSize"_s, value,
QgsSettings::Gui );
859int QgsStyleManagerDialog::selectedItemType()
861 QModelIndex index = listItems->selectionModel()->currentIndex();
862 if ( !index.isValid() )
880bool QgsStyleManagerDialog::allTypesSelected()
const
882 return tabItemType->currentIndex() == 0;
885bool QgsStyleManagerDialog::isReadOnly()
const
887 return mReadOnly || ( mStyle && mStyle->isReadOnly() );
890QList<QgsStyleManagerDialog::ItemDetails> QgsStyleManagerDialog::selectedItems()
892 QList<QgsStyleManagerDialog::ItemDetails> res;
893 QModelIndexList indices = listItems->selectionModel()->selectedRows();
894 for (
const QModelIndex &index : indices )
896 if ( !index.isValid() )
903 details.name = mModel->data( mModel->index( index.row(),
QgsStyleModel::Name, index.parent() ), Qt::DisplayRole ).toString();
910int QgsStyleManagerDialog::copyItems(
911 const QList<QgsStyleManagerDialog::ItemDetails> &items,
914 QWidget *parentWidget,
915 std::unique_ptr<QgsTemporaryCursorOverride> &cursorOverride,
917 const QStringList &importTags,
919 bool ignoreSourceTags
923 bool overwriteAll =
true;
933 for (
auto &details : items )
935 QStringList symbolTags;
936 if ( !ignoreSourceTags )
938 symbolTags = src->
tagsOfSymbol( details.entityType, details.name );
941 bool addItemToFavorites =
false;
944 symbolTags << importTags;
945 addItemToFavorites = addToFavorites;
948 switch ( details.entityType )
952 std::unique_ptr<QgsSymbol> symbol( src->
symbol( details.name ) );
956 const bool hasDuplicateName = dst->
symbolNames().contains( details.name );
957 bool overwriteThis =
false;
959 addItemToFavorites = favoriteSymbols.contains( details.name );
961 if ( hasDuplicateName && prompt )
963 cursorOverride.reset();
964 int res = QMessageBox::warning(
966 isImport ? tr(
"Import Symbol" ) : tr(
"Export Symbol" ),
967 tr(
"A symbol with the name “%1” already exists.\nOverwrite?" ).arg( details.name ),
968 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel
970 cursorOverride = std::make_unique<QgsTemporaryCursorOverride>( Qt::WaitCursor );
973 case QMessageBox::Cancel:
976 case QMessageBox::No:
979 case QMessageBox::Yes:
980 overwriteThis =
true;
983 case QMessageBox::YesToAll:
988 case QMessageBox::NoToAll:
990 overwriteAll =
false;
995 if ( !hasDuplicateName || overwriteAll || overwriteThis )
997 QgsSymbol *newSymbol = symbol.get();
998 dst->
addSymbol( details.name, symbol.release() );
999 dst->
saveSymbol( details.name, newSymbol, addItemToFavorites, symbolTags );
1007 std::unique_ptr<QgsColorRamp> ramp( src->
colorRamp( details.name ) );
1011 const bool hasDuplicateName = dst->
colorRampNames().contains( details.name );
1012 bool overwriteThis =
false;
1014 addItemToFavorites = favoriteColorramps.contains( details.name );
1016 if ( hasDuplicateName && prompt )
1018 cursorOverride.reset();
1019 int res = QMessageBox::warning(
1021 isImport ? tr(
"Import Color Ramp" ) : tr(
"Export Color Ramp" ),
1022 tr(
"A color ramp with the name “%1” already exists.\nOverwrite?" ).arg( details.name ),
1023 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel
1025 cursorOverride = std::make_unique<QgsTemporaryCursorOverride>( Qt::WaitCursor );
1028 case QMessageBox::Cancel:
1031 case QMessageBox::No:
1034 case QMessageBox::Yes:
1035 overwriteThis =
true;
1038 case QMessageBox::YesToAll:
1040 overwriteAll =
true;
1043 case QMessageBox::NoToAll:
1045 overwriteAll =
false;
1050 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1052 QgsColorRamp *newRamp = ramp.get();
1054 dst->
saveColorRamp( details.name, newRamp, addItemToFavorites, symbolTags );
1062 const QgsTextFormat format( src->
textFormat( details.name ) );
1064 const bool hasDuplicateName = dst->
textFormatNames().contains( details.name );
1065 bool overwriteThis =
false;
1067 addItemToFavorites = favoriteTextFormats.contains( details.name );
1069 if ( hasDuplicateName && prompt )
1071 cursorOverride.reset();
1072 int res = QMessageBox::warning(
1074 isImport ? tr(
"Import Text Format" ) : tr(
"Export Text Format" ),
1075 tr(
"A text format with the name “%1” already exists.\nOverwrite?" ).arg( details.name ),
1076 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel
1078 cursorOverride = std::make_unique<QgsTemporaryCursorOverride>( Qt::WaitCursor );
1081 case QMessageBox::Cancel:
1084 case QMessageBox::No:
1087 case QMessageBox::Yes:
1088 overwriteThis =
true;
1091 case QMessageBox::YesToAll:
1093 overwriteAll =
true;
1096 case QMessageBox::NoToAll:
1098 overwriteAll =
false;
1103 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1106 dst->
saveTextFormat( details.name, format, addItemToFavorites, symbolTags );
1114 const QgsPalLayerSettings settings( src->
labelSettings( details.name ) );
1117 bool overwriteThis =
false;
1119 addItemToFavorites = favoriteLabelSettings.contains( details.name );
1121 if ( hasDuplicateName && prompt )
1123 cursorOverride.reset();
1124 int res = QMessageBox::warning(
1126 isImport ? tr(
"Import Label Settings" ) : tr(
"Export Label Settings" ),
1127 tr(
"Label settings with the name “%1” already exist.\nOverwrite?" ).arg( details.name ),
1128 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel
1130 cursorOverride = std::make_unique<QgsTemporaryCursorOverride>( Qt::WaitCursor );
1133 case QMessageBox::Cancel:
1136 case QMessageBox::No:
1139 case QMessageBox::Yes:
1140 overwriteThis =
true;
1143 case QMessageBox::YesToAll:
1145 overwriteAll =
true;
1148 case QMessageBox::NoToAll:
1150 overwriteAll =
false;
1155 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1158 dst->
saveLabelSettings( details.name, settings, addItemToFavorites, symbolTags );
1169 bool overwriteThis =
false;
1171 addItemToFavorites = favoriteLegendPatchShapes.contains( details.name );
1173 if ( hasDuplicateName && prompt )
1175 cursorOverride.reset();
1176 int res = QMessageBox::warning(
1178 isImport ? tr(
"Import Legend Patch Shape" ) : tr(
"Export Legend Patch Shape" ),
1179 tr(
"Legend patch shape with the name “%1” already exist.\nOverwrite?" ).arg( details.name ),
1180 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel
1182 cursorOverride = std::make_unique<QgsTemporaryCursorOverride>( Qt::WaitCursor );
1185 case QMessageBox::Cancel:
1188 case QMessageBox::No:
1191 case QMessageBox::Yes:
1192 overwriteThis =
true;
1195 case QMessageBox::YesToAll:
1197 overwriteAll =
true;
1200 case QMessageBox::NoToAll:
1202 overwriteAll =
false;
1207 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1218 std::unique_ptr<QgsAbstract3DSymbol> symbol( src->
symbol3D( details.name ) );
1222 const bool hasDuplicateName = dst->
symbol3DNames().contains( details.name );
1223 bool overwriteThis =
false;
1225 addItemToFavorites = favorite3dSymbols.contains( details.name );
1227 if ( hasDuplicateName && prompt )
1229 cursorOverride.reset();
1230 int res = QMessageBox::warning(
1232 isImport ? tr(
"Import 3D Symbol" ) : tr(
"Export 3D Symbol" ),
1233 tr(
"A 3D symbol with the name “%1” already exists.\nOverwrite?" ).arg( details.name ),
1234 QMessageBox::Yes | QMessageBox::YesToAll | QMessageBox::No | QMessageBox::NoToAll | QMessageBox::Cancel
1236 cursorOverride = std::make_unique<QgsTemporaryCursorOverride>( Qt::WaitCursor );
1239 case QMessageBox::Cancel:
1242 case QMessageBox::No:
1245 case QMessageBox::Yes:
1246 overwriteThis =
true;
1249 case QMessageBox::YesToAll:
1251 overwriteAll =
true;
1254 case QMessageBox::NoToAll:
1256 overwriteAll =
false;
1261 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1263 QgsAbstract3DSymbol *newSymbol = symbol.get();
1264 dst->
addSymbol3D( details.name, symbol.release() );
1265 dst->
saveSymbol3D( details.name, newSymbol, addItemToFavorites, symbolTags );
1279bool QgsStyleManagerDialog::addTextFormat()
1281 QgsTextFormat format;
1282 QgsTextFormatDialog formatDlg( format,
nullptr,
this );
1283 formatDlg.setWindowTitle( tr(
"New Text Format" ) );
1284 if ( !formatDlg.exec() )
1286 format = formatDlg.format();
1289 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
1290 saveDlg.setDefaultTags( defaultTag );
1291 if ( !saveDlg.exec() )
1293 QString name = saveDlg.name();
1296 bool nameInvalid =
true;
1297 while ( nameInvalid )
1300 if ( name.isEmpty() )
1302 QMessageBox::warning(
this, tr(
"Save Text Format" ), tr(
"Cannot save text format without name. Enter a name." ) );
1304 else if ( mStyle->textFormatNames().contains( name ) )
1306 int res = QMessageBox::warning(
this, tr(
"Save Text Format" ), tr(
"Text format with name '%1' already exists. Overwrite?" ).arg( name ), QMessageBox::Yes | QMessageBox::No );
1307 if ( res == QMessageBox::Yes )
1309 mStyle->removeTextFormat( name );
1310 nameInvalid =
false;
1316 nameInvalid =
false;
1321 name = QInputDialog::getText(
this, tr(
"Text Format Name" ), tr(
"Please enter a name for new text format:" ), QLineEdit::Normal, name, &ok );
1329 QStringList symbolTags = saveDlg.tags().split(
',' );
1332 mStyle->addTextFormat( name, format );
1333 mStyle->saveTextFormat( name, format, saveDlg.isFavorite(), symbolTags );
1341 groupChanged( groupTree->selectionModel()->currentIndex() );
1352 switch ( tabItemType->currentIndex() )
1377 QModelIndex index = listItems->selectionModel()->currentIndex();
1378 if ( !index.isValid() )
1381 return mModel->data( mModel->index( index.row(),
QgsStyleModel::Name, index.parent() ), Qt::DisplayRole ).toString();
1386 bool changed =
false;
1397 changed = addTextFormat();
1416 Q_ASSERT(
false &&
"not implemented" );
1429 QString name = tr(
"new symbol" );
1430 QString dialogTitle;
1435 name = tr(
"new marker" );
1436 dialogTitle = tr(
"New Marker Symbol" );
1440 name = tr(
"new line" );
1441 dialogTitle = tr(
"New Line Symbol" );
1445 name = tr(
"new fill symbol" );
1446 dialogTitle = tr(
"New Fill Symbol" );
1449 Q_ASSERT(
false &&
"unknown symbol type" );
1459 dlg.setWindowTitle( dialogTitle );
1460 if ( dlg.exec() == 0 )
1467 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
1469 if ( !saveDlg.exec() )
1475 name = saveDlg.
name();
1478 bool nameInvalid =
true;
1479 while ( nameInvalid )
1482 if ( name.isEmpty() )
1484 QMessageBox::warning(
this, tr(
"Save Symbol" ), tr(
"Cannot save symbol without name. Enter a name." ) );
1486 else if ( mStyle->symbolNames().contains( name ) )
1488 int res = QMessageBox::warning(
this, tr(
"Save Symbol" ), tr(
"Symbol with name '%1' already exists. Overwrite?" ).arg( name ), QMessageBox::Yes | QMessageBox::No );
1489 if ( res == QMessageBox::Yes )
1491 mStyle->removeSymbol( name );
1492 nameInvalid =
false;
1498 nameInvalid =
false;
1503 name = QInputDialog::getText(
this, tr(
"Symbol Name" ), tr(
"Please enter a name for new symbol:" ), QLineEdit::Normal, name, &ok );
1512 QStringList symbolTags = saveDlg.
tags().split(
',' );
1515 mStyle->addSymbol( name, symbol );
1516 mStyle->saveSymbol( name, symbol, saveDlg.
isFavorite(), symbolTags );
1525 QString rampType = type;
1527 if ( rampType.isEmpty() )
1532 QStringList rampTypeNames;
1533 rampTypeNames.reserve( rampTypes.size() );
1534 for (
const QPair<QString, QString> &type : rampTypes )
1535 rampTypeNames << type.second;
1536 const QString selectedRampTypeName = QInputDialog::getItem( parent, tr(
"Color Ramp Type" ), tr(
"Please select color ramp type:" ), rampTypeNames, 0,
false, &ok );
1537 if ( !ok || selectedRampTypeName.isEmpty() )
1540 rampType = rampTypes.value( rampTypeNames.indexOf( selectedRampTypeName ) ).first;
1543 QString name = tr(
"new ramp" );
1545 std::unique_ptr<QgsColorRamp> ramp;
1549 dlg.setWindowTitle( tr(
"New Gradient Color Ramp" ) );
1555 name = tr(
"new gradient ramp" );
1560 dlg.setWindowTitle( tr(
"New Random Color Ramp" ) );
1566 name = tr(
"new random ramp" );
1571 dlg.setWindowTitle( tr(
"New ColorBrewer Ramp" ) );
1582 dlg.setWindowTitle( tr(
"New Preset Color Ramp" ) );
1588 name = tr(
"new preset ramp" );
1593 dlg.setWindowTitle( tr(
"New cpt-city Color Ramp" ) );
1618 if ( !saveDlg.exec() )
1623 name = saveDlg.
name();
1626 bool nameInvalid =
true;
1627 while ( nameInvalid )
1630 if ( name.isEmpty() )
1632 QMessageBox::warning( parent, tr(
"Save Color Ramp" ), tr(
"Cannot save color ramp without name. Enter a name." ) );
1636 int res = QMessageBox::warning( parent, tr(
"Save Color Ramp" ), tr(
"Color ramp with name '%1' already exists. Overwrite?" ).arg( name ), QMessageBox::Yes | QMessageBox::No );
1637 if ( res == QMessageBox::Yes )
1639 nameInvalid =
false;
1645 nameInvalid =
false;
1650 name = QInputDialog::getText( parent, tr(
"Color Ramp Name" ), tr(
"Please enter a name for new color ramp:" ), QLineEdit::Normal, name, &ok );
1658 QStringList colorRampTags = saveDlg.
tags().split(
',' );
1670 mFavoritesGroupVisible = show;
1676 mSmartGroupVisible = show;
1688 setWindowState( windowState() & ~Qt::WindowMinimized );
1696 if ( !rampName.isEmpty() )
1708 if ( selectedItemType() < 3 )
1712 else if ( selectedItemType() == 3 )
1716 else if ( selectedItemType() == 4 )
1720 else if ( selectedItemType() == 5 )
1722 editLabelSettings();
1724 else if ( selectedItemType() == 6 )
1726 editLegendPatchShape();
1728 else if ( selectedItemType() == 7 )
1734 Q_ASSERT(
false &&
"not implemented" );
1741 if ( symbolName.isEmpty() )
1744 std::unique_ptr<QgsSymbol> symbol( mStyle->symbol( symbolName ) );
1748 dlg.setWindowTitle( symbolName );
1750 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1756 mStyle->addSymbol( symbolName, symbol.release(),
true );
1764 if ( name.isEmpty() )
1767 std::unique_ptr<QgsColorRamp> ramp( mStyle->colorRamp( name ) );
1773 dlg.setWindowTitle( name );
1775 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1787 dlg.setWindowTitle( name );
1789 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1801 dlg.setWindowTitle( name );
1803 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1815 dlg.setWindowTitle( name );
1817 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1829 dlg.setWindowTitle( name );
1831 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1848 Q_ASSERT(
false &&
"invalid ramp type" );
1851 mStyle->addColorRamp( name, ramp.release(),
true );
1856bool QgsStyleManagerDialog::editTextFormat()
1859 if ( formatName.isEmpty() )
1866 dlg.setWindowTitle( formatName );
1868 dlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1881 QgsPalLayerSettings settings;
1882 QgsLabelSettingsDialog settingsDlg( settings,
nullptr,
nullptr,
this, type );
1883 settingsDlg.setWindowTitle( tr(
"New Label Settings" ) );
1885 settingsDlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1887 if ( !settingsDlg.exec() )
1890 settings = settingsDlg.settings();
1894 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
1895 saveDlg.setDefaultTags( defaultTag );
1896 if ( !saveDlg.exec() )
1898 QString name = saveDlg.name();
1901 bool nameInvalid =
true;
1902 while ( nameInvalid )
1905 if ( name.isEmpty() )
1907 QMessageBox::warning(
this, tr(
"Save Label Settings" ), tr(
"Cannot save label settings without a name. Enter a name." ) );
1909 else if ( mStyle->labelSettingsNames().contains( name ) )
1911 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 );
1912 if ( res == QMessageBox::Yes )
1914 mStyle->removeLabelSettings( name );
1915 nameInvalid =
false;
1921 nameInvalid =
false;
1926 name = QInputDialog::getText(
this, tr(
"Label Settings Name" ), tr(
"Please enter a name for the new label settings:" ), QLineEdit::Normal, name, &ok );
1934 QStringList symbolTags = saveDlg.tags().split(
',' );
1937 mStyle->addLabelSettings( name, settings );
1938 mStyle->saveLabelSettings( name, settings, saveDlg.isFavorite(), symbolTags );
1944bool QgsStyleManagerDialog::editLabelSettings()
1947 if ( formatName.isEmpty() )
1950 QgsPalLayerSettings settings = mStyle->labelSettings( formatName );
1954 QgsLabelSettingsDialog dlg( settings,
nullptr,
nullptr,
this, geomType );
1955 dlg.setWindowTitle( formatName );
1959 settings = dlg.settings();
1963 mStyle->addLabelSettings( formatName, settings,
true );
1970 QgsLegendPatchShape shape = mStyle->defaultPatch( type, QSizeF( 10, 5 ) );
1971 QgsLegendPatchShapeDialog dialog( shape,
this );
1972 dialog.setWindowTitle( tr(
"New Legend Patch Shape" ) );
1974 dialog.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1976 if ( !dialog.exec() )
1979 shape = dialog.shape();
1982 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
1983 saveDlg.setDefaultTags( defaultTag );
1984 if ( !saveDlg.exec() )
1986 QString name = saveDlg.name();
1989 bool nameInvalid =
true;
1990 while ( nameInvalid )
1993 if ( name.isEmpty() )
1995 QMessageBox::warning(
this, tr(
"Save Legend Patch Shape" ), tr(
"Cannot save legend patch shapes without a name. Enter a name." ) );
1997 else if ( mStyle->legendPatchShapeNames().contains( name ) )
1999 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 );
2000 if ( res == QMessageBox::Yes )
2003 nameInvalid =
false;
2009 nameInvalid =
false;
2014 name = QInputDialog::getText(
this, tr(
"Legend Patch Shape Name" ), tr(
"Please enter a name for the new legend patch shape:" ), QLineEdit::Normal, name, &ok );
2022 QStringList symbolTags = saveDlg.tags().split(
',' );
2025 mStyle->addLegendPatchShape( name, shape );
2026 mStyle->saveLegendPatchShape( name, shape, saveDlg.isFavorite(), symbolTags );
2032bool QgsStyleManagerDialog::editLegendPatchShape()
2035 if ( shapeName.isEmpty() )
2038 QgsLegendPatchShape shape = mStyle->legendPatchShape( shapeName );
2043 QgsLegendPatchShapeDialog dlg( shape,
this );
2044 dlg.setWindowTitle( shapeName );
2048 shape = dlg.shape();
2051 mStyle->addLegendPatchShape( shapeName, shape,
true );
2056bool QgsStyleManagerDialog::addSymbol3D(
const QString &type )
2062 Qgs3DSymbolDialog dialog( symbol.get(),
this );
2063 dialog.setWindowTitle( tr(
"New 3D Symbol" ) );
2065 dialog.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
2067 if ( !dialog.exec() )
2070 symbol.reset( dialog.symbol() );
2075 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
2076 saveDlg.setDefaultTags( defaultTag );
2077 if ( !saveDlg.exec() )
2079 QString name = saveDlg.name();
2082 bool nameInvalid =
true;
2083 while ( nameInvalid )
2086 if ( name.isEmpty() )
2088 QMessageBox::warning(
this, tr(
"Save 3D Symbol" ), tr(
"Cannot save 3D symbols without a name. Enter a name." ) );
2090 else if ( mStyle->symbol3DNames().contains( name ) )
2092 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 );
2093 if ( res == QMessageBox::Yes )
2096 nameInvalid =
false;
2102 nameInvalid =
false;
2107 name = QInputDialog::getText(
this, tr(
"3D Symbol Name" ), tr(
"Please enter a name for the new 3D symbol:" ), QLineEdit::Normal, name, &ok );
2115 QStringList symbolTags = saveDlg.tags().split(
',' );
2118 QgsAbstract3DSymbol *newSymbol = symbol.get();
2119 mStyle->addSymbol3D( name, symbol.release() );
2120 mStyle->saveSymbol3D( name, newSymbol, saveDlg.isFavorite(), symbolTags );
2126bool QgsStyleManagerDialog::editSymbol3D()
2129 if ( symbolName.isEmpty() )
2132 std::unique_ptr<QgsAbstract3DSymbol> symbol( mStyle->symbol3D( symbolName ) );
2137 Qgs3DSymbolDialog dlg( symbol.get(),
this );
2138 dlg.setWindowTitle( symbolName );
2142 symbol.reset( dlg.symbol() );
2147 mStyle->addSymbol3D( symbolName, symbol.release(),
true );
2152void QgsStyleManagerDialog::addStyleDatabase(
bool createNew )
2155 if ( initialFolder.isEmpty() )
2156 initialFolder = QDir::homePath();
2158 QString databasePath = createNew ? QFileDialog::getSaveFileName(
this, tr(
"Create Style Database" ), initialFolder, tr(
"Style databases" ) +
" (*.db)" )
2159 : QFileDialog::getOpenFileName( this, tr(
"Add Style Database" ), initialFolder, tr(
"Style databases" ) +
" (*.db *.xml)" );
2163 if ( !databasePath.isEmpty() )
2170 if ( QFile::exists( databasePath ) )
2172 QFile::remove( databasePath );
2177 QMessageBox::warning(
this, tr(
"Create Style Database" ), tr(
"The style database could not be created" ) );
2189 const QList<ItemDetails> items = selectedItems();
2191 if ( allTypesSelected() )
2193 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 ) )
2200 if ( QMessageBox::Yes
2201 != QMessageBox::question(
this, tr(
"Remove Symbol" ), QString( tr(
"Do you really want to remove %n symbol(s)?",
nullptr, items.count() ) ), QMessageBox::Yes, QMessageBox::No ) )
2206 if ( QMessageBox::Yes
2207 != 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 ) )
2212 if ( QMessageBox::Yes
2213 != 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 ) )
2218 if ( QMessageBox::Yes
2219 != 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 ) )
2224 if ( QMessageBox::Yes
2225 != 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 ) )
2230 if ( QMessageBox::Yes
2231 != 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 ) )
2238 for (
const ItemDetails &details : items )
2240 if ( details.name.isEmpty() )
2243 mStyle->removeEntityByName( details.entityType, details.name );
2264 QString dir = QFileDialog::getExistingDirectory(
this, tr(
"Export Selected Symbols as PNG" ), QDir::home().absolutePath(), QFileDialog::DontResolveSymlinks );
2270 QString dir = QFileDialog::getExistingDirectory(
this, tr(
"Export Selected Symbols as SVG" ), QDir::home().absolutePath(), QFileDialog::DontResolveSymlinks );
2277 if ( dir.isEmpty() )
2280 const QList<ItemDetails> items = selectedItems();
2281 for (
const ItemDetails &details : items )
2286 QString path = dir +
'/' + details.name +
'.' + format;
2287 std::unique_ptr<QgsSymbol> sym( mStyle->symbol( details.name ) );
2289 sym->exportImage( path, format, size );
2309 QFont font = item->font();
2310 font.setBold(
true );
2311 item->setFont( font );
2316 if ( mBlockGroupUpdates )
2319 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2322 const bool readOnly = isReadOnly();
2324 if ( mFavoritesGroupVisible )
2326 QStandardItem *favoriteSymbols =
new QStandardItem( tr(
"Favorites" ) );
2327 favoriteSymbols->setData(
"favorite" );
2328 favoriteSymbols->setEditable(
false );
2330 model->appendRow( favoriteSymbols );
2333 QStandardItem *allSymbols =
new QStandardItem( tr(
"All" ) );
2334 allSymbols->setData(
"all" );
2335 allSymbols->setEditable(
false );
2337 model->appendRow( allSymbols );
2339 QStandardItem *taggroup =
new QStandardItem( QString() );
2340 taggroup->setData(
"tags" );
2341 taggroup->setEditable(
false );
2342 QStringList tags = mStyle->tags();
2344 for (
const QString &tag : std::as_const( tags ) )
2346 QStandardItem *item =
new QStandardItem( tag );
2347 item->setData( mStyle->tagId( tag ) );
2348 item->setData( tag, GroupModelRoles::TagName );
2349 item->setEditable( !readOnly );
2350 taggroup->appendRow( item );
2352 taggroup->setText( tr(
"Tags" ) );
2354 model->appendRow( taggroup );
2356 if ( mSmartGroupVisible )
2358 QStandardItem *smart =
new QStandardItem( tr(
"Smart Groups" ) );
2359 smart->setData(
"smartgroups" );
2360 smart->setEditable(
false );
2363 QgsSymbolGroupMap::const_iterator i = sgMap.constBegin();
2364 while ( i != sgMap.constEnd() )
2366 QStandardItem *item =
new QStandardItem( i.value() );
2367 item->setData( i.key() );
2368 item->setEditable( !readOnly );
2369 smart->appendRow( item );
2372 model->appendRow( smart );
2376 int rows = model->rowCount( model->indexFromItem( model->invisibleRootItem() ) );
2377 for (
int i = 0; i < rows; i++ )
2379 groupTree->setExpanded( model->indexFromItem( model->item( i ) ),
true );
2385 const QString category = index.data( Qt::UserRole + 1 ).toString();
2386 sPreviousTag = category;
2388 const bool readOnly = isReadOnly();
2390 if ( mGroupingMode && mModel )
2392 mModel->setTagId( -1 );
2393 mModel->setSmartGroupId( -1 );
2394 mModel->setFavoritesOnly(
false );
2395 mModel->setCheckTag( index.data( Qt::DisplayRole ).toString() );
2397 else if ( category ==
"all"_L1 || category ==
"tags"_L1 || category ==
"smartgroups"_L1 )
2400 if ( category ==
"tags"_L1 )
2402 actnAddTag->setEnabled( !readOnly );
2403 actnAddSmartgroup->setEnabled(
false );
2405 else if ( category ==
"smartgroups"_L1 )
2407 actnAddTag->setEnabled(
false );
2408 actnAddSmartgroup->setEnabled( !readOnly );
2413 mModel->setTagId( -1 );
2414 mModel->setSmartGroupId( -1 );
2415 mModel->setFavoritesOnly(
false );
2418 else if ( category ==
"favorite"_L1 )
2423 mModel->setTagId( -1 );
2424 mModel->setSmartGroupId( -1 );
2425 mModel->setFavoritesOnly(
true );
2428 else if ( index.parent().data( Qt::UserRole + 1 ) ==
"smartgroups" )
2430 actnRemoveGroup->setEnabled( !readOnly );
2431 btnManageGroups->setEnabled( !readOnly );
2432 const int groupId = index.data( Qt::UserRole + 1 ).toInt();
2435 mModel->setTagId( -1 );
2436 mModel->setSmartGroupId( groupId );
2437 mModel->setFavoritesOnly(
false );
2443 int tagId = index.data( Qt::UserRole + 1 ).toInt();
2446 mModel->setTagId( tagId );
2447 mModel->setSmartGroupId( -1 );
2448 mModel->setFavoritesOnly(
false );
2452 actnEditSmartGroup->setVisible(
false );
2453 actnAddTag->setVisible(
false );
2454 actnAddSmartgroup->setVisible(
false );
2455 actnRemoveGroup->setVisible(
false );
2456 actnTagSymbols->setVisible(
false );
2457 actnFinishTagging->setVisible(
false );
2459 if ( index.parent().isValid() )
2461 if ( index.parent().data( Qt::UserRole + 1 ).toString() ==
"smartgroups"_L1 )
2463 actnEditSmartGroup->setVisible( !mGroupingMode && !readOnly );
2465 else if ( index.parent().data( Qt::UserRole + 1 ).toString() ==
"tags"_L1 )
2467 actnAddTag->setVisible( !mGroupingMode && !readOnly );
2468 actnTagSymbols->setVisible( !mGroupingMode && !readOnly );
2469 actnFinishTagging->setVisible( mGroupingMode && !readOnly );
2471 actnRemoveGroup->setVisible( !readOnly );
2473 else if ( index.data( Qt::UserRole + 1 ) ==
"smartgroups" )
2475 actnAddSmartgroup->setVisible( !mGroupingMode && !readOnly );
2477 else if ( index.data( Qt::UserRole + 1 ) ==
"tags" )
2479 actnAddTag->setVisible( !mGroupingMode && !readOnly );
2488 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2490 for (
int i = 0; i < groupTree->model()->rowCount(); i++ )
2492 index = groupTree->model()->index( i, 0 );
2493 QString data = index.data( Qt::UserRole + 1 ).toString();
2494 if ( data ==
"tags"_L1 )
2503 itemName = QInputDialog::getText(
this, tr(
"Add Tag" ), tr(
"Please enter name for the new tag:" ), QLineEdit::Normal, tr(
"New tag" ), &ok ).trimmed();
2504 if ( !ok || itemName.isEmpty() )
2507 int check = mStyle->tagId( itemName );
2510 mMessageBar->pushCritical( tr(
"Add Tag" ), tr(
"The tag “%1” already exists." ).arg( itemName ) );
2516 mBlockGroupUpdates++;
2517 id = mStyle->addTag( itemName );
2518 mBlockGroupUpdates--;
2522 mMessageBar->pushCritical( tr(
"Add Tag" ), tr(
"New tag could not be created — There was a problem with the symbol database." ) );
2526 QStandardItem *parentItem = model->itemFromIndex( index );
2527 QStandardItem *childItem =
new QStandardItem( itemName );
2528 childItem->setData(
id );
2529 childItem->setData( itemName, GroupModelRoles::TagName );
2530 parentItem->appendRow( childItem );
2540 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2542 for (
int i = 0; i < groupTree->model()->rowCount(); i++ )
2544 index = groupTree->model()->index( i, 0 );
2545 QString data = index.data( Qt::UserRole + 1 ).toString();
2546 if ( data ==
"smartgroups"_L1 )
2555 if ( dlg.exec() == QDialog::Rejected )
2560 mBlockGroupUpdates++;
2562 mBlockGroupUpdates--;
2568 QStandardItem *parentItem = model->itemFromIndex( index );
2569 QStandardItem *childItem =
new QStandardItem( itemName );
2570 childItem->setData(
id );
2571 parentItem->appendRow( childItem );
2581 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2582 QModelIndex index = groupTree->currentIndex();
2585 QString data = index.data( Qt::UserRole + 1 ).toString();
2586 if ( data ==
"all"_L1 || data ==
"favorite"_L1 || data ==
"tags"_L1 || index.data() ==
"smartgroups" )
2589 int err = QMessageBox::critical(
2591 tr(
"Remove Group" ),
2593 "Invalid selection. Cannot delete system defined categories.\n"
2594 "Kindly select a group or smart group you might want to delete."
2601 QStandardItem *parentItem = model->itemFromIndex( index.parent() );
2605 mBlockGroupUpdates++;
2607 if ( parentItem->data( Qt::UserRole + 1 ).toString() ==
"smartgroups"_L1 )
2616 mBlockGroupUpdates--;
2617 parentItem->removeRow( index.row() );
2625 QgsDebugMsgLevel( u
"Symbol group edited: data=%1 text=%2"_s.arg( item->data( Qt::UserRole + 1 ).toString(), item->text() ), 2 );
2626 int id = item->data( Qt::UserRole + 1 ).toInt();
2627 QString name = item->text();
2628 mBlockGroupUpdates++;
2629 if ( item->parent()->data( Qt::UserRole + 1 ) ==
"smartgroups" )
2637 mBlockGroupUpdates--;
2645 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2647 if ( mGroupingMode )
2649 mGroupingMode =
false;
2650 mModel->setCheckable(
false );
2651 actnTagSymbols->setVisible(
true );
2652 actnFinishTagging->setVisible(
false );
2663 listItems->setSelectionMode( QAbstractItemView::ExtendedSelection );
2664 mSymbolTreeView->setSelectionMode( QAbstractItemView::ExtendedSelection );
2668 bool validGroup =
false;
2670 QModelIndex present = groupTree->currentIndex();
2671 while ( present.parent().isValid() )
2673 if ( present.parent().data() ==
"Tags" )
2678 present = present.parent();
2683 mGroupingMode =
true;
2685 actnTagSymbols->setVisible(
false );
2686 actnFinishTagging->setVisible(
true );
2693 btnManageGroups->setEnabled(
true );
2695 mModel->setCheckable(
true );
2698 listItems->setSelectionMode( QAbstractItemView::NoSelection );
2699 mSymbolTreeView->setSelectionMode( QAbstractItemView::NoSelection );
2711 mModel->setFilterString( qword );
2716 actnEditItem->setEnabled( index.isValid() && !mGroupingMode && !isReadOnly() );
2721 Q_UNUSED( selected )
2722 Q_UNUSED( deselected )
2723 const bool nothingSelected = listItems->selectionModel()->selectedIndexes().empty();
2724 const bool readOnly = isReadOnly();
2725 actnRemoveItem->setDisabled( nothingSelected || readOnly );
2726 actnAddFavorite->setDisabled( nothingSelected || readOnly );
2727 actnRemoveFavorite->setDisabled( nothingSelected || readOnly );
2728 mGroupListMenu->setDisabled( nothingSelected || readOnly );
2729 actnDetag->setDisabled( nothingSelected || readOnly );
2730 actnExportAsPNG->setDisabled( nothingSelected );
2731 actnExportAsSVG->setDisabled( nothingSelected );
2732 if ( mActionCopyToDefault )
2733 mActionCopyToDefault->setDisabled( nothingSelected );
2734 mCopyToDefaultButton->setDisabled( nothingSelected );
2735 actnEditItem->setDisabled( nothingSelected || readOnly );
2740 const bool readOnly = isReadOnly();
2741 groupTree->setEnabled( enable );
2742 btnAddTag->setEnabled( enable && !readOnly );
2743 btnAddSmartgroup->setEnabled( enable && !readOnly );
2744 actnAddTag->setEnabled( enable && !readOnly );
2745 actnAddSmartgroup->setEnabled( enable && !readOnly );
2746 actnRemoveGroup->setEnabled( enable && !readOnly );
2747 btnManageGroups->setEnabled( !readOnly && ( enable || mGroupingMode ) );
2748 searchBox->setEnabled( enable );
2753 const bool readOnly = isReadOnly();
2754 actnRemoveGroup->setEnabled( enable && !readOnly );
2755 btnManageGroups->setEnabled( !readOnly && ( enable || mGroupingMode ) );
2760 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2761 for (
int i = 0; i < treeModel->rowCount(); i++ )
2763 treeModel->item( i )->setEnabled( enable );
2765 if ( treeModel->item( i )->data() ==
"smartgroups" )
2767 for (
int j = 0; j < treeModel->item( i )->rowCount(); j++ )
2769 treeModel->item( i )->child( j )->setEnabled( enable );
2776 for (
int i = 0; i < symbolBtnsLayout->count(); i++ )
2778 QWidget *w = symbolBtnsLayout->itemAt( i )->widget();
2780 w->setEnabled( enable );
2784 actnRemoveItem->setEnabled( enable );
2785 actnEditItem->setEnabled( enable );
2786 mActionCopyItem->setEnabled( enable );
2787 mActionPasteItem->setEnabled( enable );
2792 QPoint globalPos = groupTree->viewport()->mapToGlobal( point );
2794 QModelIndex index = groupTree->indexAt( point );
2795 if ( index.isValid() && !mGroupingMode )
2796 mGroupTreeContextMenu->popup( globalPos );
2801 QPoint globalPos = mSymbolViewStackedWidget->currentIndex() == 0 ? listItems->viewport()->mapToGlobal( point ) : mSymbolTreeView->viewport()->mapToGlobal( point );
2804 mGroupListMenu->clear();
2806 const QModelIndexList indices = listItems->selectionModel()->selectedRows();
2808 if ( !isReadOnly() )
2810 const QStringList currentTags = indices.count() == 1 ? indices.at( 0 ).data(
static_cast<int>(
QgsStyleModel::CustomRole::Tag ) ).toStringList() : QStringList();
2811 QAction *a =
nullptr;
2812 QStringList tags = mStyle->tags();
2814 for (
const QString &tag : std::as_const( tags ) )
2816 a =
new QAction( tag, mGroupListMenu );
2818 if ( indices.count() == 1 )
2820 a->setCheckable(
true );
2821 a->setChecked( currentTags.contains( tag ) );
2824 mGroupListMenu->addAction( a );
2827 if ( tags.count() > 0 )
2829 mGroupListMenu->addSeparator();
2831 a =
new QAction( tr(
"Create New Tag…" ), mGroupListMenu );
2832 connect( a, &QAction::triggered,
this, [
this](
bool ) {
tagSelectedSymbols(
true ); } );
2833 mGroupListMenu->addAction( a );
2836 const QList<ItemDetails> items = selectedItems();
2839 bool enablePaste =
false;
2845 const QMimeData *mimeData = QApplication::clipboard()->mimeData();
2846 if ( mimeData->hasFormat(
"application/qgis.labelsettings"_L1 ) )
2855 mActionPasteItem->setEnabled( enablePaste );
2857 mGroupMenu->popup( globalPos );
2865 const QList<ItemDetails> items = selectedItems();
2866 for (
const ItemDetails &details : items )
2868 mStyle->addFavorite( details.entityType, details.name );
2877 const QList<ItemDetails> items = selectedItems();
2878 for (
const ItemDetails &details : items )
2880 mStyle->removeFavorite( details.entityType, details.name );
2886 QAction *selectedItem = qobject_cast<QAction *>( sender() );
2889 const QList<ItemDetails> items = selectedItems();
2899 tag = mStyle->tag(
id );
2903 tag = selectedItem->data().toString();
2906 for (
const ItemDetails &details : items )
2908 mStyle->tagSymbol( details.entityType, details.name, QStringList( tag ) );
2918 QAction *selectedItem = qobject_cast<QAction *>( sender() );
2922 const QList<ItemDetails> items = selectedItems();
2923 for (
const ItemDetails &details : items )
2925 mStyle->detagSymbol( details.entityType, details.name );
2935 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2938 QModelIndex present = groupTree->currentIndex();
2939 if ( present.parent().data( Qt::UserRole + 1 ) !=
"smartgroups" )
2942 QMessageBox::critical(
this, tr(
"Edit Smart Group" ), tr(
"You have not selected a Smart Group. Kindly select a Smart Group to edit." ) );
2945 QStandardItem *item = treeModel->itemFromIndex( present );
2950 dlg.
setOperator( mStyle->smartgroupOperator( item->data().toInt() ) );
2953 if ( dlg.exec() == QDialog::Rejected )
2956 mBlockGroupUpdates++;
2959 mBlockGroupUpdates--;
2962 mMessageBar->pushCritical( tr(
"Edit Smart Group" ), tr(
"There was an error while editing the smart group." ) );
2966 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