52#include <QDesktopServices>
55#include <QInputDialog>
60#include <QStandardItemModel>
63#include "moc_qgsstylemanagerdialog.cpp"
72QgsCheckableStyleModel::QgsCheckableStyleModel(
QgsStyleModel *sourceModel, QObject *parent,
bool readOnly )
74 , mStyle( sourceModel->style() )
75 , mReadOnly( readOnly )
79QgsCheckableStyleModel::QgsCheckableStyleModel(
QgsStyle *style, QObject *parent,
bool readOnly )
82 , mReadOnly( readOnly )
86void QgsCheckableStyleModel::setCheckable(
bool checkable )
88 if ( checkable == mCheckable )
91 mCheckable = checkable;
92 emit dataChanged( index( 0, 0 ), index( rowCount() - 1, 0 ), QVector<int>() << Qt::CheckStateRole );
95void QgsCheckableStyleModel::setCheckTag(
const QString &tag )
97 if ( tag == mCheckTag )
101 emit dataChanged( index( 0, 0 ), index( rowCount() - 1, 0 ), QVector<int>() << Qt::CheckStateRole );
104Qt::ItemFlags QgsCheckableStyleModel::flags(
const QModelIndex &index )
const
106 Qt::ItemFlags f = QgsStyleProxyModel::flags( index );
107 if ( !mReadOnly && mCheckable && index.column() == 0 )
108 f |= Qt::ItemIsUserCheckable;
111 f &= ~Qt::ItemIsEditable;
116QVariant QgsCheckableStyleModel::data(
const QModelIndex &index,
int role )
const
123 QFont f = QgsStyleProxyModel::data( index, role ).value<QFont>();
128 case Qt::CheckStateRole:
130 if ( !mCheckable || index.column() != 0 )
134 return tags.contains( mCheckTag ) ? Qt::Checked : Qt::Unchecked;
140 return QgsStyleProxyModel::data( index, role );
143bool QgsCheckableStyleModel::setData(
const QModelIndex &i,
const QVariant &value,
int role )
145 if ( i.row() < 0 || i.row() >= rowCount( QModelIndex() ) || ( role != Qt::EditRole && role != Qt::CheckStateRole ) )
151 if ( role == Qt::CheckStateRole )
153 if ( !mCheckable || mCheckTag.isEmpty() )
156 const QString name = data( index( i.row(),
QgsStyleModel::Name ), Qt::DisplayRole ).toString();
159 if ( value.toInt() == Qt::Checked )
160 return mStyle->tagSymbol( entity, name, QStringList() << mCheckTag );
162 return mStyle->detagSymbol( entity, name, QStringList() << mCheckTag );
164 return QgsStyleProxyModel::setData( i, value, role );
174QString QgsStyleManagerDialog::sPreviousTag;
177 : QDialog( parent, flags )
178 , mReadOnly( readOnly )
181 setCurrentStyle( style );
182 mStyleDatabaseWidget->hide();
186 : QDialog( parent, flags )
191 mProjectStyleModel->setShowDefaultStyle(
true );
192 mComboBoxStyleDatabase->setModel( mProjectStyleModel );
196 connect( mComboBoxStyleDatabase, qOverload<int>( &QComboBox::currentIndexChanged ),
this, [
this]() {
197 if ( mBlockStyleDatabaseChanges )
200 const QModelIndex index = mProjectStyleModel->index( mComboBoxStyleDatabase->currentIndex(), 0, QModelIndex() );
201 setCurrentStyle( mProjectStyleModel->styleFromIndex( index ) );
204 connect( mButtonAddStyleDatabase, &QAbstractButton::clicked,
this, [
this] { addStyleDatabase(
false ); } );
205 connect( mButtonNewStyleDatabase, &QAbstractButton::clicked,
this, [
this] { addStyleDatabase(
true ); } );
208void QgsStyleManagerDialog::init()
212 connect( tabItemType, &QTabWidget::currentChanged,
this, &QgsStyleManagerDialog::tabItemType_currentChanged );
216 QPushButton *downloadButton = buttonBox->addButton( tr(
"Browse Online Styles" ), QDialogButtonBox::ResetRole );
217 downloadButton->setToolTip( tr(
"Download new styles from the online QGIS style repository" ) );
219 connect( downloadButton, &QPushButton::clicked,
this, [] {
220 QDesktopServices::openUrl( QUrl( QStringLiteral(
"https://hub.qgis.org/styles/" ) ) );
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( QStringLiteral(
"Windows/StyleV2Manager/splitter" ) ).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 )
343 item =
new QAction(
QgsApplication::getThemeIcon( QStringLiteral(
"styleicons/color.svg" ) ), tr(
"%1…" ).arg( rampType.second ),
this );
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( QStringLiteral(
"point" ) ); } );
383 mMenuBtnAddItemAll->addAction( item );
384 mMenuBtnAddItemSymbol3D->addAction( item );
386 connect( item, &QAction::triggered,
this, [
this](
bool ) { addSymbol3D( QStringLiteral(
"line" ) ); } );
387 mMenuBtnAddItemAll->addAction( item );
388 mMenuBtnAddItemSymbol3D->addAction( item );
390 connect( item, &QAction::triggered,
this, [
this](
bool ) { addSymbol3D( QStringLiteral(
"polygon" ) ); } );
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( QStringLiteral(
"Windows/StyleV2Manager/lastIconView" ), 0,
QgsSettings::Gui );
421 connect( mButtonListView, &QToolButton::toggled,
this, [
this](
bool active ) {
424 QgsSettings().setValue( QStringLiteral(
"Windows/StyleV2Manager/lastIconView" ), 1,
QgsSettings::Gui );
425 mSymbolViewStackedWidget->setCurrentIndex( 1 );
429 const int currentView = settings.
value( QStringLiteral(
"Windows/StyleV2Manager/lastIconView" ), 0,
QgsSettings::Gui ).toInt();
430 if ( currentView == 0 )
431 mButtonIconView->setChecked(
true );
433 mButtonListView->setChecked(
true );
435 mSymbolTreeView->header()->restoreState( settings.
value( QStringLiteral(
"Windows/StyleV2Manager/treeState" ), QByteArray(),
QgsSettings::Gui ).toByteArray() );
436 connect( mSymbolTreeView->header(), &QHeaderView::sectionResized,
this, [
this] {
438 QgsSettings().setValue( QStringLiteral(
"Windows/StyleV2Manager/treeState" ), mSymbolTreeView->header()->saveState(), QgsSettings::Gui );
441 const int thumbnailSize = settings.
value( QStringLiteral(
"Windows/StyleV2Manager/thumbnailSize" ), 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( QStringLiteral(
"Windows/StyleV2Manager/splitter" ), mSplitter->saveState() );
613void QgsStyleManagerDialog::tabItemType_currentChanged(
int )
622 searchBox->setPlaceholderText( isSymbol ? tr(
"Filter symbols…" ) : isColorRamp ? tr(
"Filter color ramps…" )
623 : isTextFormat ? tr(
"Filter text symbols…" )
624 : isLabelSettings ? tr(
"Filter label settings…" )
625 : isLegendPatchShape ? tr(
"Filter legend patch shapes…" )
626 : tr(
"Filter 3D symbols…" ) );
628 const bool readOnly = isReadOnly();
629 if ( !readOnly && isColorRamp )
631 btnAddItem->setMenu( mMenuBtnAddItemColorRamp );
633 else if ( !readOnly && isLegendPatchShape )
635 btnAddItem->setMenu( mMenuBtnAddItemLegendPatchShape );
637 else if ( !readOnly && isSymbol3D )
639 btnAddItem->setMenu( mMenuBtnAddItemSymbol3D );
641 else if ( !readOnly && isLabelSettings )
643 btnAddItem->setMenu( mMenuBtnAddItemLabelSettings );
645 else if ( !readOnly && !isSymbol && !isColorRamp )
647 btnAddItem->setMenu(
nullptr );
649 else if ( !readOnly && tabItemType->currentIndex() == 0 )
651 btnAddItem->setMenu( mMenuBtnAddItemAll );
655 btnAddItem->setMenu(
nullptr );
658 actnExportAsPNG->setVisible( isSymbol );
659 actnExportAsSVG->setVisible( isSymbol );
667 mModel->setEntityFilterEnabled( !allTypesSelected() );
668 mModel->setSymbolTypeFilterEnabled( isSymbol && !allTypesSelected() );
669 if ( isSymbol && !allTypesSelected() )
676void QgsStyleManagerDialog::copyItemsToDefault()
678 const QList<ItemDetails> items = selectedItems();
679 if ( !items.empty() )
683 if ( !mBaseName.isEmpty() )
684 options.append( mBaseName );
687 defaultTags.sort( Qt::CaseInsensitive );
688 options.append( defaultTags );
689 const QString tags = QInputDialog::getItem(
this, tr(
"Import Items" ), tr(
"Additional tags to add (comma separated)" ), options, mBaseName.isEmpty() ? -1 : 0,
true, &ok );
693 const QStringList parts = tags.split(
',', Qt::SkipEmptyParts );
694 QStringList additionalTags;
695 additionalTags.reserve( parts.count() );
696 for (
const QString &tag : parts )
697 additionalTags << tag.trimmed();
699 auto cursorOverride = std::make_unique<QgsTemporaryCursorOverride>( Qt::WaitCursor );
700 const int count = copyItems( items, mStyle,
QgsStyle::defaultStyle(),
this, cursorOverride,
true, additionalTags,
false,
false );
701 cursorOverride.reset();
704 mMessageBar->pushSuccess( tr(
"Import Items" ), count > 1 ? tr(
"Successfully imported %n item(s).",
nullptr, count ) : tr(
"Successfully imported item." ) );
709void QgsStyleManagerDialog::copyItem()
711 const QList<ItemDetails> items = selectedItems();
715 ItemDetails details = items.at( 0 );
716 switch ( details.entityType )
720 std::unique_ptr<QgsSymbol> symbol( mStyle->symbol( details.name ) );
729 const QgsTextFormat format( mStyle->textFormat( details.name ) );
730 QApplication::clipboard()->setMimeData( format.toMimeData() );
736 const QgsPalLayerSettings labelSettings( mStyle->labelSettings( details.name ) );
737 QApplication::clipboard()->setMimeData( labelSettings.toMimeData() );
750void QgsStyleManagerDialog::pasteItem()
752 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
756 QgsStyleSaveDialog saveDlg(
this );
757 saveDlg.setWindowTitle( tr(
"Paste Symbol" ) );
758 saveDlg.setDefaultTags( defaultTag );
759 if ( !saveDlg.exec() || saveDlg.name().isEmpty() )
762 if ( mStyle->symbolNames().contains( saveDlg.name() ) )
764 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 );
765 if ( res != QMessageBox::Yes )
769 mStyle->removeSymbol( saveDlg.name() );
772 QStringList symbolTags = saveDlg.tags().split(
',' );
773 QgsSymbol *newSymbol = tempSymbol.get();
774 mStyle->addSymbol( saveDlg.name(), tempSymbol.release() );
776 mStyle->saveSymbol( saveDlg.name(), newSymbol, saveDlg.isFavorite(), symbolTags );
786 saveDlg.setDefaultTags( defaultTag );
787 saveDlg.setWindowTitle( tr(
"Paste Label Settings" ) );
788 if ( !saveDlg.exec() || saveDlg.name().isEmpty() )
791 if ( mStyle->labelSettingsNames().contains( saveDlg.name() ) )
793 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 );
794 if ( res != QMessageBox::Yes )
798 mStyle->removeLabelSettings( saveDlg.name() );
801 QStringList symbolTags = saveDlg.tags().split(
',' );
802 mStyle->addLabelSettings( saveDlg.name(), labelSettings );
804 mStyle->saveLabelSettings( saveDlg.name(), labelSettings, saveDlg.isFavorite(), symbolTags );
813 saveDlg.setDefaultTags( defaultTag );
814 saveDlg.setWindowTitle( tr(
"Paste Text Format" ) );
815 if ( !saveDlg.exec() || saveDlg.name().isEmpty() )
818 if ( mStyle->textFormatNames().contains( saveDlg.name() ) )
820 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 );
821 if ( res != QMessageBox::Yes )
825 mStyle->removeTextFormat( saveDlg.name() );
828 QStringList symbolTags = saveDlg.tags().split(
',' );
829 mStyle->addTextFormat( saveDlg.name(), format );
831 mStyle->saveTextFormat( saveDlg.name(), format, saveDlg.isFavorite(), symbolTags );
836void QgsStyleManagerDialog::setThumbnailSize(
int value )
841 const double spacing =
Qgis::UI_SCALE_FACTOR * fontMetrics().horizontalAdvance(
'X' ) * ( value * 2.2 + 14 );
844 listItems->setIconSize( QSize(
static_cast<int>( iconSize ),
static_cast<int>( iconSize * 0.9 ) ) );
845 listItems->setGridSize( QSize(
static_cast<int>( spacing ),
static_cast<int>( verticalSpacing ) ) );
848 mModel->addDesiredIconSize( listItems->iconSize() );
851 QgsSettings().setValue( QStringLiteral(
"Windows/StyleV2Manager/thumbnailSize" ), value,
QgsSettings::Gui );
854int QgsStyleManagerDialog::selectedItemType()
856 QModelIndex index = listItems->selectionModel()->currentIndex();
857 if ( !index.isValid() )
875bool QgsStyleManagerDialog::allTypesSelected()
const
877 return tabItemType->currentIndex() == 0;
880bool QgsStyleManagerDialog::isReadOnly()
const
882 return mReadOnly || ( mStyle && mStyle->isReadOnly() );
885QList<QgsStyleManagerDialog::ItemDetails> QgsStyleManagerDialog::selectedItems()
887 QList<QgsStyleManagerDialog::ItemDetails> res;
888 QModelIndexList indices = listItems->selectionModel()->selectedRows();
889 for (
const QModelIndex &index : indices )
891 if ( !index.isValid() )
898 details.name = mModel->data( mModel->index( index.row(),
QgsStyleModel::Name, index.parent() ), Qt::DisplayRole ).toString();
905int 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 )
908 bool overwriteAll =
true;
918 for (
auto &details : items )
920 QStringList symbolTags;
921 if ( !ignoreSourceTags )
923 symbolTags = src->
tagsOfSymbol( details.entityType, details.name );
926 bool addItemToFavorites =
false;
929 symbolTags << importTags;
930 addItemToFavorites = addToFavorites;
933 switch ( details.entityType )
937 std::unique_ptr<QgsSymbol> symbol( src->
symbol( details.name ) );
941 const bool hasDuplicateName = dst->
symbolNames().contains( details.name );
942 bool overwriteThis =
false;
944 addItemToFavorites = favoriteSymbols.contains( details.name );
946 if ( hasDuplicateName && prompt )
948 cursorOverride.reset();
949 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 );
950 cursorOverride = std::make_unique<QgsTemporaryCursorOverride>( Qt::WaitCursor );
953 case QMessageBox::Cancel:
956 case QMessageBox::No:
959 case QMessageBox::Yes:
960 overwriteThis =
true;
963 case QMessageBox::YesToAll:
968 case QMessageBox::NoToAll:
970 overwriteAll =
false;
975 if ( !hasDuplicateName || overwriteAll || overwriteThis )
977 QgsSymbol *newSymbol = symbol.get();
978 dst->
addSymbol( details.name, symbol.release() );
979 dst->
saveSymbol( details.name, newSymbol, addItemToFavorites, symbolTags );
987 std::unique_ptr<QgsColorRamp> ramp( src->
colorRamp( details.name ) );
991 const bool hasDuplicateName = dst->
colorRampNames().contains( details.name );
992 bool overwriteThis =
false;
994 addItemToFavorites = favoriteColorramps.contains( details.name );
996 if ( hasDuplicateName && prompt )
998 cursorOverride.reset();
999 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 );
1000 cursorOverride = std::make_unique<QgsTemporaryCursorOverride>( Qt::WaitCursor );
1003 case QMessageBox::Cancel:
1006 case QMessageBox::No:
1009 case QMessageBox::Yes:
1010 overwriteThis =
true;
1013 case QMessageBox::YesToAll:
1015 overwriteAll =
true;
1018 case QMessageBox::NoToAll:
1020 overwriteAll =
false;
1025 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1027 QgsColorRamp *newRamp = ramp.get();
1029 dst->
saveColorRamp( details.name, newRamp, addItemToFavorites, symbolTags );
1037 const QgsTextFormat format( src->
textFormat( details.name ) );
1039 const bool hasDuplicateName = dst->
textFormatNames().contains( details.name );
1040 bool overwriteThis =
false;
1042 addItemToFavorites = favoriteTextFormats.contains( details.name );
1044 if ( hasDuplicateName && prompt )
1046 cursorOverride.reset();
1047 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 );
1048 cursorOverride = std::make_unique<QgsTemporaryCursorOverride>( Qt::WaitCursor );
1051 case QMessageBox::Cancel:
1054 case QMessageBox::No:
1057 case QMessageBox::Yes:
1058 overwriteThis =
true;
1061 case QMessageBox::YesToAll:
1063 overwriteAll =
true;
1066 case QMessageBox::NoToAll:
1068 overwriteAll =
false;
1073 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1076 dst->
saveTextFormat( details.name, format, addItemToFavorites, symbolTags );
1084 const QgsPalLayerSettings settings( src->
labelSettings( details.name ) );
1087 bool overwriteThis =
false;
1089 addItemToFavorites = favoriteLabelSettings.contains( details.name );
1091 if ( hasDuplicateName && prompt )
1093 cursorOverride.reset();
1094 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 );
1095 cursorOverride = std::make_unique<QgsTemporaryCursorOverride>( Qt::WaitCursor );
1098 case QMessageBox::Cancel:
1101 case QMessageBox::No:
1104 case QMessageBox::Yes:
1105 overwriteThis =
true;
1108 case QMessageBox::YesToAll:
1110 overwriteAll =
true;
1113 case QMessageBox::NoToAll:
1115 overwriteAll =
false;
1120 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1123 dst->
saveLabelSettings( details.name, settings, addItemToFavorites, symbolTags );
1134 bool overwriteThis =
false;
1136 addItemToFavorites = favoriteLegendPatchShapes.contains( details.name );
1138 if ( hasDuplicateName && prompt )
1140 cursorOverride.reset();
1141 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 );
1142 cursorOverride = std::make_unique<QgsTemporaryCursorOverride>( Qt::WaitCursor );
1145 case QMessageBox::Cancel:
1148 case QMessageBox::No:
1151 case QMessageBox::Yes:
1152 overwriteThis =
true;
1155 case QMessageBox::YesToAll:
1157 overwriteAll =
true;
1160 case QMessageBox::NoToAll:
1162 overwriteAll =
false;
1167 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1178 std::unique_ptr<QgsAbstract3DSymbol> symbol( src->
symbol3D( details.name ) );
1182 const bool hasDuplicateName = dst->
symbol3DNames().contains( details.name );
1183 bool overwriteThis =
false;
1185 addItemToFavorites = favorite3dSymbols.contains( details.name );
1187 if ( hasDuplicateName && prompt )
1189 cursorOverride.reset();
1190 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 );
1191 cursorOverride = std::make_unique<QgsTemporaryCursorOverride>( Qt::WaitCursor );
1194 case QMessageBox::Cancel:
1197 case QMessageBox::No:
1200 case QMessageBox::Yes:
1201 overwriteThis =
true;
1204 case QMessageBox::YesToAll:
1206 overwriteAll =
true;
1209 case QMessageBox::NoToAll:
1211 overwriteAll =
false;
1216 if ( !hasDuplicateName || overwriteAll || overwriteThis )
1218 QgsAbstract3DSymbol *newSymbol = symbol.get();
1219 dst->
addSymbol3D( details.name, symbol.release() );
1220 dst->
saveSymbol3D( details.name, newSymbol, addItemToFavorites, symbolTags );
1234bool QgsStyleManagerDialog::addTextFormat()
1236 QgsTextFormat format;
1237 QgsTextFormatDialog formatDlg( format,
nullptr,
this );
1238 formatDlg.setWindowTitle( tr(
"New Text Format" ) );
1239 if ( !formatDlg.exec() )
1241 format = formatDlg.format();
1244 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
1245 saveDlg.setDefaultTags( defaultTag );
1246 if ( !saveDlg.exec() )
1248 QString name = saveDlg.name();
1251 bool nameInvalid =
true;
1252 while ( nameInvalid )
1255 if ( name.isEmpty() )
1257 QMessageBox::warning(
this, tr(
"Save Text Format" ), tr(
"Cannot save text format without name. Enter a name." ) );
1259 else if ( mStyle->textFormatNames().contains( name ) )
1261 int res = QMessageBox::warning(
this, tr(
"Save Text Format" ), tr(
"Text format with name '%1' already exists. Overwrite?" ).arg( name ), QMessageBox::Yes | QMessageBox::No );
1262 if ( res == QMessageBox::Yes )
1264 mStyle->removeTextFormat( name );
1265 nameInvalid =
false;
1271 nameInvalid =
false;
1276 name = QInputDialog::getText(
this, tr(
"Text Format Name" ), tr(
"Please enter a name for new text format:" ), QLineEdit::Normal, name, &ok );
1284 QStringList symbolTags = saveDlg.tags().split(
',' );
1287 mStyle->addTextFormat( name, format );
1288 mStyle->saveTextFormat( name, format, saveDlg.isFavorite(), symbolTags );
1296 groupChanged( groupTree->selectionModel()->currentIndex() );
1309 switch ( tabItemType->currentIndex() )
1334 QModelIndex index = listItems->selectionModel()->currentIndex();
1335 if ( !index.isValid() )
1338 return mModel->data( mModel->index( index.row(),
QgsStyleModel::Name, index.parent() ), Qt::DisplayRole ).toString();
1343 bool changed =
false;
1354 changed = addTextFormat();
1373 Q_ASSERT(
false &&
"not implemented" );
1386 QString name = tr(
"new symbol" );
1387 QString dialogTitle;
1392 name = tr(
"new marker" );
1393 dialogTitle = tr(
"New Marker Symbol" );
1397 name = tr(
"new line" );
1398 dialogTitle = tr(
"New Line Symbol" );
1402 name = tr(
"new fill symbol" );
1403 dialogTitle = tr(
"New Fill Symbol" );
1406 Q_ASSERT(
false &&
"unknown symbol type" );
1416 dlg.setWindowTitle( dialogTitle );
1417 if ( dlg.exec() == 0 )
1424 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
1426 if ( !saveDlg.exec() )
1432 name = saveDlg.
name();
1435 bool nameInvalid =
true;
1436 while ( nameInvalid )
1439 if ( name.isEmpty() )
1441 QMessageBox::warning(
this, tr(
"Save Symbol" ), tr(
"Cannot save symbol without name. Enter a name." ) );
1443 else if ( mStyle->symbolNames().contains( name ) )
1445 int res = QMessageBox::warning(
this, tr(
"Save Symbol" ), tr(
"Symbol with name '%1' already exists. Overwrite?" ).arg( name ), QMessageBox::Yes | QMessageBox::No );
1446 if ( res == QMessageBox::Yes )
1448 mStyle->removeSymbol( name );
1449 nameInvalid =
false;
1455 nameInvalid =
false;
1460 name = QInputDialog::getText(
this, tr(
"Symbol Name" ), tr(
"Please enter a name for new symbol:" ), QLineEdit::Normal, name, &ok );
1469 QStringList symbolTags = saveDlg.
tags().split(
',' );
1472 mStyle->addSymbol( name, symbol );
1473 mStyle->saveSymbol( name, symbol, saveDlg.
isFavorite(), symbolTags );
1482 QString rampType = type;
1484 if ( rampType.isEmpty() )
1489 QStringList rampTypeNames;
1490 rampTypeNames.reserve( rampTypes.size() );
1491 for (
const QPair<QString, QString> &type : rampTypes )
1492 rampTypeNames << type.second;
1493 const QString selectedRampTypeName = QInputDialog::getItem( parent, tr(
"Color Ramp Type" ), tr(
"Please select color ramp type:" ), rampTypeNames, 0,
false, &ok );
1494 if ( !ok || selectedRampTypeName.isEmpty() )
1497 rampType = rampTypes.value( rampTypeNames.indexOf( selectedRampTypeName ) ).first;
1500 QString name = tr(
"new ramp" );
1502 std::unique_ptr<QgsColorRamp> ramp;
1506 dlg.setWindowTitle( tr(
"New Gradient Color Ramp" ) );
1512 name = tr(
"new gradient ramp" );
1517 dlg.setWindowTitle( tr(
"New Random Color Ramp" ) );
1523 name = tr(
"new random ramp" );
1528 dlg.setWindowTitle( tr(
"New ColorBrewer Ramp" ) );
1539 dlg.setWindowTitle( tr(
"New Preset Color Ramp" ) );
1545 name = tr(
"new preset ramp" );
1550 dlg.setWindowTitle( tr(
"New cpt-city Color Ramp" ) );
1570 QgsDebugError( QStringLiteral(
"invalid ramp type %1" ).arg( rampType ) );
1575 if ( !saveDlg.exec() )
1580 name = saveDlg.
name();
1583 bool nameInvalid =
true;
1584 while ( nameInvalid )
1587 if ( name.isEmpty() )
1589 QMessageBox::warning( parent, tr(
"Save Color Ramp" ), tr(
"Cannot save color ramp without name. Enter a name." ) );
1593 int res = QMessageBox::warning( parent, tr(
"Save Color Ramp" ), tr(
"Color ramp with name '%1' already exists. Overwrite?" ).arg( name ), QMessageBox::Yes | QMessageBox::No );
1594 if ( res == QMessageBox::Yes )
1596 nameInvalid =
false;
1602 nameInvalid =
false;
1607 name = QInputDialog::getText( parent, tr(
"Color Ramp Name" ), tr(
"Please enter a name for new color ramp:" ), QLineEdit::Normal, name, &ok );
1615 QStringList colorRampTags = saveDlg.
tags().split(
',' );
1627 mFavoritesGroupVisible = show;
1633 mSmartGroupVisible = show;
1645 setWindowState( windowState() & ~Qt::WindowMinimized );
1653 if ( !rampName.isEmpty() )
1665 if ( selectedItemType() < 3 )
1669 else if ( selectedItemType() == 3 )
1673 else if ( selectedItemType() == 4 )
1677 else if ( selectedItemType() == 5 )
1679 editLabelSettings();
1681 else if ( selectedItemType() == 6 )
1683 editLegendPatchShape();
1685 else if ( selectedItemType() == 7 )
1691 Q_ASSERT(
false &&
"not implemented" );
1698 if ( symbolName.isEmpty() )
1701 std::unique_ptr<QgsSymbol> symbol( mStyle->symbol( symbolName ) );
1705 dlg.setWindowTitle( symbolName );
1707 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1713 mStyle->addSymbol( symbolName, symbol.release(),
true );
1721 if ( name.isEmpty() )
1724 std::unique_ptr<QgsColorRamp> ramp( mStyle->colorRamp( name ) );
1730 dlg.setWindowTitle( name );
1732 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1744 dlg.setWindowTitle( name );
1746 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1758 dlg.setWindowTitle( name );
1760 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1772 dlg.setWindowTitle( name );
1774 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1786 dlg.setWindowTitle( name );
1788 dlg.
buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1805 Q_ASSERT(
false &&
"invalid ramp type" );
1808 mStyle->addColorRamp( name, ramp.release(),
true );
1813bool QgsStyleManagerDialog::editTextFormat()
1816 if ( formatName.isEmpty() )
1823 dlg.setWindowTitle( formatName );
1825 dlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1838 QgsPalLayerSettings settings;
1839 QgsLabelSettingsDialog settingsDlg( settings,
nullptr,
nullptr,
this, type );
1840 settingsDlg.setWindowTitle( tr(
"New Label Settings" ) );
1842 settingsDlg.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1844 if ( !settingsDlg.exec() )
1847 settings = settingsDlg.settings();
1851 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
1852 saveDlg.setDefaultTags( defaultTag );
1853 if ( !saveDlg.exec() )
1855 QString name = saveDlg.name();
1858 bool nameInvalid =
true;
1859 while ( nameInvalid )
1862 if ( name.isEmpty() )
1864 QMessageBox::warning(
this, tr(
"Save Label Settings" ), tr(
"Cannot save label settings without a name. Enter a name." ) );
1866 else if ( mStyle->labelSettingsNames().contains( name ) )
1868 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 );
1869 if ( res == QMessageBox::Yes )
1871 mStyle->removeLabelSettings( name );
1872 nameInvalid =
false;
1878 nameInvalid =
false;
1883 name = QInputDialog::getText(
this, tr(
"Label Settings Name" ), tr(
"Please enter a name for the new label settings:" ), QLineEdit::Normal, name, &ok );
1891 QStringList symbolTags = saveDlg.tags().split(
',' );
1894 mStyle->addLabelSettings( name, settings );
1895 mStyle->saveLabelSettings( name, settings, saveDlg.isFavorite(), symbolTags );
1901bool QgsStyleManagerDialog::editLabelSettings()
1904 if ( formatName.isEmpty() )
1907 QgsPalLayerSettings settings = mStyle->labelSettings( formatName );
1911 QgsLabelSettingsDialog dlg( settings,
nullptr,
nullptr,
this, geomType );
1912 dlg.setWindowTitle( formatName );
1916 settings = dlg.settings();
1920 mStyle->addLabelSettings( formatName, settings,
true );
1927 QgsLegendPatchShape shape = mStyle->defaultPatch( type, QSizeF( 10, 5 ) );
1928 QgsLegendPatchShapeDialog dialog( shape,
this );
1929 dialog.setWindowTitle( tr(
"New Legend Patch Shape" ) );
1931 dialog.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
1933 if ( !dialog.exec() )
1936 shape = dialog.shape();
1939 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
1940 saveDlg.setDefaultTags( defaultTag );
1941 if ( !saveDlg.exec() )
1943 QString name = saveDlg.name();
1946 bool nameInvalid =
true;
1947 while ( nameInvalid )
1950 if ( name.isEmpty() )
1952 QMessageBox::warning(
this, tr(
"Save Legend Patch Shape" ), tr(
"Cannot save legend patch shapes without a name. Enter a name." ) );
1954 else if ( mStyle->legendPatchShapeNames().contains( name ) )
1956 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 );
1957 if ( res == QMessageBox::Yes )
1960 nameInvalid =
false;
1966 nameInvalid =
false;
1971 name = QInputDialog::getText(
this, tr(
"Legend Patch Shape Name" ), tr(
"Please enter a name for the new legend patch shape:" ), QLineEdit::Normal, name, &ok );
1979 QStringList symbolTags = saveDlg.tags().split(
',' );
1982 mStyle->addLegendPatchShape( name, shape );
1983 mStyle->saveLegendPatchShape( name, shape, saveDlg.isFavorite(), symbolTags );
1989bool QgsStyleManagerDialog::editLegendPatchShape()
1992 if ( shapeName.isEmpty() )
1995 QgsLegendPatchShape shape = mStyle->legendPatchShape( shapeName );
2000 QgsLegendPatchShapeDialog dlg( shape,
this );
2001 dlg.setWindowTitle( shapeName );
2005 shape = dlg.shape();
2008 mStyle->addLegendPatchShape( shapeName, shape,
true );
2013bool QgsStyleManagerDialog::addSymbol3D(
const QString &type )
2019 Qgs3DSymbolDialog dialog( symbol.get(),
this );
2020 dialog.setWindowTitle( tr(
"New 3D Symbol" ) );
2022 dialog.buttonBox()->button( QDialogButtonBox::Ok )->setEnabled(
false );
2024 if ( !dialog.exec() )
2027 symbol.reset( dialog.symbol() );
2032 const QString defaultTag = groupTree->currentIndex().isValid() ? groupTree->currentIndex().data( GroupModelRoles::TagName ).toString() : QString();
2033 saveDlg.setDefaultTags( defaultTag );
2034 if ( !saveDlg.exec() )
2036 QString name = saveDlg.name();
2039 bool nameInvalid =
true;
2040 while ( nameInvalid )
2043 if ( name.isEmpty() )
2045 QMessageBox::warning(
this, tr(
"Save 3D Symbol" ), tr(
"Cannot save 3D symbols without a name. Enter a name." ) );
2047 else if ( mStyle->symbol3DNames().contains( name ) )
2049 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 );
2050 if ( res == QMessageBox::Yes )
2053 nameInvalid =
false;
2059 nameInvalid =
false;
2064 name = QInputDialog::getText(
this, tr(
"3D Symbol Name" ), tr(
"Please enter a name for the new 3D symbol:" ), QLineEdit::Normal, name, &ok );
2072 QStringList symbolTags = saveDlg.tags().split(
',' );
2075 QgsAbstract3DSymbol *newSymbol = symbol.get();
2076 mStyle->addSymbol3D( name, symbol.release() );
2077 mStyle->saveSymbol3D( name, newSymbol, saveDlg.isFavorite(), symbolTags );
2083bool QgsStyleManagerDialog::editSymbol3D()
2086 if ( symbolName.isEmpty() )
2089 std::unique_ptr<QgsAbstract3DSymbol> symbol( mStyle->symbol3D( symbolName ) );
2094 Qgs3DSymbolDialog dlg( symbol.get(),
this );
2095 dlg.setWindowTitle( symbolName );
2099 symbol.reset( dlg.symbol() );
2104 mStyle->addSymbol3D( symbolName, symbol.release(),
true );
2109void QgsStyleManagerDialog::addStyleDatabase(
bool createNew )
2112 if ( initialFolder.isEmpty() )
2113 initialFolder = QDir::homePath();
2115 QString databasePath = createNew
2116 ? QFileDialog::getSaveFileName(
2118 tr(
"Create Style Database" ),
2120 tr(
"Style databases" ) +
" (*.db)"
2122 : QFileDialog::getOpenFileName(
2124 tr(
"Add Style Database" ),
2126 tr(
"Style databases" ) +
" (*.db *.xml)"
2131 if ( !databasePath.isEmpty() )
2138 if ( QFile::exists( databasePath ) )
2140 QFile::remove( databasePath );
2145 QMessageBox::warning(
this, tr(
"Create Style Database" ), tr(
"The style database could not be created" ) );
2157 const QList<ItemDetails> items = selectedItems();
2159 if ( allTypesSelected() )
2161 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 ) )
2168 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 ) )
2173 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 ) )
2178 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 ) )
2183 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 ) )
2188 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 ) )
2193 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 ) )
2200 for (
const ItemDetails &details : items )
2202 if ( details.name.isEmpty() )
2205 mStyle->removeEntityByName( details.entityType, details.name );
2227 QString dir = QFileDialog::getExistingDirectory(
this, tr(
"Export Selected Symbols as PNG" ), QDir::home().absolutePath(), QFileDialog::DontResolveSymlinks );
2233 QString dir = QFileDialog::getExistingDirectory(
this, tr(
"Export Selected Symbols as SVG" ), QDir::home().absolutePath(), QFileDialog::DontResolveSymlinks );
2240 if ( dir.isEmpty() )
2243 const QList<ItemDetails> items = selectedItems();
2244 for (
const ItemDetails &details : items )
2249 QString path = dir +
'/' + details.name +
'.' + format;
2250 std::unique_ptr<QgsSymbol> sym( mStyle->symbol( details.name ) );
2252 sym->exportImage( path, format, size );
2272 QFont font = item->font();
2273 font.setBold(
true );
2274 item->setFont( font );
2279 if ( mBlockGroupUpdates )
2282 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2285 const bool readOnly = isReadOnly();
2287 if ( mFavoritesGroupVisible )
2289 QStandardItem *favoriteSymbols =
new QStandardItem( tr(
"Favorites" ) );
2290 favoriteSymbols->setData(
"favorite" );
2291 favoriteSymbols->setEditable(
false );
2293 model->appendRow( favoriteSymbols );
2296 QStandardItem *allSymbols =
new QStandardItem( tr(
"All" ) );
2297 allSymbols->setData(
"all" );
2298 allSymbols->setEditable(
false );
2300 model->appendRow( allSymbols );
2302 QStandardItem *taggroup =
new QStandardItem( QString() );
2303 taggroup->setData(
"tags" );
2304 taggroup->setEditable(
false );
2305 QStringList tags = mStyle->tags();
2307 for (
const QString &tag : std::as_const( tags ) )
2309 QStandardItem *item =
new QStandardItem( tag );
2310 item->setData( mStyle->tagId( tag ) );
2311 item->setData( tag, GroupModelRoles::TagName );
2312 item->setEditable( !readOnly );
2313 taggroup->appendRow( item );
2315 taggroup->setText( tr(
"Tags" ) );
2317 model->appendRow( taggroup );
2319 if ( mSmartGroupVisible )
2321 QStandardItem *smart =
new QStandardItem( tr(
"Smart Groups" ) );
2322 smart->setData(
"smartgroups" );
2323 smart->setEditable(
false );
2326 QgsSymbolGroupMap::const_iterator i = sgMap.constBegin();
2327 while ( i != sgMap.constEnd() )
2329 QStandardItem *item =
new QStandardItem( i.value() );
2330 item->setData( i.key() );
2331 item->setEditable( !readOnly );
2332 smart->appendRow( item );
2335 model->appendRow( smart );
2339 int rows = model->rowCount( model->indexFromItem( model->invisibleRootItem() ) );
2340 for (
int i = 0; i < rows; i++ )
2342 groupTree->setExpanded( model->indexFromItem( model->item( i ) ),
true );
2348 const QString category = index.data( Qt::UserRole + 1 ).toString();
2349 sPreviousTag = category;
2351 const bool readOnly = isReadOnly();
2353 if ( mGroupingMode && mModel )
2355 mModel->setTagId( -1 );
2356 mModel->setSmartGroupId( -1 );
2357 mModel->setFavoritesOnly(
false );
2358 mModel->setCheckTag( index.data( Qt::DisplayRole ).toString() );
2360 else if ( category == QLatin1String(
"all" ) || category == QLatin1String(
"tags" ) || category == QLatin1String(
"smartgroups" ) )
2363 if ( category == QLatin1String(
"tags" ) )
2365 actnAddTag->setEnabled( !readOnly );
2366 actnAddSmartgroup->setEnabled(
false );
2368 else if ( category == QLatin1String(
"smartgroups" ) )
2370 actnAddTag->setEnabled(
false );
2371 actnAddSmartgroup->setEnabled( !readOnly );
2376 mModel->setTagId( -1 );
2377 mModel->setSmartGroupId( -1 );
2378 mModel->setFavoritesOnly(
false );
2381 else if ( category == QLatin1String(
"favorite" ) )
2386 mModel->setTagId( -1 );
2387 mModel->setSmartGroupId( -1 );
2388 mModel->setFavoritesOnly(
true );
2391 else if ( index.parent().data( Qt::UserRole + 1 ) ==
"smartgroups" )
2393 actnRemoveGroup->setEnabled( !readOnly );
2394 btnManageGroups->setEnabled( !readOnly );
2395 const int groupId = index.data( Qt::UserRole + 1 ).toInt();
2398 mModel->setTagId( -1 );
2399 mModel->setSmartGroupId( groupId );
2400 mModel->setFavoritesOnly(
false );
2406 int tagId = index.data( Qt::UserRole + 1 ).toInt();
2409 mModel->setTagId( tagId );
2410 mModel->setSmartGroupId( -1 );
2411 mModel->setFavoritesOnly(
false );
2415 actnEditSmartGroup->setVisible(
false );
2416 actnAddTag->setVisible(
false );
2417 actnAddSmartgroup->setVisible(
false );
2418 actnRemoveGroup->setVisible(
false );
2419 actnTagSymbols->setVisible(
false );
2420 actnFinishTagging->setVisible(
false );
2422 if ( index.parent().isValid() )
2424 if ( index.parent().data( Qt::UserRole + 1 ).toString() == QLatin1String(
"smartgroups" ) )
2426 actnEditSmartGroup->setVisible( !mGroupingMode && !readOnly );
2428 else if ( index.parent().data( Qt::UserRole + 1 ).toString() == QLatin1String(
"tags" ) )
2430 actnAddTag->setVisible( !mGroupingMode && !readOnly );
2431 actnTagSymbols->setVisible( !mGroupingMode && !readOnly );
2432 actnFinishTagging->setVisible( mGroupingMode && !readOnly );
2434 actnRemoveGroup->setVisible( !readOnly );
2436 else if ( index.data( Qt::UserRole + 1 ) ==
"smartgroups" )
2438 actnAddSmartgroup->setVisible( !mGroupingMode && !readOnly );
2440 else if ( index.data( Qt::UserRole + 1 ) ==
"tags" )
2442 actnAddTag->setVisible( !mGroupingMode && !readOnly );
2451 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2453 for (
int i = 0; i < groupTree->model()->rowCount(); i++ )
2455 index = groupTree->model()->index( i, 0 );
2456 QString data = index.data( Qt::UserRole + 1 ).toString();
2457 if ( data == QLatin1String(
"tags" ) )
2466 itemName = QInputDialog::getText(
this, tr(
"Add Tag" ), tr(
"Please enter name for the new tag:" ), QLineEdit::Normal, tr(
"New tag" ), &ok ).trimmed();
2467 if ( !ok || itemName.isEmpty() )
2470 int check = mStyle->tagId( itemName );
2473 mMessageBar->pushCritical( tr(
"Add Tag" ), tr(
"The tag “%1” already exists." ).arg( itemName ) );
2479 mBlockGroupUpdates++;
2480 id = mStyle->addTag( itemName );
2481 mBlockGroupUpdates--;
2485 mMessageBar->pushCritical( tr(
"Add Tag" ), tr(
"New tag could not be created — There was a problem with the symbol database." ) );
2489 QStandardItem *parentItem = model->itemFromIndex( index );
2490 QStandardItem *childItem =
new QStandardItem( itemName );
2491 childItem->setData(
id );
2492 childItem->setData( itemName, GroupModelRoles::TagName );
2493 parentItem->appendRow( childItem );
2503 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2505 for (
int i = 0; i < groupTree->model()->rowCount(); i++ )
2507 index = groupTree->model()->index( i, 0 );
2508 QString data = index.data( Qt::UserRole + 1 ).toString();
2509 if ( data == QLatin1String(
"smartgroups" ) )
2518 if ( dlg.exec() == QDialog::Rejected )
2523 mBlockGroupUpdates++;
2525 mBlockGroupUpdates--;
2531 QStandardItem *parentItem = model->itemFromIndex( index );
2532 QStandardItem *childItem =
new QStandardItem( itemName );
2533 childItem->setData(
id );
2534 parentItem->appendRow( childItem );
2544 QStandardItemModel *model = qobject_cast<QStandardItemModel *>( groupTree->model() );
2545 QModelIndex index = groupTree->currentIndex();
2548 QString data = index.data( Qt::UserRole + 1 ).toString();
2549 if ( data == QLatin1String(
"all" ) || data == QLatin1String(
"favorite" ) || data == QLatin1String(
"tags" ) || index.data() ==
"smartgroups" )
2552 int err = QMessageBox::critical(
this, tr(
"Remove Group" ), tr(
"Invalid selection. Cannot delete system defined categories.\n"
2553 "Kindly select a group or smart group you might want to delete." ) );
2558 QStandardItem *parentItem = model->itemFromIndex( index.parent() );
2562 mBlockGroupUpdates++;
2564 if ( parentItem->data( Qt::UserRole + 1 ).toString() == QLatin1String(
"smartgroups" ) )
2573 mBlockGroupUpdates--;
2574 parentItem->removeRow( index.row() );
2582 QgsDebugMsgLevel( QStringLiteral(
"Symbol group edited: data=%1 text=%2" ).arg( item->data( Qt::UserRole + 1 ).toString(), item->text() ), 2 );
2583 int id = item->data( Qt::UserRole + 1 ).toInt();
2584 QString name = item->text();
2585 mBlockGroupUpdates++;
2586 if ( item->parent()->data( Qt::UserRole + 1 ) ==
"smartgroups" )
2594 mBlockGroupUpdates--;
2602 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2604 if ( mGroupingMode )
2606 mGroupingMode =
false;
2607 mModel->setCheckable(
false );
2608 actnTagSymbols->setVisible(
true );
2609 actnFinishTagging->setVisible(
false );
2620 listItems->setSelectionMode( QAbstractItemView::ExtendedSelection );
2621 mSymbolTreeView->setSelectionMode( QAbstractItemView::ExtendedSelection );
2625 bool validGroup =
false;
2627 QModelIndex present = groupTree->currentIndex();
2628 while ( present.parent().isValid() )
2630 if ( present.parent().data() ==
"Tags" )
2635 present = present.parent();
2640 mGroupingMode =
true;
2642 actnTagSymbols->setVisible(
false );
2643 actnFinishTagging->setVisible(
true );
2650 btnManageGroups->setEnabled(
true );
2652 mModel->setCheckable(
true );
2655 listItems->setSelectionMode( QAbstractItemView::NoSelection );
2656 mSymbolTreeView->setSelectionMode( QAbstractItemView::NoSelection );
2670 mModel->setFilterString( qword );
2675 actnEditItem->setEnabled( index.isValid() && !mGroupingMode && !isReadOnly() );
2680 Q_UNUSED( selected )
2681 Q_UNUSED( deselected )
2682 const bool nothingSelected = listItems->selectionModel()->selectedIndexes().empty();
2683 const bool readOnly = isReadOnly();
2684 actnRemoveItem->setDisabled( nothingSelected || readOnly );
2685 actnAddFavorite->setDisabled( nothingSelected || readOnly );
2686 actnRemoveFavorite->setDisabled( nothingSelected || readOnly );
2687 mGroupListMenu->setDisabled( nothingSelected || readOnly );
2688 actnDetag->setDisabled( nothingSelected || readOnly );
2689 actnExportAsPNG->setDisabled( nothingSelected );
2690 actnExportAsSVG->setDisabled( nothingSelected );
2691 if ( mActionCopyToDefault )
2692 mActionCopyToDefault->setDisabled( nothingSelected );
2693 mCopyToDefaultButton->setDisabled( nothingSelected );
2694 actnEditItem->setDisabled( nothingSelected || readOnly );
2699 const bool readOnly = isReadOnly();
2700 groupTree->setEnabled( enable );
2701 btnAddTag->setEnabled( enable && !readOnly );
2702 btnAddSmartgroup->setEnabled( enable && !readOnly );
2703 actnAddTag->setEnabled( enable && !readOnly );
2704 actnAddSmartgroup->setEnabled( enable && !readOnly );
2705 actnRemoveGroup->setEnabled( enable && !readOnly );
2706 btnManageGroups->setEnabled( !readOnly && ( enable || mGroupingMode ) );
2707 searchBox->setEnabled( enable );
2712 const bool readOnly = isReadOnly();
2713 actnRemoveGroup->setEnabled( enable && !readOnly );
2714 btnManageGroups->setEnabled( !readOnly && ( enable || mGroupingMode ) );
2719 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2720 for (
int i = 0; i < treeModel->rowCount(); i++ )
2722 treeModel->item( i )->setEnabled( enable );
2724 if ( treeModel->item( i )->data() ==
"smartgroups" )
2726 for (
int j = 0; j < treeModel->item( i )->rowCount(); j++ )
2728 treeModel->item( i )->child( j )->setEnabled( enable );
2735 for (
int i = 0; i < symbolBtnsLayout->count(); i++ )
2737 QWidget *w = symbolBtnsLayout->itemAt( i )->widget();
2739 w->setEnabled( enable );
2743 actnRemoveItem->setEnabled( enable );
2744 actnEditItem->setEnabled( enable );
2745 mActionCopyItem->setEnabled( enable );
2746 mActionPasteItem->setEnabled( enable );
2751 QPoint globalPos = groupTree->viewport()->mapToGlobal( point );
2753 QModelIndex index = groupTree->indexAt( point );
2754 if ( index.isValid() && !mGroupingMode )
2755 mGroupTreeContextMenu->popup( globalPos );
2760 QPoint globalPos = mSymbolViewStackedWidget->currentIndex() == 0
2761 ? listItems->viewport()->mapToGlobal( point )
2762 : mSymbolTreeView->viewport()->mapToGlobal( point );
2765 mGroupListMenu->clear();
2767 const QModelIndexList indices = listItems->selectionModel()->selectedRows();
2769 if ( !isReadOnly() )
2771 const QStringList currentTags = indices.count() == 1 ? indices.at( 0 ).data(
static_cast<int>(
QgsStyleModel::CustomRole::Tag ) ).toStringList() : QStringList();
2772 QAction *a =
nullptr;
2773 QStringList tags = mStyle->tags();
2775 for (
const QString &tag : std::as_const( tags ) )
2777 a =
new QAction( tag, mGroupListMenu );
2779 if ( indices.count() == 1 )
2781 a->setCheckable(
true );
2782 a->setChecked( currentTags.contains( tag ) );
2785 mGroupListMenu->addAction( a );
2788 if ( tags.count() > 0 )
2790 mGroupListMenu->addSeparator();
2792 a =
new QAction( tr(
"Create New Tag…" ), mGroupListMenu );
2793 connect( a, &QAction::triggered,
this, [
this](
bool ) {
tagSelectedSymbols(
true ); } );
2794 mGroupListMenu->addAction( a );
2797 const QList<ItemDetails> items = selectedItems();
2800 bool enablePaste =
false;
2806 const QMimeData *mimeData = QApplication::clipboard()->mimeData();
2807 if ( mimeData->hasFormat( QLatin1String(
"application/qgis.labelsettings" ) ) )
2816 mActionPasteItem->setEnabled( enablePaste );
2818 mGroupMenu->popup( globalPos );
2826 const QList<ItemDetails> items = selectedItems();
2827 for (
const ItemDetails &details : items )
2829 mStyle->addFavorite( details.entityType, details.name );
2838 const QList<ItemDetails> items = selectedItems();
2839 for (
const ItemDetails &details : items )
2841 mStyle->removeFavorite( details.entityType, details.name );
2847 QAction *selectedItem = qobject_cast<QAction *>( sender() );
2850 const QList<ItemDetails> items = selectedItems();
2860 tag = mStyle->tag(
id );
2864 tag = selectedItem->data().toString();
2867 for (
const ItemDetails &details : items )
2869 mStyle->tagSymbol( details.entityType, details.name, QStringList( tag ) );
2879 QAction *selectedItem = qobject_cast<QAction *>( sender() );
2883 const QList<ItemDetails> items = selectedItems();
2884 for (
const ItemDetails &details : items )
2886 mStyle->detagSymbol( details.entityType, details.name );
2896 QStandardItemModel *treeModel = qobject_cast<QStandardItemModel *>( groupTree->model() );
2899 QModelIndex present = groupTree->currentIndex();
2900 if ( present.parent().data( Qt::UserRole + 1 ) !=
"smartgroups" )
2903 QMessageBox::critical(
this, tr(
"Edit Smart Group" ), tr(
"You have not selected a Smart Group. Kindly select a Smart Group to edit." ) );
2906 QStandardItem *item = treeModel->itemFromIndex( present );
2911 dlg.
setOperator( mStyle->smartgroupOperator( item->data().toInt() ) );
2914 if ( dlg.exec() == QDialog::Rejected )
2917 mBlockGroupUpdates++;
2920 mBlockGroupUpdates--;
2923 mMessageBar->pushCritical( tr(
"Edit Smart Group" ), tr(
"There was an error while editing the smart group." ) );
2927 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