QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
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"
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 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,...
static QColor sampleColor(QPoint point)
Samples the color on screen at the specified global point (pixel).
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.
@ 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 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).
static QString iconsPath()
Returns the path to the icons image directory.
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...
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 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.
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...
Registry of available layout item GUI behavior.