Skip to content

Commit

Permalink
support icons in map layer actions
Browse files Browse the repository at this point in the history
  • Loading branch information
3nids committed Oct 31, 2014
1 parent 0bfe8ab commit c180fec
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 15 deletions.
6 changes: 3 additions & 3 deletions python/gui/qgsmaplayeractionregistry.sip
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ class QgsMapLayerAction : QAction

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

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

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

~QgsMapLayerAction();

Expand Down
8 changes: 6 additions & 2 deletions src/app/composer/qgscomposer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3607,7 +3607,9 @@ void QgsComposer::updateAtlasMapLayerAction( QgsVectorLayer *coverageLayer )

if ( coverageLayer )
{
mAtlasFeatureAction = new QgsMapLayerAction( QString( tr( "Set as atlas feature for %1" ) ).arg( mTitle ), this, coverageLayer, QgsMapLayerAction::SingleFeature );
mAtlasFeatureAction = new QgsMapLayerAction( QString( tr( "Set as atlas feature for %1" ) ).arg( mTitle ),
this, coverageLayer, QgsMapLayerAction::SingleFeature ,
QgsApplication::getThemeIcon( "/mIconAtlas.svg" ) );
QgsMapLayerActionRegistry::instance()->addMapLayerAction( mAtlasFeatureAction );
connect( mAtlasFeatureAction, SIGNAL( triggeredForFeature( QgsMapLayer*, const QgsFeature& ) ), this, SLOT( setAtlasFeature( QgsMapLayer*, const QgsFeature& ) ) );
}
Expand Down Expand Up @@ -3652,7 +3654,9 @@ void QgsComposer::updateAtlasMapLayerAction( bool atlasEnabled )
if ( atlasEnabled )
{
QgsAtlasComposition& atlas = mComposition->atlasComposition();
mAtlasFeatureAction = new QgsMapLayerAction( QString( tr( "Set as atlas feature for %1" ) ).arg( mTitle ), this, atlas.coverageLayer(), QgsMapLayerAction::SingleFeature );
mAtlasFeatureAction = new QgsMapLayerAction( QString( tr( "Set as atlas feature for %1" ) ).arg( mTitle ),
this, atlas.coverageLayer(), QgsMapLayerAction::SingleFeature ,
QgsApplication::getThemeIcon( "/mIconAtlas.svg" ) );
QgsMapLayerActionRegistry::instance()->addMapLayerAction( mAtlasFeatureAction );
connect( mAtlasFeatureAction, SIGNAL( triggeredForFeature( QgsMapLayer*, const QgsFeature& ) ), this, SLOT( setAtlasFeature( QgsMapLayer*, const QgsFeature& ) ) );
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsactionmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void QgsActionMenu::reloadActions()
for ( int i = 0; i < mapLayerActions.size(); ++i )
{
QgsMapLayerAction* qaction = mapLayerActions.at( i );
QAction* action = new QAction( qaction->text(), this );
QAction* action = new QAction( qaction->icon(), qaction->text(), this );
action->setData( QVariant::fromValue<ActionData>( ActionData( qaction, mFeatureId, mLayer ) ) );
addAction( action );
connect( action, SIGNAL( triggered() ), this, SLOT( triggerAction() ) );
Expand Down
12 changes: 6 additions & 6 deletions src/gui/qgsmaplayeractionregistry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
#include "qgsmaplayeractionregistry.h"


QgsMapLayerAction::QgsMapLayerAction( QString name, QObject* parent, Targets targets )
: QAction( name, parent )
QgsMapLayerAction::QgsMapLayerAction( QString name, QObject* parent, Targets targets, QIcon icon )
: QAction( icon, name, parent )
, mSingleLayer( false )
, mActionLayer( 0 )
, mSpecificLayerType( false )
Expand All @@ -26,8 +26,8 @@ QgsMapLayerAction::QgsMapLayerAction( QString name, QObject* parent, Targets tar
}

/**Creates a map layer action which can run only on a specific layer*/
QgsMapLayerAction::QgsMapLayerAction( QString name, QObject* parent, QgsMapLayer* layer, Targets targets )
: QAction( name, parent )
QgsMapLayerAction::QgsMapLayerAction( QString name, QObject* parent, QgsMapLayer* layer , Targets targets, QIcon icon )
: QAction( icon, name, parent )
, mSingleLayer( true )
, mActionLayer( layer )
, mSpecificLayerType( false )
Expand All @@ -36,8 +36,8 @@ QgsMapLayerAction::QgsMapLayerAction( QString name, QObject* parent, QgsMapLayer
}

/**Creates a map layer action which can run on a specific type of layer*/
QgsMapLayerAction::QgsMapLayerAction( QString name, QObject* parent, QgsMapLayer::LayerType layerType, Targets targets )
: QAction( name, parent )
QgsMapLayerAction::QgsMapLayerAction( QString name, QObject* parent, QgsMapLayer::LayerType layerType, Targets targets, QIcon icon )
: QAction( icon, name, parent )
, mSingleLayer( false )
, mActionLayer( 0 )
, mSpecificLayerType( true )
Expand Down
6 changes: 3 additions & 3 deletions src/gui/qgsmaplayeractionregistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ class GUI_EXPORT QgsMapLayerAction : public QAction

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

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

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

~QgsMapLayerAction();

Expand Down

0 comments on commit c180fec

Please sign in to comment.