-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathqtcdeveloperplugin.cpp
More file actions
executable file
·121 lines (101 loc) · 4.41 KB
/
qtcdeveloperplugin.cpp
File metadata and controls
executable file
·121 lines (101 loc) · 4.41 KB
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
/* Copyright 2016-2020 Pascal COMBES <pascom@orange.fr>
*
* This file is part of QtcDevPlugin.
*
* QtcDevPlugin 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 3 of the License, or
* (at your option) any later version.
*
* QtcDevPlugin is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with QtcDevPlugin. If not, see <http://www.gnu.org/licenses/>
*/
#include "qtcdeveloperplugin.h"
#include "qtcdevpluginconstants.h"
#include "cmakeqtcrunconfigurationfactory.h"
#include "qmakeqtcrunconfigurationfactory.h"
#include "qtcrunconfiguration.h"
#include "qtctestrunconfiguration.h"
#include "qtcrunworkerfactory.h"
#ifdef BUILD_TESTS
# include "Test/qtcrunconfigurationfactorytest.h"
# include "Test/qtcrunconfigurationtest.h"
# include "Test/qtcpluginrunnertest.h"
#endif
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/runcontrol.h>
#include <debugger/debuggerruncontrol.h>
#include <coreplugin/icore.h>
#include <extensionsystem/pluginmanager.h>
#include <QtCore>
using namespace QtcDevPlugin::Internal;
QtcDeveloperPlugin::QtcDeveloperPlugin()
{
// Create your members
#ifdef BUILD_TESTS
addTest<Test::QtcRunConfigurationFactoryTest>();
addTest<Test::QtcRunConfigurationTest>();
addTest<Test::QtcPluginRunnerTest>();
#endif
}
QtcDeveloperPlugin::~QtcDeveloperPlugin()
{
// Unregister objects from the plugin manager's object pool
// Delete members
qDeleteAll(mRunConfigurationFactories);
qDeleteAll(mRunWorkerFactories);
}
Utils::Result<> QtcDeveloperPlugin::initialize(const QStringList& arguments)
{
// Register objects in the plugin manager's object pool
// Load settings
// Add actions to menus
// Connect to other plugins' signals
// In the initialize function, a plugin can be sure that the plugins it
// depends on have initialized their members.
Q_UNUSED(arguments)
// Locate QM file for the current language and use it
QString qmFile = Core::ICore::userInterfaceLanguage();
if (qmFile.isEmpty())
qmFile = QLatin1String("en");
else
qmFile = qmFile.left(2);
qmFile = QString(QLatin1String("qtcdevplugin_%1.qm")).arg(qmFile);
QTranslator *translator = new QTranslator(this);
if (translator->load(qmFile, Core::ICore::resourcePath("translations").nativePath()) ||
translator->load(qmFile, Core::ICore::userResourcePath("translations").nativePath())) {
if (!qApp->installTranslator(translator))
qWarning() << qPrintable(QString(QLatin1String("Failed to install translator (%1)")).arg(qmFile));
} else {
qWarning() << qPrintable(QString(QLatin1String("Translator file \"%1\" not found")).arg(qmFile));
}
mRunConfigurationFactories << new CMakeQtcRunConfigurationFactory<QtcRunConfiguration>();
mRunConfigurationFactories << new CMakeQtcRunConfigurationFactory<QtcTestRunConfiguration>();
mRunConfigurationFactories << new QMakeQtcRunConfigurationFactory<QtcRunConfiguration>();
mRunConfigurationFactories << new QMakeQtcRunConfigurationFactory<QtcTestRunConfiguration>();
mRunWorkerFactories << new QtcRunWorkerFactory(ProjectExplorer::Constants::NORMAL_RUN_MODE, [] (ProjectExplorer::RunControl* runControl) {
return ProjectExplorer::processRecipe(runControl);
});
mRunWorkerFactories << new QtcRunWorkerFactory(ProjectExplorer::Constants::DEBUG_RUN_MODE, [] (ProjectExplorer::RunControl* runControl) {
return Debugger::debuggerRecipe(runControl, Debugger::DebuggerRunParameters::fromRunControl(runControl));
});
return Utils::ResultOk;
}
void QtcDeveloperPlugin::extensionsInitialized()
{
// Retrieve objects from the plugin manager's object pool
// In the extensionsInitialized function, a plugin can be sure that all
// plugins that depend on it are completely initialized.
}
ExtensionSystem::IPlugin::ShutdownFlag QtcDeveloperPlugin::aboutToShutdown()
{
// Save settings
// Disconnect from signals that are not needed during shutdown
// Hide UI (if you add UI that is not in the main window directly)
return SynchronousShutdown;
}