diff options
Diffstat (limited to 'src/plugins/qmldesigner/components/stateseditor')
4 files changed, 17 insertions, 31 deletions
diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp index 997852cfb2..cf1f377141 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.cpp @@ -85,12 +85,6 @@ void StatesEditorView::rootNodeTypeChanged(const QString &/*type*/, int /*majorV checkForStatesAvailability(); } -void StatesEditorView::toggleStatesViewExpanded() -{ - if (m_statesEditorWidget) - m_statesEditorWidget->toggleStatesViewExpanded(); -} - void StatesEditorView::removeState(int nodeId) { try { @@ -102,6 +96,22 @@ void StatesEditorView::removeState(int nodeId) if (modelState.isValid()) { QStringList lockedTargets; const auto propertyChanges = modelState.propertyChanges(); + + // confirm removing not empty states + if (!propertyChanges.isEmpty()) { + QMessageBox msgBox; + msgBox.setTextFormat(Qt::RichText); + msgBox.setIcon(QMessageBox::Question); + msgBox.setWindowTitle(tr("Remove State")); + msgBox.setText(tr("This state is not empty. Are you sure you want to remove it?")); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel); + msgBox.setDefaultButton(QMessageBox::Yes); + + if (msgBox.exec() == QMessageBox::Cancel) + return; + } + + // confirm removing states with locked targets for (const QmlPropertyChanges &change : propertyChanges) { const ModelNode target = change.target(); QTC_ASSERT(target.isValid(), continue); diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h index 1ac7a6f39f..71a82711ea 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorview.h @@ -87,8 +87,6 @@ public: void rootNodeTypeChanged(const QString &type, int majorVersion, int minorVersion) override; - void toggleStatesViewExpanded(); - public slots: void synchonizeCurrentStateFromWidget(); void createNewState(); diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp b/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp index 4701a4079e..b7b391944a 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.cpp @@ -133,13 +133,6 @@ QString StatesEditorWidget::qmlSourcesPath() return Core::ICore::resourcePath("qmldesigner/statesEditorQmlSources").toString(); } -void StatesEditorWidget::toggleStatesViewExpanded() -{ - QTC_ASSERT(rootObject(), return); - bool expanded = rootObject()->property("expanded").toBool(); - rootObject()->setProperty("expanded", !expanded); -} - void StatesEditorWidget::showEvent(QShowEvent *event) { QQuickWidget::showEvent(event); @@ -168,18 +161,6 @@ void StatesEditorWidget::reloadQmlSource() connect(rootObject(), SIGNAL(createNewState()), m_statesEditorView.data(), SLOT(createNewState())); connect(rootObject(), SIGNAL(deleteState(int)), m_statesEditorView.data(), SLOT(removeState(int))); m_statesEditorView.data()->synchonizeCurrentStateFromWidget(); - - if (!DesignerSettings::getValue(DesignerSettingsKey::STATESEDITOR_EXPANDED).toBool()) - toggleStatesViewExpanded(); - - connect(rootObject(), SIGNAL(expandedChanged()), this, SLOT(handleExpandedChanged())); } -void StatesEditorWidget::handleExpandedChanged() -{ - QTC_ASSERT(rootObject(), return); - - bool expanded = rootObject()->property("expanded").toBool(); - DesignerSettings::setValue(DesignerSettingsKey::STATESEDITOR_EXPANDED, expanded); -} -} +} // QmlDesigner diff --git a/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.h b/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.h index e4e9668abb..b613e600c4 100644 --- a/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.h +++ b/src/plugins/qmldesigner/components/stateseditor/stateseditorwidget.h @@ -57,14 +57,11 @@ public: static QString qmlSourcesPath(); - void toggleStatesViewExpanded(); - protected: void showEvent(QShowEvent *) override; private: void reloadQmlSource(); - Q_SLOT void handleExpandedChanged(); private: QPointer<StatesEditorView> m_statesEditorView; |