diff options
author | Eike Ziller <eike.ziller@qt.io> | 2019-07-18 14:17:25 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2019-07-19 07:21:26 +0000 |
commit | e9272d848b31d603e57bed645ebc580e4ff1aebe (patch) | |
tree | e8246dd4709bb5236a6ccbc824599abcd0905d1b /src | |
parent | d20c738919640e38362fbc28958028da1e845bd8 (diff) |
QmlJsEditor: Avoid unneeded exports of constants
Change-Id: I332ff9a01963fe4d37dce9ecd0586d8f0fa6573c
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/qmljseditor/qmljseditingsettingspage.cpp | 37 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljseditor.cpp | 25 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljseditorconstants.h | 18 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljseditordocument.cpp | 6 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljseditorplugin.cpp | 11 | ||||
-rw-r--r-- | src/plugins/qmljseditor/qmljsfindreferences.cpp | 6 |
6 files changed, 43 insertions, 60 deletions
diff --git a/src/plugins/qmljseditor/qmljseditingsettingspage.cpp b/src/plugins/qmljseditor/qmljseditingsettingspage.cpp index 37cd32fa63..4958cfcba5 100644 --- a/src/plugins/qmljseditor/qmljseditingsettingspage.cpp +++ b/src/plugins/qmljseditor/qmljseditingsettingspage.cpp @@ -33,6 +33,10 @@ #include <QTextStream> #include <QCheckBox> +const char AUTO_FORMAT_ON_SAVE[] = "QmlJSEditor.AutoFormatOnSave"; +const char AUTO_FORMAT_ONLY_CURRENT_PROJECT[] = "QmlJSEditor.AutoFormatOnlyCurrentProject"; +const char QML_CONTEXTPANE_KEY[] = "QmlJSEditor.ContextPaneEnabled"; +const char QML_CONTEXTPANEPIN_KEY[] = "QmlJSEditor.ContextPanePinned"; using namespace QmlJSEditor; using namespace QmlJSEditor::Internal; @@ -52,33 +56,22 @@ void QmlJsEditingSettings::set() void QmlJsEditingSettings::fromSettings(QSettings *settings) { - settings->beginGroup(QLatin1String(QmlJSEditor::Constants::SETTINGS_CATEGORY_QML)); - m_enableContextPane = settings->value( - QLatin1String(QmlJSEditor::Constants::QML_CONTEXTPANE_KEY), - QVariant(false)).toBool(); - m_pinContextPane = settings->value( - QLatin1String(QmlJSEditor::Constants::QML_CONTEXTPANEPIN_KEY), - QVariant(false)).toBool(); - m_autoFormatOnSave = settings->value( - QLatin1String(QmlJSEditor::Constants::AUTO_FORMAT_ON_SAVE), - QVariant(false)).toBool(); - m_autoFormatOnlyCurrentProject = settings->value( - QLatin1String(QmlJSEditor::Constants::AUTO_FORMAT_ONLY_CURRENT_PROJECT), - QVariant(false)).toBool(); + settings->beginGroup(QmlJSEditor::Constants::SETTINGS_CATEGORY_QML); + m_enableContextPane = settings->value(QML_CONTEXTPANE_KEY, QVariant(false)).toBool(); + m_pinContextPane = settings->value(QML_CONTEXTPANEPIN_KEY, QVariant(false)).toBool(); + m_autoFormatOnSave = settings->value(AUTO_FORMAT_ON_SAVE, QVariant(false)).toBool(); + m_autoFormatOnlyCurrentProject + = settings->value(AUTO_FORMAT_ONLY_CURRENT_PROJECT, QVariant(false)).toBool(); settings->endGroup(); } void QmlJsEditingSettings::toSettings(QSettings *settings) const { - settings->beginGroup(QLatin1String(QmlJSEditor::Constants::SETTINGS_CATEGORY_QML)); - settings->setValue(QLatin1String(QmlJSEditor::Constants::QML_CONTEXTPANE_KEY), - m_enableContextPane); - settings->setValue(QLatin1String(QmlJSEditor::Constants::QML_CONTEXTPANEPIN_KEY), - m_pinContextPane); - settings->setValue(QLatin1String(QmlJSEditor::Constants::AUTO_FORMAT_ON_SAVE), - m_autoFormatOnSave); - settings->setValue(QLatin1String(QmlJSEditor::Constants::AUTO_FORMAT_ONLY_CURRENT_PROJECT), - m_autoFormatOnlyCurrentProject); + settings->beginGroup(QmlJSEditor::Constants::SETTINGS_CATEGORY_QML); + settings->setValue(QML_CONTEXTPANE_KEY, m_enableContextPane); + settings->setValue(QML_CONTEXTPANEPIN_KEY, m_pinContextPane); + settings->setValue(AUTO_FORMAT_ON_SAVE, m_autoFormatOnSave); + settings->setValue(AUTO_FORMAT_ONLY_CURRENT_PROJECT, m_autoFormatOnlyCurrentProject); settings->endGroup(); } diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index 068d12f320..c08e7bed49 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -92,6 +92,9 @@ enum { UPDATE_OUTLINE_INTERVAL = 500 // msecs after new semantic info has been arrived / cursor has moved }; +const char QML_JS_EDITOR_PLUGIN[] = "QmlJSEditorPlugin"; +const char QT_QUICK_TOOLBAR_MARKER_ID[] = "QtQuickToolbarMarkerId"; + using namespace Core; using namespace QmlJS; using namespace QmlJS::AST; @@ -286,8 +289,8 @@ void QmlJSEditorWidget::updateContextPane() if (m_contextPane->isAvailable(this, info.document, newNode) && !m_contextPane->widget()->isVisible()) { - QList<RefactorMarker> markers = RefactorMarker::filterOutType( - refactorMarkers(), Constants::QT_QUICK_TOOLBAR_MARKER_ID); + QList<RefactorMarker> markers + = RefactorMarker::filterOutType(refactorMarkers(), QT_QUICK_TOOLBAR_MARKER_ID); if (UiObjectMember *m = newNode->uiObjectMemberCast()) { const int start = qualifiedTypeNameId(m)->identifierToken.begin(); for (UiQualifiedId *q = qualifiedTypeNameId(m); q; q = q->next) { @@ -299,7 +302,7 @@ void QmlJSEditorWidget::updateContextPane() tc.setPosition(end); marker.cursor = tc; marker.tooltip = tr("Show Qt Quick ToolBar"); - marker.type = Constants::QT_QUICK_TOOLBAR_MARKER_ID; + marker.type = QT_QUICK_TOOLBAR_MARKER_ID; marker.callback = [this](TextEditorWidget *) { showContextPane(); }; @@ -310,8 +313,8 @@ void QmlJSEditorWidget::updateContextPane() } setRefactorMarkers(markers); } else if (oldNode != newNode) { - setRefactorMarkers(RefactorMarker::filterOutType( - refactorMarkers(), Constants::QT_QUICK_TOOLBAR_MARKER_ID)); + setRefactorMarkers( + RefactorMarker::filterOutType(refactorMarkers(), QT_QUICK_TOOLBAR_MARKER_ID)); } m_oldCursorPosition = position(); @@ -672,7 +675,7 @@ void QmlJSEditorWidget::inspectElementUnderCursor() const const CppComponentValue *cppValue = findCppComponentToInspect(semanticInfo, cursorPosition); if (!cppValue) { QString title = tr("Code Model Not Available"); - const QString documentId = Constants::QML_JS_EDITOR_PLUGIN + QStringLiteral(".NothingToShow"); + const QString documentId = QML_JS_EDITOR_PLUGIN + QStringLiteral(".NothingToShow"); EditorManager::openEditorWithContents(Core::Constants::K_DEFAULT_TEXT_EDITOR_ID, &title, tr("Code model not available.").toUtf8(), documentId, EditorManager::IgnoreNavigationHistory); @@ -680,8 +683,8 @@ void QmlJSEditorWidget::inspectElementUnderCursor() const } QString title = tr("Code Model of %1").arg(cppValue->metaObject()->className()); - const QString documentId = Constants::QML_JS_EDITOR_PLUGIN + QStringLiteral(".Class.") - + cppValue->metaObject()->className(); + const QString documentId = QML_JS_EDITOR_PLUGIN + QStringLiteral(".Class.") + + cppValue->metaObject()->className(); IEditor *outputEditor = EditorManager::openEditorWithContents( Core::Constants::K_DEFAULT_TEXT_EDITOR_ID, &title, QByteArray(), documentId, EditorManager::IgnoreNavigationHistory); @@ -812,8 +815,8 @@ void QmlJSEditorWidget::showContextPane() &scopeChain, newNode, false, true); m_oldCursorPosition = position(); - setRefactorMarkers(RefactorMarker::filterOutType( - refactorMarkers(), Constants::QT_QUICK_TOOLBAR_MARKER_ID)); + setRefactorMarkers( + RefactorMarker::filterOutType(refactorMarkers(), QT_QUICK_TOOLBAR_MARKER_ID)); } } @@ -1028,7 +1031,7 @@ bool QmlJSEditor::isDesignModePreferred() const QmlJSEditorFactory::QmlJSEditorFactory() { setId(Constants::C_QMLJSEDITOR_ID); - setDisplayName(QCoreApplication::translate("OpenWith::Editors", Constants::C_QMLJSEDITOR_DISPLAY_NAME)); + setDisplayName(QCoreApplication::translate("OpenWith::Editors", "QMLJS Editor")); addMimeType(QmlJSTools::Constants::QML_MIMETYPE); addMimeType(QmlJSTools::Constants::QMLUI_MIMETYPE); diff --git a/src/plugins/qmljseditor/qmljseditorconstants.h b/src/plugins/qmljseditor/qmljseditorconstants.h index 61624bf1ff..ab58d44316 100644 --- a/src/plugins/qmljseditor/qmljseditorconstants.h +++ b/src/plugins/qmljseditor/qmljseditorconstants.h @@ -30,37 +30,19 @@ namespace QmlJSEditor { namespace Constants { -const char QML_JS_EDITOR_PLUGIN[] = "QmlJSEditorPlugin"; - const char M_CONTEXT[] = "QML JS Editor.ContextMenu"; const char M_REFACTORING_MENU_INSERTION_POINT[] = "QmlJSEditor.RefactorGroup"; const char C_QMLJSEDITOR_ID[] = "QMLProjectManager.QMLJSEditor"; -const char C_QMLJSEDITOR_DISPLAY_NAME[] = QT_TRANSLATE_NOOP("OpenWith::Editors", "QMLJS Editor"); -const char TASK_SEARCH[] = "QmlJSEditor.TaskSearch"; const char SETTINGS_CATEGORY_QML[] = "J.QtQuick"; -const char RENAME_USAGES[] = "QmlJSEditor.RenameUsages"; -const char RUN_SEMANTIC_SCAN[] = "QmlJSEditor.RunSemanticScan"; -const char REFORMAT_FILE[] = "QmlJSEditor.ReformatFile"; const char SHOW_QT_QUICK_HELPER[] = "QmlJSEditor.ShowQtQuickHelper"; -const char INSPECT_ELEMENT_UNDER_CURSOR[] = "QmlJSEditor.InspectElementUnderCursor"; const char TASK_CATEGORY_QML[] = "Task.Category.Qml"; const char TASK_CATEGORY_QML_ANALYSIS[] = "Task.Category.QmlAnalysis"; const char QML_SNIPPETS_GROUP_ID[] = "QML"; -const char QML_CONTEXTPANE_KEY[] = "QmlJSEditor.ContextPaneEnabled"; -const char QML_CONTEXTPANEPIN_KEY[] = "QmlJSEditor.ContextPanePinned"; - -const char QML_UI_FILE_WARNING[] = "QmlJSEditor.QmlUiFileWarning"; - -const char AUTO_FORMAT_ON_SAVE[] = "QmlJSEditor.AutoFormatOnSave"; -const char AUTO_FORMAT_ONLY_CURRENT_PROJECT[] = "QmlJSEditor.AutoFormatOnlyCurrentProject"; - -const char QT_QUICK_TOOLBAR_MARKER_ID[] = "QtQuickToolbarMarkerId"; - } // namespace Constants } // namespace QmlJSEditor diff --git a/src/plugins/qmljseditor/qmljseditordocument.cpp b/src/plugins/qmljseditor/qmljseditordocument.cpp index 18348907f4..05aa8e649c 100644 --- a/src/plugins/qmljseditor/qmljseditordocument.cpp +++ b/src/plugins/qmljseditor/qmljseditordocument.cpp @@ -43,6 +43,8 @@ #include <qmljstools/qmljsmodelmanager.h> #include <qmljstools/qmljsqtstylecodeformatter.h> +const char QML_UI_FILE_WARNING[] = "QmlJSEditor.QmlUiFileWarning"; + using namespace QmlJSEditor; using namespace QmlJS; using namespace QmlJS::AST; @@ -564,8 +566,8 @@ void QmlJSEditorDocumentPrivate::acceptNewSemanticInfo(const SemanticInfo &seman if (m_firstSementicInfo) { m_firstSementicInfo = false; if (semanticInfo.document->language() == Dialect::QmlQtQuick2Ui - && !q->infoBar()->containsInfo(Core::Id(Constants::QML_UI_FILE_WARNING))) { - Core::InfoBarEntry info(Core::Id(Constants::QML_UI_FILE_WARNING), + && !q->infoBar()->containsInfo(Core::Id(QML_UI_FILE_WARNING))) { + Core::InfoBarEntry info(Core::Id(QML_UI_FILE_WARNING), tr("This file should only be edited in <b>Design</b> mode.")); info.setCustomButtonInfo(tr("Switch Mode"), []() { Core::ModeManager::activateMode(Core::Constants::MODE_DESIGN); diff --git a/src/plugins/qmljseditor/qmljseditorplugin.cpp b/src/plugins/qmljseditor/qmljseditorplugin.cpp index afd33c18b8..de5daf6a61 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.cpp +++ b/src/plugins/qmljseditor/qmljseditorplugin.cpp @@ -161,26 +161,29 @@ QmlJSEditorPluginPrivate::QmlJSEditorPluginPrivate() qmlToolsMenu->addAction(cmd); QAction *renameUsagesAction = new QAction(QmlJSEditorPlugin::tr("Rename Symbol Under Cursor"), this); - cmd = ActionManager::registerAction(renameUsagesAction, Constants::RENAME_USAGES, context); + cmd = ActionManager::registerAction(renameUsagesAction, "QmlJSEditor.RenameUsages", context); cmd->setDefaultKeySequence(QKeySequence(QmlJSEditorPlugin::tr("Ctrl+Shift+R"))); connect(renameUsagesAction, &QAction::triggered, this, &QmlJSEditorPluginPrivate::renameUsages); contextMenu->addAction(cmd); qmlToolsMenu->addAction(cmd); QAction *semanticScan = new QAction(QmlJSEditorPlugin::tr("Run Checks"), this); - cmd = ActionManager::registerAction(semanticScan, Id(Constants::RUN_SEMANTIC_SCAN)); + cmd = ActionManager::registerAction(semanticScan, Id("QmlJSEditor.RunSemanticScan")); cmd->setDefaultKeySequence(QKeySequence(QmlJSEditorPlugin::tr("Ctrl+Shift+C"))); connect(semanticScan, &QAction::triggered, this, &QmlJSEditorPluginPrivate::runSemanticScan); qmlToolsMenu->addAction(cmd); m_reformatFileAction = new QAction(QmlJSEditorPlugin::tr("Reformat File"), this); - cmd = ActionManager::registerAction(m_reformatFileAction, Id(Constants::REFORMAT_FILE), context); + cmd = ActionManager::registerAction(m_reformatFileAction, + Id("QmlJSEditor.ReformatFile"), + context); connect(m_reformatFileAction, &QAction::triggered, this, &QmlJSEditorPluginPrivate::reformatFile); qmlToolsMenu->addAction(cmd); QAction *inspectElementAction = new QAction(QmlJSEditorPlugin::tr("Inspect API for Element Under Cursor"), this); cmd = ActionManager::registerAction(inspectElementAction, - Id(Constants::INSPECT_ELEMENT_UNDER_CURSOR), context); + Id("QmlJSEditor.InspectElementUnderCursor"), + context); connect(inspectElementAction, &QAction::triggered, [] { if (auto widget = qobject_cast<QmlJSEditorWidget *>(EditorManager::currentEditor()->widget())) widget->inspectElementUnderCursor(); diff --git a/src/plugins/qmljseditor/qmljsfindreferences.cpp b/src/plugins/qmljseditor/qmljsfindreferences.cpp index 8b790c3351..57796ea4bb 100644 --- a/src/plugins/qmljseditor/qmljsfindreferences.cpp +++ b/src/plugins/qmljseditor/qmljsfindreferences.cpp @@ -980,9 +980,9 @@ void FindReferences::displayResults(int first, int last) connect(m_currentSearch.data(), &SearchResult::paused, this, &FindReferences::setPaused); SearchResultWindow::instance()->popup(IOutputPane::Flags(IOutputPane::ModeSwitch | IOutputPane::WithFocus)); - FutureProgress *progress = ProgressManager::addTask( - m_watcher.future(), tr("Searching for Usages"), - QmlJSEditor::Constants::TASK_SEARCH); + FutureProgress *progress = ProgressManager::addTask(m_watcher.future(), + tr("Searching for Usages"), + "QmlJSEditor.TaskSearch"); connect(progress, &FutureProgress::clicked, m_currentSearch.data(), &SearchResult::popup); ++first; |