Commit a68352f0 authored by Tobias Hunger's avatar Tobias Hunger

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: default avatarMajid Khan <mkhan3189@gmail.com>
Reviewed-by: default avatarDaniel Teske <daniel.teske@nokia.com>
Reviewed-by: Orgad Shaneh's avatarOrgad Shaneh <orgads@gmail.com>
parent e1ae73cf
...@@ -798,6 +798,7 @@ void PluginManagerPrivate::nextDelayedInitialize() ...@@ -798,6 +798,7 @@ void PluginManagerPrivate::nextDelayedInitialize()
if (delayedInitializeQueue.isEmpty()) { if (delayedInitializeQueue.isEmpty()) {
delete delayedInitializeTimer; delete delayedInitializeTimer;
delayedInitializeTimer = 0; delayedInitializeTimer = 0;
emit q->initializationDone();
} else { } else {
delayedInitializeTimer->start(); delayedInitializeTimer->start();
} }
......
...@@ -135,6 +135,7 @@ signals: ...@@ -135,6 +135,7 @@ signals:
void aboutToRemoveObject(QObject *obj); void aboutToRemoveObject(QObject *obj);
void pluginsChanged(); void pluginsChanged();
void initializationDone();
public slots: public slots:
void remoteArguments(const QString &serializedArguments); void remoteArguments(const QString &serializedArguments);
......
...@@ -542,6 +542,8 @@ void SettingsDialog::done(int val) ...@@ -542,6 +542,8 @@ void SettingsDialog::done(int val)
settings->setValue(QLatin1String(categoryKeyC), m_currentCategory); settings->setValue(QLatin1String(categoryKeyC), m_currentCategory);
settings->setValue(QLatin1String(pageKeyC), m_currentPage); settings->setValue(QLatin1String(pageKeyC), m_currentPage);
ICore::saveSettings(); // save all settings
// exit all additional event loops, see comment in execDialog() // exit all additional event loops, see comment in execDialog()
QListIterator<QEventLoop *> it(m_eventLoops); QListIterator<QEventLoop *> it(m_eventLoops);
it.toBack(); it.toBack();
......
...@@ -1506,6 +1506,9 @@ void EditorManager::autoSave() ...@@ -1506,6 +1506,9 @@ void EditorManager::autoSave()
if (!errors.isEmpty()) if (!errors.isEmpty())
QMessageBox::critical(ICore::mainWindow(), tr("File Error"), QMessageBox::critical(ICore::mainWindow(), tr("File Error"),
errors.join(QLatin1String("\n"))); errors.join(QLatin1String("\n")));
// Also save settings while accessing the disk anyway:
ICore::saveSettings();
} }
MakeWritableResult EditorManager::makeFileWritable(IDocument *document) MakeWritableResult EditorManager::makeFileWritable(IDocument *document)
......
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
#include "icore.h" #include "icore.h"
#include <extensionsystem/pluginmanager.h>
/*! /*!
\namespace Core \namespace Core
\brief The Core namespace contains all classes that make up the Core plugin \brief The Core namespace contains all classes that make up the Core plugin
...@@ -373,6 +375,9 @@ ICore::ICore(MainWindow *mainwindow) ...@@ -373,6 +375,9 @@ ICore::ICore(MainWindow *mainwindow)
{ {
m_instance = this; m_instance = this;
m_mainwindow = mainwindow; m_mainwindow = mainwindow;
// Save settings once after all plugins are initialized:
connect(ExtensionSystem::PluginManager::instance(), SIGNAL(initializationDone()),
this, SIGNAL(saveSettingsRequested()));
} }
ICore::~ICore() ICore::~ICore()
...@@ -553,4 +558,12 @@ void ICore::emitNewItemsDialogRequested() ...@@ -553,4 +558,12 @@ void ICore::emitNewItemsDialogRequested()
emit m_instance->newItemsDialogRequested(); emit m_instance->newItemsDialogRequested();
} }
void ICore::saveSettings()
{
emit m_instance->saveSettingsRequested();
ICore::settings(QSettings::SystemScope)->sync();
ICore::settings(QSettings::UserScope)->sync();
}
} // namespace Core } // namespace Core
...@@ -134,6 +134,8 @@ public: ...@@ -134,6 +134,8 @@ public:
static void emitNewItemsDialogRequested(); static void emitNewItemsDialogRequested();
static void saveSettings();
signals: signals:
void coreAboutToOpen(); void coreAboutToOpen();
void coreOpened(); void coreOpened();
......
...@@ -233,11 +233,6 @@ MainWindow::MainWindow() : ...@@ -233,11 +233,6 @@ MainWindow::MainWindow() :
#if defined(Q_OS_MAC) #if defined(Q_OS_MAC)
MacFullScreen::addFullScreen(this); MacFullScreen::addFullScreen(this);
#endif #endif
m_autoSaveSessionTimer = new QTimer(this);
m_autoSaveSessionTimer->setInterval(10000);
connect(m_autoSaveSessionTimer, SIGNAL(timeout()),
m_coreImpl, SIGNAL(saveSettingsRequested()));
} }
void MainWindow::setSidebarVisible(bool visible) void MainWindow::setSidebarVisible(bool visible)
...@@ -377,13 +372,11 @@ void MainWindow::extensionsInitialized() ...@@ -377,13 +372,11 @@ void MainWindow::extensionsInitialized()
emit m_coreImpl->coreAboutToOpen(); emit m_coreImpl->coreAboutToOpen();
show(); show();
emit m_coreImpl->coreOpened(); emit m_coreImpl->coreOpened();
m_autoSaveSessionTimer->start();
} }
void MainWindow::closeEvent(QCloseEvent *event) void MainWindow::closeEvent(QCloseEvent *event)
{ {
m_autoSaveSessionTimer->stop(); ICore::saveSettings();
emit m_coreImpl->saveSettingsRequested();
// Save opened files // Save opened files
bool cancelled; bool cancelled;
...@@ -979,7 +972,6 @@ bool MainWindow::showOptionsDialog(const QString &category, ...@@ -979,7 +972,6 @@ bool MainWindow::showOptionsDialog(const QString &category,
void MainWindow::saveAll() void MainWindow::saveAll()
{ {
DocumentManager::saveModifiedDocumentsSilently(DocumentManager::modifiedDocuments()); DocumentManager::saveModifiedDocumentsSilently(DocumentManager::modifiedDocuments());
emit m_coreImpl->saveSettingsRequested();
} }
void MainWindow::exit() void MainWindow::exit()
......
...@@ -229,7 +229,6 @@ private: ...@@ -229,7 +229,6 @@ private:
QColor m_overrideColor; QColor m_overrideColor;
QStringList m_filesToOpenDelayed; QStringList m_filesToOpenDelayed;
QTimer *m_autoSaveSessionTimer;
}; };
} // namespace Internal } // namespace Internal
......
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