mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-16 00:03:12 -04:00
support icons in map layer actions
This commit is contained in:
parent
0bfe8aba56
commit
c180fecbef
@ -16,13 +16,13 @@ class QgsMapLayerAction : QAction
|
|||||||
|
|
||||||
//! Creates a map layer action which can run on any layer
|
//! 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.
|
//! @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
|
//! 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
|
//! 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();
|
~QgsMapLayerAction();
|
||||||
|
|
||||||
|
@ -3607,7 +3607,9 @@ void QgsComposer::updateAtlasMapLayerAction( QgsVectorLayer *coverageLayer )
|
|||||||
|
|
||||||
if ( 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 );
|
QgsMapLayerActionRegistry::instance()->addMapLayerAction( mAtlasFeatureAction );
|
||||||
connect( mAtlasFeatureAction, SIGNAL( triggeredForFeature( QgsMapLayer*, const QgsFeature& ) ), this, SLOT( setAtlasFeature( QgsMapLayer*, const QgsFeature& ) ) );
|
connect( mAtlasFeatureAction, SIGNAL( triggeredForFeature( QgsMapLayer*, const QgsFeature& ) ), this, SLOT( setAtlasFeature( QgsMapLayer*, const QgsFeature& ) ) );
|
||||||
}
|
}
|
||||||
@ -3652,7 +3654,9 @@ void QgsComposer::updateAtlasMapLayerAction( bool atlasEnabled )
|
|||||||
if ( atlasEnabled )
|
if ( atlasEnabled )
|
||||||
{
|
{
|
||||||
QgsAtlasComposition& atlas = mComposition->atlasComposition();
|
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 );
|
QgsMapLayerActionRegistry::instance()->addMapLayerAction( mAtlasFeatureAction );
|
||||||
connect( mAtlasFeatureAction, SIGNAL( triggeredForFeature( QgsMapLayer*, const QgsFeature& ) ), this, SLOT( setAtlasFeature( QgsMapLayer*, const QgsFeature& ) ) );
|
connect( mAtlasFeatureAction, SIGNAL( triggeredForFeature( QgsMapLayer*, const QgsFeature& ) ), this, SLOT( setAtlasFeature( QgsMapLayer*, const QgsFeature& ) ) );
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ void QgsActionMenu::reloadActions()
|
|||||||
for ( int i = 0; i < mapLayerActions.size(); ++i )
|
for ( int i = 0; i < mapLayerActions.size(); ++i )
|
||||||
{
|
{
|
||||||
QgsMapLayerAction* qaction = mapLayerActions.at( 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 ) ) );
|
action->setData( QVariant::fromValue<ActionData>( ActionData( qaction, mFeatureId, mLayer ) ) );
|
||||||
addAction( action );
|
addAction( action );
|
||||||
connect( action, SIGNAL( triggered() ), this, SLOT( triggerAction() ) );
|
connect( action, SIGNAL( triggered() ), this, SLOT( triggerAction() ) );
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
#include "qgsmaplayeractionregistry.h"
|
#include "qgsmaplayeractionregistry.h"
|
||||||
|
|
||||||
|
|
||||||
QgsMapLayerAction::QgsMapLayerAction( QString name, QObject* parent, Targets targets )
|
QgsMapLayerAction::QgsMapLayerAction( QString name, QObject* parent, Targets targets, QIcon icon )
|
||||||
: QAction( name, parent )
|
: QAction( icon, name, parent )
|
||||||
, mSingleLayer( false )
|
, mSingleLayer( false )
|
||||||
, mActionLayer( 0 )
|
, mActionLayer( 0 )
|
||||||
, mSpecificLayerType( false )
|
, mSpecificLayerType( false )
|
||||||
@ -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*/
|
/**Creates a map layer action which can run only on a specific layer*/
|
||||||
QgsMapLayerAction::QgsMapLayerAction( QString name, QObject* parent, QgsMapLayer* layer, Targets targets )
|
QgsMapLayerAction::QgsMapLayerAction( QString name, QObject* parent, QgsMapLayer* layer , Targets targets, QIcon icon )
|
||||||
: QAction( name, parent )
|
: QAction( icon, name, parent )
|
||||||
, mSingleLayer( true )
|
, mSingleLayer( true )
|
||||||
, mActionLayer( layer )
|
, mActionLayer( layer )
|
||||||
, mSpecificLayerType( false )
|
, mSpecificLayerType( false )
|
||||||
@ -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*/
|
/**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 )
|
QgsMapLayerAction::QgsMapLayerAction( QString name, QObject* parent, QgsMapLayer::LayerType layerType, Targets targets, QIcon icon )
|
||||||
: QAction( name, parent )
|
: QAction( icon, name, parent )
|
||||||
, mSingleLayer( false )
|
, mSingleLayer( false )
|
||||||
, mActionLayer( 0 )
|
, mActionLayer( 0 )
|
||||||
, mSpecificLayerType( true )
|
, mSpecificLayerType( true )
|
||||||
|
@ -45,13 +45,13 @@ class GUI_EXPORT QgsMapLayerAction : public QAction
|
|||||||
|
|
||||||
//! Creates a map layer action which can run on any layer
|
//! 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.
|
//! @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
|
//! 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
|
//! 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();
|
~QgsMapLayerAction();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user