Skip to content

Commit

Permalink
Add 'Copy to default' action as a dedicated button when browsing non-…
Browse files Browse the repository at this point in the history
…default style
  • Loading branch information
nyalldawson committed Jan 16, 2019
1 parent 878cec9 commit 1a45c8c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/gui/symbology/qgsstylemanagerdialog.cpp
Expand Up @@ -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();
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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 );
}

Expand Down
11 changes: 11 additions & 0 deletions src/ui/qgsstylemanagerdialogbase.ui
Expand Up @@ -189,6 +189,16 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="mCopyToDefaultButton">
<property name="toolTip">
<string>Copies the selected items to the default style library</string>
</property>
<property name="text">
<string>Copy to Default Style…</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
Expand Down Expand Up @@ -625,6 +635,7 @@
<tabstop>btnAddItem</tabstop>
<tabstop>btnRemoveItem</tabstop>
<tabstop>btnEditItem</tabstop>
<tabstop>mCopyToDefaultButton</tabstop>
<tabstop>mButtonIconView</tabstop>
<tabstop>mButtonListView</tabstop>
<tabstop>searchBox</tabstop>
Expand Down

0 comments on commit 1a45c8c

Please sign in to comment.