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
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljsbundleprovider.h"
#include "qmljscodestylesettings.h"
#include "qmljsfunctionfilter.h"
#include "qmljsmodelmanager.h"
#include "qmljstoolsconstants.h"
#include "qmljstoolssettings.h"
#include "qmljstoolstr.h"
#include "qmljstools_test.h"
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/icontext.h>
#include <coreplugin/icore.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <extensionsystem/iplugin.h>
#include <projectexplorer/devicesupport/idevice.h>
#include <qmljseditor/qmljseditorconstants.h>
#include <QMenu>
using namespace Core;
using namespace ProjectExplorer;
namespace QmlJSTools::Internal {
class QmlRuntimeToolFactory : public DeviceToolAspectFactory
{
public:
QmlRuntimeToolFactory()
{
setToolId(Constants::QML_TOOL_ID);
setToolType(DeviceToolAspect::RunTool);
setFilePattern({"qml"});
setLabelText(Tr::tr("QML runtime executable:"));
setToolTip(Tr::tr("The QML runtime executable to use on the device."));
}
};
class QmlJSToolsPluginPrivate : public QObject
{
public:
QmlJSToolsPluginPrivate();
ModelManager modelManager;
QAction resetCodeModelAction{Tr::tr("Reset Code Model"), nullptr};
QmlJSCodeStyleSettingsPage codeStyleSettingsPage;
BasicBundleProvider basicBundleProvider;
QmlRuntimeToolFactory qmlRuntimeToolFactory;
};
QmlJSToolsPluginPrivate::QmlJSToolsPluginPrivate()
{
// Menus
ActionContainer *mtools = ActionManager::actionContainer(Core::Constants::M_TOOLS);
ActionContainer *mqmljstools = ActionManager::createMenu(Constants::M_TOOLS_QMLJS);
QMenu *menu = mqmljstools->menu();
menu->setTitle(Tr::tr("&QML/JS"));
menu->setEnabled(true);
mtools->addMenu(mqmljstools);
// Update context in global context
Command *cmd = ActionManager::registerAction(
&resetCodeModelAction, Constants::RESET_CODEMODEL);
connect(&resetCodeModelAction, &QAction::triggered,
&modelManager, &ModelManager::resetCodeModel);
mqmljstools->addAction(cmd);
// Watch task progress
connect(ProgressManager::instance(), &ProgressManager::taskStarted, this,
[this](Utils::Id type) {
if (type == QmlJS::Constants::TASK_INDEX)
resetCodeModelAction.setEnabled(false);
});
connect(ProgressManager::instance(), &ProgressManager::allTasksFinished,
[this](Utils::Id type) {
if (type == QmlJS::Constants::TASK_INDEX)
resetCodeModelAction.setEnabled(true);
});
}
class QmlJSToolsPlugin final : public ExtensionSystem::IPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "QmlJSTools.json")
public:
~QmlJSToolsPlugin() final
{
delete d;
}
private:
void initialize() final
{
IOptionsPage::registerCategory(
QmlJSEditor::Constants::SETTINGS_CATEGORY_QML,
Tr::tr("Qt Quick"),
":/qmljstools/images/settingscategory_qml.png");
#ifdef WITH_TESTS
addTestCreator(createQmlJSToolsTest);
#endif
setupQmlJSToolsSettings();
d = new QmlJSToolsPluginPrivate;
setupQmlJSFunctionsFilter();
}
void extensionsInitialized() final
{
d->modelManager.delayedInitialization();
}
QmlJSToolsPluginPrivate *d = nullptr;
};
} // QmlJSTools::Internal
#include "qmljstoolsplugin.moc"
|