forked from qt-creator/qt-creator
Added mime-type for JS files to the QMLJS text editor.
This commit is contained in:
@@ -46,7 +46,7 @@ Core::GeneratedFiles QmlFileWizard::generateFilesFromPath(const QString &path,
|
|||||||
QString * /*errorMessage*/) const
|
QString * /*errorMessage*/) const
|
||||||
|
|
||||||
{
|
{
|
||||||
const QString mimeType = QLatin1String(Constants::QMLJSEDITOR_MIMETYPE);
|
const QString mimeType = QLatin1String(Constants::QML_MIMETYPE);
|
||||||
const QString fileName = Core::BaseFileWizard::buildFileName(path, name, preferredSuffix(mimeType));
|
const QString fileName = Core::BaseFileWizard::buildFileName(path, name, preferredSuffix(mimeType));
|
||||||
|
|
||||||
Core::GeneratedFile file(fileName);
|
Core::GeneratedFile file(fileName);
|
||||||
|
|||||||
@@ -46,8 +46,9 @@
|
|||||||
#include <qmljs/qmldocument.h>
|
#include <qmljs/qmldocument.h>
|
||||||
#include <qmljs/qmlidcollector.h>
|
#include <qmljs/qmlidcollector.h>
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
#include <coreplugin/mimedatabase.h>
|
||||||
#include <coreplugin/uniqueidmanager.h>
|
#include <coreplugin/uniqueidmanager.h>
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <texteditor/basetextdocument.h>
|
#include <texteditor/basetextdocument.h>
|
||||||
@@ -59,6 +60,7 @@
|
|||||||
#include <utils/changeset.h>
|
#include <utils/changeset.h>
|
||||||
#include <utils/uncommentselection.h>
|
#include <utils/uncommentselection.h>
|
||||||
|
|
||||||
|
#include <QtCore/QFileInfo>
|
||||||
#include <QtCore/QTimer>
|
#include <QtCore/QTimer>
|
||||||
|
|
||||||
#include <QtGui/QMenu>
|
#include <QtGui/QMenu>
|
||||||
@@ -317,7 +319,6 @@ QmlJSTextEditor::QmlJSTextEditor(QWidget *parent) :
|
|||||||
setMarksVisible(true);
|
setMarksVisible(true);
|
||||||
setCodeFoldingSupported(true);
|
setCodeFoldingSupported(true);
|
||||||
setCodeFoldingVisible(true);
|
setCodeFoldingVisible(true);
|
||||||
setMimeType(QmlJSEditor::Constants::QMLJSEDITOR_MIMETYPE);
|
|
||||||
|
|
||||||
m_updateDocumentTimer = new QTimer(this);
|
m_updateDocumentTimer = new QTimer(this);
|
||||||
m_updateDocumentTimer->setInterval(UPDATE_DOCUMENT_DEFAULT_INTERVAL);
|
m_updateDocumentTimer->setInterval(UPDATE_DOCUMENT_DEFAULT_INTERVAL);
|
||||||
@@ -363,6 +364,13 @@ QString QmlJSEditorEditable::id() const
|
|||||||
return QLatin1String(QmlJSEditor::Constants::C_QMLJSEDITOR_ID);
|
return QLatin1String(QmlJSEditor::Constants::C_QMLJSEDITOR_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QmlJSEditorEditable::open(const QString &fileName)
|
||||||
|
{
|
||||||
|
bool b = TextEditor::BaseTextEditorEditable::open(fileName);
|
||||||
|
editor()->setMimeType(Core::ICore::instance()->mimeDatabase()->findByFile(QFileInfo(fileName)).type());
|
||||||
|
return b;
|
||||||
|
}
|
||||||
|
|
||||||
QmlJSTextEditor::Context QmlJSEditorEditable::context() const
|
QmlJSTextEditor::Context QmlJSEditorEditable::context() const
|
||||||
{
|
{
|
||||||
return m_context;
|
return m_context;
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ public:
|
|||||||
Core::IEditor *duplicate(QWidget *parent);
|
Core::IEditor *duplicate(QWidget *parent);
|
||||||
QString id() const;
|
QString id() const;
|
||||||
bool isTemporary() const { return false; }
|
bool isTemporary() const { return false; }
|
||||||
|
virtual bool open(const QString & fileName);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<int> m_context;
|
QList<int> m_context;
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ const char * const C_QMLJSEDITOR_ID = "QMLProjectManager.QMLJSEditor";
|
|||||||
const char * const C_QMLJSEDITOR_DISPLAY_NAME = QT_TRANSLATE_NOOP("OpenWith::Editors", "QMLJS Editor");
|
const char * const C_QMLJSEDITOR_DISPLAY_NAME = QT_TRANSLATE_NOOP("OpenWith::Editors", "QMLJS Editor");
|
||||||
const char * const TASK_INDEX = "QmlJSEditor.TaskIndex";
|
const char * const TASK_INDEX = "QmlJSEditor.TaskIndex";
|
||||||
|
|
||||||
const char * const QMLJSEDITOR_MIMETYPE = "application/x-qml";
|
const char * const QML_MIMETYPE = "application/x-qml";
|
||||||
|
const char * const JS_MIMETYPE = "application/javascript";
|
||||||
|
|
||||||
} // namespace Constants
|
} // namespace Constants
|
||||||
} // namespace QmlJSEditor
|
} // namespace QmlJSEditor
|
||||||
|
|||||||
@@ -42,9 +42,12 @@ using namespace QmlJSEditor::Internal;
|
|||||||
using namespace QmlJSEditor::Constants;
|
using namespace QmlJSEditor::Constants;
|
||||||
|
|
||||||
QmlJSEditorFactory::QmlJSEditorFactory(QObject *parent)
|
QmlJSEditorFactory::QmlJSEditorFactory(QObject *parent)
|
||||||
: Core::IEditorFactory(parent),
|
: Core::IEditorFactory(parent)
|
||||||
m_mimeTypes(QLatin1String(QmlJSEditor::Constants::QMLJSEDITOR_MIMETYPE))
|
|
||||||
{
|
{
|
||||||
|
m_mimeTypes
|
||||||
|
<< QLatin1String(QmlJSEditor::Constants::QML_MIMETYPE)
|
||||||
|
<< QLatin1String(QmlJSEditor::Constants::JS_MIMETYPE)
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
QmlJSEditorFactory::~QmlJSEditorFactory()
|
QmlJSEditorFactory::~QmlJSEditorFactory()
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public:
|
|||||||
Core::IEditor *createEditor(QWidget *parent);
|
Core::IEditor *createEditor(QWidget *parent);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const QStringList m_mimeTypes;
|
QStringList m_mimeTypes;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
Reference in New Issue
Block a user