Commit 047901aa authored by Daniel Molkentin's avatar Daniel Molkentin
Browse files

Allow access to system scope setting.

This commit add a Settings::Scope parameter to
Core::ICore::settings(), the default is UserScope,
which falls back to SystemScope. Specifying SystemScope
instead gives exclusive access to the SystemScope.
parent 88e24a61
......@@ -31,6 +31,7 @@
#include <QtCore/QDir>
#include <QtCore/QCoreApplication>
#include <QtCore/QSettings>
namespace Core {
namespace Internal {
......@@ -135,9 +136,9 @@ MimeDatabase *CoreImpl::mimeDatabase() const
return m_mainwindow->mimeDatabase();
}
QSettings *CoreImpl::settings() const
QSettings *CoreImpl::settings(QSettings::Scope scope) const
{
return m_mainwindow->settings();
return m_mainwindow->settings(scope);
}
SettingsDatabase *CoreImpl::settingsDatabase() const
......
......@@ -68,7 +68,7 @@ public:
ModeManager *modeManager() const;
MimeDatabase *mimeDatabase() const;
QSettings *settings() const;
QSettings *settings(QSettings::Scope scope = QSettings::UserScope) const;
SettingsDatabase *settingsDatabase() const;
QPrinter *printer() const;
......
......@@ -188,12 +188,20 @@
*/
/*!
\fn QSettings *ICore::settings() const
\fn QSettings *ICore::settings(QSettings::UserScope scope) const
\brief Returns the application's main settings object.
You can use it to retrieve or set application wide settings
(in contrast to session or project specific settings).
If \a scope is QSettings::UserScope (the default), the
users settings will be read from the users settings, with
a fallback to global settings provided with Qt Creator.
If \a scope is QSettings::SystemScope, only the system settings
shipped with the current version of Qt Creator will be read. This
functionality exists for internal purposes only.
\see settingsDatabase()
*/
......
......@@ -32,6 +32,7 @@
#include "core_global.h"
#include <QtCore/QObject>
#include <QtCore/QSettings>
QT_BEGIN_NAMESPACE
class QMainWindow;
......@@ -40,6 +41,7 @@ class QSettings;
template <class T> class QList;
QT_END_NAMESPACE
namespace Core {
class ActionManager;
......@@ -93,7 +95,7 @@ public:
virtual ModeManager *modeManager() const = 0;
virtual MimeDatabase *mimeDatabase() const = 0;
virtual QSettings *settings() const = 0;
virtual QSettings *settings(QSettings::Scope scope = QSettings::UserScope) const = 0;
virtual SettingsDatabase *settingsDatabase() const = 0;
virtual QPrinter *printer() const = 0;
......
......@@ -945,6 +945,14 @@ VCSManager *MainWindow::vcsManager() const
return m_vcsManager;
}
QSettings *MainWindow::settings(QSettings::Scope scope) const
{
if (scope == QSettings::UserScope)
return m_settings;
else
return m_globalSettings;
}
EditorManager *MainWindow::editorManager() const
{
return m_editorManager;
......
......@@ -36,6 +36,7 @@
#include <QtCore/QMap>
#include <QtGui/QColor>
#include <QtCore/QSettings>
QT_BEGIN_NAMESPACE
class QSettings;
......@@ -107,7 +108,7 @@ public:
Core::MimeDatabase *mimeDatabase() const;
VCSManager *vcsManager() const;
inline QSettings *settings() const { return m_settings; }
QSettings *settings(QSettings::Scope scope) const;
inline SettingsDatabase *settingsDatabase() const { return m_settingsDatabase; }
virtual QPrinter *printer() const;
IContext * currentContextObject() const;
......@@ -176,6 +177,7 @@ private:
QList<int> m_globalContext;
QList<int> m_additionalContexts;
QSettings *m_settings;
QSettings *m_globalSettings;
SettingsDatabase *m_settingsDatabase;
mutable QPrinter *m_printer;
ActionManagerPrivate *m_actionManager;
......
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