forked from qt-creator/qt-creator
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: Daniel Teske <daniel.teske@nokia.com>
This commit is contained in:
@@ -78,6 +78,7 @@ struct ModeManagerPrivate
|
|||||||
QSignalMapper *m_signalMapper;
|
QSignalMapper *m_signalMapper;
|
||||||
Context m_addedContexts;
|
Context m_addedContexts;
|
||||||
int m_oldCurrent;
|
int m_oldCurrent;
|
||||||
|
bool m_saveSettingsOnModeChange;
|
||||||
};
|
};
|
||||||
|
|
||||||
static ModeManagerPrivate *d;
|
static ModeManagerPrivate *d;
|
||||||
@@ -104,10 +105,13 @@ ModeManager::ModeManager(Internal::MainWindow *mainWindow,
|
|||||||
d->m_oldCurrent = -1;
|
d->m_oldCurrent = -1;
|
||||||
d->m_actionBar = new Internal::FancyActionBar(modeStack);
|
d->m_actionBar = new Internal::FancyActionBar(modeStack);
|
||||||
d->m_modeStack->addCornerWidget(d->m_actionBar);
|
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(currentAboutToShow(int)), SLOT(currentTabAboutToChange(int)));
|
||||||
connect(d->m_modeStack, SIGNAL(currentChanged(int)), SLOT(currentTabChanged(int)));
|
connect(d->m_modeStack, SIGNAL(currentChanged(int)), SLOT(currentTabChanged(int)));
|
||||||
connect(d->m_signalMapper, SIGNAL(mapped(int)), this, SLOT(slotActivateMode(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()
|
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)
|
void ModeManager::aboutToRemoveObject(QObject *obj)
|
||||||
{
|
{
|
||||||
IMode *mode = Aggregation::query<IMode>(obj);
|
IMode *mode = Aggregation::query<IMode>(obj);
|
||||||
@@ -290,9 +300,12 @@ void ModeManager::currentTabAboutToChange(int index)
|
|||||||
{
|
{
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
IMode *mode = d->m_modes.at(index);
|
IMode *mode = d->m_modes.at(index);
|
||||||
if (mode)
|
if (mode) {
|
||||||
|
if (d->m_saveSettingsOnModeChange)
|
||||||
|
ICore::saveSettings();
|
||||||
emit currentModeAboutToChange(mode);
|
emit currentModeAboutToChange(mode);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModeManager::currentTabChanged(int index)
|
void ModeManager::currentTabChanged(int index)
|
||||||
|
@@ -85,6 +85,8 @@ private slots:
|
|||||||
void currentTabChanged(int index);
|
void currentTabChanged(int index);
|
||||||
void updateModeToolTip();
|
void updateModeToolTip();
|
||||||
void enabledStateChanged();
|
void enabledStateChanged();
|
||||||
|
void handleStartup();
|
||||||
|
void handleShutdown();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
Reference in New Issue
Block a user