QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
20 #include <QDesktopWidget>
21 #include <QMessageBox>
32 #include "qgsmacnative.h"
33 #elif defined (Q_OS_WIN)
35 #include "qgswinnative.h"
37 #include "qgsnative.h"
39 #elif defined (Q_OS_LINUX)
40 #include "qgslinuxnative.h"
42 #include "qgsnative.h"
52 #include "qgsgdalguiprovider.h"
53 #include "qgsogrguiprovider.h"
76 return instance()->mEditorWidgetRegistry;
81 return instance()->mSourceSelectProviderRegistry;
86 return instance()->mShortcutsManager;
91 return instance()->mLayerTreeEmbeddedWidgetRegistry;
96 return instance()->mMapLayerActionRegistry;
101 return instance()->mLayoutItemGuiRegistry;
106 return instance()->mProcessingGuiRegistry;
111 return instance()->mNumericFormatGuiRegistry;
116 return instance()->mCodeEditorColorSchemeRegistry;
121 return instance()->mProcessingRecentAlgorithmLog;
126 return instance()->mDataItemGuiProviderRegistry;
131 return instance()->mProjectStorageGuiRegistry;
136 return instance()->mProviderGuiRegistry;
141 if ( widget->objectName().isEmpty() )
143 QgsDebugMsg( QStringLiteral(
"WARNING: No object name set. Best for it to be set objectName when using QgsGui::enableAutoGeometryRestore" ) );
150 return instance()->mWindowManager.get();
155 instance()->mWindowManager.reset( manager );
161 if ( settings.
value( QStringLiteral(
"locale/userLocale" ), QString() ).toString().startsWith( QLatin1String(
"en" ) ) )
167 return QgsGui::HigFlags();
173 delete mProcessingGuiRegistry;
174 delete mDataItemGuiProviderRegistry;
175 delete mProcessingRecentAlgorithmLog;
176 delete mLayoutItemGuiRegistry;
177 delete mLayerTreeEmbeddedWidgetRegistry;
178 delete mEditorWidgetRegistry;
179 delete mMapLayerActionRegistry;
180 delete mSourceSelectProviderRegistry;
181 delete mShortcutsManager;
183 delete mNumericFormatGuiRegistry;
184 delete mWidgetStateHelper;
185 delete mProjectStorageGuiRegistry;
186 delete mProviderGuiRegistry;
187 delete mCodeEditorColorSchemeRegistry;
197 QPixmap snappedPixmap = screen->grabWindow( QApplication::desktop()->winId(), point.x(), point.y(), 1, 1 );
198 QImage snappedImage = snappedPixmap.toImage();
199 return snappedImage.pixel( 0, 0 );
204 const QList< QScreen * > screens = QGuiApplication::screens();
205 for ( QScreen *screen : screens )
207 if ( screen->geometry().contains( point ) )
218 QgsMacNative *macNative =
new QgsMacNative();
221 #elif defined (Q_OS_WIN)
223 mNative =
new QgsWinNative();
225 mNative =
new QgsNative();
227 #elif defined(Q_OS_LINUX)
228 mNative =
new QgsLinuxNative();
230 mNative =
new QgsNative();
252 mProcessingRecentAlgorithmLog =
new QgsProcessingRecentAlgorithmLog();
262 case Qgis::PythonMacroMode::SessionOnly:
263 case Qgis::PythonMacroMode::Always:
267 case Qgis::PythonMacroMode::Never:
268 case Qgis::PythonMacroMode::NotForThisSession:
272 tr(
"Python macros are currently disabled and will not be run" ),
273 Qgis::MessageLevel::Warning );
276 case Qgis::PythonMacroMode::Ask:
279 QMessageBox msgBox( QMessageBox::Information, tr(
"Python Macros" ),
280 tr(
"Python macros are currently disabled. Do you allow this macro to run?" ) );
281 QAbstractButton *stopSessionButton = msgBox.addButton( tr(
"Don't Ask Anymore" ), QMessageBox::DestructiveRole );
282 msgBox.addButton( tr(
"No" ), QMessageBox::NoRole );
283 QAbstractButton *yesButton = msgBox.addButton( tr(
"Yes" ), QMessageBox::YesRole );
286 QAbstractButton *clicked = msgBox.clickedButton();
287 if ( clicked == stopSessionButton )
291 return clicked == yesButton;
296 Q_ASSERT( messageBar );
299 QToolButton *btnEnableMacros =
new QToolButton();
300 btnEnableMacros->setText( tr(
"Enable Macros" ) );
301 btnEnableMacros->setStyleSheet( QStringLiteral(
"background-color: rgba(255, 255, 255, 0); color: black; text-decoration: underline;" ) );
302 btnEnableMacros->setCursor( Qt::PointingHandCursor );
303 btnEnableMacros->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred );
306 tr(
"Security warning" ),
307 tr(
"Python macros cannot currently be run." ),
313 connect( btnEnableMacros, &QToolButton::clicked, messageBar, [ = ]()
330 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 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.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
@ HigMenuTextIsTitleCase
Menu action texts should be title case.
static void setWindowManager(QgsWindowManagerInterface *manager)
Sets the global window manager.
static QgsMapLayerActionRegistry * mapLayerActionRegistry()
Returns the global map layer action registry, used for registering map layer actions.
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.
static QgsGui::HigFlags higFlags()
Returns the platform's HIG flags.
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.
static QgsCodeEditorColorSchemeRegistry * codeEditorColorSchemeRegistry()
Returns the global code editor color scheme registry, used for registering the color schemes for QgsC...
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).
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.
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 QgsGui * instance()
Returns a pointer to the singleton instance.
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.
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.
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::Info, int duration=5)
A convenience method for pushing a message with the specified text to the bar.
PythonMacroMode
Authorisation to run Python Macros.
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.