Skip to content

Commit a1b44c9

Browse files
committedJan 16, 2019
[FEATURE] When browsing a style from the browser panel, allow copying
symbols to the default style from the right click menu and share button Allows users to easily transfer symbols and ramps from a style xml file directly to their local style database.
1 parent dd00777 commit a1b44c9

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed
 

‎src/gui/symbology/qgsstylemanagerdialog.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,17 @@ QgsStyleManagerDialog::QgsStyleManagerDialog( QgsStyle *style, QWidget *parent,
203203
shareMenu->addAction( importAction );
204204
connect( importAction, &QAction::triggered, this, &QgsStyleManagerDialog::importItems );
205205
}
206+
if ( mStyle != QgsStyle::defaultStyle() )
207+
{
208+
mActionCopyToDefault = new QAction( tr( "Copy Item(s) to Default Style…" ), this );
209+
shareMenu->addAction( mActionCopyToDefault );
210+
connect( mActionCopyToDefault, &QAction::triggered, this, &QgsStyleManagerDialog::copyItemsToDefault );
211+
}
212+
206213
shareMenu->addSeparator();
207214
shareMenu->addAction( actnExportAsPNG );
208215
shareMenu->addAction( actnExportAsSVG );
216+
209217
connect( actnExportAsPNG, &QAction::triggered, this, &QgsStyleManagerDialog::exportItemsPNG );
210218
connect( actnExportAsSVG, &QAction::triggered, this, &QgsStyleManagerDialog::exportItemsSVG );
211219
connect( exportAction, &QAction::triggered, this, &QgsStyleManagerDialog::exportItems );
@@ -320,6 +328,10 @@ QgsStyleManagerDialog::QgsStyleManagerDialog( QgsStyle *style, QWidget *parent,
320328
btnAddTag->setVisible( false );
321329
btnManageGroups->setVisible( false );
322330
}
331+
if ( mActionCopyToDefault )
332+
{
333+
mGroupMenu->addAction( mActionCopyToDefault );
334+
}
323335
mGroupMenu->addAction( actnExportAsPNG );
324336
mGroupMenu->addAction( actnExportAsSVG );
325337

@@ -410,6 +422,18 @@ void QgsStyleManagerDialog::tabItemType_currentChanged( int )
410422
populateList();
411423
}
412424

425+
void QgsStyleManagerDialog::copyItemsToDefault()
426+
{
427+
const QList< ItemDetails > items = selectedItems();
428+
if ( !items.empty() )
429+
{
430+
auto cursorOverride = qgis::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
431+
copyItems( items, mStyle, QgsStyle::defaultStyle(), this, cursorOverride, true, QStringList(), false, false );
432+
QMessageBox::information( this, tr( "Import Symbols" ),
433+
tr( "Symbols successfully imported." ) );
434+
}
435+
}
436+
413437
int QgsStyleManagerDialog::selectedItemType()
414438
{
415439
QModelIndex index = listItems->selectionModel()->currentIndex();
@@ -1556,6 +1580,8 @@ void QgsStyleManagerDialog::selectedSymbolsChanged( const QItemSelection &select
15561580
actnDetag->setDisabled( nothingSelected || mReadOnly );
15571581
actnExportAsPNG->setDisabled( nothingSelected );
15581582
actnExportAsSVG->setDisabled( nothingSelected );
1583+
if ( mActionCopyToDefault )
1584+
mActionCopyToDefault->setDisabled( nothingSelected );
15591585
actnEditItem->setDisabled( nothingSelected || mReadOnly );
15601586
}
15611587

‎src/gui/symbology/qgsstylemanagerdialog.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ class GUI_EXPORT QgsStyleManagerDialog : public QDialog, private Ui::QgsStyleMan
317317

318318
void tabItemType_currentChanged( int );
319319

320+
void copyItemsToDefault();
321+
320322
private:
321323
int selectedItemType();
322324

@@ -365,6 +367,8 @@ class GUI_EXPORT QgsStyleManagerDialog : public QDialog, private Ui::QgsStyleMan
365367
//! Menu for the "Add item" toolbutton when in colorramp mode
366368
QMenu *mMenuBtnAddItemColorRamp = nullptr;
367369

370+
QAction *mActionCopyToDefault = nullptr;
371+
368372
int mBlockGroupUpdates = 0;
369373

370374
bool mReadOnly = false;

0 commit comments

Comments
 (0)
Please sign in to comment.