forked from qt-creator/qt-creator
QmlDesigner: Show message box if StatesList.qml cannot be created
I also removed the hard assert. Change-Id: Ia15d9f82fb63e7d8dd6acf8547b9e96bad838d3f Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -33,6 +33,7 @@
|
|||||||
|
|
||||||
#include <invalidqmlsourceexception.h>
|
#include <invalidqmlsourceexception.h>
|
||||||
|
|
||||||
|
#include <coreplugin/messagebox.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -57,15 +58,15 @@ namespace QmlDesigner {
|
|||||||
|
|
||||||
int StatesEditorWidget::currentStateInternalId() const
|
int StatesEditorWidget::currentStateInternalId() const
|
||||||
{
|
{
|
||||||
Q_ASSERT(rootObject());
|
QTC_ASSERT(rootObject(), return -1);
|
||||||
Q_ASSERT(rootObject()->property("currentStateInternalId").isValid());
|
QTC_ASSERT(rootObject()->property("currentStateInternalId").isValid(), return -1);
|
||||||
|
|
||||||
return rootObject()->property("currentStateInternalId").toInt();
|
return rootObject()->property("currentStateInternalId").toInt();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatesEditorWidget::setCurrentStateInternalId(int internalId)
|
void StatesEditorWidget::setCurrentStateInternalId(int internalId)
|
||||||
{
|
{
|
||||||
Q_ASSERT(rootObject());
|
QTC_ASSERT(rootObject(), return);
|
||||||
rootObject()->setProperty("currentStateInternalId", internalId);
|
rootObject()->setProperty("currentStateInternalId", internalId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,6 +120,7 @@ QString StatesEditorWidget::qmlSourcesPath() {
|
|||||||
|
|
||||||
void StatesEditorWidget::toggleStatesViewExpanded()
|
void StatesEditorWidget::toggleStatesViewExpanded()
|
||||||
{
|
{
|
||||||
|
QTC_ASSERT(rootObject(), return);
|
||||||
bool expanded = rootObject()->property("expanded").toBool();
|
bool expanded = rootObject()->property("expanded").toBool();
|
||||||
rootObject()->setProperty("expanded", !expanded);
|
rootObject()->setProperty("expanded", !expanded);
|
||||||
}
|
}
|
||||||
@@ -130,7 +132,13 @@ void StatesEditorWidget::reloadQmlSource()
|
|||||||
engine()->clearComponentCache();
|
engine()->clearComponentCache();
|
||||||
setSource(QUrl::fromLocalFile(statesListQmlFilePath));
|
setSource(QUrl::fromLocalFile(statesListQmlFilePath));
|
||||||
|
|
||||||
QTC_ASSERT(rootObject(), return);
|
if (!rootObject()) {
|
||||||
|
Core::AsynchronousMessageBox::warning(tr("Cannot create QtQuick View"),
|
||||||
|
tr("StatesEditorWidget: %1 cannot be created. "
|
||||||
|
"Most likely QtQuick.Controls 1 are not installed.").arg(qmlSourcesPath()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
connect(rootObject(), SIGNAL(currentStateInternalIdChanged()), m_statesEditorView.data(), SLOT(synchonizeCurrentStateFromWidget()));
|
connect(rootObject(), SIGNAL(currentStateInternalIdChanged()), m_statesEditorView.data(), SLOT(synchonizeCurrentStateFromWidget()));
|
||||||
connect(rootObject(), SIGNAL(createNewState()), m_statesEditorView.data(), SLOT(createNewState()));
|
connect(rootObject(), SIGNAL(createNewState()), m_statesEditorView.data(), SLOT(createNewState()));
|
||||||
connect(rootObject(), SIGNAL(deleteState(int)), m_statesEditorView.data(), SLOT(removeState(int)));
|
connect(rootObject(), SIGNAL(deleteState(int)), m_statesEditorView.data(), SLOT(removeState(int)));
|
||||||
@@ -147,8 +155,9 @@ void StatesEditorWidget::reloadQmlSource()
|
|||||||
|
|
||||||
void StatesEditorWidget::handleExpandedChanged()
|
void StatesEditorWidget::handleExpandedChanged()
|
||||||
{
|
{
|
||||||
bool expanded = rootObject()->property("expanded").toBool();
|
QTC_ASSERT(rootObject(), return);
|
||||||
|
|
||||||
|
bool expanded = rootObject()->property("expanded").toBool();
|
||||||
DesignerSettings::setValue(DesignerSettingsKey::STATESEDITOR_EXPANDED, expanded);
|
DesignerSettings::setValue(DesignerSettingsKey::STATESEDITOR_EXPANDED, expanded);
|
||||||
|
|
||||||
setFixedHeight(rootObject()->height());
|
setFixedHeight(rootObject()->height());
|
||||||
|
|||||||
Reference in New Issue
Block a user