forked from qt-creator/qt-creator
Utils/all: Move mime constants into a central place
They are reasonably standardized, and generally usable cross-plugin, so this can help to avoid a few cross-plugin compiletime dependencies. Change-Id: Icb2b010c3e12dee69df54ab16f6f8e90d9cffba6 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/layoutbuilder.h>
|
||||
#include <utils/mimeconstants.h>
|
||||
#include <utils/mimeutils.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -216,25 +217,25 @@ bool QmlMainFileAspect::isQmlFilePresent()
|
||||
{
|
||||
bool qmlFileFound = false;
|
||||
if (mainScriptSource() == FileInEditor && !mainScript().isEmpty()) {
|
||||
using namespace Utils::Constants;
|
||||
IDocument *document = EditorManager::currentDocument();
|
||||
const MimeType mainScriptMimeType = mimeTypeForFile(mainScript());
|
||||
if (document) {
|
||||
m_currentFileFilename = document->filePath();
|
||||
if (mainScriptMimeType.matchesName(ProjectExplorer::Constants::QML_MIMETYPE)
|
||||
|| mainScriptMimeType.matchesName(ProjectExplorer::Constants::QMLUI_MIMETYPE)) {
|
||||
if (mainScriptMimeType.matchesName(QML_MIMETYPE)
|
||||
|| mainScriptMimeType.matchesName(QMLUI_MIMETYPE)) {
|
||||
qmlFileFound = true;
|
||||
}
|
||||
}
|
||||
if (!document
|
||||
|| mainScriptMimeType.matchesName(QmlJSTools::Constants::QMLPROJECT_MIMETYPE)) {
|
||||
|| mainScriptMimeType.matchesName(QMLPROJECT_MIMETYPE)) {
|
||||
// find a qml file with lowercase filename. This is slow, but only done
|
||||
// in initialization/other border cases.
|
||||
const FilePaths files = m_target->project()->files(Project::SourceFiles);
|
||||
for (const FilePath &filename : files) {
|
||||
if (!filename.isEmpty() && filename.baseName().at(0).isLower()) {
|
||||
const MimeType type = mimeTypeForFile(filename);
|
||||
if (type.matchesName(ProjectExplorer::Constants::QML_MIMETYPE)
|
||||
|| type.matchesName(ProjectExplorer::Constants::QMLUI_MIMETYPE)) {
|
||||
if (type.matchesName(QML_MIMETYPE) || type.matchesName(QMLUI_MIMETYPE)) {
|
||||
m_currentFileFilename = filename;
|
||||
qmlFileFound = true;
|
||||
break;
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
#include <utils/infobar.h>
|
||||
#include <utils/mimeconstants.h>
|
||||
#include <utils/process.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
@@ -44,7 +45,7 @@ using namespace Utils;
|
||||
namespace QmlProjectManager {
|
||||
|
||||
QmlProject::QmlProject(const Utils::FilePath &fileName)
|
||||
: Project(QString::fromLatin1(Constants::QMLPROJECT_MIMETYPE), fileName)
|
||||
: Project(Utils::Constants::QMLPROJECT_MIMETYPE, fileName)
|
||||
{
|
||||
setId(QmlProjectManager::Constants::QML_PROJECT_ID);
|
||||
setProjectLanguages(Core::Context(ProjectExplorer::Constants::QMLJS_LANGUAGE_ID));
|
||||
|
||||
@@ -3,12 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <qmljstools/qmljstoolsconstants.h>
|
||||
namespace QmlProjectManager::Constants {
|
||||
|
||||
namespace QmlProjectManager {
|
||||
namespace Constants {
|
||||
|
||||
const char * const QMLPROJECT_MIMETYPE = QmlJSTools::Constants::QMLPROJECT_MIMETYPE;
|
||||
const char customFileSelectorsData[] = "CustomFileSelectorsData";
|
||||
const char supportedLanguagesData[] = "SupportedLanguagesData";
|
||||
const char primaryLanguageData[] = "PrimaryLanguageData";
|
||||
@@ -25,5 +21,5 @@ const char enviromentLaunchedQDS[] = "QTC_LAUNCHED_QDS";
|
||||
const char ALWAYS_OPEN_UI_MODE[] = "J.QtQuick/QmlJSEditor.openUiQmlMode";
|
||||
const char QML_RESOURCE_PATH[] = "qmldesigner/propertyEditorQmlSources/imports";
|
||||
const char LANDING_PAGE_PATH[] = "qmldesigner/landingpage";
|
||||
} // namespace Constants
|
||||
} // namespace QmlProjectManager
|
||||
|
||||
} // QmlProjectManager::Constants
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
|
||||
#include <utils/fileutils.h>
|
||||
#include <utils/fsengine/fileiconprovider.h>
|
||||
#include <utils/mimeconstants.h>
|
||||
#include <utils/process.h>
|
||||
#include <utils/qtcsettings.h>
|
||||
|
||||
@@ -252,7 +253,7 @@ void QmlProjectPlugin::initialize()
|
||||
|
||||
d->landingPageWidget = new QdsLandingPageWidget();
|
||||
|
||||
const QStringList mimeTypes = {QmlJSTools::Constants::QMLUI_MIMETYPE};
|
||||
const QStringList mimeTypes = {Utils::Constants::QMLUI_MIMETYPE};
|
||||
auto context = new Internal::DesignModeContext(d->landingPageWidget);
|
||||
Core::ICore::addContextObject(context);
|
||||
|
||||
@@ -262,7 +263,7 @@ void QmlProjectPlugin::initialize()
|
||||
this, &QmlProjectPlugin::editorModeChanged);
|
||||
}
|
||||
|
||||
ProjectManager::registerProjectType<QmlProject>(QmlJSTools::Constants::QMLPROJECT_MIMETYPE);
|
||||
ProjectManager::registerProjectType<QmlProject>(Utils::Constants::QMLPROJECT_MIMETYPE);
|
||||
Utils::FileIconProvider::registerIconOverlayForSuffix(":/qmlproject/images/qmlproject.png",
|
||||
"qmlproject");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user