Commit eb694775 authored by Marco Bubke's avatar Marco Bubke
Browse files

QmlDesigner: Only open QtQuick and no js files



Task-number: QTCREATORBUG-11650
Change-Id: I27e62bf307a8b00157444b09c8b65a93137296ce
Reviewed-by: default avatarFawzi Mohamed <fawzi.mohamed@digia.com>
parent 645a3db2
......@@ -42,7 +42,7 @@
#include <coreplugin/icore.h>
#include <coreplugin/modemanager.h>
#include <extensionsystem/pluginspec.h>
#include <qmljs/qmljsmodelmanagerinterface.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <utils/hostosinfo.h>
......@@ -339,29 +339,41 @@ static bool isDesignerMode(Core::IMode *mode)
return mode == Core::DesignMode::instance();
}
void QmlDesignerPlugin::onCurrentModeChanged(Core::IMode *newMode, Core::IMode *oldMode)
static bool checkIfEditorIsQtQuick(Core::IEditor *editor)
{
if (!Core::EditorManager::currentEditor())
return;
if (Core::EditorManager::currentEditor()
&& Core::EditorManager::currentEditor()->id() != QmlJSEditor::Constants::C_QMLJSEDITOR_ID)
return;
if (editor->id() == QmlJSEditor::Constants::C_QMLJSEDITOR_ID) {
QmlJS::Document::Ptr document = QmlJS::ModelManagerInterface::instance()->snapshot().document(editor->document()->filePath());
if (!document.isNull())
return document->language() == QmlJS::Language::QmlQtQuick1
|| document->language() == QmlJS::Language::QmlQtQuick2
|| document->language() == QmlJS::Language::Qml;
}
if ((currentDesignDocument()
&& Core::EditorManager::currentEditor() == currentDesignDocument()->editor())
&& isDesignerMode(newMode))
return;
return false;
}
if (!isDesignerMode(newMode) && isDesignerMode(oldMode))
hideDesigner();
else if (Core::EditorManager::currentEditor()
&& isDesignerMode(newMode)
&& isQmlFile(Core::EditorManager::currentEditor()))
showDesigner();
else if (currentDesignDocument())
hideDesigner();
static bool documentIsAlreadyOpen(DesignDocument *designDocument, Core::IEditor *editor, Core::IMode *newMode)
{
return designDocument
&& editor == designDocument->editor()
&& isDesignerMode(newMode);
}
void QmlDesignerPlugin::onCurrentModeChanged(Core::IMode *newMode, Core::IMode *oldMode)
{
if (Core::EditorManager::currentEditor()
&& checkIfEditorIsQtQuick(Core::EditorManager::currentEditor())
&& !documentIsAlreadyOpen(currentDesignDocument(), Core::EditorManager::currentEditor(), newMode)) {
if (!isDesignerMode(newMode) && isDesignerMode(oldMode))
hideDesigner();
else if (Core::EditorManager::currentEditor()
&& isDesignerMode(newMode)
&& isQmlFile(Core::EditorManager::currentEditor()))
showDesigner();
else if (currentDesignDocument())
hideDesigner();
}
}
DesignDocument *QmlDesignerPlugin::currentDesignDocument() const
......
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