QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgsoptionswidgetfactory.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsoptionswidgetfactory.h
3  -------------------------------
4  Date : March 2017
5  Copyright : (C) 2017 Nyall Dawson
6  Email : nyall dot dawson at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSOPTIONSWIDGETFACTORY_H
17 #define QGSOPTIONSWIDGETFACTORY_H
18 
19 #include <QListWidgetItem>
20 #include "qgis_gui.h"
21 #include "qgis_sip.h"
23 
30 class GUI_EXPORT QgsOptionsPageWidget : public QWidget
31 {
32  Q_OBJECT
33 
34  public:
35 
39  QgsOptionsPageWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr )
40  : QWidget( parent )
41  {}
42 
53  virtual QString helpKey() const { return QString(); }
54 
59  QHash<QWidget *, QgsOptionsDialogHighlightWidget *> registeredHighlightWidgets() {return mHighlightWidgets;} SIP_SKIP
60 
70  virtual bool isValid() { return true; }
71 
72  public slots:
73 
78  virtual void apply() = 0;
79 
80  protected:
81 
88  {
89  mHighlightWidgets.insert( highlightWidget->widget(), highlightWidget );
90  }
91 
92  private:
93  QHash<QWidget *, QgsOptionsDialogHighlightWidget *> mHighlightWidgets;
94 
95 
96 };
97 
104 // NOTE - this is a QObject so we can detect its destruction and avoid
105 // QGIS crashing when a plugin crashes/exits without deregistering a factory
106 class GUI_EXPORT QgsOptionsWidgetFactory : public QObject
107 {
108  Q_OBJECT
109 
110  public:
111 
113  QgsOptionsWidgetFactory() = default;
114 
116  QgsOptionsWidgetFactory( const QString &title, const QIcon &icon )
117  : mTitle( title )
118  , mIcon( icon )
119  {}
120 
126  virtual QIcon icon() const { return mIcon; }
127 
132  void setIcon( const QIcon &icon ) { mIcon = icon; }
133 
138  virtual QString title() const { return mTitle; }
139 
144  void setTitle( const QString &title ) { mTitle = title; }
145 
158  virtual QString pagePositionHint() const { return QString(); }
159 
169  virtual QStringList path() const { return QStringList(); }
170 
176  virtual QgsOptionsPageWidget *createWidget( QWidget *parent = nullptr ) const = 0 SIP_FACTORY;
177 
178  private:
179  QString mTitle;
180  QIcon mIcon;
181 
182 
183 };
184 
185 #endif // QGSOPTIONSWIDGETFACTORY_H
QgsOptionsPageWidget::helpKey
virtual QString helpKey() const
Returns the optional help key for the options page.
Definition: qgsoptionswidgetfactory.h:53
QgsOptionsWidgetFactory
A factory class for creating custom options pages.
Definition: qgsoptionswidgetfactory.h:106
QgsOptionsDialogHighlightWidget
Container for a widget to be used to search text in the option dialog If the widget type is handled,...
Definition: qgsoptionsdialoghighlightwidget.h:35
QgsOptionsDialogHighlightWidget::widget
QWidget * widget()
Returns the widget.
Definition: qgsoptionsdialoghighlightwidget.h:63
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsOptionsPageWidget::registeredHighlightWidgets
QHash< QWidget *, QgsOptionsDialogHighlightWidget * > registeredHighlightWidgets()
Returns the registered highlight widgets used to search and highlight text in options dialogs.
Definition: qgsoptionswidgetfactory.h:59
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsOptionsPageWidget::QgsOptionsPageWidget
QgsOptionsPageWidget(QWidget *parent=nullptr)
Constructor for QgsOptionsPageWidget.
Definition: qgsoptionswidgetfactory.h:39
qgis_sip.h
QgsOptionsPageWidget::registerHighlightWidget
void registerHighlightWidget(QgsOptionsDialogHighlightWidget *highlightWidget)
Register a highlight widget to be used to search and highlight text in options dialogs.
Definition: qgsoptionswidgetfactory.h:87
QgsOptionsWidgetFactory::pagePositionHint
virtual QString pagePositionHint() const
Returns a tab name hinting at where this page should be inserted into the options properties tab list...
Definition: qgsoptionswidgetfactory.h:158
QgsOptionsWidgetFactory::title
virtual QString title() const
The title of the panel.
Definition: qgsoptionswidgetfactory.h:138
qgsoptionsdialoghighlightwidget.h
QgsOptionsWidgetFactory::setIcon
void setIcon(const QIcon &icon)
Set the icon to show in the interface for the factory object.
Definition: qgsoptionswidgetfactory.h:132
QgsOptionsPageWidget::isValid
virtual bool isValid()
Validates the current state of the widget.
Definition: qgsoptionswidgetfactory.h:70
QgsOptionsWidgetFactory::QgsOptionsWidgetFactory
QgsOptionsWidgetFactory(const QString &title, const QIcon &icon)
Constructor.
Definition: qgsoptionswidgetfactory.h:116
QgsOptionsWidgetFactory::icon
virtual QIcon icon() const
The icon that will be shown in the UI for the panel.
Definition: qgsoptionswidgetfactory.h:126
QgsOptionsWidgetFactory::setTitle
void setTitle(const QString &title)
Set the title for the interface.
Definition: qgsoptionswidgetfactory.h:144
QgsOptionsWidgetFactory::path
virtual QStringList path() const
Returns the path to place the widget page at, for options dialogs which are structured using a tree v...
Definition: qgsoptionswidgetfactory.h:169
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
QgsOptionsPageWidget
Base class for widgets for pages included in the options dialog.
Definition: qgsoptionswidgetfactory.h:30