Skip to content

Commit c180fec

Browse files
committedOct 31, 2014
support icons in map layer actions
1 parent 0bfe8ab commit c180fec

File tree

5 files changed

+19
-15
lines changed

5 files changed

+19
-15
lines changed
 

‎python/gui/qgsmaplayeractionregistry.sip

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ class QgsMapLayerAction : QAction
1616

1717
//! Creates a map layer action which can run on any layer
1818
//! @note using AllActions as a target probably does not make a lot of sense. This default action was settled for API compatiblity reasons.
19-
QgsMapLayerAction( QString name, QObject *parent, Targets targets = AllActions );
19+
QgsMapLayerAction( QString name, QObject *parent, Targets targets = AllActions, QIcon icon = QIcon() );
2020

2121
//! Creates a map layer action which can run only on a specific layer
22-
QgsMapLayerAction( QString name, QObject *parent, QgsMapLayer* layer, Targets targets = AllActions );
22+
QgsMapLayerAction( QString name, QObject *parent, QgsMapLayer* layer, Targets targets = AllActions, QIcon icon = QIcon() );
2323

2424
//! Creates a map layer action which can run on a specific type of layer
25-
QgsMapLayerAction( QString name, QObject *parent, QgsMapLayer::LayerType layerType, Targets targets = AllActions );
25+
QgsMapLayerAction( QString name, QObject *parent, QgsMapLayer::LayerType layerType, Targets targets = AllActions, QIcon icon = QIcon() );
2626

2727
~QgsMapLayerAction();
2828

‎src/app/composer/qgscomposer.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3607,7 +3607,9 @@ void QgsComposer::updateAtlasMapLayerAction( QgsVectorLayer *coverageLayer )
36073607

36083608
if ( coverageLayer )
36093609
{
3610-
mAtlasFeatureAction = new QgsMapLayerAction( QString( tr( "Set as atlas feature for %1" ) ).arg( mTitle ), this, coverageLayer, QgsMapLayerAction::SingleFeature );
3610+
mAtlasFeatureAction = new QgsMapLayerAction( QString( tr( "Set as atlas feature for %1" ) ).arg( mTitle ),
3611+
this, coverageLayer, QgsMapLayerAction::SingleFeature ,
3612+
QgsApplication::getThemeIcon( "/mIconAtlas.svg" ) );
36113613
QgsMapLayerActionRegistry::instance()->addMapLayerAction( mAtlasFeatureAction );
36123614
connect( mAtlasFeatureAction, SIGNAL( triggeredForFeature( QgsMapLayer*, const QgsFeature& ) ), this, SLOT( setAtlasFeature( QgsMapLayer*, const QgsFeature& ) ) );
36133615
}
@@ -3652,7 +3654,9 @@ void QgsComposer::updateAtlasMapLayerAction( bool atlasEnabled )
36523654
if ( atlasEnabled )
36533655
{
36543656
QgsAtlasComposition& atlas = mComposition->atlasComposition();
3655-
mAtlasFeatureAction = new QgsMapLayerAction( QString( tr( "Set as atlas feature for %1" ) ).arg( mTitle ), this, atlas.coverageLayer(), QgsMapLayerAction::SingleFeature );
3657+
mAtlasFeatureAction = new QgsMapLayerAction( QString( tr( "Set as atlas feature for %1" ) ).arg( mTitle ),
3658+
this, atlas.coverageLayer(), QgsMapLayerAction::SingleFeature ,
3659+
QgsApplication::getThemeIcon( "/mIconAtlas.svg" ) );
36563660
QgsMapLayerActionRegistry::instance()->addMapLayerAction( mAtlasFeatureAction );
36573661
connect( mAtlasFeatureAction, SIGNAL( triggeredForFeature( QgsMapLayer*, const QgsFeature& ) ), this, SLOT( setAtlasFeature( QgsMapLayer*, const QgsFeature& ) ) );
36583662
}

‎src/gui/qgsactionmenu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ void QgsActionMenu::reloadActions()
151151
for ( int i = 0; i < mapLayerActions.size(); ++i )
152152
{
153153
QgsMapLayerAction* qaction = mapLayerActions.at( i );
154-
QAction* action = new QAction( qaction->text(), this );
154+
QAction* action = new QAction( qaction->icon(), qaction->text(), this );
155155
action->setData( QVariant::fromValue<ActionData>( ActionData( qaction, mFeatureId, mLayer ) ) );
156156
addAction( action );
157157
connect( action, SIGNAL( triggered() ), this, SLOT( triggerAction() ) );

‎src/gui/qgsmaplayeractionregistry.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
#include "qgsmaplayeractionregistry.h"
1717

1818

19-
QgsMapLayerAction::QgsMapLayerAction( QString name, QObject* parent, Targets targets )
20-
: QAction( name, parent )
19+
QgsMapLayerAction::QgsMapLayerAction( QString name, QObject* parent, Targets targets, QIcon icon )
20+
: QAction( icon, name, parent )
2121
, mSingleLayer( false )
2222
, mActionLayer( 0 )
2323
, mSpecificLayerType( false )
@@ -26,8 +26,8 @@ QgsMapLayerAction::QgsMapLayerAction( QString name, QObject* parent, Targets tar
2626
}
2727

2828
/**Creates a map layer action which can run only on a specific layer*/
29-
QgsMapLayerAction::QgsMapLayerAction( QString name, QObject* parent, QgsMapLayer* layer, Targets targets )
30-
: QAction( name, parent )
29+
QgsMapLayerAction::QgsMapLayerAction( QString name, QObject* parent, QgsMapLayer* layer , Targets targets, QIcon icon )
30+
: QAction( icon, name, parent )
3131
, mSingleLayer( true )
3232
, mActionLayer( layer )
3333
, mSpecificLayerType( false )
@@ -36,8 +36,8 @@ QgsMapLayerAction::QgsMapLayerAction( QString name, QObject* parent, QgsMapLayer
3636
}
3737

3838
/**Creates a map layer action which can run on a specific type of layer*/
39-
QgsMapLayerAction::QgsMapLayerAction( QString name, QObject* parent, QgsMapLayer::LayerType layerType, Targets targets )
40-
: QAction( name, parent )
39+
QgsMapLayerAction::QgsMapLayerAction( QString name, QObject* parent, QgsMapLayer::LayerType layerType, Targets targets, QIcon icon )
40+
: QAction( icon, name, parent )
4141
, mSingleLayer( false )
4242
, mActionLayer( 0 )
4343
, mSpecificLayerType( true )

‎src/gui/qgsmaplayeractionregistry.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ class GUI_EXPORT QgsMapLayerAction : public QAction
4545

4646
//! Creates a map layer action which can run on any layer
4747
//! @note using AllActions as a target probably does not make a lot of sense. This default action was settled for API compatiblity reasons.
48-
QgsMapLayerAction( QString name, QObject *parent, Targets targets = AllActions );
48+
QgsMapLayerAction( QString name, QObject *parent, Targets targets = AllActions, QIcon icon = QIcon() );
4949

5050
//! Creates a map layer action which can run only on a specific layer
51-
QgsMapLayerAction( QString name, QObject *parent, QgsMapLayer* layer, Targets targets = AllActions );
51+
QgsMapLayerAction( QString name, QObject *parent, QgsMapLayer* layer, Targets targets = AllActions, QIcon icon = QIcon() );
5252

5353
//! Creates a map layer action which can run on a specific type of layer
54-
QgsMapLayerAction( QString name, QObject *parent, QgsMapLayer::LayerType layerType, Targets targets = AllActions );
54+
QgsMapLayerAction( QString name, QObject *parent, QgsMapLayer::LayerType layerType, Targets targets = AllActions, QIcon icon = QIcon() );
5555

5656
~QgsMapLayerAction();
5757

0 commit comments

Comments
 (0)
Please sign in to comment.