QGIS API Documentation  3.2.0-Bonn (bc43194)
qgsgui.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsgui.cpp
3  ----------
4  begin : May 2017
5  copyright : (C) 2017 by Nyall Dawson
6  email : nyall dot dawson at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include "qgsgui.h"
23 #include "qgslayoutitemregistry.h"
24 #include "qgslayoutitemguiregistry.h"
25 #include "qgslayoutviewrubberband.h"
26 #ifdef Q_OS_MACX
27 #include "qgsmacnative.h"
28 #else
29 #include "qgsnative.h"
30 #endif
32 #include "qgsshortcutsmanager.h"
33 #include "qgswidgetstatehelper_p.h"
34 #include "qgslogger.h"
35 
37 {
38  static QgsGui *sInstance( new QgsGui() );
39  return sInstance;
40 }
41 
43 {
44  return instance()->mNative;
45 }
46 
48 {
49  return instance()->mEditorWidgetRegistry;
50 }
51 
53 {
54  return instance()->mSourceSelectProviderRegistry;
55 }
56 
58 {
59  return instance()->mShortcutsManager;
60 }
61 
63 {
64  return instance()->mLayerTreeEmbeddedWidgetRegistry;
65 }
66 
68 {
69  return instance()->mMapLayerActionRegistry;
70 }
71 
72 QgsLayoutItemGuiRegistry *QgsGui::layoutItemGuiRegistry()
73 {
74  return instance()->mLayoutItemGuiRegistry;
75 }
76 
78 {
79  return instance()->mProcessingGuiRegistry;
80 }
81 
82 void QgsGui::enableAutoGeometryRestore( QWidget *widget, const QString &key )
83 {
84  if ( widget->objectName().isEmpty() )
85  {
86  QgsDebugMsg( "WARNING: No object name set. Best for it to be set objectName when using QgsGui::enableAutoGeometryRestore" );
87  }
88  instance()->mWidgetStateHelper->registerWidget( widget, key );
89 }
90 
92 {
93  delete mProcessingGuiRegistry;
94  delete mLayoutItemGuiRegistry;
95  delete mLayerTreeEmbeddedWidgetRegistry;
96  delete mEditorWidgetRegistry;
97  delete mMapLayerActionRegistry;
98  delete mSourceSelectProviderRegistry;
99  delete mShortcutsManager;
100  delete mNative;
101  delete mWidgetStateHelper;
102 }
103 
105 {
106 #ifdef Q_OS_MAC
107  mNative = new QgsMacNative();
108 #else
109  mNative = new QgsNative();
110 #endif
111 
112  mEditorWidgetRegistry = new QgsEditorWidgetRegistry();
113  mShortcutsManager = new QgsShortcutsManager();
114  mLayerTreeEmbeddedWidgetRegistry = new QgsLayerTreeEmbeddedWidgetRegistry();
115  mMapLayerActionRegistry = new QgsMapLayerActionRegistry();
116  mSourceSelectProviderRegistry = new QgsSourceSelectProviderRegistry();
117  mLayoutItemGuiRegistry = new QgsLayoutItemGuiRegistry();
118  mWidgetStateHelper = new QgsWidgetStateHelper();
119  mProcessingGuiRegistry = new QgsProcessingGuiRegistry();
120 }
static QgsProcessingGuiRegistry * processingGuiRegistry()
Returns the global processing gui registry, used for registering the GUI behavior of processing algor...
Definition: qgsgui.cpp:77
static QgsNative * nativePlatformInterface()
Returns the global native interface, which offers abstraction to the host OS's underlying public inte...
Definition: qgsgui.cpp:42
This class manages all known edit widget factories.
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
QgsGui is a singleton class containing various registry and other global members related to GUI class...
Definition: qgsgui.h:41
static QgsSourceSelectProviderRegistry * sourceSelectProviderRegistry()
Returns the global source select provider registry, used for managing all known source select widget ...
Definition: qgsgui.cpp:52
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.
~QgsGui()
Definition: qgsgui.cpp:91
static QgsGui * instance()
Returns a pointer to the singleton instance.
Definition: qgsgui.cpp:36
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.
Definition: qgsgui.cpp:57
static QgsLayoutItemGuiRegistry * layoutItemGuiRegistry()
Returns the global layout item GUI registry, used for registering the GUI behavior of layout items...
Definition: qgsgui.cpp:72
static QgsLayerTreeEmbeddedWidgetRegistry * layerTreeEmbeddedWidgetRegistry()
Returns the global layer tree embedded widget registry, used for registering widgets that may be embe...
Definition: qgsgui.cpp:62
static QgsEditorWidgetRegistry * editorWidgetRegistry()
Returns the global editor widget registry, used for managing all known edit widget factories...
Definition: qgsgui.cpp:47
Registry of widgets that may be embedded into layer tree view.
This class tracks map layer actions.
This class keeps a list of source select providers that may add items to the QgsDataSourceManagerDial...
QgsWidgetStateHelper is a helper class to save and restore the geometry of QWidgets in the applicatio...
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...
Definition: qgsgui.cpp:82
void registerWidget(QWidget *widget, const QString &key=QString())
Register a widget to have it geometry state automatically saved and restored.
static QgsMapLayerActionRegistry * mapLayerActionRegistry()
Returns the global map layer action registry, used for registering map layer actions.
Definition: qgsgui.cpp:67