forked from qt-creator/qt-creator
QmlJSEditor: warn when editing .ui.qml, activate designer checks
Change-Id: I2f6d39633341bd1197d16c5c097573d4ab090896 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@digia.com> Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
@@ -56,6 +56,7 @@
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/id.h>
|
||||
#include <coreplugin/infobar.h>
|
||||
#include <coreplugin/modemanager.h>
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
@@ -109,6 +110,7 @@ QmlJSEditorWidget::QmlJSEditorWidget()
|
||||
{
|
||||
m_outlineCombo = 0;
|
||||
m_contextPane = 0;
|
||||
m_firstSementicInfo = true;
|
||||
m_findReferences = new FindReferences(this);
|
||||
|
||||
setParenthesesMatchingEnabled(true);
|
||||
@@ -788,6 +790,16 @@ void QmlJSEditorWidget::semanticInfoUpdated(const SemanticInfo &semanticInfo)
|
||||
}
|
||||
}
|
||||
|
||||
if (m_firstSementicInfo) {
|
||||
m_firstSementicInfo = false;
|
||||
if (semanticInfo.document->language() == Dialect::QmlQtQuick2Ui) {
|
||||
Core::InfoBarEntry info(Core::Id(Constants::QML_UI_FILE_WARNING),
|
||||
tr("This file should only be edited in <b>Design</b> mode."));
|
||||
info.setCustomButtonInfo(tr("Switch Mode"), []() { ModeManager::activateMode(Core::Constants::MODE_DESIGN); });
|
||||
textDocument()->infoBar()->addInfo(info);
|
||||
}
|
||||
}
|
||||
|
||||
updateUses();
|
||||
}
|
||||
|
||||
@@ -873,9 +885,16 @@ QmlJSEditor::QmlJSEditor()
|
||||
|
||||
bool QmlJSEditor::isDesignModePreferred() const
|
||||
{
|
||||
|
||||
bool alwaysPreferDesignMode = false;
|
||||
// always prefer design mode for .ui.qml files
|
||||
if (textDocument() && textDocument()->mimeType() == QLatin1String(QmlJSTools::Constants::QMLUI_MIMETYPE))
|
||||
alwaysPreferDesignMode = true;
|
||||
|
||||
// stay in design mode if we are there
|
||||
IMode *mode = ModeManager::currentMode();
|
||||
return mode && mode->id() == Core::Constants::MODE_DESIGN;
|
||||
return alwaysPreferDesignMode
|
||||
|| (mode && mode->id() == Core::Constants::MODE_DESIGN);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -135,6 +135,8 @@ private:
|
||||
int m_oldCursorPosition;
|
||||
|
||||
FindReferences *m_findReferences;
|
||||
|
||||
bool m_firstSementicInfo;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -59,6 +59,8 @@ 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";
|
||||
|
||||
} // namespace Constants
|
||||
} // namespace QmlJSEditor
|
||||
|
||||
|
||||
Reference in New Issue
Block a user