Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Enhance the ability to customize icons for QgsPluginLayer #59537

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/core/qgsiconutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "qgsapplication.h"
#include "qgsmaplayer.h"
#include "qgsvectorlayer.h"
#include "qgspluginlayer.h"

#include <QIcon>

Expand Down Expand Up @@ -111,14 +112,21 @@ QIcon QgsIconUtils::iconForLayer( const QgsMapLayer *layer )
case Qgis::LayerType::Mesh:
case Qgis::LayerType::VectorTile:
case Qgis::LayerType::PointCloud:
case Qgis::LayerType::Plugin:
case Qgis::LayerType::Annotation:
case Qgis::LayerType::Group:
case Qgis::LayerType::TiledScene:
{
return QgsIconUtils::iconForLayerType( layer->type() );
}

case Qgis::LayerType::Plugin:
{
const QgsPluginLayer *vl = qobject_cast<const QgsPluginLayer *>( layer );
if ( !vl )
{
return QIcon();
}
return vl->icon();
hxbb00 marked this conversation as resolved.
Show resolved Hide resolved
}
case Qgis::LayerType::Vector:
{
const QgsVectorLayer *vl = qobject_cast<const QgsVectorLayer *>( layer );
Expand Down
5 changes: 5 additions & 0 deletions src/core/qgspluginlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ const QgsDataProvider *QgsPluginLayer::dataProvider() const
return mDataProvider;
}

QIcon QgsPluginLayer::icon() const
{
return QIcon();
hxbb00 marked this conversation as resolved.
Show resolved Hide resolved
}

//
// QgsPluginLayerDataProvider
//
Expand Down
6 changes: 6 additions & 0 deletions src/core/qgspluginlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ class CORE_EXPORT QgsPluginLayer : public QgsMapLayer
QgsDataProvider *dataProvider() override;
const QgsDataProvider *dataProvider() const override SIP_SKIP;

/**
* Returns a icon.
* \returns a icon
hxbb00 marked this conversation as resolved.
Show resolved Hide resolved
*/
virtual QIcon icon() const;

protected:
QString mPluginLayerType;
QgsDataProvider *mDataProvider;
Expand Down
Loading