Commit 062fa8e7 authored by Erik Verbruggen's avatar Erik Verbruggen

Added mime-type for JS files to the QMLJS text editor.

parent 4f953780
......@@ -46,7 +46,7 @@ Core::GeneratedFiles QmlFileWizard::generateFilesFromPath(const QString &path,
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));
Core::GeneratedFile file(fileName);
......
......@@ -46,8 +46,9 @@
#include <qmljs/qmldocument.h>
#include <qmljs/qmlidcollector.h>
#include <coreplugin/icore.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>
#include <coreplugin/uniqueidmanager.h>
#include <extensionsystem/pluginmanager.h>
#include <texteditor/basetextdocument.h>
......@@ -59,6 +60,7 @@
#include <utils/changeset.h>
#include <utils/uncommentselection.h>
#include <QtCore/QFileInfo>
#include <QtCore/QTimer>
#include <QtGui/QMenu>
......@@ -317,7 +319,6 @@ QmlJSTextEditor::QmlJSTextEditor(QWidget *parent) :
setMarksVisible(true);
setCodeFoldingSupported(true);
setCodeFoldingVisible(true);
setMimeType(QmlJSEditor::Constants::QMLJSEDITOR_MIMETYPE);
m_updateDocumentTimer = new QTimer(this);
m_updateDocumentTimer->setInterval(UPDATE_DOCUMENT_DEFAULT_INTERVAL);
......@@ -363,6 +364,13 @@ QString QmlJSEditorEditable::id() const
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
{
return m_context;
......
......@@ -68,6 +68,7 @@ public:
Core::IEditor *duplicate(QWidget *parent);
QString id() const;
bool isTemporary() const { return false; }
virtual bool open(const QString & fileName);
private:
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 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 QmlJSEditor
......
......@@ -42,9 +42,12 @@ using namespace QmlJSEditor::Internal;
using namespace QmlJSEditor::Constants;
QmlJSEditorFactory::QmlJSEditorFactory(QObject *parent)
: Core::IEditorFactory(parent),
m_mimeTypes(QLatin1String(QmlJSEditor::Constants::QMLJSEDITOR_MIMETYPE))
: Core::IEditorFactory(parent)
{
m_mimeTypes
<< QLatin1String(QmlJSEditor::Constants::QML_MIMETYPE)
<< QLatin1String(QmlJSEditor::Constants::JS_MIMETYPE)
;
}
QmlJSEditorFactory::~QmlJSEditorFactory()
......
......@@ -59,7 +59,7 @@ public:
Core::IEditor *createEditor(QWidget *parent);
private:
const QStringList m_mimeTypes;
QStringList m_mimeTypes;
};
} // namespace Internal
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment