23#include "moc_qgsgui.cpp"
34#include "qgsmacnative.h"
35#elif defined (Q_OS_WIN)
37#include "qgswinnative.h"
41#elif defined (Q_OS_LINUX)
42#include "qgslinuxnative.h"
91 return instance()->mSettingsRegistryGui;
96 return instance()->mEditorWidgetRegistry;
101 return instance()->mRelationEditorRegistry;
106 return instance()->mShapeMapToolRegistry;
111 return instance()->mSourceSelectProviderRegistry;
116 return instance()->mSubsetStringEditorProviderRegistry;
121 return instance()->mProviderSourceWidgetProviderRegistry;
126 return instance()->mShortcutsManager;
131 return instance()->mLayerTreeEmbeddedWidgetRegistry;
136 return instance()->mMapLayerActionRegistry;
141 return instance()->mLayoutItemGuiRegistry;
146 return instance()->mAnnotationItemGuiRegistry;
151 return instance()->mAdvancedDigitizingToolsRegistry;
156 return instance()->mProcessingGuiRegistry;
161 return instance()->mNumericFormatGuiRegistry;
166 return instance()->mCodeEditorColorSchemeRegistry;
171 return instance()->mProcessingFavoriteAlgorithmManager;
176 return instance()->mProcessingRecentAlgorithmLog;
181 return instance()->mDataItemGuiProviderRegistry;
186 return instance()->mProjectStorageGuiRegistry;
191 return instance()->mProviderGuiRegistry;
196 return instance()->mSensorGuiRegistry;
201 return instance()->mHistoryProviderRegistry;
206 return instance()->mSettingsEditorRegistry;
211 if ( widget->objectName().isEmpty() )
213 QgsDebugError( QStringLiteral(
"WARNING: No object name set. Best for it to be set objectName when using QgsGui::enableAutoGeometryRestore" ) );
220 return instance()->mWindowManager.get();
225 return instance()->mInputControllerManager;
230 instance()->mWindowManager.reset( manager );
247 delete mProcessingGuiRegistry;
248 delete mDataItemGuiProviderRegistry;
249 delete mProcessingFavoriteAlgorithmManager;
250 delete mProcessingRecentAlgorithmLog;
251 delete mLayoutItemGuiRegistry;
252 delete mAnnotationItemGuiRegistry;
253 delete mAdvancedDigitizingToolsRegistry;
254 delete mLayerTreeEmbeddedWidgetRegistry;
255 delete mEditorWidgetRegistry;
256 delete mMapLayerActionRegistry;
257 delete mSourceSelectProviderRegistry;
258 delete mHistoryProviderRegistry;
259 delete mShortcutsManager;
261 delete mNumericFormatGuiRegistry;
262 delete mWidgetStateHelper;
263 delete mProjectStorageGuiRegistry;
264 delete mProviderGuiRegistry;
265 delete mCodeEditorColorSchemeRegistry;
266 delete mSubsetStringEditorProviderRegistry;
267 delete mProviderSourceWidgetProviderRegistry;
268 delete mShapeMapToolRegistry;
269 delete mRelationEditorRegistry;
270 delete mInputControllerManager;
271 delete mSettingsRegistryGui;
272 delete mSensorGuiRegistry;
273 delete mSettingsEditorRegistry;
284 const int x = point.x() - screen->geometry().left();
285 const int y = point.y() - screen->geometry().top();
286 const QPixmap snappedPixmap = screen->grabWindow( 0, x, y, 1, 1 );
287 const QImage snappedImage = snappedPixmap.toImage();
288 return snappedImage.pixel( 0, 0 );
293 const QList< QScreen * > screens = QGuiApplication::screens();
294 for ( QScreen *screen : screens )
296 if ( screen->geometry().contains( point ) )
307 QgsMacNative *macNative =
new QgsMacNative();
310#elif defined (Q_OS_WIN)
312 mNative =
new QgsWinNative();
314 mNative =
new QgsNative();
316#elif defined(Q_OS_LINUX)
317 mNative =
new QgsLinuxNative();
319 mNative =
new QgsNative();
367 mProcessingFavoriteAlgorithmManager =
new QgsProcessingFavoriteAlgorithmManager();
368 mProcessingRecentAlgorithmLog =
new QgsProcessingRecentAlgorithmLog();
371 qRegisterMetaType< QgsHistoryEntry >(
"QgsHistoryEntry" );
378 switch ( pythonEmbeddedMode )
394 switch ( embeddedType )
398 tr(
"Python macros are currently disabled and will not be run" ),
402 messageBar->
pushMessage( tr(
"Python Expressions" ),
403 tr(
"Python expressions from project are currently disabled and will not be loaded" ),
414 QMessageBox msgBox( QMessageBox::Information, tr(
"Python Macros" ),
415 tr(
"Python macros are currently disabled. Do you allow this macro to run?" ) );
416 QAbstractButton *stopSessionButton = msgBox.addButton( tr(
"Disable for this Session" ), QMessageBox::DestructiveRole );
417 msgBox.addButton( tr(
"No" ), QMessageBox::NoRole );
418 QAbstractButton *yesButton = msgBox.addButton( tr(
"Yes" ), QMessageBox::YesRole );
421 QAbstractButton *clicked = msgBox.clickedButton();
422 if ( clicked == stopSessionButton )
426 return clicked == yesButton;
431 Q_ASSERT( messageBar );
434 QToolButton *btnEnableMacros =
new QToolButton();
435 btnEnableMacros->setText( tr(
"Enable Macros" ) );
436 btnEnableMacros->setStyleSheet( QStringLiteral(
"background-color: rgba(255, 255, 255, 0); color: black; text-decoration: underline;" ) );
437 btnEnableMacros->setCursor( Qt::PointingHandCursor );
438 btnEnableMacros->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred );
441 tr(
"Security warning" ),
442 tr(
"Python macros cannot currently be run." ),
448 connect( btnEnableMacros, &QToolButton::clicked, messageBar, [ = ]()
464 Q_ASSERT( messageBar );
467 QToolButton *btnEnableExpressionsFromProject =
new QToolButton();
468 btnEnableExpressionsFromProject->setText( tr(
"Enable python expressions from project" ) );
469 btnEnableExpressionsFromProject->setStyleSheet( QStringLiteral(
"background-color: rgba(255, 255, 255, 0); color: black; text-decoration: underline;" ) );
470 btnEnableExpressionsFromProject->setCursor( Qt::PointingHandCursor );
471 btnEnableExpressionsFromProject->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred );
474 tr(
"Security warning" ),
475 tr(
"Python expressions from project cannot currently be loaded." ),
476 btnEnableExpressionsFromProject,
481 connect( btnEnableExpressionsFromProject, &QToolButton::clicked, messageBar, [ = ]()
484 messageBar->
popWidget( expressionFromProjectMsg );
488 messageBar->
pushItem( expressionFromProjectMsg );
499 static std::once_flag initialized;
500 std::call_once( initialized, [ = ]( )
508 if ( !abstractMetadata )
510 QgsDebugError( QStringLiteral(
"Failed to find callout entry in registry: %1" ).arg( name ) );
515 QgsDebugError( QStringLiteral(
"Failed to cast callout's metadata: " ) .arg( name ) );
523 _initCalloutWidgetFunction( QStringLiteral(
"simple" ), QgsSimpleLineCalloutWidget::create );
524 _initCalloutWidgetFunction( QStringLiteral(
"manhattan" ), QgsManhattanLineCalloutWidget::create );
525 _initCalloutWidgetFunction( QStringLiteral(
"curved" ), QgsCurvedLineCalloutWidget::create );
526 _initCalloutWidgetFunction( QStringLiteral(
"balloon" ), QgsBalloonCalloutWidget::create );
531void QgsGui::emitOptionsChanged()
@ Warning
Warning message.
PythonEmbeddedMode
Authorisation to run Python Embedded in projects.
@ Always
Python embedded is always run.
@ NotForThisSession
Python embedded will not be run for this session.
@ Never
Python embedded never run.
@ Ask
User is prompt before running.
@ SessionOnly
Only during this session.
PythonEmbeddedType
Type of Python Embedded in projects.
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.
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.
This class keeps a list of data item GUI providers that may affect how QgsDataItems behave within the...
void initializeFromProviderGuiRegistry(QgsProviderGuiRegistry *providerGuiRegistry)
Initializes the registry.
QgsGui is a singleton class containing various registry and other global members related to GUI class...
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.
@ HigMenuTextIsTitleCase
Menu action texts should be title case.
@ HigDialogTitleIsTitleCase
Dialog titles should be title case.
static bool pythonEmbeddedInProjectAllowed(void(*lambda)()=nullptr, QgsMessageBar *messageBar=nullptr, Qgis::PythonEmbeddedType embeddedType=Qgis::PythonEmbeddedType::Macro)
Returns true if python embedded in a project is currently allowed to be loaded.
static QgsNative * nativePlatformInterface()
Returns the global native interface, which offers abstraction to the host OS's underlying public inte...
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 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).
The QgsHistoryProviderRegistry is a registry for objects which track user history (i....
void addDefaultProviders()
Adds the default history providers to the registry.
Registry of available layout item GUI behavior.
This class tracks map layer actions.
Represents an item shown within a QgsMessageBar widget.
A bar for displaying non-blocking messages to the user.
bool popWidget(QgsMessageBarItem *item)
Remove the specified item from the bar, and display the next most recent one in the stack.
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.
void pushItem(QgsMessageBarItem *item)
Display a message item on the bar, after hiding the currently visible one and putting it in a stack.
The QgsProcessingGuiRegistry is a home for widgets for processing configuration widgets.
A registry / canonical manager of GUI parts of project storage backends.
void initializeFromProviderGuiRegistry(QgsProviderGuiRegistry *providerGuiRegistry)
Initializes the registry.
static QgsProject * instance()
Returns the QgsProject singleton instance.
bool loadFunctionsFromProject(bool force=false)
Loads python expression functions stored in the currrent project.
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.
QgsSettingsRegistryGui is used for settings introspection and collects all QgsSettingsEntry instances...
This class is a composition of two QSettings instances:
void setEnumValue(const QString &key, const T &value, const Section section=NoSection)
Set the value of a setting based on an enum.
T enumValue(const QString &key, const T &defaultValue, const Section section=NoSection)
Returns the setting value for a setting based on an enum.
Shortcuts manager is a class that contains a list of QActions and QShortcuts that have been registere...
This class keeps a list of source select providers that may add items to the QgsDataSourceManagerDial...
void initializeFromProviderGuiRegistry(QgsProviderGuiRegistry *providerGuiRegistry)
Initializes the registry.
void addProvider(QgsSourceSelectProvider *provider)
Add a provider implementation. Takes ownership of the object.
This class keeps a list of subset string editor providers.
void initializeFromProviderGuiRegistry(QgsProviderGuiRegistry *providerGuiRegistry)
Initializes the registry.
QgsCalloutWidget *(* QgsCalloutWidgetFunc)(QgsMapLayer *)
#define QgsDebugError(str)