QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
Loading...
Searching...
No Matches
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
29class GUI_EXPORT QgsOptionsPageWidget : public QWidget
30{
31 Q_OBJECT
32
33 public:
34
38 QgsOptionsPageWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr )
39 : QWidget( parent )
40 {}
41
52 virtual QString helpKey() const { return QString(); }
53
58 QHash<QWidget *, QgsOptionsDialogHighlightWidget *> registeredHighlightWidgets() {return mHighlightWidgets;} SIP_SKIP
59
69 virtual bool isValid() { return true; }
70
71 public slots:
72
77 virtual void apply() = 0;
78
83 virtual void cancel() { return; }
84
85 protected:
86
93 {
94 mHighlightWidgets.insert( highlightWidget->widget(), highlightWidget );
95 }
96
97 private:
98 QHash<QWidget *, QgsOptionsDialogHighlightWidget *> mHighlightWidgets;
99
100
101};
102
108// NOTE - this is a QObject so we can detect its destruction and avoid
109// QGIS crashing when a plugin crashes/exits without deregistering a factory
110class GUI_EXPORT QgsOptionsWidgetFactory : public QObject
111{
112 Q_OBJECT
113
114 public:
115
117
119 QgsOptionsWidgetFactory( const QString &title, const QIcon &icon, const QString &key = QString() )
120 : mTitle( title )
121 , mIcon( icon )
122 , mKey( key )
123 {}
124
130 virtual QIcon icon() const { return mIcon; }
131
136 void setIcon( const QIcon &icon ) { mIcon = icon; }
137
142 virtual QString title() const { return mTitle; }
143
148 void setTitle( const QString &title ) { mTitle = title; }
149
156 virtual QString key() const { return mKey; }
157
162 void setKey( const QString &key ) { mKey = key; }
163
176 virtual QString pagePositionHint() const { return QString(); }
177
187 virtual QStringList path() const { return QStringList(); }
188
194 virtual QgsOptionsPageWidget *createWidget( QWidget *parent = nullptr ) const = 0 SIP_FACTORY;
195
196 private:
197 QString mTitle;
198 QIcon mIcon;
199 QString mKey;
200
201
202};
203
204#endif // QGSOPTIONSWIDGETFACTORY_H
Container for a widget to be used to search text in the option dialog If the widget type is handled,...
Base class for widgets for pages included in the options dialog.
QgsOptionsPageWidget(QWidget *parent=nullptr)
Constructor for QgsOptionsPageWidget.
QHash< QWidget *, QgsOptionsDialogHighlightWidget * > registeredHighlightWidgets()
Returns the registered highlight widgets used to search and highlight text in options dialogs.
void registerHighlightWidget(QgsOptionsDialogHighlightWidget *highlightWidget)
Register a highlight widget to be used to search and highlight text in options dialogs.
virtual QString helpKey() const
Returns the optional help key for the options page.
virtual void cancel()
Called to cancel settings changed in the options page (e.g.
virtual bool isValid()
Validates the current state of the widget.
virtual void apply()=0
Called to permanently apply the settings shown in the options page (e.g.
A factory class for creating custom options pages.
void setKey(const QString &key)
Set the key for the interface.
void setTitle(const QString &title)
Set the title for the interface.
QgsOptionsWidgetFactory(const QString &title, const QIcon &icon, const QString &key=QString())
Constructor.
void setIcon(const QIcon &icon)
Set the icon to show in the interface for the factory object.
virtual QStringList path() const
Returns the path to place the widget page at, for options dialogs which are structured using a tree v...
virtual QgsOptionsPageWidget * createWidget(QWidget *parent=nullptr) const =0
Factory function to create the widget on demand as needed by the options dialog.
virtual QString key() const
The key of the panel (untranslated title).
virtual QIcon icon() const
The icon that will be shown in the UI for the panel.
virtual QString title() const
The title of the panel.
virtual QString pagePositionHint() const
Returns a tab name hinting at where this page should be inserted into the options properties tab list...
QgsOptionsWidgetFactory()=default
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:53
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_FACTORY
Definition qgis_sip.h:76