forked from qt-creator/qt-creator
Support view/hide right side bar in Debug mode
Like it is now supported in Widget Designer, the view/hide action toggles the corresponding dock widget area. We cannot do that for the left dock widget area yet, because that action still needs to toggle the navigation side bar. To support this, we need to save not only the QMainWindow state for the debugger perspectives, but the whole FancyMainWindow state including the information about hidden dock widget areas. Unfortunately the PerspectiveState was serialized to QVariant without versioning, so keeping it that way is difficult. Switch saving&restoring of PerspectiveState to Utils::Store (and keep some compatibility code). Change-Id: I0035841930c6a574aeb31650a28be9989e2b5741 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -437,8 +437,14 @@ void DebuggerMainWindow::restorePersistentSettings()
|
||||
d->m_lastTypePerspectiveStates.clear();
|
||||
QSet<QString> keys = Utils::toSet(states2.keys());
|
||||
for (const QString &type : keys) {
|
||||
PerspectiveState state = states2.value(type).value<PerspectiveState>();
|
||||
QTC_ASSERT(!state.mainWindowState.isEmpty(), continue);
|
||||
PerspectiveState state;
|
||||
if (states2.value(type).canConvert<QVariantMap>()) {
|
||||
state = PerspectiveState::fromSettings(storeFromMap(states2.value(type).toMap()));
|
||||
} else {
|
||||
// legacy for up to QtC 12
|
||||
state = states2.value(type).value<PerspectiveState>();
|
||||
}
|
||||
QTC_ASSERT(state.hasWindowState(), continue);
|
||||
d->m_lastTypePerspectiveStates.insert(type, state);
|
||||
}
|
||||
|
||||
@@ -469,7 +475,7 @@ void DebuggerMainWindow::savePersistentSettings() const
|
||||
qCDebug(perspectivesLog) << "PERSPECTIVE TYPE " << type
|
||||
<< " HAS STATE: " << !state.mainWindowState.isEmpty();
|
||||
QTC_ASSERT(!state.mainWindowState.isEmpty(), continue);
|
||||
states.insert(type, QVariant::fromValue(state));
|
||||
states.insert(type, mapFromStore(state.toSettings()));
|
||||
}
|
||||
|
||||
QtcSettings *settings = ICore::settings();
|
||||
@@ -965,10 +971,10 @@ void PerspectivePrivate::restoreLayout()
|
||||
{
|
||||
qCDebug(perspectivesLog) << "RESTORE LAYOUT FOR " << m_id << settingsId();
|
||||
PerspectiveState state = theMainWindow->d->m_lastPerspectiveStates.value(m_id);
|
||||
if (state.mainWindowState.isEmpty()) {
|
||||
if (!state.hasWindowState()) {
|
||||
qCDebug(perspectivesLog) << "PERSPECTIVE STATE NOT AVAILABLE BY FULL ID.";
|
||||
state = theMainWindow->d->m_lastTypePerspectiveStates.value(settingsId());
|
||||
if (state.mainWindowState.isEmpty()) {
|
||||
if (state.hasWindowState()) {
|
||||
qCDebug(perspectivesLog) << "PERSPECTIVE STATE NOT AVAILABLE BY PERSPECTIVE TYPE";
|
||||
} else {
|
||||
qCDebug(perspectivesLog) << "PERSPECTIVE STATE AVAILABLE BY PERSPECTIVE TYPE.";
|
||||
@@ -994,10 +1000,10 @@ void PerspectivePrivate::restoreLayout()
|
||||
}
|
||||
}
|
||||
|
||||
if (state.mainWindowState.isEmpty()) {
|
||||
if (!state.hasWindowState()) {
|
||||
qCDebug(perspectivesLog) << "PERSPECTIVE " << m_id << "RESTORE NOT POSSIBLE, NO STORED STATE";
|
||||
} else {
|
||||
bool result = theMainWindow->restoreFancyState(state.mainWindowState);
|
||||
const bool result = state.restoreWindowState(theMainWindow);
|
||||
qCDebug(perspectivesLog) << "PERSPECTIVE " << m_id << "RESTORED, SUCCESS: " << result;
|
||||
}
|
||||
|
||||
@@ -1019,7 +1025,7 @@ void PerspectivePrivate::saveLayout()
|
||||
{
|
||||
qCDebug(perspectivesLog) << "PERSPECTIVE" << m_id << "SAVE LAYOUT TO " << settingsId();
|
||||
PerspectiveState state;
|
||||
state.mainWindowState = theMainWindow->saveState();
|
||||
state.mainWindowState = theMainWindow->saveSettings();
|
||||
for (DockOperation &op : m_dockOperations) {
|
||||
if (op.operationType != Perspective::Raise) {
|
||||
QTC_ASSERT(op.dock, continue);
|
||||
@@ -1070,4 +1076,36 @@ const char *PerspectiveState::savesHeaderKey()
|
||||
return "SavesHeader";
|
||||
}
|
||||
|
||||
bool PerspectiveState::hasWindowState() const
|
||||
{
|
||||
return !mainWindowState.isEmpty() || !mainWindowStateLegacy.isEmpty();
|
||||
}
|
||||
|
||||
bool PerspectiveState::restoreWindowState(FancyMainWindow * mainWindow)
|
||||
{
|
||||
if (!mainWindowState.isEmpty())
|
||||
return mainWindow->restoreSettings(mainWindowState);
|
||||
if (!mainWindowStateLegacy.isEmpty())
|
||||
return mainWindow->restoreFancyState(mainWindowStateLegacy);
|
||||
return false;
|
||||
}
|
||||
|
||||
const char kMainWindowStateKey[] = "MainWindow";
|
||||
const char kHeaderViewStatesKey[] = "HeaderViewStates";
|
||||
|
||||
Store PerspectiveState::toSettings() const
|
||||
{
|
||||
Store result;
|
||||
result.insert(kMainWindowStateKey, QVariant::fromValue(mainWindowState));
|
||||
result.insert(kHeaderViewStatesKey, QVariant::fromValue(headerViewStates));
|
||||
return result;
|
||||
}
|
||||
PerspectiveState PerspectiveState::fromSettings(const Store &settings)
|
||||
{
|
||||
PerspectiveState state;
|
||||
state.mainWindowState = settings.value(kMainWindowStateKey).value<Store>();
|
||||
state.headerViewStates = settings.value(kHeaderViewStatesKey).value<QVariantHash>();
|
||||
return state;
|
||||
}
|
||||
|
||||
} // Utils
|
||||
|
||||
Reference in New Issue
Block a user