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