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" 74 return instance()->mEditorWidgetRegistry;
79 return instance()->mSourceSelectProviderRegistry;
84 return instance()->mShortcutsManager;
89 return instance()->mLayerTreeEmbeddedWidgetRegistry;
94 return instance()->mMapLayerActionRegistry;
99 return instance()->mLayoutItemGuiRegistry;
104 return instance()->mProcessingGuiRegistry;
109 return instance()->mProcessingRecentAlgorithmLog;
114 return instance()->mDataItemGuiProviderRegistry;
119 return instance()->mProjectStorageGuiRegistry;
124 return instance()->mProviderGuiRegistry;
129 if ( widget->objectName().isEmpty() )
131 QgsDebugMsg( QStringLiteral(
"WARNING: No object name set. Best for it to be set objectName when using QgsGui::enableAutoGeometryRestore" ) );
138 return instance()->mWindowManager.get();
143 instance()->mWindowManager.reset( manager );
149 if ( settings.
value( QStringLiteral(
"locale/userLocale" ), QString() ).toString().startsWith( QLatin1String(
"en" ) ) )
161 delete mProcessingGuiRegistry;
162 delete mDataItemGuiProviderRegistry;
163 delete mProcessingRecentAlgorithmLog;
164 delete mLayoutItemGuiRegistry;
165 delete mLayerTreeEmbeddedWidgetRegistry;
166 delete mEditorWidgetRegistry;
167 delete mMapLayerActionRegistry;
168 delete mSourceSelectProviderRegistry;
169 delete mShortcutsManager;
171 delete mWidgetStateHelper;
172 delete mProjectStorageGuiRegistry;
173 delete mProviderGuiRegistry;
183 QPixmap snappedPixmap = screen->grabWindow( QApplication::desktop()->winId(), point.x(), point.y(), 1, 1 );
184 QImage snappedImage = snappedPixmap.toImage();
185 return snappedImage.pixel( 0, 0 );
190 const QList< QScreen * > screens = QGuiApplication::screens();
191 for ( QScreen *screen : screens )
193 if ( screen->geometry().contains( point ) )
204 QgsMacNative *macNative =
new QgsMacNative();
207 #elif defined (Q_OS_WIN) 209 mNative =
new QgsWinNative();
211 mNative =
new QgsNative();
213 #elif defined(Q_OS_LINUX) 214 mNative =
new QgsLinuxNative();
216 mNative =
new QgsNative();
235 mProcessingRecentAlgorithmLog =
new QgsProcessingRecentAlgorithmLog();
245 case Qgis::PythonMacroMode::SessionOnly:
246 case Qgis::PythonMacroMode::Always:
250 case Qgis::PythonMacroMode::Never:
251 case Qgis::PythonMacroMode::NotForThisSession:
255 tr(
"Python macros are currently disabled and will not be run" ),
256 Qgis::MessageLevel::Warning );
259 case Qgis::PythonMacroMode::Ask:
262 QMessageBox msgBox( QMessageBox::Information, tr(
"Python Macros" ),
263 tr(
"Python macros are currently disabled. Do you allow this macro to run?" ) );
264 QAbstractButton *stopSessionButton = msgBox.addButton( tr(
"Don't Ask Anymore" ), QMessageBox::DestructiveRole );
265 msgBox.addButton( tr(
"No" ), QMessageBox::NoRole );
266 QAbstractButton *yesButton = msgBox.addButton( tr(
"Yes" ), QMessageBox::YesRole );
269 QAbstractButton *clicked = msgBox.clickedButton();
270 if ( clicked == stopSessionButton )
274 return clicked == yesButton;
279 Q_ASSERT( messageBar );
282 QToolButton *btnEnableMacros =
new QToolButton();
283 btnEnableMacros->setText( tr(
"Enable Macros" ) );
284 btnEnableMacros->setStyleSheet( QStringLiteral(
"background-color: rgba(255, 255, 255, 0); color: black; text-decoration: underline;" ) );
285 btnEnableMacros->setCursor( Qt::PointingHandCursor );
286 btnEnableMacros->setSizePolicy( QSizePolicy::Maximum, QSizePolicy::Preferred );
289 tr(
"Security warning" ),
290 tr(
"Python macros cannot currently be run." ),
296 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.
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.