forked from qt-creator/qt-creator
Change configuration saving
* Save initial configuration after all the plugins are done with their delayed initialization * Save configuration when the autosave timer triggers. The disks are in use at that time anyway and saving can be turned off completely * Save settings when closing the options page dialog Change-Id: Idcf9ad61e8f9b94899c580d5a855a883a62f8dc0 Reviewed-by: Majid Khan <mkhan3189@gmail.com> Reviewed-by: Daniel Teske <daniel.teske@nokia.com> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -798,6 +798,7 @@ void PluginManagerPrivate::nextDelayedInitialize()
|
||||
if (delayedInitializeQueue.isEmpty()) {
|
||||
delete delayedInitializeTimer;
|
||||
delayedInitializeTimer = 0;
|
||||
emit q->initializationDone();
|
||||
} else {
|
||||
delayedInitializeTimer->start();
|
||||
}
|
||||
|
@@ -135,6 +135,7 @@ signals:
|
||||
void aboutToRemoveObject(QObject *obj);
|
||||
|
||||
void pluginsChanged();
|
||||
void initializationDone();
|
||||
|
||||
public slots:
|
||||
void remoteArguments(const QString &serializedArguments);
|
||||
|
@@ -542,6 +542,8 @@ void SettingsDialog::done(int val)
|
||||
settings->setValue(QLatin1String(categoryKeyC), m_currentCategory);
|
||||
settings->setValue(QLatin1String(pageKeyC), m_currentPage);
|
||||
|
||||
ICore::saveSettings(); // save all settings
|
||||
|
||||
// exit all additional event loops, see comment in execDialog()
|
||||
QListIterator<QEventLoop *> it(m_eventLoops);
|
||||
it.toBack();
|
||||
|
@@ -1506,6 +1506,9 @@ void EditorManager::autoSave()
|
||||
if (!errors.isEmpty())
|
||||
QMessageBox::critical(ICore::mainWindow(), tr("File Error"),
|
||||
errors.join(QLatin1String("\n")));
|
||||
|
||||
// Also save settings while accessing the disk anyway:
|
||||
ICore::saveSettings();
|
||||
}
|
||||
|
||||
MakeWritableResult EditorManager::makeFileWritable(IDocument *document)
|
||||
|
@@ -30,6 +30,8 @@
|
||||
|
||||
#include "icore.h"
|
||||
|
||||
#include <extensionsystem/pluginmanager.h>
|
||||
|
||||
/*!
|
||||
\namespace Core
|
||||
\brief The Core namespace contains all classes that make up the Core plugin
|
||||
@@ -373,6 +375,9 @@ ICore::ICore(MainWindow *mainwindow)
|
||||
{
|
||||
m_instance = this;
|
||||
m_mainwindow = mainwindow;
|
||||
// Save settings once after all plugins are initialized:
|
||||
connect(ExtensionSystem::PluginManager::instance(), SIGNAL(initializationDone()),
|
||||
this, SIGNAL(saveSettingsRequested()));
|
||||
}
|
||||
|
||||
ICore::~ICore()
|
||||
@@ -553,4 +558,12 @@ void ICore::emitNewItemsDialogRequested()
|
||||
emit m_instance->newItemsDialogRequested();
|
||||
}
|
||||
|
||||
void ICore::saveSettings()
|
||||
{
|
||||
emit m_instance->saveSettingsRequested();
|
||||
|
||||
ICore::settings(QSettings::SystemScope)->sync();
|
||||
ICore::settings(QSettings::UserScope)->sync();
|
||||
}
|
||||
|
||||
} // namespace Core
|
||||
|
@@ -134,6 +134,8 @@ public:
|
||||
|
||||
static void emitNewItemsDialogRequested();
|
||||
|
||||
static void saveSettings();
|
||||
|
||||
signals:
|
||||
void coreAboutToOpen();
|
||||
void coreOpened();
|
||||
|
@@ -233,11 +233,6 @@ MainWindow::MainWindow() :
|
||||
#if defined(Q_OS_MAC)
|
||||
MacFullScreen::addFullScreen(this);
|
||||
#endif
|
||||
|
||||
m_autoSaveSessionTimer = new QTimer(this);
|
||||
m_autoSaveSessionTimer->setInterval(10000);
|
||||
connect(m_autoSaveSessionTimer, SIGNAL(timeout()),
|
||||
m_coreImpl, SIGNAL(saveSettingsRequested()));
|
||||
}
|
||||
|
||||
void MainWindow::setSidebarVisible(bool visible)
|
||||
@@ -377,13 +372,11 @@ void MainWindow::extensionsInitialized()
|
||||
emit m_coreImpl->coreAboutToOpen();
|
||||
show();
|
||||
emit m_coreImpl->coreOpened();
|
||||
m_autoSaveSessionTimer->start();
|
||||
}
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
m_autoSaveSessionTimer->stop();
|
||||
emit m_coreImpl->saveSettingsRequested();
|
||||
ICore::saveSettings();
|
||||
|
||||
// Save opened files
|
||||
bool cancelled;
|
||||
@@ -979,7 +972,6 @@ bool MainWindow::showOptionsDialog(const QString &category,
|
||||
void MainWindow::saveAll()
|
||||
{
|
||||
DocumentManager::saveModifiedDocumentsSilently(DocumentManager::modifiedDocuments());
|
||||
emit m_coreImpl->saveSettingsRequested();
|
||||
}
|
||||
|
||||
void MainWindow::exit()
|
||||
|
@@ -229,7 +229,6 @@ private:
|
||||
QColor m_overrideColor;
|
||||
|
||||
QStringList m_filesToOpenDelayed;
|
||||
QTimer *m_autoSaveSessionTimer;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
|
Reference in New Issue
Block a user