Skip to content
Permalink
Browse files

[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.
  • Loading branch information
nyalldawson committed Jan 16, 2019
1 parent dd00777 commit a1b44c939d474279a7e901a924c577fde7d6dc1a
Showing with 30 additions and 0 deletions.
  1. +26 −0 src/gui/symbology/qgsstylemanagerdialog.cpp
  2. +4 −0 src/gui/symbology/qgsstylemanagerdialog.h
@@ -203,9 +203,17 @@ QgsStyleManagerDialog::QgsStyleManagerDialog( QgsStyle *style, QWidget *parent,
shareMenu->addAction( importAction );
connect( importAction, &QAction::triggered, this, &QgsStyleManagerDialog::importItems );
}
if ( mStyle != QgsStyle::defaultStyle() )
{
mActionCopyToDefault = new QAction( tr( "Copy Item(s) to Default Style…" ), this );
shareMenu->addAction( mActionCopyToDefault );
connect( mActionCopyToDefault, &QAction::triggered, this, &QgsStyleManagerDialog::copyItemsToDefault );
}

shareMenu->addSeparator();
shareMenu->addAction( actnExportAsPNG );
shareMenu->addAction( actnExportAsSVG );

connect( actnExportAsPNG, &QAction::triggered, this, &QgsStyleManagerDialog::exportItemsPNG );
connect( actnExportAsSVG, &QAction::triggered, this, &QgsStyleManagerDialog::exportItemsSVG );
connect( exportAction, &QAction::triggered, this, &QgsStyleManagerDialog::exportItems );
@@ -320,6 +328,10 @@ QgsStyleManagerDialog::QgsStyleManagerDialog( QgsStyle *style, QWidget *parent,
btnAddTag->setVisible( false );
btnManageGroups->setVisible( false );
}
if ( mActionCopyToDefault )
{
mGroupMenu->addAction( mActionCopyToDefault );
}
mGroupMenu->addAction( actnExportAsPNG );
mGroupMenu->addAction( actnExportAsSVG );

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

void QgsStyleManagerDialog::copyItemsToDefault()
{
const QList< ItemDetails > items = selectedItems();
if ( !items.empty() )
{
auto cursorOverride = qgis::make_unique< QgsTemporaryCursorOverride >( Qt::WaitCursor );
copyItems( items, mStyle, QgsStyle::defaultStyle(), this, cursorOverride, true, QStringList(), false, false );
QMessageBox::information( this, tr( "Import Symbols" ),
tr( "Symbols successfully imported." ) );
}
}

int QgsStyleManagerDialog::selectedItemType()
{
QModelIndex index = listItems->selectionModel()->currentIndex();
@@ -1556,6 +1580,8 @@ void QgsStyleManagerDialog::selectedSymbolsChanged( const QItemSelection &select
actnDetag->setDisabled( nothingSelected || mReadOnly );
actnExportAsPNG->setDisabled( nothingSelected );
actnExportAsSVG->setDisabled( nothingSelected );
if ( mActionCopyToDefault )
mActionCopyToDefault->setDisabled( nothingSelected );
actnEditItem->setDisabled( nothingSelected || mReadOnly );
}

@@ -317,6 +317,8 @@ class GUI_EXPORT QgsStyleManagerDialog : public QDialog, private Ui::QgsStyleMan

void tabItemType_currentChanged( int );

void copyItemsToDefault();

private:
int selectedItemType();

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

QAction *mActionCopyToDefault = nullptr;

int mBlockGroupUpdates = 0;

bool mReadOnly = false;

0 comments on commit a1b44c9

Please sign in to comment.
You can’t perform that action at this time.