Commit f47a916c authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Save settings on mode changes



This partly addresses QTCREATORBUG-7754: Settings are lost way less
often this way. We do not really want to save whenever settings might
have been touched, so this seems like a good compromise to me.

Most modes at least have some view specific settings that need saving,
so lets just save everything on each mode change. Settings are only
written to disk if they really changed nowadays, so this should be fine.

Task-number: QTCREATORBUG-7754
Change-Id: I26ae18cae38754da6c79a8b870ffae2e681db7c1
Reviewed-by: default avatarDaniel Teske <daniel.teske@nokia.com>
parent 2ebce73d
......@@ -78,6 +78,7 @@ struct ModeManagerPrivate
QSignalMapper *m_signalMapper;
Context m_addedContexts;
int m_oldCurrent;
bool m_saveSettingsOnModeChange;
};
static ModeManagerPrivate *d;
......@@ -104,10 +105,13 @@ ModeManager::ModeManager(Internal::MainWindow *mainWindow,
d->m_oldCurrent = -1;
d->m_actionBar = new Internal::FancyActionBar(modeStack);
d->m_modeStack->addCornerWidget(d->m_actionBar);
d->m_saveSettingsOnModeChange = false;
connect(d->m_modeStack, SIGNAL(currentAboutToShow(int)), SLOT(currentTabAboutToChange(int)));
connect(d->m_modeStack, SIGNAL(currentChanged(int)), SLOT(currentTabChanged(int)));
connect(d->m_signalMapper, SIGNAL(mapped(int)), this, SLOT(slotActivateMode(int)));
connect(ExtensionSystem::PluginManager::instance(), SIGNAL(initializationDone()), this, SLOT(handleStartup()));
connect(ICore::instance(), SIGNAL(coreAboutToClose()), this, SLOT(handleShutdown()));
}
void ModeManager::init()
......@@ -252,6 +256,12 @@ void ModeManager::enabledStateChanged()
}
}
void ModeManager::handleStartup()
{ d->m_saveSettingsOnModeChange = true; }
void ModeManager::handleShutdown()
{ d->m_saveSettingsOnModeChange = false; }
void ModeManager::aboutToRemoveObject(QObject *obj)
{
IMode *mode = Aggregation::query<IMode>(obj);
......@@ -290,8 +300,11 @@ void ModeManager::currentTabAboutToChange(int index)
{
if (index >= 0) {
IMode *mode = d->m_modes.at(index);
if (mode)
if (mode) {
if (d->m_saveSettingsOnModeChange)
ICore::saveSettings();
emit currentModeAboutToChange(mode);
}
}
}
......
......@@ -85,6 +85,8 @@ private slots:
void currentTabChanged(int index);
void updateModeToolTip();
void enabledStateChanged();
void handleStartup();
void handleShutdown();
};
} // namespace Core
......
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