diff --git a/python/gui/qgsmaplayerconfigwidgetfactory.sip b/python/gui/qgsmaplayerconfigwidgetfactory.sip index 362b6d409ab..48914e67704 100644 --- a/python/gui/qgsmaplayerconfigwidgetfactory.sip +++ b/python/gui/qgsmaplayerconfigwidgetfactory.sip @@ -13,6 +13,9 @@ class QgsMapLayerConfigWidgetFactory /** Constructor */ QgsMapLayerConfigWidgetFactory(); + /** Constructor */ + QgsMapLayerConfigWidgetFactory(QString title, QIcon icon); + /** Destructor */ virtual ~QgsMapLayerConfigWidgetFactory(); @@ -22,6 +25,8 @@ class QgsMapLayerConfigWidgetFactory */ virtual QIcon icon() const; + void setIcon(QIcon icon); + /** * @brief The title of the panel. * @note This may or may not be shown to the user. @@ -29,10 +34,16 @@ class QgsMapLayerConfigWidgetFactory */ virtual QString title() const; + void setTitlte(QString title); + virtual bool supportsStyleDock() const; + void setSupportsStyleDock(bool supports); + virtual bool supportLayerPropertiesDialog() const; + void setSupportLayerPropertiesDialog(bool supports); + /** * @brief Check if the layer is supported for this widget. * @return True if this layer is supported for this widget diff --git a/src/app/qgslayerstylingwidget.cpp b/src/app/qgslayerstylingwidget.cpp index 6240fd3986d..90e9adecfbc 100644 --- a/src/app/qgslayerstylingwidget.cpp +++ b/src/app/qgslayerstylingwidget.cpp @@ -505,14 +505,10 @@ bool QgsMapLayerStyleCommand::mergeWith( const QUndoCommand* other ) return true; } -QIcon QgsLayerStyleManagerWidgetFactory::icon() const +QgsLayerStyleManagerWidgetFactory::QgsLayerStyleManagerWidgetFactory() { - return QgsApplication::getThemeIcon( "propertyicons/stylepreset.svg" ); -} - -QString QgsLayerStyleManagerWidgetFactory::title() const -{ - return QObject::tr( "Style Manager" ); + setIcon( QgsApplication::getThemeIcon( "propertyicons/stylepreset.svg" ) ); + setTitlte( QObject::tr( "Style Manager" ) ); } QgsMapLayerConfigWidget *QgsLayerStyleManagerWidgetFactory::createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool dockMode, QWidget *parent ) const diff --git a/src/app/qgslayerstylingwidget.h b/src/app/qgslayerstylingwidget.h index 51fe1b63d98..9e47deae676 100644 --- a/src/app/qgslayerstylingwidget.h +++ b/src/app/qgslayerstylingwidget.h @@ -42,8 +42,7 @@ class QgsMapLayerStyleManagerWidget; class APP_EXPORT QgsLayerStyleManagerWidgetFactory : public QgsMapLayerConfigWidgetFactory { public: - QIcon icon() const override; - QString title() const override; + QgsLayerStyleManagerWidgetFactory(); bool supportsStyleDock() const override { return true; } QgsMapLayerConfigWidget *createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool dockMode, QWidget *parent ) const override; bool supportsLayer( QgsMapLayer *layer ) const override; diff --git a/src/gui/qgsmaplayerconfigwidgetfactory.cpp b/src/gui/qgsmaplayerconfigwidgetfactory.cpp index 6aa2f9ff9ae..7725b6c3eca 100644 --- a/src/gui/qgsmaplayerconfigwidgetfactory.cpp +++ b/src/gui/qgsmaplayerconfigwidgetfactory.cpp @@ -17,6 +17,13 @@ QgsMapLayerConfigWidgetFactory::QgsMapLayerConfigWidgetFactory() { + +} + +QgsMapLayerConfigWidgetFactory::QgsMapLayerConfigWidgetFactory( QString title, QIcon icon ) + : mIcon( icon ) + , mTitle( title ) +{ } QgsMapLayerConfigWidgetFactory::~QgsMapLayerConfigWidgetFactory() diff --git a/src/gui/qgsmaplayerconfigwidgetfactory.h b/src/gui/qgsmaplayerconfigwidgetfactory.h index abcdcbd13c3..9f809f2cfc5 100644 --- a/src/gui/qgsmaplayerconfigwidgetfactory.h +++ b/src/gui/qgsmaplayerconfigwidgetfactory.h @@ -28,9 +28,13 @@ class GUI_EXPORT QgsMapLayerConfigWidgetFactory { public: + /** Constructor */ QgsMapLayerConfigWidgetFactory(); + /** Constructor */ + QgsMapLayerConfigWidgetFactory( QString title, QIcon icon ); + /** Destructor */ virtual ~QgsMapLayerConfigWidgetFactory(); @@ -38,14 +42,28 @@ class GUI_EXPORT QgsMapLayerConfigWidgetFactory * @brief The icon that will be shown in the UI for the panel. * @return A QIcon for the panel icon. */ - virtual QIcon icon() const { return QIcon(); } + virtual QIcon icon() const { return mIcon; } + + /** + * Set the icon for the factory object. + * @param icon The icon to show in the interface. + */ + void setIcon( QIcon icon ) { mIcon = icon; } /** * @brief The title of the panel. * @note This may or may not be shown to the user. * @return Title of the panel */ - virtual QString title() const { return QString(); } + virtual QString title() const { return mTitle; } + + /** + * Set the title for the interface + * @note Not all users may show this as a label + * e.g style dock uses this as a tooltip. + * @param title The title to set. + */ + void setTitlte( QString title ) { mTitle = title; } /** * Flag if widget is supported for use in style dock. @@ -53,12 +71,24 @@ class GUI_EXPORT QgsMapLayerConfigWidgetFactory */ virtual bool supportsStyleDock() const { return false; } + /** + * Set support flag for style dock + * @param supports True if this widget is supported in the style dock. + */ + void setSupportsStyleDock( bool supports ) { mSuppprtsDock = supports; } + /** * Flag if widget is supported for use in layer properties dialog. * @return True if supported */ virtual bool supportLayerPropertiesDialog() const { return false; } + /** + * Set support flag for style dock + * @param supports True if this widget is supported in the style dock. + */ + void setSupportLayerPropertiesDialog( bool supports ) { mSuppprtsProperties = supports; } + /** * @brief Check if the layer is supported for this widget. * @return True if this layer is supported for this widget @@ -75,6 +105,12 @@ class GUI_EXPORT QgsMapLayerConfigWidgetFactory * @return A new QgsMapStylePanel which is shown in the map style dock. */ virtual QgsMapLayerConfigWidget* createWidget( QgsMapLayer* layer, QgsMapCanvas *canvas, bool dockWidget = true, QWidget* parent = 0 ) const = 0; + + private: + QIcon mIcon; + QString mTitle; + bool mSuppprtsDock; + bool mSuppprtsProperties; }; #endif // QGSMAPLAYERCONFIGWIDGETFACTORY_H