Skip to content

Commit 1a45c8c

Browse files
committedJan 16, 2019
Add 'Copy to default' action as a dedicated button when browsing non-default style
1 parent 878cec9 commit 1a45c8c

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed
 

‎src/gui/symbology/qgsstylemanagerdialog.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,14 @@ QgsStyleManagerDialog::QgsStyleManagerDialog( QgsStyle *style, QWidget *parent,
205205
}
206206
if ( mStyle != QgsStyle::defaultStyle() )
207207
{
208-
mActionCopyToDefault = new QAction( tr( "Copy Selection to Default Style" ), this );
208+
mActionCopyToDefault = new QAction( tr( "Copy Selection to Default Style" ), this );
209209
shareMenu->addAction( mActionCopyToDefault );
210210
connect( mActionCopyToDefault, &QAction::triggered, this, &QgsStyleManagerDialog::copyItemsToDefault );
211+
connect( mCopyToDefaultButton, &QPushButton::clicked, this, &QgsStyleManagerDialog::copyItemsToDefault );
212+
}
213+
else
214+
{
215+
mCopyToDefaultButton->hide();
211216
}
212217

213218
shareMenu->addSeparator();
@@ -386,6 +391,9 @@ QgsStyleManagerDialog::QgsStyleManagerDialog( QgsStyle *style, QWidget *parent,
386391
// note -- we have to save state here and not in destructor, as new symbol list widgets are created before the previous ones are destroyed
387392
QgsSettings().setValue( QStringLiteral( "Windows/StyleV2Manager/treeState" ), mSymbolTreeView->header()->saveState(), QgsSettings::Gui );
388393
} );
394+
395+
// set initial disabled state for actions requiring a selection
396+
selectedSymbolsChanged( QItemSelection(), QItemSelection() );
389397
}
390398

391399
void QgsStyleManagerDialog::onFinished()
@@ -1596,6 +1604,7 @@ void QgsStyleManagerDialog::selectedSymbolsChanged( const QItemSelection &select
15961604
actnExportAsSVG->setDisabled( nothingSelected );
15971605
if ( mActionCopyToDefault )
15981606
mActionCopyToDefault->setDisabled( nothingSelected );
1607+
mCopyToDefaultButton->setDisabled( nothingSelected );
15991608
actnEditItem->setDisabled( nothingSelected || mReadOnly );
16001609
}
16011610

‎src/ui/qgsstylemanagerdialogbase.ui

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,16 @@
189189
</property>
190190
</widget>
191191
</item>
192+
<item>
193+
<widget class="QPushButton" name="mCopyToDefaultButton">
194+
<property name="toolTip">
195+
<string>Copies the selected items to the default style library</string>
196+
</property>
197+
<property name="text">
198+
<string>Copy to Default Style…</string>
199+
</property>
200+
</widget>
201+
</item>
192202
<item>
193203
<spacer name="horizontalSpacer">
194204
<property name="orientation">
@@ -625,6 +635,7 @@
625635
<tabstop>btnAddItem</tabstop>
626636
<tabstop>btnRemoveItem</tabstop>
627637
<tabstop>btnEditItem</tabstop>
638+
<tabstop>mCopyToDefaultButton</tabstop>
628639
<tabstop>mButtonIconView</tabstop>
629640
<tabstop>mButtonListView</tabstop>
630641
<tabstop>searchBox</tabstop>

0 commit comments

Comments
 (0)
Please sign in to comment.