forked from qt-creator/qt-creator
QmlJsEditor: Work around moc-produced 'using namepace'
... for QmlJsEditor::QmlJsEditor causing ambiguities. Change-Id: If15a0cb0410093857848b871d7f99c84b1b35826 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -51,6 +51,7 @@
|
|||||||
#include <texteditor/codeassist/genericproposal.h>
|
#include <texteditor/codeassist/genericproposal.h>
|
||||||
#include <texteditor/codeassist/genericproposalmodel.h>
|
#include <texteditor/codeassist/genericproposalmodel.h>
|
||||||
#include <texteditor/colorpreviewhoverhandler.h>
|
#include <texteditor/colorpreviewhoverhandler.h>
|
||||||
|
#include <texteditor/snippets/snippetprovider.h>
|
||||||
#include <texteditor/texteditoractionhandler.h>
|
#include <texteditor/texteditoractionhandler.h>
|
||||||
#include <texteditor/textmark.h>
|
#include <texteditor/textmark.h>
|
||||||
|
|
||||||
@@ -307,11 +308,6 @@ void QmlJSEditorWidget::updateOutlineIndexNow()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace QmlJSEditor
|
|
||||||
|
|
||||||
|
|
||||||
namespace QmlJSEditor {
|
|
||||||
|
|
||||||
void QmlJSEditorWidget::updateContextPane()
|
void QmlJSEditorWidget::updateContextPane()
|
||||||
{
|
{
|
||||||
const SemanticInfo info = m_qmlJsEditorDocument->semanticInfo();
|
const SemanticInfo info = m_qmlJsEditorDocument->semanticInfo();
|
||||||
@@ -1181,11 +1177,37 @@ QmlJSEditorFactory::QmlJSEditorFactory(Utils::Id _id)
|
|||||||
| TextEditorActionHandler::FindUsage);
|
| TextEditorActionHandler::FindUsage);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSEditorFactory::decorateEditor(TextEditorWidget *editor)
|
static void decorateEditor(TextEditorWidget *editor)
|
||||||
{
|
{
|
||||||
editor->textDocument()->resetSyntaxHighlighter([] { return new QmlJSHighlighter(); });
|
editor->textDocument()->resetSyntaxHighlighter([] { return new QmlJSHighlighter(); });
|
||||||
editor->textDocument()->setIndenter(createQmlJsIndenter(editor->textDocument()->document()));
|
editor->textDocument()->setIndenter(createQmlJsIndenter(editor->textDocument()->document()));
|
||||||
editor->setAutoCompleter(new AutoCompleter);
|
editor->setAutoCompleter(new AutoCompleter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
void inspectElement()
|
||||||
|
{
|
||||||
|
if (auto widget = qobject_cast<QmlJSEditorWidget *>(EditorManager::currentEditor()->widget()))
|
||||||
|
widget->inspectElementUnderCursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
void showContextPane()
|
||||||
|
{
|
||||||
|
if (auto editor = qobject_cast<QmlJSEditorWidget*>(EditorManager::currentEditor()->widget()))
|
||||||
|
editor->showContextPane();
|
||||||
|
}
|
||||||
|
|
||||||
|
void setupQmlJSEditor()
|
||||||
|
{
|
||||||
|
static QmlJSEditorFactory theQmlJSEditorFactory;
|
||||||
|
|
||||||
|
TextEditor::SnippetProvider::registerGroup(Constants::QML_SNIPPETS_GROUP_ID,
|
||||||
|
Tr::tr("QML", "SnippetProvider"),
|
||||||
|
&decorateEditor);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
|
||||||
} // namespace QmlJSEditor
|
} // namespace QmlJSEditor
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
// Copyright (C) 2016 The Qt Company Ltd.
|
// Copyright (C) 2016 The Qt Company Ltd.
|
||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
|
#include "qmljseditorplugin.h"
|
||||||
|
|
||||||
#include "qmljseditingsettingspage.h"
|
#include "qmljseditingsettingspage.h"
|
||||||
#include "qmljseditor.h"
|
|
||||||
#include "qmljseditorconstants.h"
|
#include "qmljseditorconstants.h"
|
||||||
#include "qmljseditordocument.h"
|
#include "qmljseditordocument.h"
|
||||||
#include "qmljseditortr.h"
|
#include "qmljseditortr.h"
|
||||||
@@ -49,7 +50,6 @@
|
|||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
|
||||||
using namespace QmlJSEditor::Constants;
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
@@ -69,9 +69,7 @@ public:
|
|||||||
Command *addToolAction(QAction *a, Context &context, Id id,
|
Command *addToolAction(QAction *a, Context &context, Id id,
|
||||||
ActionContainer *c1, const QString &keySequence);
|
ActionContainer *c1, const QString &keySequence);
|
||||||
|
|
||||||
void renameUsages();
|
|
||||||
void reformatFile();
|
void reformatFile();
|
||||||
void showContextPane();
|
|
||||||
|
|
||||||
QmlJSQuickFixAssistProvider m_quickFixAssistProvider;
|
QmlJSQuickFixAssistProvider m_quickFixAssistProvider;
|
||||||
QmlTaskManager m_qmlTaskManager;
|
QmlTaskManager m_qmlTaskManager;
|
||||||
@@ -83,7 +81,6 @@ public:
|
|||||||
QmlJS::JsonSchemaManager m_jsonManager{
|
QmlJS::JsonSchemaManager m_jsonManager{
|
||||||
{ICore::userResourcePath("json/").toString(),
|
{ICore::userResourcePath("json/").toString(),
|
||||||
ICore::resourcePath("json/").toString()}};
|
ICore::resourcePath("json/").toString()}};
|
||||||
QmlJSEditorFactory m_qmlJSEditorFactory;
|
|
||||||
QmlJSOutlineWidgetFactory m_qmlJSOutlineWidgetFactory;
|
QmlJSOutlineWidgetFactory m_qmlJSOutlineWidgetFactory;
|
||||||
QmlJsEditingSettingsPage m_qmJSEditingSettingsPage;
|
QmlJsEditingSettingsPage m_qmJSEditingSettingsPage;
|
||||||
};
|
};
|
||||||
@@ -92,10 +89,6 @@ static QmlJSEditorPluginPrivate *dd = nullptr;
|
|||||||
|
|
||||||
QmlJSEditorPluginPrivate::QmlJSEditorPluginPrivate()
|
QmlJSEditorPluginPrivate::QmlJSEditorPluginPrivate()
|
||||||
{
|
{
|
||||||
TextEditor::SnippetProvider::registerGroup(Constants::QML_SNIPPETS_GROUP_ID,
|
|
||||||
Tr::tr("QML", "SnippetProvider"),
|
|
||||||
&QmlJSEditorFactory::decorateEditor);
|
|
||||||
|
|
||||||
QmlJS::ModelManagerInterface *modelManager = QmlJS::ModelManagerInterface::instance();
|
QmlJS::ModelManagerInterface *modelManager = QmlJS::ModelManagerInterface::instance();
|
||||||
QmllsSettingsManager::instance();
|
QmllsSettingsManager::instance();
|
||||||
|
|
||||||
@@ -150,17 +143,15 @@ QmlJSEditorPluginPrivate::QmlJSEditorPluginPrivate()
|
|||||||
cmd = ActionManager::registerAction(inspectElementAction,
|
cmd = ActionManager::registerAction(inspectElementAction,
|
||||||
Id("QmlJSEditor.InspectElementUnderCursor"),
|
Id("QmlJSEditor.InspectElementUnderCursor"),
|
||||||
context);
|
context);
|
||||||
connect(inspectElementAction, &QAction::triggered, [] {
|
connect(inspectElementAction, &QAction::triggered, &Internal::inspectElement);
|
||||||
if (auto widget = qobject_cast<QmlJSEditorWidget *>(EditorManager::currentEditor()->widget()))
|
|
||||||
widget->inspectElementUnderCursor();
|
|
||||||
});
|
|
||||||
qmlToolsMenu->addAction(cmd);
|
qmlToolsMenu->addAction(cmd);
|
||||||
|
|
||||||
QAction *showQuickToolbar = new QAction(Tr::tr("Show Qt Quick Toolbar"), this);
|
QAction *showQuickToolbar = new QAction(Tr::tr("Show Qt Quick Toolbar"), this);
|
||||||
cmd = ActionManager::registerAction(showQuickToolbar, Constants::SHOW_QT_QUICK_HELPER, context);
|
cmd = ActionManager::registerAction(showQuickToolbar, Constants::SHOW_QT_QUICK_HELPER, context);
|
||||||
cmd->setDefaultKeySequence(useMacShortcuts ? QKeySequence(Qt::META | Qt::ALT | Qt::Key_Space)
|
cmd->setDefaultKeySequence(useMacShortcuts ? QKeySequence(Qt::META | Qt::ALT | Qt::Key_Space)
|
||||||
: QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_Space));
|
: QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_Space));
|
||||||
connect(showQuickToolbar, &QAction::triggered, this, &QmlJSEditorPluginPrivate::showContextPane);
|
connect(showQuickToolbar, &QAction::triggered, this, &showContextPane);
|
||||||
contextMenu->addAction(cmd);
|
contextMenu->addAction(cmd);
|
||||||
qmlToolsMenu->addAction(cmd);
|
qmlToolsMenu->addAction(cmd);
|
||||||
|
|
||||||
@@ -189,12 +180,6 @@ QmlJS::JsonSchemaManager *jsonManager()
|
|||||||
return &dd->m_jsonManager;
|
return &dd->m_jsonManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSEditorPluginPrivate::renameUsages()
|
|
||||||
{
|
|
||||||
if (auto editor = qobject_cast<QmlJSEditorWidget*>(EditorManager::currentEditor()->widget()))
|
|
||||||
editor->renameSymbolUnderCursor();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QmlJSEditorPluginPrivate::reformatFile()
|
void QmlJSEditorPluginPrivate::reformatFile()
|
||||||
{
|
{
|
||||||
if (m_currentDocument) {
|
if (m_currentDocument) {
|
||||||
@@ -263,12 +248,6 @@ void QmlJSEditorPluginPrivate::reformatFile()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlJSEditorPluginPrivate::showContextPane()
|
|
||||||
{
|
|
||||||
if (auto editor = qobject_cast<QmlJSEditorWidget*>(EditorManager::currentEditor()->widget()))
|
|
||||||
editor->showContextPane();
|
|
||||||
}
|
|
||||||
|
|
||||||
Command *QmlJSEditorPluginPrivate::addToolAction(QAction *a,
|
Command *QmlJSEditorPluginPrivate::addToolAction(QAction *a,
|
||||||
Context &context, Id id,
|
Context &context, Id id,
|
||||||
ActionContainer *c1, const QString &keySequence)
|
ActionContainer *c1, const QString &keySequence)
|
||||||
@@ -350,6 +329,8 @@ class QmlJSEditorPlugin final : public ExtensionSystem::IPlugin
|
|||||||
void initialize() final
|
void initialize() final
|
||||||
{
|
{
|
||||||
dd = new QmlJSEditorPluginPrivate;
|
dd = new QmlJSEditorPluginPrivate;
|
||||||
|
|
||||||
|
setupQmlJSEditor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void extensionsInitialized() final
|
void extensionsInitialized() final
|
||||||
|
|||||||
@@ -12,4 +12,8 @@ class QmlJSQuickFixAssistProvider;
|
|||||||
QmlJSQuickFixAssistProvider *quickFixAssistProvider();
|
QmlJSQuickFixAssistProvider *quickFixAssistProvider();
|
||||||
QmlJS::JsonSchemaManager *jsonManager();
|
QmlJS::JsonSchemaManager *jsonManager();
|
||||||
|
|
||||||
|
void setupQmlJSEditor();
|
||||||
|
void inspectElement();
|
||||||
|
void showContextPane();
|
||||||
|
|
||||||
} // QmlJSEditor::Internal
|
} // QmlJSEditor::Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user