-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
qgsgui.cpp
157 lines (139 loc) · 4.64 KB
/
qgsgui.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
/***************************************************************************
qgsgui.cpp
----------
begin : May 2017
copyright : (C) 2017 by Nyall Dawson
email : nyall dot dawson at gmail dot com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include "qgsgui.h"
#include "qgseditorwidgetregistry.h"
#include "qgslayertreeembeddedwidgetregistry.h"
#include "qgsmaplayeractionregistry.h"
#include "qgssourceselectproviderregistry.h"
#include "qgslayoutitemregistry.h"
#include "qgslayoutitemguiregistry.h"
#include "qgslayoutviewrubberband.h"
#ifdef Q_OS_MACX
#include "qgsmacnative.h"
#elif defined (Q_OS_WIN)
#ifndef __MINGW32__
#include "qgswinnative.h"
#else
#include "qgsnative.h"
#endif
#elif defined (Q_OS_LINUX)
#include "qgslinuxnative.h"
#else
#include "qgsnative.h"
#endif
#include "qgsprocessingguiregistry.h"
#include "qgsshortcutsmanager.h"
#include "qgswidgetstatehelper_p.h"
#include "qgslogger.h"
#include "qgsprocessingrecentalgorithmlog.h"
#include "qgswindowmanagerinterface.h"
QgsGui *QgsGui::instance()
{
static QgsGui *sInstance( new QgsGui() );
return sInstance;
}
QgsNative *QgsGui::nativePlatformInterface()
{
return instance()->mNative;
}
QgsEditorWidgetRegistry *QgsGui::editorWidgetRegistry()
{
return instance()->mEditorWidgetRegistry;
}
QgsSourceSelectProviderRegistry *QgsGui::sourceSelectProviderRegistry()
{
return instance()->mSourceSelectProviderRegistry;
}
QgsShortcutsManager *QgsGui::shortcutsManager()
{
return instance()->mShortcutsManager;
}
QgsLayerTreeEmbeddedWidgetRegistry *QgsGui::layerTreeEmbeddedWidgetRegistry()
{
return instance()->mLayerTreeEmbeddedWidgetRegistry;
}
QgsMapLayerActionRegistry *QgsGui::mapLayerActionRegistry()
{
return instance()->mMapLayerActionRegistry;
}
QgsLayoutItemGuiRegistry *QgsGui::layoutItemGuiRegistry()
{
return instance()->mLayoutItemGuiRegistry;
}
QgsProcessingGuiRegistry *QgsGui::processingGuiRegistry()
{
return instance()->mProcessingGuiRegistry;
}
QgsProcessingRecentAlgorithmLog *QgsGui::processingRecentAlgorithmLog()
{
return instance()->mProcessingRecentAlgorithmLog;
}
void QgsGui::enableAutoGeometryRestore( QWidget *widget, const QString &key )
{
if ( widget->objectName().isEmpty() )
{
QgsDebugMsg( QStringLiteral( "WARNING: No object name set. Best for it to be set objectName when using QgsGui::enableAutoGeometryRestore" ) );
}
instance()->mWidgetStateHelper->registerWidget( widget, key );
}
QgsWindowManagerInterface *QgsGui::windowManager()
{
return instance()->mWindowManager.get();
}
void QgsGui::setWindowManager( QgsWindowManagerInterface *manager )
{
instance()->mWindowManager.reset( manager );
}
QgsGui::~QgsGui()
{
delete mProcessingGuiRegistry;
delete mProcessingRecentAlgorithmLog;
delete mLayoutItemGuiRegistry;
delete mLayerTreeEmbeddedWidgetRegistry;
delete mEditorWidgetRegistry;
delete mMapLayerActionRegistry;
delete mSourceSelectProviderRegistry;
delete mShortcutsManager;
delete mNative;
delete mWidgetStateHelper;
}
QgsGui::QgsGui()
{
#ifdef Q_OS_MAC
QgsMacNative *macNative = new QgsMacNative();
macNative->setIconPath( QgsApplication::iconsPath() + QStringLiteral( "qgis-icon-macos.png" ) );
mNative = macNative;
#elif defined (Q_OS_WIN)
#ifndef __MINGW32__
mNative = new QgsWinNative();
#else
mNative = new QgsNative();
#endif
#elif defined(Q_OS_LINUX)
mNative = new QgsLinuxNative();
#else
mNative = new QgsNative();
#endif
mEditorWidgetRegistry = new QgsEditorWidgetRegistry();
mShortcutsManager = new QgsShortcutsManager();
mLayerTreeEmbeddedWidgetRegistry = new QgsLayerTreeEmbeddedWidgetRegistry();
mMapLayerActionRegistry = new QgsMapLayerActionRegistry();
mSourceSelectProviderRegistry = new QgsSourceSelectProviderRegistry();
mLayoutItemGuiRegistry = new QgsLayoutItemGuiRegistry();
mWidgetStateHelper = new QgsWidgetStateHelper();
mProcessingRecentAlgorithmLog = new QgsProcessingRecentAlgorithmLog();
mProcessingGuiRegistry = new QgsProcessingGuiRegistry();
}