mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-18 13:12:50 +00:00
Implemented UserSettings as a singleton.
This commit is contained in:
parent
d0b23a4786
commit
88df3b980f
@ -10,6 +10,7 @@
|
||||
#include "view/doc/viewmanager.hpp"
|
||||
#include "view/doc/startup.hpp"
|
||||
#include "view/doc/filedialog.hpp"
|
||||
#include "model/settings/usersettings.hpp"
|
||||
|
||||
namespace CS
|
||||
{
|
||||
@ -23,7 +24,6 @@ namespace CS
|
||||
FileDialog mFileDialog;
|
||||
|
||||
Files::ConfigurationManager mCfgMgr;
|
||||
|
||||
void setupDataFiles();
|
||||
|
||||
// not implemented
|
||||
|
@ -30,9 +30,9 @@ namespace boost
|
||||
#endif /* (BOOST_VERSION <= 104600) */
|
||||
|
||||
|
||||
CSMSettings::UserSettings::UserSettings(Files::ConfigurationManager &cfg)
|
||||
: mCfgMgr(cfg)
|
||||
CSMSettings::UserSettings::UserSettings()
|
||||
{
|
||||
mUserSettingsInstance = this;
|
||||
}
|
||||
|
||||
CSMSettings::UserSettings::~UserSettings()
|
||||
|
@ -17,18 +17,29 @@ class QFile;
|
||||
|
||||
namespace CSMSettings {
|
||||
|
||||
class UserSettings
|
||||
struct UserSettings
|
||||
{
|
||||
public:
|
||||
UserSettings(Files::ConfigurationManager &cfg);
|
||||
~UserSettings();
|
||||
|
||||
static UserSettings &instance()
|
||||
{
|
||||
static UserSettings instance;
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
QFile *openFile (const QString &);
|
||||
bool writeFile(QFile *file, QMap<QString, SettingList *> §ions);
|
||||
void getSettings (QTextStream &stream, SectionMap &settings);
|
||||
|
||||
private:
|
||||
Files::ConfigurationManager &mCfgMgr;
|
||||
|
||||
UserSettings *mUserSettingsInstance;
|
||||
UserSettings();
|
||||
~UserSettings();
|
||||
|
||||
UserSettings (UserSettings const &); //not implemented
|
||||
void operator= (UserSettings const &); //not implemented
|
||||
|
||||
};
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include <QDebug>
|
||||
|
||||
CSVSettings::UserSettingsDialog::UserSettingsDialog(QMainWindow *parent) :
|
||||
QMainWindow (parent), mUserSettings (mCfgMgr), mStackedWidget (0)
|
||||
QMainWindow (parent), mStackedWidget (0)
|
||||
{
|
||||
setWindowTitle(QString::fromUtf8 ("User Settings"));
|
||||
buildPages();
|
||||
@ -135,7 +135,7 @@ CSMSettings::SectionMap CSVSettings::UserSettingsDialog::loadSettings ()
|
||||
QTextStream stream(&file);
|
||||
stream.setCodec(QTextCodec::codecForName("UTF-8"));
|
||||
|
||||
mUserSettings.getSettings(stream, settingsMap);
|
||||
CSMSettings::UserSettings::instance().getSettings(stream, settingsMap);
|
||||
}
|
||||
|
||||
file.close();
|
||||
@ -154,7 +154,7 @@ void CSVSettings::UserSettingsDialog::writeSettings()
|
||||
settings [page->objectName()] = page->getSettings();
|
||||
}
|
||||
|
||||
mUserSettings.writeFile(mUserSettings.openFile(mPaths.back()), settings);
|
||||
CSMSettings::UserSettings::instance().writeFile(CSMSettings::UserSettings::instance().openFile(mPaths.back()), settings);
|
||||
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,6 @@ namespace CSVSettings {
|
||||
QStringList mPaths;
|
||||
QListWidget *mListWidget;
|
||||
QStackedWidget *mStackedWidget;
|
||||
CSMSettings::UserSettings mUserSettings;
|
||||
Files::ConfigurationManager mCfgMgr;
|
||||
|
||||
public:
|
||||
|
Loading…
x
Reference in New Issue
Block a user