35#include "moc_qgsgui.cpp"
37using namespace Qt::StringLiterals;
40#include "qgsmacnative.h"
41#elif defined( Q_OS_WIN )
43#include "qgswinnative.h"
47#elif defined( Q_OS_LINUX )
48#include "qgslinuxnative.h"
80#include "qgsstacsourceselectprovider.h"
106 return instance()->mSettingsRegistryGui.get();
111 return instance()->mEditorWidgetRegistry.get();
116 return instance()->mRelationEditorRegistry.get();
121 return instance()->mShapeMapToolRegistry.get();
126 return instance()->mSourceSelectProviderRegistry.get();
131 return instance()->mSubsetStringEditorProviderRegistry.get();
136 return instance()->mProviderSourceWidgetProviderRegistry.get();
141 return instance()->mShortcutsManager.get();
146 return instance()->mLayerTreeEmbeddedWidgetRegistry.get();
151 return instance()->mMapLayerActionRegistry.get();
156 return instance()->mLayoutItemGuiRegistry.get();
161 return instance()->mAnnotationItemGuiRegistry.get();
166 return instance()->mAdvancedDigitizingToolsRegistry.get();
171 return instance()->mProcessingGuiRegistry.get();
176 return instance()->mNumericFormatGuiRegistry.get();
181 return instance()->mCodeEditorColorSchemeRegistry.get();
186 return instance()->mProcessingFavoriteAlgorithmManager.get();
191 return instance()->mProcessingRecentAlgorithmLog.get();
196 return instance()->mDataItemGuiProviderRegistry.get();
201 return instance()->mProjectStorageGuiRegistry.get();
206 return instance()->mProviderGuiRegistry.get();
211 return instance()->mSensorGuiRegistry.get();
216 return instance()->mHistoryProviderRegistry.get();
221 return instance()->mSettingsEditorRegistry.get();
226 if ( widget->objectName().isEmpty() )
228 QgsDebugError( u
"WARNING: No object name set. Best for it to be set objectName when using QgsGui::enableAutoGeometryRestore"_s );
230 instance()->mWidgetStateHelper->registerWidget( widget, key );
235 return instance()->mWindowManager.get();
240 return instance()->mInputControllerManager.get();
245 return instance()->mStoredQueryManager.get();
250 instance()->mWindowManager.reset( manager );
268 mProcessingGuiRegistry.reset();
269 mDataItemGuiProviderRegistry.reset();
270 mProcessingFavoriteAlgorithmManager.reset();
271 mProcessingRecentAlgorithmLog.reset();
272 mLayoutItemGuiRegistry.reset();
273 mAnnotationItemGuiRegistry.reset();
274 mAdvancedDigitizingToolsRegistry.reset();
275 mLayerTreeEmbeddedWidgetRegistry.reset();
276 mEditorWidgetRegistry.reset();
277 mMapLayerActionRegistry.reset();
278 mSourceSelectProviderRegistry.reset();
279 mHistoryProviderRegistry.reset();
280 mShortcutsManager.reset();
282 mNumericFormatGuiRegistry.reset();
283 mWidgetStateHelper.reset();
284 mProjectStorageGuiRegistry.reset();
285 mProviderGuiRegistry.reset();
286 mCodeEditorColorSchemeRegistry.reset();
287 mSubsetStringEditorProviderRegistry.reset();
288 mProviderSourceWidgetProviderRegistry.reset();
289 mShapeMapToolRegistry.reset();
290 mRelationEditorRegistry.reset();
291 mInputControllerManager.reset();
292 mSettingsRegistryGui.reset();
293 mSensorGuiRegistry.reset();
294 mStoredQueryManager.reset();
295 mSettingsEditorRegistry.reset();
306 const int x = point.x() - screen->geometry().left();
307 const int y = point.y() - screen->geometry().top();
308 const QPixmap snappedPixmap = screen->grabWindow( 0, x, y, 1, 1 );
309 const QImage snappedImage = snappedPixmap.toImage();
310 return snappedImage.pixel( 0, 0 );
315 const QList<QScreen *> screens = QGuiApplication::screens();
316 for ( QScreen *screen : screens )
318 if ( screen->geometry().contains( point ) )
329 auto macNative = std::make_unique<QgsMacNative>();
331 mNative = std::move( macNative );
332#elif defined( Q_OS_WIN )
334 mNative = std::make_unique<QgsWinNative>();
336 mNative = std::make_unique<QgsNative>();
338#elif defined( Q_OS_LINUX )
339 mNative = std::make_unique<QgsLinuxNative>();
341 mNative = std::make_unique<QgsNative>();
344 mSettingsRegistryGui = std::make_unique<QgsSettingsRegistryGui>();
346 mSettingsEditorRegistry = std::make_unique<QgsSettingsEditorWidgetRegistry>();
348 mStoredQueryManager = std::make_unique<QgsStoredQueryManager>();
349 mCodeEditorColorSchemeRegistry = std::make_unique<QgsCodeEditorColorSchemeRegistry>();
352 mSensorGuiRegistry = std::make_unique<QgsSensorGuiRegistry>();
353 mSensorGuiRegistry->populate();
355 mHistoryProviderRegistry = std::make_unique<QgsHistoryProviderRegistry>();
356 mHistoryProviderRegistry->addDefaultProviders();
358 mInputControllerManager = std::make_unique<QgsInputControllerManager>();
361 mProjectStorageGuiRegistry = std::make_unique<QgsProjectStorageGuiRegistry>();
362 mDataItemGuiProviderRegistry = std::make_unique<QgsDataItemGuiProviderRegistry>();
363 mSourceSelectProviderRegistry = std::make_unique<QgsSourceSelectProviderRegistry>();
364 mNumericFormatGuiRegistry = std::make_unique<QgsNumericFormatGuiRegistry>();
365 mSubsetStringEditorProviderRegistry = std::make_unique<QgsSubsetStringEditorProviderRegistry>();
366 mProviderSourceWidgetProviderRegistry = std::make_unique<QgsProviderSourceWidgetProviderRegistry>();
368 mProjectStorageGuiRegistry->initializeFromProviderGuiRegistry( mProviderGuiRegistry.get() );
369 mDataItemGuiProviderRegistry->initializeFromProviderGuiRegistry( mProviderGuiRegistry.get() );
370 mSourceSelectProviderRegistry->initializeFromProviderGuiRegistry( mProviderGuiRegistry.get() );
372 mSourceSelectProviderRegistry->addProvider(
new QgsStacSourceSelectProvider() );
373 mSubsetStringEditorProviderRegistry->initializeFromProviderGuiRegistry( mProviderGuiRegistry.get() );
374 mProviderSourceWidgetProviderRegistry->initializeFromProviderGuiRegistry( mProviderGuiRegistry.get() );
376 mEditorWidgetRegistry = std::make_unique<QgsEditorWidgetRegistry>();
377 mRelationEditorRegistry = std::make_unique<QgsRelationWidgetRegistry>();
378 mShapeMapToolRegistry = std::make_unique<QgsMapToolShapeRegistry>();
379 mShortcutsManager = std::make_unique<QgsShortcutsManager>();
380 mLayerTreeEmbeddedWidgetRegistry = std::make_unique<QgsLayerTreeEmbeddedWidgetRegistry>();
381 mMapLayerActionRegistry = std::make_unique<QgsMapLayerActionRegistry>();
382 mLayoutItemGuiRegistry = std::make_unique<QgsLayoutItemGuiRegistry>();
384 mAnnotationItemGuiRegistry = std::make_unique<QgsAnnotationItemGuiRegistry>();
385 mAnnotationItemGuiRegistry->addDefaultItems();
387 mAdvancedDigitizingToolsRegistry = std::make_unique<QgsAdvancedDigitizingToolsRegistry>();
388 mAdvancedDigitizingToolsRegistry->addDefaultTools();
390 mWidgetStateHelper = std::make_unique<QgsWidgetStateHelper>();
391 mProcessingFavoriteAlgorithmManager = std::make_unique<QgsProcessingFavoriteAlgorithmManager>();
392 mProcessingRecentAlgorithmLog = std::make_unique<QgsProcessingRecentAlgorithmLog>();
393 mProcessingGuiRegistry = std::make_unique<QgsProcessingGuiRegistry>();
395 qRegisterMetaType<QgsHistoryEntry>(
"QgsHistoryEntry" );
428 static std::once_flag initialized;
429 std::call_once( initialized, []() {
434 if ( !abstractMetadata )
436 QgsDebugError( u
"Failed to find callout entry in registry: %1"_s.arg( name ) );
441 QgsDebugError( u
"Failed to cast callout's metadata: "_s.arg( name ) );
449 _initCalloutWidgetFunction( u
"simple"_s, QgsSimpleLineCalloutWidget::create );
450 _initCalloutWidgetFunction( u
"manhattan"_s, QgsManhattanLineCalloutWidget::create );
451 _initCalloutWidgetFunction( u
"curved"_s, QgsCurvedLineCalloutWidget::create );
452 _initCalloutWidgetFunction( u
"balloon"_s, QgsBalloonCalloutWidget::create );
458 static std::once_flag initialized;
459 std::call_once( initialized, []() {
464 if ( !abstractMetadata )
466 QgsDebugError( u
"Failed to find plot entry in registry: %1"_s.arg( name ) );
471 QgsDebugError( u
"Failed to cast plot's metadata: "_s.arg( name ) );
495void QgsGui::emitOptionsChanged()
ProjectTrustStatus
Project trust status.
@ Trusted
The project trust has not yet been determined by the user.
@ Warning
Warning message.
@ Info
Information message.
EmbeddedScriptMode
Authorisation to run script embedded in projects.
@ Always
Embedded scripts are always run.
@ Never
Embedded scripts never run.
@ Ask
User is prompted before running scripts.
Registry of available annotation item GUI behavior.
static QString pluginPath()
Returns the path to the application plugin directory.
static const QgsSettingsEntryString * settingsLocaleUserLocale
Settings entry locale user locale.
static QgsCalloutRegistry * calloutRegistry()
Returns the application's callout registry, used for managing callout types.
static QString iconsPath()
Returns the path to the icons image directory.
static QgsPlotRegistry * plotRegistry()
Returns the application's plot registry, used for plot types.
Registry of available callout classes.
QgsCalloutAbstractMetadata * calloutMetadata(const QString &type) const
Returns the metadata for specified the specified callout type.
A registry of color schemes for use in QgsCodeEditor widgets.
A registry for data item GUI providers that may affect how QgsDataItems behave within the application...
static QgsMapToolShapeRegistry * mapToolShapeRegistry()
Returns the registry of shape map tools.
static QgsEditorWidgetRegistry * editorWidgetRegistry()
Returns the global editor widget registry, used for managing all known edit widget factories.
static QgsProviderSourceWidgetProviderRegistry * sourceWidgetProviderRegistry()
Returns the registry of provider source widget providers.
static QgsProcessingGuiRegistry * processingGuiRegistry()
Returns the global processing gui registry, used for registering the GUI behavior of processing algor...
static QgsShortcutsManager * shortcutsManager()
Returns the global shortcuts manager, used for managing a QAction and QShortcut sequences.
static void setWindowManager(QgsWindowManagerInterface *manager)
Sets the global window manager.
void optionsChanged()
This signal is emitted whenever the application options have been changed.
static QgsInputControllerManager * inputControllerManager()
Returns the global input controller manager.
static QgsProcessingFavoriteAlgorithmManager * processingFavoriteAlgorithmManager()
Returns the global Processing favorite algorithm manager, used for tracking favorite Processing algor...
static QgsLayerTreeEmbeddedWidgetRegistry * layerTreeEmbeddedWidgetRegistry()
Returns the global layer tree embedded widget registry, used for registering widgets that may be embe...
static QScreen * findScreenAt(QPoint point)
Returns the screen at the given global point (pixel).
static QgsAnnotationItemGuiRegistry * annotationItemGuiRegistry()
Returns the global annotation item GUI registry, used for registering the GUI behavior of annotation ...
static QgsMapLayerActionRegistry * mapLayerActionRegistry()
Returns the global map layer action registry, used for registering map layer actions.
static QgsGui * instance()
Returns a pointer to the singleton instance.
static QgsProviderGuiRegistry * providerGuiRegistry()
Returns the registry of GUI-related components of data providers.
static QgsRelationWidgetRegistry * relationWidgetRegistry()
Returns the global relation widget registry, used for managing all known relation widget factories.
static QgsSensorGuiRegistry * sensorGuiRegistry()
Returns the registry of GUI-related components for sensors.
static QgsAdvancedDigitizingToolsRegistry * advancedDigitizingToolsRegistry()
Returns the global advanced digitizing tools registry, used for registering advanced digitizing tools...
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
static QgsHistoryProviderRegistry * historyProviderRegistry()
Returns the global history provider registry, used for tracking history providers.
static bool allowExecutionOfEmbeddedScripts(QgsProject *project, QgsMessageBar *messageBar=nullptr)
Returns true if python embedded in a project is currently allowed to be loaded.
@ HigMenuTextIsTitleCase
Menu action texts should be title case.
@ HigDialogTitleIsTitleCase
Dialog titles should be title case.
static QgsStoredQueryManager * storedQueryManager()
Returns the global stored SQL query manager.
static QgsNative * nativePlatformInterface()
Returns the global native interface, which offers abstraction to the host OS's underlying public inte...
static bool hasWebEngine()
Checks whether QWebEngineView is available to display HTML content.
QgsGui(const QgsGui &other)=delete
static QgsWindowManagerInterface * windowManager()
Returns the global window manager, if set.
static QgsDataItemGuiProviderRegistry * dataItemGuiProviderRegistry()
Returns the global data item GUI provider registry, used for tracking providers which affect the brow...
static QgsProcessingRecentAlgorithmLog * processingRecentAlgorithmLog()
Returns the global processing recent algorithm log, used for tracking recently used processing algori...
QFlags< HigFlag > HigFlags
static QgsSubsetStringEditorProviderRegistry * subsetStringEditorProviderRegistry()
Returns the registry of subset string editors of data providers.
static QgsProjectStorageGuiRegistry * projectStorageGuiRegistry()
Returns the global GUI-related project storage registry.
static QgsGui::HigFlags higFlags()
Returns the platform's HIG flags.
static QgsLayoutItemGuiRegistry * layoutItemGuiRegistry()
Returns the global layout item GUI registry, used for registering the GUI behavior of layout items.
static void initPlotWidgets()
Initializes plot widgets.
static void initCalloutWidgets()
Initializes callout widgets.
static QgsSettingsRegistryGui * settingsRegistryGui()
Returns the gui's settings registry, used for managing gui settings.
static QgsSourceSelectProviderRegistry * sourceSelectProviderRegistry()
Returns the global source select provider registry, used for managing all known source select widget ...
static QgsCodeEditorColorSchemeRegistry * codeEditorColorSchemeRegistry()
Returns the global code editor color scheme registry, used for registering the color schemes for QgsC...
static QgsNumericFormatGuiRegistry * numericFormatGuiRegistry()
Returns the global numeric format gui registry, used for registering the GUI widgets associated with ...
static QgsSettingsEditorWidgetRegistry * settingsEditorWidgetRegistry()
Returns the registry of settings editors.
static QColor sampleColor(QPoint point)
Samples the color on screen at the specified global point (pixel).
A registry for objects which track user history (i.e.
Registry of available layout item GUI behavior.
A registry which tracks map layer actions.
A bar for displaying non-blocking messages to the user.
void pushMessage(const QString &text, Qgis::MessageLevel level=Qgis::MessageLevel::Info, int duration=-1)
A convenience method for pushing a message with the specified text to the bar.
Registry of available plot types.
QgsPlotAbstractMetadata * plotMetadata(const QString &type) const
Returns the metadata for the specified plot type.
A registry for widgets for use with the Processing framework.
A registry / canonical manager of GUI parts of project storage backends.
A dialog to handle granting of trust to projects containing embedded script.
static Qgis::ProjectTrustStatus checkUserTrust(QgsProject *project)
Returns the current trust status of the specified project.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
A registry / canonical manager of GUI parts of data providers.
Registry of available sensor GUI behavior.
static const QgsSettingsEntryEnumFlag< Qgis::EmbeddedScriptMode > * settingsCodeExecutionBehaviorUndeterminedProjects
Settings entry for behavior handling embedded scripts within projects.
Used for settings introspection and collects all QgsSettingsEntry instances of GUI.
Shortcuts manager is a class that contains a list of QActions and QShortcuts that have been registere...
A registry for QgsSourceSelectProvider source select providers.
A manager for stored SQL queries.
A registry for subset string editor providers.
QgsCalloutWidget *(* QgsCalloutWidgetFunc)(QgsMapLayer *)
#define QgsDebugError(str)
std::function< QgsPlotWidget *(QWidget *parent)> QgsPlotWidgetCreateFunc