Commit df75ec5e authored by Marco Bubke's avatar Marco Bubke

QmlDesigner: Disable States for ApplicationWindow

Change-Id: Ia86ee67cdb0ab25f5ba00877997ae6b74fe4687a
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
parent 5ee0ab93
......@@ -76,7 +76,7 @@ void StatesEditorView::propertiesAboutToBeRemoved(const QList<AbstractProperty>
void StatesEditorView::rootNodeTypeChanged(const QString &/*type*/, int /*majorVersion*/, int /*minorVersion*/)
{
checkForApplicationWindow();
}
void StatesEditorView::instancePropertyChange(const QList<QPair<ModelNode, PropertyName> > &/*propertyList*/)
......@@ -245,6 +245,12 @@ void StatesEditorView::duplicateCurrentState()
setCurrentState(newState);
}
void StatesEditorView::checkForApplicationWindow()
{
if (m_statesEditorWidget)
m_statesEditorWidget->showAddNewStatesButton(!rootModelNode().metaInfo().isSubclassOf("QtQuick.Controls.ApplicationWindow", -1, -1));
}
void StatesEditorView::setCurrentState(const QmlModelState &state)
{
if (!model() && !state.isValid())
......@@ -310,6 +316,8 @@ void StatesEditorView::modelAttached(Model *model)
if (m_statesEditorWidget)
m_statesEditorWidget->setNodeInstanceView(nodeInstanceView());
checkForApplicationWindow();
resetModel();
}
......
......@@ -112,6 +112,7 @@ private:
void resetModel();
void addState();
void duplicateCurrentState();
void checkForApplicationWindow();
private:
QWeakPointer<StatesEditorModel> m_statesEditorModel;
......
......@@ -67,6 +67,11 @@ void StatesEditorWidget::setNodeInstanceView(NodeInstanceView *nodeInstanceView)
m_imageProvider->setNodeInstanceView(nodeInstanceView);
}
void StatesEditorWidget::showAddNewStatesButton(bool showAddNewStatesButton)
{
m_declarativeView->rootContext()->setContextProperty("canAddNewStates", showAddNewStatesButton);
}
StatesEditorWidget::StatesEditorWidget(StatesEditorView *statesEditorView, StatesEditorModel *statesEditorModel):
QWidget(),
m_declarativeView(new QDeclarativeView(this)),
......@@ -94,6 +99,8 @@ StatesEditorWidget::StatesEditorWidget(StatesEditorView *statesEditorView, State
highlightColor.setHsvF(highlightColor.hsvHueF(),0.1 + highlightColor.saturationF()*2.0, highlightColor.valueF());
m_declarativeView->rootContext()->setContextProperty(QLatin1String("highlightColor"), highlightColor);
m_declarativeView->rootContext()->setContextProperty("canAddNewStates", true);
// Work around ASSERT in the internal QGraphicsScene that happens when
// the scene is created + items set dirty in one event loop run (BAUHAUS-459)
//QApplication::processEvents();
......
......@@ -62,6 +62,8 @@ public:
void setCurrentStateInternalId(int internalId);
void setNodeInstanceView(NodeInstanceView *nodeInstanceView);
void showAddNewStatesButton(bool showAddNewStatesButton);
private:
QWeakPointer<QDeclarativeView> m_declarativeView;
QWeakPointer<StatesEditorView> m_statesEditorView;
......
......@@ -85,6 +85,7 @@ Rectangle {
id: newStateBoxLoader;
width:132
height:listViewRow.height
visible: canAddNewStates
Loader {
sourceComponent: addState;
// make it square
......
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