From 1a45c8c0391ecffb86a29f03854134cd3d050dbb Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Wed, 16 Jan 2019 07:41:05 +1000 Subject: [PATCH] Add 'Copy to default' action as a dedicated button when browsing non-default style --- src/gui/symbology/qgsstylemanagerdialog.cpp | 11 ++++++++++- src/ui/qgsstylemanagerdialogbase.ui | 11 +++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/gui/symbology/qgsstylemanagerdialog.cpp b/src/gui/symbology/qgsstylemanagerdialog.cpp index 56d576adb5b4..00dd69fdab2e 100644 --- a/src/gui/symbology/qgsstylemanagerdialog.cpp +++ b/src/gui/symbology/qgsstylemanagerdialog.cpp @@ -205,9 +205,14 @@ QgsStyleManagerDialog::QgsStyleManagerDialog( QgsStyle *style, QWidget *parent, } if ( mStyle != QgsStyle::defaultStyle() ) { - mActionCopyToDefault = new QAction( tr( "Copy Selection to Default Style" ), this ); + mActionCopyToDefault = new QAction( tr( "Copy Selection to Default Style…" ), this ); shareMenu->addAction( mActionCopyToDefault ); connect( mActionCopyToDefault, &QAction::triggered, this, &QgsStyleManagerDialog::copyItemsToDefault ); + connect( mCopyToDefaultButton, &QPushButton::clicked, this, &QgsStyleManagerDialog::copyItemsToDefault ); + } + else + { + mCopyToDefaultButton->hide(); } shareMenu->addSeparator(); @@ -386,6 +391,9 @@ QgsStyleManagerDialog::QgsStyleManagerDialog( QgsStyle *style, QWidget *parent, // note -- we have to save state here and not in destructor, as new symbol list widgets are created before the previous ones are destroyed QgsSettings().setValue( QStringLiteral( "Windows/StyleV2Manager/treeState" ), mSymbolTreeView->header()->saveState(), QgsSettings::Gui ); } ); + + // set initial disabled state for actions requiring a selection + selectedSymbolsChanged( QItemSelection(), QItemSelection() ); } void QgsStyleManagerDialog::onFinished() @@ -1596,6 +1604,7 @@ void QgsStyleManagerDialog::selectedSymbolsChanged( const QItemSelection &select actnExportAsSVG->setDisabled( nothingSelected ); if ( mActionCopyToDefault ) mActionCopyToDefault->setDisabled( nothingSelected ); + mCopyToDefaultButton->setDisabled( nothingSelected ); actnEditItem->setDisabled( nothingSelected || mReadOnly ); } diff --git a/src/ui/qgsstylemanagerdialogbase.ui b/src/ui/qgsstylemanagerdialogbase.ui index 6c139488cc5a..641dba02e0f1 100644 --- a/src/ui/qgsstylemanagerdialogbase.ui +++ b/src/ui/qgsstylemanagerdialogbase.ui @@ -189,6 +189,16 @@ + + + + Copies the selected items to the default style library + + + Copy to Default Style… + + + @@ -625,6 +635,7 @@ btnAddItem btnRemoveItem btnEditItem + mCopyToDefaultButton mButtonIconView mButtonListView searchBox