QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
20 #include <QDesktopWidget>
21 #include <QMessageBox>
33 #include "qgsmacnative.h"
34 #elif defined (Q_OS_WIN)
36 #include "qgswinnative.h"
38 #include "qgsnative.h"
40 #elif defined (Q_OS_LINUX)
41 #include "qgslinuxnative.h"
43 #include "qgsnative.h"
53 #include "qgsgdalguiprovider.h"
54 #include "qgsogrguiprovider.h"
82 return instance()->mSettingsRegistryGui;
87 return instance()->mEditorWidgetRegistry;
92 return instance()->mRelationEditorRegistry;
97 return instance()->mShapeMapToolRegistry;
102 return instance()->mSourceSelectProviderRegistry;
107 return instance()->mSubsetStringEditorProviderRegistry;
112 return instance()->mProviderSourceWidgetProviderRegistry;
117 return instance()->mShortcutsManager;
122 return instance()->mLayerTreeEmbeddedWidgetRegistry;
127 return instance()->mMapLayerActionRegistry;
132 return instance()->mLayoutItemGuiRegistry;
137 return instance()->mAnnotationItemGuiRegistry;
142 return instance()->mProcessingGuiRegistry;
147 return instance()->mNumericFormatGuiRegistry;
152 return instance()->mCodeEditorColorSchemeRegistry;
157 return instance()->mProcessingRecentAlgorithmLog;
162 return instance()->mDataItemGuiProviderRegistry;
167 return instance()->mProjectStorageGuiRegistry;
172 return instance()->mProviderGuiRegistry;
177 return instance()->mHistoryProviderRegistry;
182 if ( widget->objectName().isEmpty() )
184 QgsDebugMsg( QStringLiteral(
"WARNING: No object name set. Best for it to be set objectName when using QgsGui::enableAutoGeometryRestore" ) );
191 return instance()->mWindowManager.get();
196 instance()->mWindowManager.reset( manager );
207 return QgsGui::HigFlags();
213 delete mProcessingGuiRegistry;
214 delete mDataItemGuiProviderRegistry;
215 delete mProcessingRecentAlgorithmLog;
216 delete mLayoutItemGuiRegistry;
217 delete mAnnotationItemGuiRegistry;
218 delete mLayerTreeEmbeddedWidgetRegistry;
219 delete mEditorWidgetRegistry;
220 delete mMapLayerActionRegistry;
221 delete mSourceSelectProviderRegistry;
222 delete mHistoryProviderRegistry;
223 delete mShortcutsManager;
225 delete mNumericFormatGuiRegistry;
226 delete mWidgetStateHelper;
227 delete mProjectStorageGuiRegistry;
228 delete mProviderGuiRegistry;
229 delete mCodeEditorColorSchemeRegistry;
230 delete mSubsetStringEditorProviderRegistry;
231 delete mProviderSourceWidgetProviderRegistry;
232 delete mShapeMapToolRegistry;
233 delete mRelationEditorRegistry;
234 delete mSettingsRegistryGui;
244 const QPixmap snappedPixmap = screen->grabWindow( QApplication::desktop()->winId(), point.x(), point.y(), 1, 1 );
245 const QImage snappedImage = snappedPixmap.toImage();
246 return snappedImage.pixel( 0, 0 );
251 const QList< QScreen * > screens = QGuiApplication::screens();
252 for ( QScreen *screen : screens )
254 if ( screen->geometry().contains( point ) )
265 QgsMacNative *macNative =
new QgsMacNative();
268 #elif defined (Q_OS_WIN)
270 mNative =
new QgsWinNative();
272 mNative =
new QgsNative();
274 #elif defined(Q_OS_LINUX)
275 mNative =
new QgsLinuxNative();
277 mNative =
new QgsNative();
314 mProcessingRecentAlgorithmLog =
new QgsProcessingRecentAlgorithmLog();
334 tr(
"Python macros are currently disabled and will not be run" ),
335 Qgis::MessageLevel::Warning );
341 QMessageBox msgBox( QMessageBox::Information, tr(
"Python Macros" ),
342 tr(
"Python macros are currently disabled. Do you allow this macro to run?" ) );
343 QAbstractButton *stopSessionButton = msgBox.addButton( tr(
"Disable for this Session" ), QMessageBox::DestructiveRole );
344 msgBox.addButton( tr(
"No" ), QMessageBox::NoRole );
345 QAbstractButton *yesButton = msgBox.addButton( tr(
"Yes" ), QMessageBox::YesRole );
348 QAbstractButton *clicked = msgBox.clickedButton();
349 if ( clicked == stopSessionButton )
353 return clicked == yesButton;
358 Q_ASSERT( messageBar );
361 QToolButton *btnEnableMacros =
new QToolButton();
362 btnEnableMacros->setText( tr(
"Enable Macros" ) );
363 btnEnableMacros->setStyleSheet( QStringLiteral(
"background-color: rgba(255, 255, 255, 0); color: black; text-decoration: underline;" ) );
364 btnEnableMacros->setCursor( Qt::PointingHandCursor );
365 btnEnableMacros->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred );
368 tr(
"Security warning" ),
369 tr(
"Python macros cannot currently be run." ),
371 Qgis::MessageLevel::Warning,
375 connect( btnEnableMacros, &QToolButton::clicked, messageBar, [ = ]()
392 void QgsGui::emitOptionsChanged()
This class keeps a list of data item GUI providers that may affect how QgsDataItems behave within the...
static QgsEditorWidgetRegistry * editorWidgetRegistry()
Returns the global editor widget registry, used for managing all known edit widget factories.
static bool pythonMacroAllowed(void(*lambda)()=nullptr, QgsMessageBar *messageBar=nullptr)
Returns true if python macros are currently allowed to be run If the global option is to ask user,...
This class keeps a list of source select providers that may add items to the QgsDataSourceManagerDial...
static QgsSettingsRegistryGui * settingsRegistryGui()
Returns the gui's settings registry, used for managing gui settings.
static QColor sampleColor(QPoint point)
Samples the color on screen at the specified global point (pixel).
A registry of color schemes for use in QgsCodeEditor widgets.
@ SessionOnly
Only during this session.
@ HigMenuTextIsTitleCase
Menu action texts should be title case.
static void setWindowManager(QgsWindowManagerInterface *manager)
Sets the global window manager.
PythonMacroMode
Vector layer type flags.
static QgsMapLayerActionRegistry * mapLayerActionRegistry()
Returns the global map layer action registry, used for registering map layer actions.
Registry of available annotation item GUI behavior.
static QgsProviderGuiRegistry * providerGuiRegistry()
Returns the registry of GUI-related components of data providers.
static QgsWindowManagerInterface * windowManager()
Returns the global window manager, if set.
void initializeFromProviderGuiRegistry(QgsProviderGuiRegistry *providerGuiRegistry)
Initializes the registry.
void initializeFromProviderGuiRegistry(QgsProviderGuiRegistry *providerGuiRegistry)
Initializes the registry.
static QgsGui::HigFlags higFlags()
Returns the platform's HIG flags.
@ Never
Macros are never run.
This class is a composition of two QSettings instances:
@ HigDialogTitleIsTitleCase
Dialog titles should be title case.
bool popWidget(QgsMessageBarItem *item)
Remove the specified item from the bar, and display the next most recent one in the stack.
@ Always
Macros are always run.
static QgsCodeEditorColorSchemeRegistry * codeEditorColorSchemeRegistry()
Returns the global code editor color scheme registry, used for registering the color schemes for QgsC...
void addDefaultProviders()
Adds the default history providers to the registry.
Shortcuts manager is a class that contains a list of QActions and QShortcuts that have been registere...
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 QScreen * findScreenAt(QPoint point)
Returns the screen at the given global point (pixel).
@ Ask
User is prompt before running.
The QgsHistoryProviderRegistry is a registry for objects which track user history (i....
This class tracks map layer actions.
static QString iconsPath()
Returns the path to the icons image directory.
Represents an item shown within a QgsMessageBar widget.
static QgsProjectStorageGuiRegistry * projectStorageGuiRegistry()
Returns the global GUI-related project storage registry.
void pushItem(QgsMessageBarItem *item)
Display a message item on the bar, after hiding the currently visible one and putting it in a stack.
void setEnumValue(const QString &key, const T &value, const Section section=NoSection)
Set the value of a setting based on an enum.
static QgsProcessingGuiRegistry * processingGuiRegistry()
Returns the global processing gui registry, used for registering the GUI behavior of processing algor...
A bar for displaying non-blocking messages to the user.
A registry / canonical manager of GUI parts of data providers.
@ NotForThisSession
Macros will not be run for this session.
static const QgsSettingsEntryString settingsLocaleUserLocale
Settings entry locale user locale.
static QgsSubsetStringEditorProviderRegistry * subsetStringEditorProviderRegistry()
Returns the registry of subset string editors of data providers.
This class keeps a list of subset string editor providers.
static QgsLayerTreeEmbeddedWidgetRegistry * layerTreeEmbeddedWidgetRegistry()
Returns the global layer tree embedded widget registry, used for registering widgets that may be embe...
static QgsNative * nativePlatformInterface()
Returns the global native interface, which offers abstraction to the host OS's underlying public inte...
void optionsChanged()
This signal is emitted whenever the application options have been changed.
void initializeFromProviderGuiRegistry(QgsProviderGuiRegistry *providerGuiRegistry)
Initializes the registry.
static QgsDataItemGuiProviderRegistry * dataItemGuiProviderRegistry()
Returns the global data item GUI provider registry, used for tracking providers which affect the brow...
static QgsProviderSourceWidgetProviderRegistry * sourceWidgetProviderRegistry()
Returns the registry of provider source widget providers.
static QgsMapToolShapeRegistry * mapToolShapeRegistry()
Returns the registry of shape map tools.
static QgsAnnotationItemGuiRegistry * annotationItemGuiRegistry()
Returns the global annotation item GUI registry, used for registering the GUI behavior of annotation ...
static QgsGui * instance()
Returns a pointer to the singleton instance.
static QgsRelationWidgetRegistry * relationWidgetRegistry()
Returns the global relation widget registry, used for managing all known relation widget factories.
The QgsProcessingGuiRegistry is a home for widgets for processing configuration widgets.
void initializeFromProviderGuiRegistry(QgsProviderGuiRegistry *providerGuiRegistry)
Initializes the registry.
static QgsShortcutsManager * shortcutsManager()
Returns the global shortcuts manager, used for managing a QAction and QShortcut sequences.
static QgsHistoryProviderRegistry * historyProviderRegistry()
Returns the global history provider registry, used for tracking history providers.
QgsSettingsRegistryGui is used for settings introspection and collects all QgsSettingsEntry instances...
T enumValue(const QString &key, const T &defaultValue, const Section section=NoSection)
Returns the setting value for a setting based on an enum.
A registry / canonical manager of GUI parts of project storage backends.
static QgsLayoutItemGuiRegistry * layoutItemGuiRegistry()
Returns the global layout item GUI registry, used for registering the GUI behavior of layout items.
void addDefaultItems()
Populates the registry with default items.
static QgsNumericFormatGuiRegistry * numericFormatGuiRegistry()
Returns the global numeric format gui registry, used for registering the GUI widgets associated with ...
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.
static QString pluginPath()
Returns the path to the application plugin directory.
static QgsSourceSelectProviderRegistry * sourceSelectProviderRegistry()
Returns the global source select provider registry, used for managing all known source select widget ...
static QgsProcessingRecentAlgorithmLog * processingRecentAlgorithmLog()
Returns the global processing recent algorithm log, used for tracking recently used processing algori...
QgsGui is a singleton class containing various registry and other global members related to GUI class...
Registry of available layout item GUI behavior.