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"
107 return instance()->mSettingsRegistryGui.get();
112 return instance()->mEditorWidgetRegistry.get();
117 return instance()->mRelationEditorRegistry.get();
122 return instance()->mShapeMapToolRegistry.get();
127 return instance()->mSourceSelectProviderRegistry.get();
132 return instance()->mSubsetStringEditorProviderRegistry.get();
137 return instance()->mProviderSourceWidgetProviderRegistry.get();
142 return instance()->mShortcutsManager.get();
147 return instance()->mLayerTreeEmbeddedWidgetRegistry.get();
152 return instance()->mMapLayerActionRegistry.get();
157 return instance()->mLayoutItemGuiRegistry.get();
162 return instance()->mAnnotationItemGuiRegistry.get();
167 return instance()->mAdvancedDigitizingToolsRegistry.get();
172 return instance()->mProcessingGuiRegistry.get();
177 return instance()->mNumericFormatGuiRegistry.get();
182 return instance()->mCodeEditorColorSchemeRegistry.get();
187 return instance()->mProcessingFavoriteAlgorithmManager.get();
192 return instance()->mProcessingRecentAlgorithmLog.get();
197 return instance()->mDataItemGuiProviderRegistry.get();
202 return instance()->mProjectStorageGuiRegistry.get();
207 return instance()->mProviderGuiRegistry.get();
212 return instance()->mSensorGuiRegistry.get();
217 return instance()->mHistoryProviderRegistry.get();
222 return instance()->mSettingsEditorRegistry.get();
227 if ( widget->objectName().isEmpty() )
229 QgsDebugError( u
"WARNING: No object name set. Best for it to be set objectName when using QgsGui::enableAutoGeometryRestore"_s );
231 instance()->mWidgetStateHelper->registerWidget( widget, key );
236 return instance()->mWindowManager.get();
241 return instance()->mInputControllerManager.get();
246 return instance()->mStoredQueryManager.get();
251 instance()->mWindowManager.reset( manager );
269 mProcessingGuiRegistry.reset();
270 mDataItemGuiProviderRegistry.reset();
271 mProcessingFavoriteAlgorithmManager.reset();
272 mProcessingRecentAlgorithmLog.reset();
273 mLayoutItemGuiRegistry.reset();
274 mAnnotationItemGuiRegistry.reset();
275 mAdvancedDigitizingToolsRegistry.reset();
276 mLayerTreeEmbeddedWidgetRegistry.reset();
277 mEditorWidgetRegistry.reset();
278 mMapLayerActionRegistry.reset();
279 mSourceSelectProviderRegistry.reset();
280 mHistoryProviderRegistry.reset();
281 mShortcutsManager.reset();
283 mNumericFormatGuiRegistry.reset();
284 mWidgetStateHelper.reset();
285 mProjectStorageGuiRegistry.reset();
286 mProviderGuiRegistry.reset();
287 mCodeEditorColorSchemeRegistry.reset();
288 mSubsetStringEditorProviderRegistry.reset();
289 mProviderSourceWidgetProviderRegistry.reset();
290 mShapeMapToolRegistry.reset();
291 mRelationEditorRegistry.reset();
292 mInputControllerManager.reset();
293 mSettingsRegistryGui.reset();
294 mSensorGuiRegistry.reset();
295 mStoredQueryManager.reset();
296 mSettingsEditorRegistry.reset();
307 const int x = point.x() - screen->geometry().left();
308 const int y = point.y() - screen->geometry().top();
309 const QPixmap snappedPixmap = screen->grabWindow( 0, x, y, 1, 1 );
310 const QImage snappedImage = snappedPixmap.toImage();
311 return snappedImage.pixel( 0, 0 );
316 const QList<QScreen *> screens = QGuiApplication::screens();
317 for ( QScreen *screen : screens )
319 if ( screen->geometry().contains( point ) )
330 auto macNative = std::make_unique<QgsMacNative>();
332 mNative = std::move( macNative );
333#elif defined( Q_OS_WIN )
335 mNative = std::make_unique<QgsWinNative>();
337 mNative = std::make_unique<QgsNative>();
339#elif defined( Q_OS_LINUX )
340 mNative = std::make_unique<QgsLinuxNative>();
342 mNative = std::make_unique<QgsNative>();
345 mSettingsRegistryGui = std::make_unique<QgsSettingsRegistryGui>();
347 mSettingsEditorRegistry = std::make_unique<QgsSettingsEditorWidgetRegistry>();
349 mStoredQueryManager = std::make_unique<QgsStoredQueryManager>();
350 mCodeEditorColorSchemeRegistry = std::make_unique<QgsCodeEditorColorSchemeRegistry>();
353 mSensorGuiRegistry = std::make_unique<QgsSensorGuiRegistry>();
354 mSensorGuiRegistry->populate();
356 mHistoryProviderRegistry = std::make_unique<QgsHistoryProviderRegistry>();
357 mHistoryProviderRegistry->addDefaultProviders();
359 mInputControllerManager = std::make_unique<QgsInputControllerManager>();
362 mProjectStorageGuiRegistry = std::make_unique<QgsProjectStorageGuiRegistry>();
363 mDataItemGuiProviderRegistry = std::make_unique<QgsDataItemGuiProviderRegistry>();
364 mSourceSelectProviderRegistry = std::make_unique<QgsSourceSelectProviderRegistry>();
365 mNumericFormatGuiRegistry = std::make_unique<QgsNumericFormatGuiRegistry>();
366 mSubsetStringEditorProviderRegistry = std::make_unique<QgsSubsetStringEditorProviderRegistry>();
367 mProviderSourceWidgetProviderRegistry = std::make_unique<QgsProviderSourceWidgetProviderRegistry>();
369 mProjectStorageGuiRegistry->initializeFromProviderGuiRegistry( mProviderGuiRegistry.get() );
370 mDataItemGuiProviderRegistry->initializeFromProviderGuiRegistry( mProviderGuiRegistry.get() );
371 mSourceSelectProviderRegistry->initializeFromProviderGuiRegistry( mProviderGuiRegistry.get() );
373 mSourceSelectProviderRegistry->addProvider(
new QgsStacSourceSelectProvider() );
374 mSubsetStringEditorProviderRegistry->initializeFromProviderGuiRegistry( mProviderGuiRegistry.get() );
375 mProviderSourceWidgetProviderRegistry->initializeFromProviderGuiRegistry( mProviderGuiRegistry.get() );
377 mEditorWidgetRegistry = std::make_unique<QgsEditorWidgetRegistry>();
378 mRelationEditorRegistry = std::make_unique<QgsRelationWidgetRegistry>();
379 mShapeMapToolRegistry = std::make_unique<QgsMapToolShapeRegistry>();
380 mShortcutsManager = std::make_unique<QgsShortcutsManager>();
381 mLayerTreeEmbeddedWidgetRegistry = std::make_unique<QgsLayerTreeEmbeddedWidgetRegistry>();
382 mMapLayerActionRegistry = std::make_unique<QgsMapLayerActionRegistry>();
383 mLayoutItemGuiRegistry = std::make_unique<QgsLayoutItemGuiRegistry>();
385 mAnnotationItemGuiRegistry = std::make_unique<QgsAnnotationItemGuiRegistry>();
386 mAnnotationItemGuiRegistry->addDefaultItems();
388 mAdvancedDigitizingToolsRegistry = std::make_unique<QgsAdvancedDigitizingToolsRegistry>();
389 mAdvancedDigitizingToolsRegistry->addDefaultTools();
391 mWidgetStateHelper = std::make_unique<QgsWidgetStateHelper>();
392 mProcessingFavoriteAlgorithmManager = std::make_unique<QgsProcessingFavoriteAlgorithmManager>();
393 mProcessingRecentAlgorithmLog = std::make_unique<QgsProcessingRecentAlgorithmLog>();
394 mProcessingGuiRegistry = std::make_unique<QgsProcessingGuiRegistry>();
396 qRegisterMetaType<QgsHistoryEntry>(
"QgsHistoryEntry" );
406 if ( styleSheet == mApplicationStyleSheet )
409 mApplicationStyleSheet = styleSheet;
443 static std::once_flag initialized;
444 std::call_once( initialized, []() {
449 if ( !abstractMetadata )
451 QgsDebugError( u
"Failed to find callout entry in registry: %1"_s.arg( name ) );
456 QgsDebugError( u
"Failed to cast callout's metadata: "_s.arg( name ) );
464 _initCalloutWidgetFunction( u
"simple"_s, QgsSimpleLineCalloutWidget::create );
465 _initCalloutWidgetFunction( u
"manhattan"_s, QgsManhattanLineCalloutWidget::create );
466 _initCalloutWidgetFunction( u
"curved"_s, QgsCurvedLineCalloutWidget::create );
467 _initCalloutWidgetFunction( u
"balloon"_s, QgsBalloonCalloutWidget::create );
473 static std::once_flag initialized;
474 std::call_once( initialized, []() {
479 if ( !abstractMetadata )
481 QgsDebugError( u
"Failed to find plot entry in registry: %1"_s.arg( name ) );
486 QgsDebugError( u
"Failed to cast plot's metadata: "_s.arg( name ) );
512 const int w = s.
value( u
"/qgis/toolbarIconSize"_s, 32 ).toInt();
526void QgsGui::emitOptionsChanged()
ProjectTrustStatus
Project trust status.
@ Trusted
The project has been determined by the user as trusted.
@ Undetermined
The project trust has not yet been determined by the user.
UserInterfaceIconType
Icon types for icons shown in the user interface.
@ MainWindowToolbar
Main window toolbar icons.
@ DockedToolbar
Toolbars for docked windows.
@ 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 QSize iconSize(Qgis::UserInterfaceIconType iconType=Qgis::UserInterfaceIconType::MainWindowToolbar)
Returns the desired size for user interface icons.
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...
void applicationStyleSheetChanged(const QString &styleSheet)
Emitted whenever the application style sheet is changed.
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 QString applicationStyleSheet()
Returns the application style sheet.
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.
void setApplicationStyleSheet(const QString &styleSheet)
Sets the application style sheet.
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.
Stores settings for use within QGIS.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
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.
QSize panelIconSize(QSize size)
Returns dockable panel toolbar icon width based on the provided window toolbar width.
#define BUILTIN_UNREACHABLE
QgsCalloutWidget *(* QgsCalloutWidgetFunc)(QgsMapLayer *)
#define QgsDebugError(str)
std::function< QgsPlotWidget *(QWidget *parent)> QgsPlotWidgetCreateFunc