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());
return createWidgetInfo(m_statesEditorWidget.data(),
QLatin1String("StatesEditorNew"),
"StatesEditor",
WidgetInfo::BottomPane,
0,
tr("States New"));
tr("States"));
}
void StatesEditorView::rootNodeTypeChanged(const QString &/*type*/, int /*majorVersion*/, int /*minorVersion*/)

View File

@@ -58,6 +58,14 @@
namespace QmlDesigner {
static bool useOldStatesEditor()
{
return QmlDesignerPlugin::instance()
->settings()
.value(DesignerSettingsKey::OLD_STATES_EDITOR)
.toBool();
}
static Q_LOGGING_CATEGORY(viewBenchmark, "qtc.viewmanager.attach", QtWarningMsg)
class ViewManagerData
@@ -166,26 +174,30 @@ void ViewManager::detachRewriterView()
void ViewManager::switchStateEditorViewToBaseState()
{
if (d->statesEditorView.isAttached()) {
d->savedState = d->statesEditorView.currentState();
d->statesEditorView.setCurrentState(d->statesEditorView.baseState());
}
// TODO Settings branch
if (d->newStatesEditorView.isAttached()) {
d->savedState = d->newStatesEditorView.currentState();
d->newStatesEditorView.setCurrentState(d->newStatesEditorView.baseState());
if (useOldStatesEditor()) {
if (d->statesEditorView.isAttached()) {
d->savedState = d->statesEditorView.currentState();
d->statesEditorView.setCurrentState(d->statesEditorView.baseState());
}
} else {
// TODO remove old statesview
if (d->newStatesEditorView.isAttached()) {
d->savedState = d->newStatesEditorView.currentState();
d->newStatesEditorView.setCurrentState(d->newStatesEditorView.baseState());
}
}
}
void ViewManager::switchStateEditorViewToSavedState()
{
if (d->savedState.isValid() && d->statesEditorView.isAttached())
d->statesEditorView.setCurrentState(d->savedState);
// TODO Settings branch
if (d->savedState.isValid() && d->newStatesEditorView.isAttached())
d->newStatesEditorView.setCurrentState(d->savedState);
if (useOldStatesEditor()) {
if (d->savedState.isValid() && d->statesEditorView.isAttached())
d->statesEditorView.setCurrentState(d->savedState);
} else {
// TODO remove old statesview
if (d->savedState.isValid() && d->newStatesEditorView.isAttached())
d->newStatesEditorView.setCurrentState(d->savedState);
}
}
QList<AbstractView *> ViewManager::views() const
@@ -211,9 +223,16 @@ QList<AbstractView *> ViewManager::standardViews() const
&d->newStatesEditorView, // TODO
&d->designerActionManagerView};
if (QmlDesignerPlugin::instance()->settings().value(
DesignerSettingsKey::ENABLE_DEBUGVIEW).toBool())
list.append(&d->debugView);
if (useOldStatesEditor())
list.removeAll(&d->newStatesEditorView);
else
list.removeAll(&d->statesEditorView);
if (QmlDesignerPlugin::instance()
->settings()
.value(DesignerSettingsKey::ENABLE_DEBUGVIEW)
.toBool())
list.append(&d->debugView);
return list;
}
@@ -343,8 +362,11 @@ QList<WidgetInfo> ViewManager::widgetInfos() const
widgetInfoList.append(d->propertyEditorView.widgetInfo());
widgetInfoList.append(d->materialEditorView.widgetInfo());
widgetInfoList.append(d->materialBrowserView.widgetInfo());
widgetInfoList.append(d->statesEditorView.widgetInfo());
widgetInfoList.append(d->newStatesEditorView.widgetInfo()); // TODO
if (useOldStatesEditor())
widgetInfoList.append(d->statesEditorView.widgetInfo());
else
widgetInfoList.append(d->newStatesEditorView.widgetInfo());
if (d->debugView.hasWidget())
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::SMOOTH_RENDERING, false);
restoreValue(settings, DesignerSettingsKey::SHOW_DEBUG_SETTINGS, false);
restoreValue(settings, DesignerSettingsKey::OLD_STATES_EDITOR, true);
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 ASK_BEFORE_DELETING_ASSET[] = "AskBeforeDeletingAsset";
const char SMOOTH_RENDERING[] = "SmoothRendering";
const char OLD_STATES_EDITOR[] = "OldStatesEditor";
}
class QMLDESIGNERCORE_EXPORT DesignerSettings : public QHash<QByteArray, QVariant>