Commit 99a93dc2 authored by con's avatar con

Get rid of hardcoded settingspaths that need to be synced.

Share the (user)settings object between plugin manager and Qt Creator
core.
parent 5c11a8e5
......@@ -201,11 +201,15 @@ int main(int argc, char **argv)
// Must be done before any QSettings class is created
QSettings::setPath(QSettings::IniFormat, QSettings::SystemScope,
QCoreApplication::applicationDirPath()+QLatin1String(SHARE_PATH));
// keep this in sync with the MainWindow ctor in coreplugin/mainwindow.cpp
const QSettings settings(QSettings::IniFormat, QSettings::UserScope,
// plugin manager takes control of this settings object
QSettings *settings = new QSettings(QSettings::IniFormat, QSettings::UserScope,
QLatin1String("Nokia"), QLatin1String("QtCreator"));
locale = settings.value("General/OverrideLanguage", locale).toString();
ExtensionSystem::PluginManager pluginManager;
pluginManager.setFileExtension(QLatin1String("pluginspec"));
pluginManager.setSettings(settings);
locale = settings->value("General/OverrideLanguage", locale).toString();
const QString &creatorTrPath = QCoreApplication::applicationDirPath()
+ QLatin1String(SHARE_PATH "/translations");
if (translator.load(QLatin1String("qtcreator_") + locale, creatorTrPath)) {
......@@ -233,9 +237,6 @@ int main(int argc, char **argv)
QNetworkProxyFactory::setUseSystemConfiguration(true);
#endif
// Load
ExtensionSystem::PluginManager pluginManager;
pluginManager.setFileExtension(QLatin1String("pluginspec"));
const QStringList pluginPaths = getPluginPaths();
pluginManager.setPluginPaths(pluginPaths);
......
......@@ -311,9 +311,19 @@ void PluginManager::setFileExtension(const QString &extension)
d->extension = extension;
}
void PluginManager::loadSettings()
void PluginManager::setSettings(QSettings *settings)
{
d->loadSettings();
d->setSettings(settings);
}
QSettings *PluginManager::settings() const
{
return d->settings;
}
void PluginManager::readSettings()
{
d->readSettings();
}
void PluginManager::writeSettings()
......@@ -616,6 +626,19 @@ PluginSpec *PluginManagerPrivate::createSpec()
return new PluginSpec();
}
/*!
\fn void PluginManagerPrivate::setSettings(QSettings *settings)
\internal
*/
void PluginManagerPrivate::setSettings(QSettings *s)
{
if (settings)
delete settings;
settings = s;
if (settings)
settings->setParent(this);
}
/*!
\fn PluginSpecPrivate *PluginManagerPrivate::privateSpec(PluginSpec *spec)
\internal
......@@ -633,6 +656,7 @@ PluginManagerPrivate::PluginManagerPrivate(PluginManager *pluginManager) :
extension(QLatin1String("xml")),
m_profileElapsedMS(0),
m_profilingVerbosity(0),
settings(0),
q(pluginManager)
{
}
......@@ -654,9 +678,8 @@ PluginManagerPrivate::~PluginManagerPrivate()
*/
void PluginManagerPrivate::writeSettings()
{
QSettings settings(QSettings::IniFormat, QSettings::UserScope,
QLatin1String("Nokia"), QLatin1String("QtCreator"));
if (!settings)
return;
QStringList tempDisabledPlugins;
QStringList tempForceEnabledPlugins;
foreach(PluginSpec *spec, pluginSpecs) {
......@@ -666,21 +689,20 @@ void PluginManagerPrivate::writeSettings()
tempForceEnabledPlugins.append(spec->name());
}
settings.setValue(QLatin1String(C_IGNORED_PLUGINS), tempDisabledPlugins);
settings.setValue(QLatin1String(C_FORCEENABLED_PLUGINS), tempForceEnabledPlugins);
settings->setValue(QLatin1String(C_IGNORED_PLUGINS), tempDisabledPlugins);
settings->setValue(QLatin1String(C_FORCEENABLED_PLUGINS), tempForceEnabledPlugins);
}
/*!
\fn void PluginManagerPrivate::loadSettings()
\fn void PluginManagerPrivate::readSettings()
\internal
*/
void PluginManagerPrivate::loadSettings()
void PluginManagerPrivate::readSettings()
{
const QSettings settings(QSettings::IniFormat, QSettings::UserScope,
QLatin1String("Nokia"), QLatin1String("QtCreator"));
disabledPlugins = settings.value(QLatin1String(C_IGNORED_PLUGINS)).toStringList();
forceEnabledPlugins = settings.value(QLatin1String(C_FORCEENABLED_PLUGINS)).toStringList();
if (!settings)
return;
disabledPlugins = settings->value(QLatin1String(C_IGNORED_PLUGINS)).toStringList();
forceEnabledPlugins = settings->value(QLatin1String(C_FORCEENABLED_PLUGINS)).toStringList();
}
/*!
......@@ -941,7 +963,7 @@ void PluginManagerPrivate::loadPlugin(PluginSpec *spec, PluginSpec::State destSt
void PluginManagerPrivate::setPluginPaths(const QStringList &paths)
{
pluginPaths = paths;
loadSettings();
readSettings();
readPluginPaths();
}
......
......@@ -39,6 +39,7 @@
QT_BEGIN_NAMESPACE
class QTextStream;
class QSettings;
QT_END_NAMESPACE
namespace ExtensionSystem {
......@@ -101,7 +102,9 @@ public:
QString fileExtension() const;
// Settings
void loadSettings();
void setSettings(QSettings *settings);
QSettings *settings() const;
void readSettings();
void writeSettings();
// command line arguments
......
......@@ -41,6 +41,7 @@
QT_BEGIN_NAMESPACE
class QTime;
class QSettings;
QT_END_NAMESPACE
namespace ExtensionSystem {
......@@ -72,7 +73,8 @@ public:
void resolveDependencies();
void initProfiling();
void profilingReport(const char *what, const PluginSpec *spec = 0);
void loadSettings();
void setSettings(QSettings *settings);
void readSettings();
void writeSettings();
void disablePluginIndirectly(PluginSpec *spec);
......@@ -91,6 +93,7 @@ public:
QScopedPointer<QTime> m_profileTimer;
int m_profileElapsedMS;
unsigned m_profilingVerbosity;
QSettings *settings;
// Look in argument descriptions of the specs for the option.
PluginSpec *pluginForOption(const QString &option, bool *requiresArgument) const;
......
......@@ -118,9 +118,7 @@ MainWindow::MainWindow() :
m_coreImpl(new CoreImpl(this)),
m_uniqueIDManager(new UniqueIDManager()),
m_additionalContexts(Constants::C_GLOBAL),
// keep this in sync with main() in app/main.cpp
m_settings(new QSettings(QSettings::IniFormat, QSettings::UserScope,
QLatin1String("Nokia"), QLatin1String("QtCreator"), this)),
m_settings(ExtensionSystem::PluginManager::instance()->settings()),
m_globalSettings(new QSettings(QSettings::IniFormat, QSettings::SystemScope,
QLatin1String("Nokia"), QLatin1String("QtCreator"), this)),
m_settingsDatabase(new SettingsDatabase(QFileInfo(m_settings->fileName()).path(),
......
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