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"
50 #include "qgssettings.h"
52 #include "qgsgdalguiprovider.h"
53 #include "qgsogrguiprovider.h"
78 return instance()->mEditorWidgetRegistry;
83 return instance()->mRelationEditorRegistry;
88 return instance()->mSourceSelectProviderRegistry;
93 return instance()->mSubsetStringEditorProviderRegistry;
98 return instance()->mProviderSourceWidgetProviderRegistry;
103 return instance()->mShortcutsManager;
108 return instance()->mLayerTreeEmbeddedWidgetRegistry;
113 return instance()->mMapLayerActionRegistry;
118 return instance()->mLayoutItemGuiRegistry;
123 return instance()->mProcessingGuiRegistry;
128 return instance()->mNumericFormatGuiRegistry;
133 return instance()->mCodeEditorColorSchemeRegistry;
138 return instance()->mProcessingRecentAlgorithmLog;
143 return instance()->mDataItemGuiProviderRegistry;
148 return instance()->mProjectStorageGuiRegistry;
153 return instance()->mProviderGuiRegistry;
158 if ( widget->objectName().isEmpty() )
160 QgsDebugMsg( QStringLiteral(
"WARNING: No object name set. Best for it to be set objectName when using QgsGui::enableAutoGeometryRestore" ) );
167 return instance()->mWindowManager.get();
172 instance()->mWindowManager.reset( manager );
183 return QgsGui::HigFlags();
189 delete mProcessingGuiRegistry;
190 delete mDataItemGuiProviderRegistry;
191 delete mProcessingRecentAlgorithmLog;
192 delete mLayoutItemGuiRegistry;
193 delete mLayerTreeEmbeddedWidgetRegistry;
194 delete mEditorWidgetRegistry;
195 delete mMapLayerActionRegistry;
196 delete mSourceSelectProviderRegistry;
197 delete mShortcutsManager;
199 delete mNumericFormatGuiRegistry;
200 delete mWidgetStateHelper;
201 delete mProjectStorageGuiRegistry;
202 delete mProviderGuiRegistry;
203 delete mCodeEditorColorSchemeRegistry;
204 delete mSubsetStringEditorProviderRegistry;
205 delete mProviderSourceWidgetProviderRegistry;
206 delete mRelationEditorRegistry;
216 QPixmap snappedPixmap = screen->grabWindow( QApplication::desktop()->winId(), point.x(), point.y(), 1, 1 );
217 QImage snappedImage = snappedPixmap.toImage();
218 return snappedImage.pixel( 0, 0 );
223 const QList< QScreen * > screens = QGuiApplication::screens();
224 for ( QScreen *screen : screens )
226 if ( screen->geometry().contains( point ) )
237 QgsMacNative *macNative =
new QgsMacNative();
240 #elif defined (Q_OS_WIN)
242 mNative =
new QgsWinNative();
244 mNative =
new QgsNative();
246 #elif defined(Q_OS_LINUX)
247 mNative =
new QgsLinuxNative();
249 mNative =
new QgsNative();
276 mProcessingRecentAlgorithmLog =
new QgsProcessingRecentAlgorithmLog();
296 tr(
"Python macros are currently disabled and will not be run" ),
297 Qgis::MessageLevel::Warning );
303 QMessageBox msgBox( QMessageBox::Information, tr(
"Python Macros" ),
304 tr(
"Python macros are currently disabled. Do you allow this macro to run?" ) );
305 QAbstractButton *stopSessionButton = msgBox.addButton( tr(
"Don't Ask Anymore" ), QMessageBox::DestructiveRole );
306 msgBox.addButton( tr(
"No" ), QMessageBox::NoRole );
307 QAbstractButton *yesButton = msgBox.addButton( tr(
"Yes" ), QMessageBox::YesRole );
310 QAbstractButton *clicked = msgBox.clickedButton();
311 if ( clicked == stopSessionButton )
315 return clicked == yesButton;
320 Q_ASSERT( messageBar );
323 QToolButton *btnEnableMacros =
new QToolButton();
324 btnEnableMacros->setText( tr(
"Enable Macros" ) );
325 btnEnableMacros->setStyleSheet( QStringLiteral(
"background-color: rgba(255, 255, 255, 0); color: black; text-decoration: underline;" ) );
326 btnEnableMacros->setCursor( Qt::PointingHandCursor );
327 btnEnableMacros->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred );
330 tr(
"Security warning" ),
331 tr(
"Python macros cannot currently be run." ),
333 Qgis::MessageLevel::Warning,
337 connect( btnEnableMacros, &QToolButton::clicked, messageBar, [ = ]()
354 void QgsGui::emitOptionsChanged()
PythonMacroMode
Authorisation to run Python Macros.
@ Always
Macros are always run.
@ NotForThisSession
Macros will not be run for this session.
@ Never
Macros are never run.
@ Ask
User is prompt before running.
@ SessionOnly
Only during this session.
static QString pluginPath()
Returns the path to the application plugin directory.
static QString iconsPath()
Returns the path to the icons image directory.
static const QgsSettingsEntryString settingsLocaleUserLocale
Settings entry locale user locale.
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 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 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,...
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 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 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...
@ HigMenuTextIsTitleCase
Menu action texts should be title case.
@ HigDialogTitleIsTitleCase
Dialog titles should be title case.
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...
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 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 QColor sampleColor(QPoint point)
Samples the color on screen at the specified global point (pixel).
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.
A registry / canonical manager of GUI parts of data providers.
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.
This class keeps a list of subset string editor providers.
void initializeFromProviderGuiRegistry(QgsProviderGuiRegistry *providerGuiRegistry)
Initializes the registry.