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"    75   return instance()->mEditorWidgetRegistry;
    80   return instance()->mSourceSelectProviderRegistry;
    85   return instance()->mShortcutsManager;
    90   return instance()->mLayerTreeEmbeddedWidgetRegistry;
    95   return instance()->mMapLayerActionRegistry;
   100   return instance()->mLayoutItemGuiRegistry;
   105   return instance()->mProcessingGuiRegistry;
   110   return instance()->mNumericFormatGuiRegistry;
   115   return instance()->mProcessingRecentAlgorithmLog;
   120   return instance()->mDataItemGuiProviderRegistry;
   125   return instance()->mProjectStorageGuiRegistry;
   130   return instance()->mProviderGuiRegistry;
   135   if ( widget->objectName().isEmpty() )
   137     QgsDebugMsg( QStringLiteral( 
"WARNING: No object name set. Best for it to be set objectName when using QgsGui::enableAutoGeometryRestore" ) );
   144   return instance()->mWindowManager.get();
   149   instance()->mWindowManager.reset( manager );
   155   if ( settings.
value( QStringLiteral( 
"locale/userLocale" ), QString() ).toString().startsWith( QLatin1String( 
"en" ) ) )
   167   delete mProcessingGuiRegistry;
   168   delete mDataItemGuiProviderRegistry;
   169   delete mProcessingRecentAlgorithmLog;
   170   delete mLayoutItemGuiRegistry;
   171   delete mLayerTreeEmbeddedWidgetRegistry;
   172   delete mEditorWidgetRegistry;
   173   delete mMapLayerActionRegistry;
   174   delete mSourceSelectProviderRegistry;
   175   delete mShortcutsManager;
   177   delete mNumericFormatGuiRegistry;
   178   delete mWidgetStateHelper;
   179   delete mProjectStorageGuiRegistry;
   180   delete mProviderGuiRegistry;
   190   QPixmap snappedPixmap = screen->grabWindow( QApplication::desktop()->winId(), point.x(), point.y(), 1, 1 );
   191   QImage snappedImage = snappedPixmap.toImage();
   192   return snappedImage.pixel( 0, 0 );
   197   const QList< QScreen * > screens = QGuiApplication::screens();
   198   for ( QScreen *screen : screens )
   200     if ( screen->geometry().contains( point ) )
   211   QgsMacNative *macNative = 
new QgsMacNative();
   214 #elif defined (Q_OS_WIN)   216   mNative = 
new QgsWinNative();
   218   mNative = 
new QgsNative();
   220 #elif defined(Q_OS_LINUX)   221   mNative = 
new QgsLinuxNative();
   223   mNative = 
new QgsNative();
   243   mProcessingRecentAlgorithmLog = 
new QgsProcessingRecentAlgorithmLog();
   253     case Qgis::PythonMacroMode::SessionOnly:
   254     case Qgis::PythonMacroMode::Always:
   258     case Qgis::PythonMacroMode::Never:
   259     case Qgis::PythonMacroMode::NotForThisSession:
   263                                  tr( 
"Python macros are currently disabled and will not be run" ),
   264                                  Qgis::MessageLevel::Warning );
   267     case Qgis::PythonMacroMode::Ask:
   270         QMessageBox msgBox( QMessageBox::Information, tr( 
"Python Macros" ),
   271                             tr( 
"Python macros are currently disabled. Do you allow this macro to run?" ) );
   272         QAbstractButton *stopSessionButton = msgBox.addButton( tr( 
"Don't Ask Anymore" ), QMessageBox::DestructiveRole );
   273         msgBox.addButton( tr( 
"No" ), QMessageBox::NoRole );
   274         QAbstractButton *yesButton = msgBox.addButton( tr( 
"Yes" ), QMessageBox::YesRole );
   277         QAbstractButton *clicked = msgBox.clickedButton();
   278         if ( clicked == stopSessionButton )
   282         return clicked == yesButton;
   287         Q_ASSERT( messageBar );
   290           QToolButton *btnEnableMacros = 
new QToolButton();
   291           btnEnableMacros->setText( tr( 
"Enable Macros" ) );
   292           btnEnableMacros->setStyleSheet( QStringLiteral( 
"background-color: rgba(255, 255, 255, 0); color: black; text-decoration: underline;" ) );
   293           btnEnableMacros->setCursor( Qt::PointingHandCursor );
   294           btnEnableMacros->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred );
   297             tr( 
"Security warning" ),
   298             tr( 
"Python macros cannot currently be run." ),
   304           connect( btnEnableMacros, &QToolButton::clicked, messageBar, [ = ]()
 static QgsProviderGuiRegistry * providerGuiRegistry()
Returns the registry of GUI-related components of data providers. 
 
static QgsProcessingGuiRegistry * processingGuiRegistry()
Returns the global processing gui registry, used for registering the GUI behavior of processing algor...
 
static QgsWindowManagerInterface * windowManager()
Returns the global window manager, if set. 
 
A registry / canonical manager of GUI parts of project storage backends. 
 
This class is a composition of two QSettings instances: 
 
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...
 
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key. 
 
QgsGui is a singleton class containing various registry and other global members related to GUI class...
 
static QgsDataItemGuiProviderRegistry * dataItemGuiProviderRegistry()
Returns the global data item GUI provider registry, used for tracking providers which affect the brow...
 
static QgsSourceSelectProviderRegistry * sourceSelectProviderRegistry()
Returns the global source select provider registry, used for managing all known source select widget ...
 
A bar for displaying non-blocking messages to the user. 
 
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...
 
Shortcuts manager is a class that contains a list of QActions and QShortcuts that have been registere...
 
The QgsProcessingGuiRegistry is a home for widgets for processing configuration widgets. 
 
void initializeFromProviderGuiRegistry(QgsProviderGuiRegistry *providerGuiRegistry)
Initializes the registry. 
 
Registry of available layout item GUI behavior. 
 
static QgsGui * instance()
Returns a pointer to the singleton instance. 
 
static QgsProjectStorageGuiRegistry * projectStorageGuiRegistry()
Returns the global GUI-related project storage registry. 
 
void initializeFromProviderGuiRegistry(QgsProviderGuiRegistry *providerGuiRegistry)
Initializes the registry. 
 
QgsGui(const QgsGui &other)=delete
QgsGui cannot be copied. 
 
static QgsShortcutsManager * shortcutsManager()
Returns the global shortcuts manager, used for managing a QAction and QShortcut sequences. 
 
void initializeFromProviderGuiRegistry(QgsProviderGuiRegistry *providerGuiRegistry)
Initializes the registry. 
 
static QgsLayoutItemGuiRegistry * layoutItemGuiRegistry()
Returns the global layout item GUI registry, used for registering the GUI behavior of layout items...
 
static QString pluginPath()
Returns the path to the application plugin directory. 
 
static QgsNumericFormatGuiRegistry * numericFormatGuiRegistry()
Returns the global numeric format gui registry, used for registering the GUI widgets associated with ...
 
bool popWidget(QgsMessageBarItem *item)
Remove the passed widget from the bar (if previously added), then display the next one in the stack i...
 
static QgsLayerTreeEmbeddedWidgetRegistry * layerTreeEmbeddedWidgetRegistry()
Returns the global layer tree embedded widget registry, used for registering widgets that may be embe...
 
static QgsEditorWidgetRegistry * editorWidgetRegistry()
Returns the global editor widget registry, used for managing all known edit widget factories...
 
static QgsProcessingRecentAlgorithmLog * processingRecentAlgorithmLog()
Returns the global processing recent algorithm log, used for tracking recently used processing algori...
 
void pushMessage(const QString &text, Qgis::MessageLevel level=Qgis::Info, int duration=5)
convenience method for pushing a message to the bar 
 
This class tracks map layer actions. 
 
This class keeps a list of source select providers that may add items to the QgsDataSourceManagerDial...
 
This class keeps a list of data item GUI providers that may affect how QgsDataItems behave within the...
 
Menu action texts should be title case. 
 
static void setWindowManager(QgsWindowManagerInterface *manager)
Sets the global window manager. 
 
void setEnumValue(const QString &key, const T &value, const Section section=NoSection)
Set the value of a setting based on an enum. 
 
void pushItem(QgsMessageBarItem *item)
Display a message item on the bar after hiding the currently visible one and putting it in a stack...
 
static QgsGui::HigFlags higFlags()
Returns the platform's HIG flags. 
 
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...
 
PythonMacroMode
Authorisation to run Python Macros. 
 
T enumValue(const QString &key, const T &defaultValue, const Section section=NoSection)
Returns the setting value for a setting based on an enum. 
 
static QScreen * findScreenAt(QPoint point)
Returns the screen at the given global point (pixel). 
 
static QString iconsPath()
Returns the path to the icons image directory. 
 
static QgsMapLayerActionRegistry * mapLayerActionRegistry()
Returns the global map layer action registry, used for registering map layer actions. 
 
static QColor sampleColor(QPoint point)
Samples the color on screen at the specified global point (pixel). 
 
A registry / canonical manager of GUI parts of data providers.