/
qgsgui.h
300 lines (253 loc) · 10.7 KB
/
qgsgui.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
/***************************************************************************
qgsgui.h
--------
begin : May 2017
copyright : (C) 2017 by Nyall Dawson
email : nyall dot dawson at gmail dot com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSGUI_H
#define QGSGUI_H
#include "qgis_gui.h"
#include "qgis_sip.h"
#include <QWidget>
#include <memory>
class QgsSettingsRegistryGui;
class QgsEditorWidgetRegistry;
class QgsShortcutsManager;
class QgsLayerTreeEmbeddedWidgetRegistry;
class QgsMapLayerActionRegistry;
class QgsSourceSelectProviderRegistry;
class QgsNative;
class QgsLayoutItemGuiRegistry;
class QgsWidgetStateHelper;
class QgsProcessingGuiRegistry;
class QgsProcessingRecentAlgorithmLog;
class QgsWindowManagerInterface;
class QgsDataItemGuiProviderRegistry;
class QgsProviderGuiRegistry;
class QgsProjectStorageGuiRegistry;
class QgsNumericFormatGuiRegistry;
class QgsCodeEditorColorSchemeRegistry;
class QgsMessageBar;
class QgsSubsetStringEditorProviderRegistry;
class QgsProviderSourceWidgetProviderRegistry;
class QgsRelationWidgetRegistry;
/**
* \ingroup gui
* \brief QgsGui is a singleton class containing various registry and other global members
* related to GUI classes.
* \since QGIS 3.0
*/
class GUI_EXPORT QgsGui : public QObject
{
Q_OBJECT
public:
/**
* Defines the behavior to use when setting the CRS for a newly created project.
*/
enum ProjectCrsBehavior
{
UseCrsOfFirstLayerAdded = 1, //!< Set the project CRS to the CRS of the first layer added to a new project
UsePresetCrs = 2, //!< Always set new projects to use a preset default CRS
};
Q_ENUM( ProjectCrsBehavior )
//! QgsGui cannot be copied
QgsGui( const QgsGui &other ) = delete;
//! QgsGui cannot be copied
QgsGui &operator=( const QgsGui &other ) = delete;
/**
* Returns a pointer to the singleton instance.
*/
static QgsGui *instance();
/**
* Returns the global native interface, which offers abstraction to the host OS's underlying public
* interfaces.
* \note Not available in Python bindings
*/
SIP_SKIP static QgsNative *nativePlatformInterface();
/**
* Returns the gui's settings registry, used for managing gui settings.
* \since QGIS 3.22
*/
static QgsSettingsRegistryGui *settingsRegistryGui() SIP_KEEPREFERENCE;
/**
* Returns the global editor widget registry, used for managing all known edit widget factories.
*/
static QgsEditorWidgetRegistry *editorWidgetRegistry() SIP_KEEPREFERENCE;
/**
* Returns the global source select provider registry, used for managing all known source select widget factories.
*/
static QgsSourceSelectProviderRegistry *sourceSelectProviderRegistry() SIP_KEEPREFERENCE;
/**
* Returns the global shortcuts manager, used for managing a QAction and QShortcut sequences.
*/
static QgsShortcutsManager *shortcutsManager();
/**
* Returns the global layer tree embedded widget registry, used for registering widgets that may be embedded into layer tree view.
*/
static QgsLayerTreeEmbeddedWidgetRegistry *layerTreeEmbeddedWidgetRegistry() SIP_KEEPREFERENCE;
/**
* Returns the global map layer action registry, used for registering map layer actions.
*/
static QgsMapLayerActionRegistry *mapLayerActionRegistry() SIP_KEEPREFERENCE;
/**
* Returns the global layout item GUI registry, used for registering the GUI behavior of layout items.
*/
static QgsLayoutItemGuiRegistry *layoutItemGuiRegistry() SIP_KEEPREFERENCE;
/**
* Returns the global processing gui registry, used for registering the GUI behavior of processing algorithms.
* \since QGIS 3.2
*/
static QgsProcessingGuiRegistry *processingGuiRegistry() SIP_KEEPREFERENCE;
/**
* Returns the global numeric format gui registry, used for registering the GUI widgets associated with QgsNumericFormats.
* \since QGIS 3.12
*/
static QgsNumericFormatGuiRegistry *numericFormatGuiRegistry() SIP_KEEPREFERENCE;
/**
* Returns the global code editor color scheme registry, used for registering the color schemes for QgsCodeEditor widgets.
* \since QGIS 3.16
*/
static QgsCodeEditorColorSchemeRegistry *codeEditorColorSchemeRegistry() SIP_KEEPREFERENCE;
/**
* Returns the global processing recent algorithm log, used for tracking recently used processing algorithms.
* \since QGIS 3.4
*/
static QgsProcessingRecentAlgorithmLog *processingRecentAlgorithmLog();
/**
* Returns the global data item GUI provider registry, used for tracking providers which affect the browser
* GUI.
* \since QGIS 3.6
*/
static QgsDataItemGuiProviderRegistry *dataItemGuiProviderRegistry() SIP_KEEPREFERENCE;
/**
* Returns the global GUI-related project storage registry
* \since QGIS 3.10
*/
static QgsProjectStorageGuiRegistry *projectStorageGuiRegistry() SIP_KEEPREFERENCE;
/**
* Returns the registry of GUI-related components of data providers
* \since QGIS 3.10
*/
static QgsProviderGuiRegistry *providerGuiRegistry() SIP_KEEPREFERENCE;
/**
* Returns the registry of subset string editors of data providers
* \since QGIS 3.18
*/
static QgsSubsetStringEditorProviderRegistry *subsetStringEditorProviderRegistry() SIP_KEEPREFERENCE;
/**
* Returns the registry of provider source widget providers.
* \since QGIS 3.18
*/
static QgsProviderSourceWidgetProviderRegistry *sourceWidgetProviderRegistry() SIP_KEEPREFERENCE;
/**
* Returns the global relation widget registry, used for managing all known relation widget factories.
* \since QGIS 3.18
*/
static QgsRelationWidgetRegistry *relationWidgetRegistry() SIP_KEEPREFERENCE;
/**
* Register the widget to allow its position to be automatically saved and restored when open and closed.
* Use this to avoid needing to call saveGeometry() and restoreGeometry() on your widget.
*/
static void enableAutoGeometryRestore( QWidget *widget, const QString &key = QString() );
/**
* Returns the global window manager, if set.
* \see setWindowManager()
* \since QGIS 3.4
*/
static QgsWindowManagerInterface *windowManager();
/**
* Sets the global window \a manager. Ownership is transferred to the QgsGui instance.
* \see windowManager()
* \since QGIS 3.4
*/
static void setWindowManager( QgsWindowManagerInterface *manager SIP_TRANSFER );
/**
* HIG flags, which indicate the Human Interface Guidelines for the current platform.
* \since QGIS 3.4
*/
enum HigFlag
{
HigMenuTextIsTitleCase = 1 << 0, //!< Menu action texts should be title case
HigDialogTitleIsTitleCase = 1 << 1 //!< Dialog titles should be title case
};
Q_DECLARE_FLAGS( HigFlags, HigFlag )
/**
* Returns the platform's HIG flags.
* \since QGIS 3.4
*/
static QgsGui::HigFlags higFlags();
~QgsGui();
/**
* Samples the color on screen at the specified global \a point (pixel).
*
* \since QGIS 3.10
*/
static QColor sampleColor( QPoint point );
/**
* Returns the screen at the given global \a point (pixel).
*
* \since QGIS 3.10
*/
static QScreen *findScreenAt( QPoint point );
/**
* Returns TRUE if python macros are currently allowed to be run
* If the global option is to ask user, a modal dialog will be shown
* \param lambda a pointer to a lambda method. If specified, the dialog is not modal,
* a message is shown with a button to enable macro.
* The lambda will be run either if macros are currently allowed or if the user accepts the message.
* The \a messageBar must be given in such case.
* \param messageBar the message bar must be provided if a lambda method is used.
*/
static bool pythonMacroAllowed( void ( *lambda )() = nullptr, QgsMessageBar *messageBar = nullptr ) SIP_SKIP;
///@cond PRIVATE
void emitOptionsChanged() SIP_SKIP;
///@endcond
signals:
/**
* This signal is emitted whenever the application options have been changed.
*
* This signal is a "blanket" signal, and will be emitted whenever the options dialog
* has been accepted regardless of whether or not individual settings are changed.
* It is designed as a "last resort" fallback only, allowing widgets to respond
* to possible settings changes.
*
* \since QGIS 3.16
*/
void optionsChanged();
private:
QgsGui();
QgsSettingsRegistryGui *mSettingsRegistryGui = nullptr;
QgsProviderGuiRegistry *mProviderGuiRegistry = nullptr;
QgsWidgetStateHelper *mWidgetStateHelper = nullptr;
QgsNative *mNative = nullptr;
QgsEditorWidgetRegistry *mEditorWidgetRegistry = nullptr;
QgsSourceSelectProviderRegistry *mSourceSelectProviderRegistry = nullptr;
QgsShortcutsManager *mShortcutsManager = nullptr;
QgsLayerTreeEmbeddedWidgetRegistry *mLayerTreeEmbeddedWidgetRegistry = nullptr;
QgsMapLayerActionRegistry *mMapLayerActionRegistry = nullptr;
QgsLayoutItemGuiRegistry *mLayoutItemGuiRegistry = nullptr;
QgsProcessingGuiRegistry *mProcessingGuiRegistry = nullptr;
QgsProcessingRecentAlgorithmLog *mProcessingRecentAlgorithmLog = nullptr;
QgsNumericFormatGuiRegistry *mNumericFormatGuiRegistry = nullptr;
QgsDataItemGuiProviderRegistry *mDataItemGuiProviderRegistry = nullptr;
QgsCodeEditorColorSchemeRegistry *mCodeEditorColorSchemeRegistry = nullptr;
QgsProjectStorageGuiRegistry *mProjectStorageGuiRegistry = nullptr;
QgsSubsetStringEditorProviderRegistry *mSubsetStringEditorProviderRegistry = nullptr;
QgsProviderSourceWidgetProviderRegistry *mProviderSourceWidgetProviderRegistry = nullptr;
QgsRelationWidgetRegistry *mRelationEditorRegistry = nullptr;
std::unique_ptr< QgsWindowManagerInterface > mWindowManager;
#ifdef SIP_RUN
QgsGui( const QgsGui &other );
#endif
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsGui::HigFlags )
#endif // QGSGUI_H