QmlDesigner: Add setting for new states editor

This makes it easy to enable/disable the new states editor.
[QML}
Designer\OldStatesEditor=false

Change-Id: Ib3545bf0be8547af06eb0e9dda0cee2a143659b1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Aleksei German <aleksei.german@qt.io>
This commit is contained in:
Thomas Hartmann
2022-09-19 16:53:32 +02:00
parent f639f72c14
commit bbffd88c1b
4 changed files with 46 additions and 22 deletions

View File

@@ -80,10 +80,10 @@ WidgetInfo StatesEditorView::widgetInfo()
m_statesEditorWidget = new StatesEditorWidget(this, m_statesEditorModel.data()); m_statesEditorWidget = new StatesEditorWidget(this, m_statesEditorModel.data());
return createWidgetInfo(m_statesEditorWidget.data(), return createWidgetInfo(m_statesEditorWidget.data(),
QLatin1String("StatesEditorNew"), "StatesEditor",
WidgetInfo::BottomPane, WidgetInfo::BottomPane,
0, 0,
tr("States New")); tr("States"));
} }
void StatesEditorView::rootNodeTypeChanged(const QString &/*type*/, int /*majorVersion*/, int /*minorVersion*/) void StatesEditorView::rootNodeTypeChanged(const QString &/*type*/, int /*majorVersion*/, int /*minorVersion*/)

View File

@@ -58,6 +58,14 @@
namespace QmlDesigner { namespace QmlDesigner {
static bool useOldStatesEditor()
{
return QmlDesignerPlugin::instance()
->settings()
.value(DesignerSettingsKey::OLD_STATES_EDITOR)
.toBool();
}
static Q_LOGGING_CATEGORY(viewBenchmark, "qtc.viewmanager.attach", QtWarningMsg) static Q_LOGGING_CATEGORY(viewBenchmark, "qtc.viewmanager.attach", QtWarningMsg)
class ViewManagerData class ViewManagerData
@@ -166,27 +174,31 @@ void ViewManager::detachRewriterView()
void ViewManager::switchStateEditorViewToBaseState() void ViewManager::switchStateEditorViewToBaseState()
{ {
if (useOldStatesEditor()) {
if (d->statesEditorView.isAttached()) { if (d->statesEditorView.isAttached()) {
d->savedState = d->statesEditorView.currentState(); d->savedState = d->statesEditorView.currentState();
d->statesEditorView.setCurrentState(d->statesEditorView.baseState()); d->statesEditorView.setCurrentState(d->statesEditorView.baseState());
} }
} else {
// TODO Settings branch // TODO remove old statesview
if (d->newStatesEditorView.isAttached()) { if (d->newStatesEditorView.isAttached()) {
d->savedState = d->newStatesEditorView.currentState(); d->savedState = d->newStatesEditorView.currentState();
d->newStatesEditorView.setCurrentState(d->newStatesEditorView.baseState()); d->newStatesEditorView.setCurrentState(d->newStatesEditorView.baseState());
} }
} }
}
void ViewManager::switchStateEditorViewToSavedState() void ViewManager::switchStateEditorViewToSavedState()
{ {
if (useOldStatesEditor()) {
if (d->savedState.isValid() && d->statesEditorView.isAttached()) if (d->savedState.isValid() && d->statesEditorView.isAttached())
d->statesEditorView.setCurrentState(d->savedState); d->statesEditorView.setCurrentState(d->savedState);
} else {
// TODO Settings branch // TODO remove old statesview
if (d->savedState.isValid() && d->newStatesEditorView.isAttached()) if (d->savedState.isValid() && d->newStatesEditorView.isAttached())
d->newStatesEditorView.setCurrentState(d->savedState); d->newStatesEditorView.setCurrentState(d->savedState);
} }
}
QList<AbstractView *> ViewManager::views() const QList<AbstractView *> ViewManager::views() const
{ {
@@ -211,8 +223,15 @@ QList<AbstractView *> ViewManager::standardViews() const
&d->newStatesEditorView, // TODO &d->newStatesEditorView, // TODO
&d->designerActionManagerView}; &d->designerActionManagerView};
if (QmlDesignerPlugin::instance()->settings().value( if (useOldStatesEditor())
DesignerSettingsKey::ENABLE_DEBUGVIEW).toBool()) list.removeAll(&d->newStatesEditorView);
else
list.removeAll(&d->statesEditorView);
if (QmlDesignerPlugin::instance()
->settings()
.value(DesignerSettingsKey::ENABLE_DEBUGVIEW)
.toBool())
list.append(&d->debugView); list.append(&d->debugView);
return list; return list;
@@ -343,8 +362,11 @@ QList<WidgetInfo> ViewManager::widgetInfos() const
widgetInfoList.append(d->propertyEditorView.widgetInfo()); widgetInfoList.append(d->propertyEditorView.widgetInfo());
widgetInfoList.append(d->materialEditorView.widgetInfo()); widgetInfoList.append(d->materialEditorView.widgetInfo());
widgetInfoList.append(d->materialBrowserView.widgetInfo()); widgetInfoList.append(d->materialBrowserView.widgetInfo());
if (useOldStatesEditor())
widgetInfoList.append(d->statesEditorView.widgetInfo()); widgetInfoList.append(d->statesEditorView.widgetInfo());
widgetInfoList.append(d->newStatesEditorView.widgetInfo()); // TODO else
widgetInfoList.append(d->newStatesEditorView.widgetInfo());
if (d->debugView.hasWidget()) if (d->debugView.hasWidget())
widgetInfoList.append(d->debugView.widgetInfo()); widgetInfoList.append(d->debugView.widgetInfo());

View File

@@ -85,6 +85,7 @@ void DesignerSettings::fromSettings(QSettings *settings)
restoreValue(settings, DesignerSettingsKey::EDIT3DVIEW_GRID_COLOR, "#aaaaaa"); restoreValue(settings, DesignerSettingsKey::EDIT3DVIEW_GRID_COLOR, "#aaaaaa");
restoreValue(settings, DesignerSettingsKey::SMOOTH_RENDERING, false); restoreValue(settings, DesignerSettingsKey::SMOOTH_RENDERING, false);
restoreValue(settings, DesignerSettingsKey::SHOW_DEBUG_SETTINGS, false); restoreValue(settings, DesignerSettingsKey::SHOW_DEBUG_SETTINGS, false);
restoreValue(settings, DesignerSettingsKey::OLD_STATES_EDITOR, true);
settings->endGroup(); settings->endGroup();
settings->endGroup(); settings->endGroup();

View File

@@ -74,6 +74,7 @@ const char ALWAYS_DESIGN_MODE[] = "AlwaysDesignMode";
const char DISABLE_ITEM_LIBRARY_UPDATE_TIMER[] = "DisableItemLibraryUpdateTimer"; const char DISABLE_ITEM_LIBRARY_UPDATE_TIMER[] = "DisableItemLibraryUpdateTimer";
const char ASK_BEFORE_DELETING_ASSET[] = "AskBeforeDeletingAsset"; const char ASK_BEFORE_DELETING_ASSET[] = "AskBeforeDeletingAsset";
const char SMOOTH_RENDERING[] = "SmoothRendering"; const char SMOOTH_RENDERING[] = "SmoothRendering";
const char OLD_STATES_EDITOR[] = "OldStatesEditor";
} }
class QMLDESIGNERCORE_EXPORT DesignerSettings : public QHash<QByteArray, QVariant> class QMLDESIGNERCORE_EXPORT DesignerSettings : public QHash<QByteArray, QVariant>