QmlDesigner: Disable widgets while text is edited manually

While the user is editing text in the text editor
we disable the input widgets.
This ensures that the rewriter is not confused by the
manual editing and also there is no guarantee that the
QML code is syntacially correct.

We also disable the toolbar.

Change-Id: If062b49f834e901a933a9b1f67582ee9be6232bc
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Thomas Hartmann
2017-11-15 10:10:21 +01:00
committed by Tim Jenssen
parent 68e3da84f3
commit 9624bf0508
2 changed files with 17 additions and 4 deletions

View File

@@ -40,6 +40,11 @@
#include <modelnode.h> #include <modelnode.h>
#include <nodeproperty.h> #include <nodeproperty.h>
#ifndef QMLDESIGNER_TEST
#include <qmldesignerplugin.h>
#include <viewmanager.h>
#endif
#include <qmljs/parser/qmljsengine_p.h> #include <qmljs/parser/qmljsengine_p.h>
#include <qmljs/qmljsmodelmanagerinterface.h> #include <qmljs/qmljsmodelmanagerinterface.h>
#include <qmljs/qmljssimplereader.h> #include <qmljs/qmljssimplereader.h>
@@ -855,15 +860,17 @@ void RewriterView::qmlTextChanged()
} }
case Amend: { case Amend: {
if (m_instantQmlTextUpdate) if (m_instantQmlTextUpdate) {
amendQmlText(); amendQmlText();
else } else {
#ifndef QMLDESIGNER_TEST #ifndef QMLDESIGNER_TEST
QmlDesignerPlugin::instance()->viewManager().disableWidgets();
m_amendTimer.start(400); m_amendTimer.start(400);
#else #else
/*Keep test synchronous*/ /*Keep test synchronous*/
amendQmlText(); amendQmlText();
#endif #endif
}
break; break;
} }
} }

View File

@@ -360,15 +360,21 @@ QWidget *ViewManager::widget(const QString &uniqueId) const
void ViewManager::disableWidgets() void ViewManager::disableWidgets()
{ {
foreach (const WidgetInfo &widgetInfo, widgetInfos()) foreach (const WidgetInfo &widgetInfo, widgetInfos())
if (widgetInfo.widgetFlags == DesignerWidgetFlags::DisableOnError) if (widgetInfo.widgetFlags == DesignerWidgetFlags::DisableOnError) {
widgetInfo.widget->setEnabled(false); widgetInfo.widget->setEnabled(false);
if (auto parentWidget = widgetInfo.widget->parentWidget())
parentWidget->setEnabled(false);
}
} }
void ViewManager::enableWidgets() void ViewManager::enableWidgets()
{ {
foreach (const WidgetInfo &widgetInfo, widgetInfos()) foreach (const WidgetInfo &widgetInfo, widgetInfos())
if (widgetInfo.widgetFlags == DesignerWidgetFlags::DisableOnError) if (widgetInfo.widgetFlags == DesignerWidgetFlags::DisableOnError) {
widgetInfo.widget->setEnabled(true); widgetInfo.widget->setEnabled(true);
if (auto parentWidget = widgetInfo.widget->parentWidget())
parentWidget->setEnabled(true);
}
} }
void ViewManager::pushFileOnCrumbleBar(const Utils::FileName &fileName) void ViewManager::pushFileOnCrumbleBar(const Utils::FileName &fileName)