QGIS API Documentation  3.0.2-Girona (307d082)
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
31 #include "qgsshortcutsmanager.h"
32 #include "qgswidgetstatehelper_p.h"
33 #include "qgslogger.h"
34 
36 {
37  static QgsGui *sInstance( new QgsGui() );
38  return sInstance;
39 }
40 
42 {
43  return instance()->mNative;
44 }
45 
47 {
48  return instance()->mEditorWidgetRegistry;
49 }
50 
52 {
53  return instance()->mSourceSelectProviderRegistry;
54 }
55 
57 {
58  return instance()->mShortcutsManager;
59 }
60 
62 {
63  return instance()->mLayerTreeEmbeddedWidgetRegistry;
64 }
65 
67 {
68  return instance()->mMapLayerActionRegistry;
69 }
70 
71 QgsLayoutItemGuiRegistry *QgsGui::layoutItemGuiRegistry()
72 {
73  return instance()->mLayoutItemGuiRegistry;
74 }
75 
76 void QgsGui::enableAutoGeometryRestore( QWidget *widget, const QString &key )
77 {
78  if ( widget->objectName().isEmpty() )
79  {
80  QgsDebugMsg( "WARNING: No object name set. Best for it to be set objectName when using QgsGui::enableAutoGeometryRestore" );
81  }
82  instance()->mWidgetStateHelper->registerWidget( widget, key );
83 }
84 
86 {
87  delete mLayoutItemGuiRegistry;
88  delete mLayerTreeEmbeddedWidgetRegistry;
89  delete mEditorWidgetRegistry;
90  delete mMapLayerActionRegistry;
91  delete mSourceSelectProviderRegistry;
92  delete mShortcutsManager;
93  delete mNative;
94  delete mWidgetStateHelper;
95 }
96 
98 {
99 #ifdef Q_OS_MAC
100  mNative = new QgsMacNative();
101 #else
102  mNative = new QgsNative();
103 #endif
104 
105  mEditorWidgetRegistry = new QgsEditorWidgetRegistry();
106  mShortcutsManager = new QgsShortcutsManager();
107  mLayerTreeEmbeddedWidgetRegistry = new QgsLayerTreeEmbeddedWidgetRegistry();
108  mMapLayerActionRegistry = new QgsMapLayerActionRegistry();
109  mSourceSelectProviderRegistry = new QgsSourceSelectProviderRegistry();
110  mLayoutItemGuiRegistry = new QgsLayoutItemGuiRegistry();
111  mWidgetStateHelper = new QgsWidgetStateHelper();
112 }
static QgsNative * nativePlatformInterface()
Returns the global native interface, which offers abstraction to the host OS's underlying public inte...
Definition: qgsgui.cpp:41
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:40
static QgsSourceSelectProviderRegistry * sourceSelectProviderRegistry()
Returns the global source select provider registry, used for managing all known source select widget ...
Definition: qgsgui.cpp:51
Shortcuts manager is a class that contains a list of QActions and QShortcuts that have been registere...
~QgsGui()
Definition: qgsgui.cpp:85
static QgsGui * instance()
Returns a pointer to the singleton instance.
Definition: qgsgui.cpp:35
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:56
static QgsLayoutItemGuiRegistry * layoutItemGuiRegistry()
Returns the global layout item GUI registry, used for registering the GUI behavior of layout items...
Definition: qgsgui.cpp:71
static QgsLayerTreeEmbeddedWidgetRegistry * layerTreeEmbeddedWidgetRegistry()
Returns the global layer tree embedded widget registry, used for registering widgets that may be embe...
Definition: qgsgui.cpp:61
static QgsEditorWidgetRegistry * editorWidgetRegistry()
Returns the global editor widget registry, used for managing all known edit widget factories...
Definition: qgsgui.cpp:46
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:76
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:66