34#include "moc_qgsgui.cpp"
37#include "qgsmacnative.h"
38#elif defined( Q_OS_WIN )
40#include "qgswinnative.h"
44#elif defined( Q_OS_LINUX )
45#include "qgslinuxnative.h"
77#include "qgsstacsourceselectprovider.h"
103 return instance()->mSettingsRegistryGui;
108 return instance()->mEditorWidgetRegistry;
113 return instance()->mRelationEditorRegistry;
118 return instance()->mShapeMapToolRegistry;
123 return instance()->mSourceSelectProviderRegistry;
128 return instance()->mSubsetStringEditorProviderRegistry;
133 return instance()->mProviderSourceWidgetProviderRegistry;
138 return instance()->mShortcutsManager;
143 return instance()->mLayerTreeEmbeddedWidgetRegistry;
148 return instance()->mMapLayerActionRegistry;
153 return instance()->mLayoutItemGuiRegistry;
158 return instance()->mAnnotationItemGuiRegistry;
163 return instance()->mAdvancedDigitizingToolsRegistry;
168 return instance()->mProcessingGuiRegistry;
173 return instance()->mNumericFormatGuiRegistry;
178 return instance()->mCodeEditorColorSchemeRegistry;
183 return instance()->mProcessingFavoriteAlgorithmManager;
188 return instance()->mProcessingRecentAlgorithmLog;
193 return instance()->mDataItemGuiProviderRegistry;
198 return instance()->mProjectStorageGuiRegistry;
203 return instance()->mProviderGuiRegistry;
208 return instance()->mSensorGuiRegistry;
213 return instance()->mHistoryProviderRegistry;
218 return instance()->mSettingsEditorRegistry;
223 if ( widget->objectName().isEmpty() )
225 QgsDebugError( QStringLiteral(
"WARNING: No object name set. Best for it to be set objectName when using QgsGui::enableAutoGeometryRestore" ) );
232 return instance()->mWindowManager.get();
237 return instance()->mInputControllerManager;
242 return instance()->mStoredQueryManager;
247 instance()->mWindowManager.reset( manager );
264 delete mProcessingGuiRegistry;
265 delete mDataItemGuiProviderRegistry;
266 delete mProcessingFavoriteAlgorithmManager;
267 delete mProcessingRecentAlgorithmLog;
268 delete mLayoutItemGuiRegistry;
269 delete mAnnotationItemGuiRegistry;
270 delete mAdvancedDigitizingToolsRegistry;
271 delete mLayerTreeEmbeddedWidgetRegistry;
272 delete mEditorWidgetRegistry;
273 delete mMapLayerActionRegistry;
274 delete mSourceSelectProviderRegistry;
275 delete mHistoryProviderRegistry;
276 delete mShortcutsManager;
278 delete mNumericFormatGuiRegistry;
279 delete mWidgetStateHelper;
280 delete mProjectStorageGuiRegistry;
281 delete mProviderGuiRegistry;
282 delete mCodeEditorColorSchemeRegistry;
283 delete mSubsetStringEditorProviderRegistry;
284 delete mProviderSourceWidgetProviderRegistry;
285 delete mShapeMapToolRegistry;
286 delete mRelationEditorRegistry;
287 delete mInputControllerManager;
288 delete mSettingsRegistryGui;
289 delete mSensorGuiRegistry;
290 delete mStoredQueryManager;
291 delete mSettingsEditorRegistry;
302 const int x = point.x() - screen->geometry().left();
303 const int y = point.y() - screen->geometry().top();
304 const QPixmap snappedPixmap = screen->grabWindow( 0, x, y, 1, 1 );
305 const QImage snappedImage = snappedPixmap.toImage();
306 return snappedImage.pixel( 0, 0 );
311 const QList<QScreen *> screens = QGuiApplication::screens();
312 for ( QScreen *screen : screens )
314 if ( screen->geometry().contains( point ) )
325 QgsMacNative *macNative =
new QgsMacNative();
328#elif defined( Q_OS_WIN )
330 mNative =
new QgsWinNative();
332 mNative =
new QgsNative();
334#elif defined( Q_OS_LINUX )
335 mNative =
new QgsLinuxNative();
337 mNative =
new QgsNative();
368 mSourceSelectProviderRegistry->
addProvider(
new QgsStacSourceSelectProvider() );
387 mProcessingFavoriteAlgorithmManager =
new QgsProcessingFavoriteAlgorithmManager();
388 mProcessingRecentAlgorithmLog =
new QgsProcessingRecentAlgorithmLog();
391 qRegisterMetaType<QgsHistoryEntry>(
"QgsHistoryEntry" );
410 tr(
"Security warning" ),
411 tr(
"The loaded project contains embedded scripts which have been allowed execution." ),
418 tr(
"Security warning" ),
419 tr(
"The loaded project contains embedded scripts which have been denied execution." ),
430 static std::once_flag initialized;
431 std::call_once( initialized, []() {
436 if ( !abstractMetadata )
438 QgsDebugError( QStringLiteral(
"Failed to find callout entry in registry: %1" ).arg( name ) );
443 QgsDebugError( QStringLiteral(
"Failed to cast callout's metadata: " ).arg( name ) );
451 _initCalloutWidgetFunction( QStringLiteral(
"simple" ), QgsSimpleLineCalloutWidget::create );
452 _initCalloutWidgetFunction( QStringLiteral(
"manhattan" ), QgsManhattanLineCalloutWidget::create );
453 _initCalloutWidgetFunction( QStringLiteral(
"curved" ), QgsCurvedLineCalloutWidget::create );
454 _initCalloutWidgetFunction( QStringLiteral(
"balloon" ), QgsBalloonCalloutWidget::create );
460 static std::once_flag initialized;
461 std::call_once( initialized, []() {
466 if ( !abstractMetadata )
468 QgsDebugError( QStringLiteral(
"Failed to find plot entry in registry: %1" ).arg( name ) );
473 QgsDebugError( QStringLiteral(
"Failed to cast plot's metadata: " ).arg( name ) );
497void 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