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;
111 return instance()->mEditorWidgetRegistry;
116 return instance()->mRelationEditorRegistry;
121 return instance()->mShapeMapToolRegistry;
126 return instance()->mSourceSelectProviderRegistry;
131 return instance()->mSubsetStringEditorProviderRegistry;
136 return instance()->mProviderSourceWidgetProviderRegistry;
141 return instance()->mShortcutsManager;
146 return instance()->mLayerTreeEmbeddedWidgetRegistry;
151 return instance()->mMapLayerActionRegistry;
156 return instance()->mLayoutItemGuiRegistry;
161 return instance()->mAnnotationItemGuiRegistry;
166 return instance()->mAdvancedDigitizingToolsRegistry;
171 return instance()->mProcessingGuiRegistry;
176 return instance()->mNumericFormatGuiRegistry;
181 return instance()->mCodeEditorColorSchemeRegistry;
186 return instance()->mProcessingFavoriteAlgorithmManager;
191 return instance()->mProcessingRecentAlgorithmLog;
196 return instance()->mDataItemGuiProviderRegistry;
201 return instance()->mProjectStorageGuiRegistry;
206 return instance()->mProviderGuiRegistry;
211 return instance()->mSensorGuiRegistry;
216 return instance()->mHistoryProviderRegistry;
221 return instance()->mSettingsEditorRegistry;
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 );
235 return instance()->mWindowManager.get();
240 return instance()->mInputControllerManager;
245 return instance()->mStoredQueryManager;
250 instance()->mWindowManager.reset( manager );
267 delete mProcessingGuiRegistry;
268 delete mDataItemGuiProviderRegistry;
269 delete mProcessingFavoriteAlgorithmManager;
270 delete mProcessingRecentAlgorithmLog;
271 delete mLayoutItemGuiRegistry;
272 delete mAnnotationItemGuiRegistry;
273 delete mAdvancedDigitizingToolsRegistry;
274 delete mLayerTreeEmbeddedWidgetRegistry;
275 delete mEditorWidgetRegistry;
276 delete mMapLayerActionRegistry;
277 delete mSourceSelectProviderRegistry;
278 delete mHistoryProviderRegistry;
279 delete mShortcutsManager;
281 delete mNumericFormatGuiRegistry;
282 delete mWidgetStateHelper;
283 delete mProjectStorageGuiRegistry;
284 delete mProviderGuiRegistry;
285 delete mCodeEditorColorSchemeRegistry;
286 delete mSubsetStringEditorProviderRegistry;
287 delete mProviderSourceWidgetProviderRegistry;
288 delete mShapeMapToolRegistry;
289 delete mRelationEditorRegistry;
290 delete mInputControllerManager;
291 delete mSettingsRegistryGui;
292 delete mSensorGuiRegistry;
293 delete mStoredQueryManager;
294 delete mSettingsEditorRegistry;
305 const int x = point.x() - screen->geometry().left();
306 const int y = point.y() - screen->geometry().top();
307 const QPixmap snappedPixmap = screen->grabWindow( 0, x, y, 1, 1 );
308 const QImage snappedImage = snappedPixmap.toImage();
309 return snappedImage.pixel( 0, 0 );
314 const QList<QScreen *> screens = QGuiApplication::screens();
315 for ( QScreen *screen : screens )
317 if ( screen->geometry().contains( point ) )
328 QgsMacNative *macNative =
new QgsMacNative();
331#elif defined( Q_OS_WIN )
333 mNative =
new QgsWinNative();
335 mNative =
new QgsNative();
337#elif defined( Q_OS_LINUX )
338 mNative =
new QgsLinuxNative();
340 mNative =
new QgsNative();
371 mSourceSelectProviderRegistry->
addProvider(
new QgsStacSourceSelectProvider() );
390 mProcessingFavoriteAlgorithmManager =
new QgsProcessingFavoriteAlgorithmManager();
391 mProcessingRecentAlgorithmLog =
new QgsProcessingRecentAlgorithmLog();
394 qRegisterMetaType<QgsHistoryEntry>(
"QgsHistoryEntry" );
413 tr(
"Security warning" ),
414 tr(
"The loaded project contains embedded scripts which have been allowed execution." ),
421 tr(
"Security warning" ),
422 tr(
"The loaded project contains embedded scripts which have been denied execution." ),
433 static std::once_flag initialized;
434 std::call_once( initialized, []() {
439 if ( !abstractMetadata )
441 QgsDebugError( u
"Failed to find callout entry in registry: %1"_s.arg( name ) );
446 QgsDebugError( u
"Failed to cast callout's metadata: "_s.arg( name ) );
454 _initCalloutWidgetFunction( u
"simple"_s, QgsSimpleLineCalloutWidget::create );
455 _initCalloutWidgetFunction( u
"manhattan"_s, QgsManhattanLineCalloutWidget::create );
456 _initCalloutWidgetFunction( u
"curved"_s, QgsCurvedLineCalloutWidget::create );
457 _initCalloutWidgetFunction( u
"balloon"_s, QgsBalloonCalloutWidget::create );
463 static std::once_flag initialized;
464 std::call_once( initialized, []() {
469 if ( !abstractMetadata )
471 QgsDebugError( u
"Failed to find plot entry in registry: %1"_s.arg( name ) );
476 QgsDebugError( u
"Failed to cast plot's metadata: "_s.arg( name ) );
500void 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.
void addDefaultItems()
Populates the registry with default items.
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...
void initializeFromProviderGuiRegistry(QgsProviderGuiRegistry *providerGuiRegistry)
Initializes the registry.
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.
void addDefaultProviders()
Adds the default history providers to the registry.
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.
void initializeFromProviderGuiRegistry(QgsProviderGuiRegistry *providerGuiRegistry)
Initializes the registry.
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.
bool populate()
Populates the registry with standard sensor types.
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.
void initializeFromProviderGuiRegistry(QgsProviderGuiRegistry *providerGuiRegistry)
Initializes the registry.
void addProvider(QgsSourceSelectProvider *provider)
Add a provider implementation. Takes ownership of the object.
A manager for stored SQL queries.
A registry for subset string editor providers.
void initializeFromProviderGuiRegistry(QgsProviderGuiRegistry *providerGuiRegistry)
Initializes the registry.
QgsCalloutWidget *(* QgsCalloutWidgetFunc)(QgsMapLayer *)
#define QgsDebugError(str)
std::function< QgsPlotWidget *(QWidget *parent)> QgsPlotWidgetCreateFunc