mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
Fixed opencs.ini formatting
This commit is contained in:
parent
5cba828cc9
commit
a17cb1f389
15 changed files with 164 additions and 185 deletions
|
@ -368,8 +368,8 @@ configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg.local
|
|||
configure_file(${OpenMW_SOURCE_DIR}/files/openmw.cfg
|
||||
"${OpenMW_BINARY_DIR}/openmw.cfg.install")
|
||||
|
||||
configure_file(${OpenMW_SOURCE_DIR}/files/opencs.conf
|
||||
"${OpenMW_BINARY_DIR}/opencs.cfg")
|
||||
configure_file(${OpenMW_SOURCE_DIR}/files/opencs.ini
|
||||
"${OpenMW_BINARY_DIR}/opencs.ini")
|
||||
|
||||
configure_file(${OpenMW_SOURCE_DIR}/files/opencs/defaultfilters
|
||||
"${OpenMW_BINARY_DIR}/resources/defaultfilters" COPYONLY)
|
||||
|
|
|
@ -106,7 +106,6 @@ opencs_units_noqt (view/settings
|
|||
|
||||
opencs_units (model/settings
|
||||
usersettings
|
||||
settingmanager
|
||||
setting
|
||||
connector
|
||||
)
|
||||
|
|
|
@ -124,11 +124,6 @@ std::pair<Files::PathContainer, std::vector<std::string> > CS::Editor::readConfi
|
|||
QString path = QString::fromUtf8 (iter->string().c_str());
|
||||
mFileDialog.addFiles(path);
|
||||
}
|
||||
/*
|
||||
//load the settings into the userSettings instance.
|
||||
const QString settingFileName = "opencs.cfg";
|
||||
CSMSettings::UserSettings::instance().loadSettings(settingFileName);
|
||||
*/
|
||||
|
||||
return std::make_pair (dataDirs, variables["fallback-archive"].as<std::vector<std::string> >());
|
||||
}
|
||||
|
|
|
@ -1,93 +0,0 @@
|
|||
#include <QFile>
|
||||
#include <QTextCodec>
|
||||
#include <QMessageBox>
|
||||
#include <QDebug>
|
||||
#include <QList>
|
||||
#include <QSettings>
|
||||
|
||||
#include "setting.hpp"
|
||||
#include "settingmanager.hpp"
|
||||
|
||||
CSMSettings::SettingManager::SettingManager(QObject *parent) :
|
||||
QObject(parent)
|
||||
{}
|
||||
|
||||
CSMSettings::Setting *CSMSettings::SettingManager::createSetting
|
||||
(CSMSettings::SettingType typ, const QString &page, const QString &name)
|
||||
{
|
||||
//get list of all settings for the current setting name
|
||||
if (findSetting (page, name))
|
||||
{
|
||||
qWarning() << "Duplicate declaration encountered: "
|
||||
<< (name + '/' + page);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Setting *setting = new Setting (typ, name, page);
|
||||
|
||||
|
||||
//add declaration to the model
|
||||
mSettings.append (setting);
|
||||
|
||||
return setting;
|
||||
}
|
||||
|
||||
void CSMSettings::SettingManager::addDefinitions (const QSettings *settings)
|
||||
{
|
||||
foreach (const QString &key, settings->allKeys())
|
||||
{
|
||||
QStringList names = key.split('/');
|
||||
|
||||
Setting *setting = findSetting (names.at(0), names.at(1));
|
||||
|
||||
if (!setting)
|
||||
{
|
||||
qWarning() << "Found definitions for undeclared setting "
|
||||
<< names.at(0) << "." << names.at(1);
|
||||
continue;
|
||||
}
|
||||
|
||||
QStringList values = settings->value (key).toStringList();
|
||||
|
||||
if (values.isEmpty())
|
||||
values.append (setting->defaultValues());
|
||||
|
||||
setting->setDefinedValues (values);
|
||||
}
|
||||
}
|
||||
|
||||
CSMSettings::Setting *CSMSettings::SettingManager::findSetting
|
||||
(const QString &pageName, const QString &settingName)
|
||||
{
|
||||
foreach (Setting *setting, mSettings)
|
||||
{
|
||||
if (setting->name() == settingName)
|
||||
{
|
||||
if (setting->page() == pageName)
|
||||
return setting;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
CSMSettings::SettingPageMap CSMSettings::SettingManager::settingPageMap() const
|
||||
{
|
||||
SettingPageMap pageMap;
|
||||
|
||||
foreach (Setting *setting, mSettings)
|
||||
pageMap[setting->page()].append (setting);
|
||||
|
||||
return pageMap;
|
||||
}
|
||||
|
||||
void CSMSettings::SettingManager::updateUserSetting(const QString &settingKey,
|
||||
const QStringList &list)
|
||||
{
|
||||
QStringList names = settingKey.split('/');
|
||||
|
||||
Setting *setting = findSetting (names.at(0), names.at(1));
|
||||
|
||||
setting->setDefinedValues (list);
|
||||
|
||||
emit userSettingUpdated (settingKey, list);
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
#ifndef CSMSETTINGS_SETTINGMANAGER_HPP
|
||||
#define CSMSETTINGS_SETTINGMANAGER_HPP
|
||||
|
||||
#include <QObject>
|
||||
#include <QMap>
|
||||
#include <QStringList>
|
||||
#include <QTextStream>
|
||||
#include <QSettings>
|
||||
|
||||
#include "support.hpp"
|
||||
#include "setting.hpp"
|
||||
|
||||
namespace CSMSettings
|
||||
{
|
||||
|
||||
typedef QMap <QString, QStringList *> DefinitionMap;
|
||||
typedef QMap <QString, DefinitionMap *> DefinitionPageMap;
|
||||
|
||||
typedef QMap <QString, QList <Setting *> > SettingPageMap;
|
||||
|
||||
class SettingManager : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
QList <Setting *> mSettings;
|
||||
|
||||
public:
|
||||
explicit SettingManager(QObject *parent = 0);
|
||||
|
||||
///retrieve a setting object from a given page and setting name
|
||||
Setting *findSetting
|
||||
(const QString &pageName, const QString &settingName = QString());
|
||||
|
||||
///Retreive a map of the settings, keyed by page name
|
||||
SettingPageMap settingPageMap() const;
|
||||
|
||||
protected:
|
||||
|
||||
///add a new setting to the model and return it
|
||||
Setting *createSetting (CSMSettings::SettingType typ,
|
||||
const QString &page, const QString &name);
|
||||
|
||||
///add definitions to the settings specified in the page map
|
||||
void addDefinitions (const QSettings *settings);
|
||||
|
||||
signals:
|
||||
|
||||
void userSettingUpdated (const QString &, const QStringList &);
|
||||
|
||||
public slots:
|
||||
|
||||
void updateUserSetting (const QString &, const QStringList &);
|
||||
};
|
||||
}
|
||||
#endif // CSMSETTINGS_SETTINGMANAGER_HPP
|
|
@ -42,7 +42,7 @@ CSMSettings::UserSettings::UserSettings()
|
|||
assert(!mUserSettingsInstance);
|
||||
mUserSettingsInstance = this;
|
||||
|
||||
mSettings = 0;
|
||||
mSettingDefinitions = 0;
|
||||
|
||||
mReadWriteMessage = QObject::tr("<br><b>Could not open or create file for \
|
||||
writing</b><br><br> Please make sure you have the right\
|
||||
|
@ -55,6 +55,31 @@ CSMSettings::UserSettings::UserSettings()
|
|||
buildSettingModelDefaults();
|
||||
}
|
||||
|
||||
void CSMSettings::UserSettings::addDefinitions ()
|
||||
{
|
||||
foreach (const QString &key, mSettingDefinitions->allKeys())
|
||||
{
|
||||
QStringList names = key.split('/');
|
||||
|
||||
Setting *setting = findSetting (names.at(0), names.at(1));
|
||||
|
||||
if (!setting)
|
||||
{
|
||||
qWarning() << "Found definitions for undeclared setting "
|
||||
<< names.at(0) << "/" << names.at(1);
|
||||
removeSetting (names.at(0), names.at(1));
|
||||
continue;
|
||||
}
|
||||
|
||||
QStringList values = mSettingDefinitions->value (key).toStringList();
|
||||
|
||||
if (values.isEmpty())
|
||||
values.append (setting->defaultValues());
|
||||
|
||||
setting->setDefinedValues (values);
|
||||
}
|
||||
}
|
||||
|
||||
void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||
{
|
||||
QString section = "Window Size";
|
||||
|
@ -355,22 +380,19 @@ void CSMSettings::UserSettings::loadSettings (const QString &fileName)
|
|||
QSettings::setPath
|
||||
(QSettings::IniFormat, QSettings::SystemScope, otherFilePath);
|
||||
|
||||
if (mSettings)
|
||||
delete mSettings;
|
||||
|
||||
mSettings = new QSettings
|
||||
mSettingDefinitions = new QSettings
|
||||
(QSettings::IniFormat, QSettings::UserScope, "opencs", QString(), this);
|
||||
|
||||
addDefinitions (mSettings);
|
||||
addDefinitions();
|
||||
}
|
||||
|
||||
void CSMSettings::UserSettings::saveSettings
|
||||
(const QMap <QString, QStringList> &settingMap)
|
||||
{
|
||||
foreach (const QString &key, settingMap.keys())
|
||||
mSettings->setValue (key, settingMap.value (key));
|
||||
mSettingDefinitions->setValue (key, settingMap.value (key));
|
||||
|
||||
delete mSettings;
|
||||
mSettingDefinitions->sync();
|
||||
}
|
||||
|
||||
QString CSMSettings::UserSettings::settingValue (const QString &settingKey)
|
||||
|
@ -392,3 +414,82 @@ CSMSettings::UserSettings& CSMSettings::UserSettings::instance()
|
|||
assert(mUserSettingsInstance);
|
||||
return *mUserSettingsInstance;
|
||||
}
|
||||
|
||||
void CSMSettings::UserSettings::updateUserSetting(const QString &settingKey,
|
||||
const QStringList &list)
|
||||
{
|
||||
QStringList names = settingKey.split('/');
|
||||
|
||||
Setting *setting = findSetting (names.at(0), names.at(1));
|
||||
|
||||
setting->setDefinedValues (list);
|
||||
|
||||
emit userSettingUpdated (settingKey, list);
|
||||
}
|
||||
|
||||
CSMSettings::Setting *CSMSettings::UserSettings::findSetting
|
||||
(const QString &pageName, const QString &settingName)
|
||||
{
|
||||
foreach (Setting *setting, mSettings)
|
||||
{
|
||||
if (setting->name() == settingName)
|
||||
{
|
||||
if (setting->page() == pageName)
|
||||
return setting;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CSMSettings::UserSettings::removeSetting
|
||||
(const QString &pageName, const QString &settingName)
|
||||
{
|
||||
if (mSettings.isEmpty())
|
||||
return;
|
||||
|
||||
QList <Setting *>::iterator removeIterator = mSettings.begin();
|
||||
|
||||
while (removeIterator != mSettings.end())
|
||||
{
|
||||
if ((*removeIterator)->name() == settingName)
|
||||
{
|
||||
if ((*removeIterator)->page() == pageName)
|
||||
{
|
||||
mSettings.erase (removeIterator);
|
||||
break;
|
||||
}
|
||||
}
|
||||
removeIterator++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CSMSettings::SettingPageMap CSMSettings::UserSettings::settingPageMap() const
|
||||
{
|
||||
SettingPageMap pageMap;
|
||||
|
||||
foreach (Setting *setting, mSettings)
|
||||
pageMap[setting->page()].append (setting);
|
||||
|
||||
return pageMap;
|
||||
}
|
||||
|
||||
CSMSettings::Setting *CSMSettings::UserSettings::createSetting
|
||||
(CSMSettings::SettingType typ, const QString &page, const QString &name)
|
||||
{
|
||||
//get list of all settings for the current setting name
|
||||
if (findSetting (page, name))
|
||||
{
|
||||
qWarning() << "Duplicate declaration encountered: "
|
||||
<< (name + '/' + page);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Setting *setting = new Setting (typ, name, page);
|
||||
|
||||
|
||||
//add declaration to the model
|
||||
mSettings.append (setting);
|
||||
|
||||
return setting;
|
||||
}
|
||||
|
|
|
@ -7,8 +7,7 @@
|
|||
#include <QMap>
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include "settingmanager.hpp"
|
||||
#include "support.hpp"
|
||||
|
||||
#ifndef Q_MOC_RUN
|
||||
#include <components/files/configurationmanager.hpp>
|
||||
|
@ -22,7 +21,10 @@ class QSettings;
|
|||
|
||||
namespace CSMSettings {
|
||||
|
||||
class UserSettings: public SettingManager
|
||||
class Setting;
|
||||
typedef QMap <QString, QList <Setting *> > SettingPageMap;
|
||||
|
||||
class UserSettings: public QObject
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
@ -32,7 +34,8 @@ namespace CSMSettings {
|
|||
|
||||
QString mReadOnlyMessage;
|
||||
QString mReadWriteMessage;
|
||||
QSettings *mSettings;
|
||||
QSettings *mSettingDefinitions;
|
||||
QList <Setting *> mSettings;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -53,13 +56,38 @@ namespace CSMSettings {
|
|||
|
||||
QString settingValue (const QString &settingKey);
|
||||
|
||||
///retrieve a setting object from a given page and setting name
|
||||
Setting *findSetting
|
||||
(const QString &pageName, const QString &settingName = QString());
|
||||
|
||||
///remove a setting from the list
|
||||
void removeSetting
|
||||
(const QString &pageName, const QString &settingName);
|
||||
|
||||
///Retreive a map of the settings, keyed by page name
|
||||
SettingPageMap settingPageMap() const;
|
||||
|
||||
private:
|
||||
|
||||
///add definitions to the settings specified in the page map
|
||||
void addDefinitions();
|
||||
|
||||
void buildSettingModelDefaults();
|
||||
void displayFileErrorMessage(const QString &userpath,
|
||||
const QString &globalpath,
|
||||
const QString &localpath) const;
|
||||
|
||||
///add a new setting to the model and return it
|
||||
Setting *createSetting (CSMSettings::SettingType typ,
|
||||
const QString &page, const QString &name);
|
||||
|
||||
signals:
|
||||
|
||||
void userSettingUpdated (const QString &, const QStringList &);
|
||||
|
||||
public slots:
|
||||
|
||||
void updateUserSetting (const QString &, const QStringList &);
|
||||
};
|
||||
}
|
||||
#endif // USERSETTINGS_HPP
|
||||
|
|
|
@ -236,10 +236,10 @@ CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int to
|
|||
mViewTotal (totalViews)
|
||||
{
|
||||
QString width = CSMSettings::UserSettings::instance().settingValue
|
||||
("Window Size.Width");
|
||||
("Window Size/Width");
|
||||
|
||||
QString height = CSMSettings::UserSettings::instance().settingValue
|
||||
("Window Size.Height");
|
||||
("Window Size/Height");
|
||||
|
||||
resize (width.toInt(), height.toInt());
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
namespace CSMSettings {
|
||||
class Setting;
|
||||
class SettingManager;
|
||||
class UserSettings;
|
||||
}
|
||||
|
||||
namespace CSVSettings {
|
||||
|
@ -23,13 +23,13 @@ namespace CSVSettings {
|
|||
Q_OBJECT
|
||||
|
||||
PageList mPages;
|
||||
CSMSettings::SettingManager *mModel;
|
||||
CSMSettings::UserSettings *mModel;
|
||||
|
||||
public:
|
||||
explicit SettingWindow(QWidget *parent = 0);
|
||||
|
||||
View *findView (const QString &pageName, const QString &setting);
|
||||
void setModel (CSMSettings::SettingManager &model) { mModel = &model; }
|
||||
void setModel (CSMSettings::UserSettings &model) { mModel = &model; }
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -7,18 +7,19 @@
|
|||
CSVWorld::DataDisplayDelegate::DataDisplayDelegate(const ValueList &values,
|
||||
const IconList &icons,
|
||||
QUndoStack &undoStack,
|
||||
const QString &settingKey,
|
||||
const QString &pageName,
|
||||
const QString &settingName,
|
||||
QObject *parent)
|
||||
: EnumDelegate (values, undoStack, parent), mDisplayMode (Mode_TextOnly),
|
||||
mIcons (icons), mIconSize (QSize(16, 16)), mIconLeftOffset(3),
|
||||
mTextLeftOffset(8), mSettingKey (settingKey)
|
||||
mTextLeftOffset(8), mSettingKey (pageName + '/' + settingName)
|
||||
{
|
||||
mTextAlignment.setAlignment (Qt::AlignLeft | Qt::AlignVCenter );
|
||||
|
||||
buildPixmaps();
|
||||
|
||||
QString value =
|
||||
CSMSettings::UserSettings::instance().settingValue (settingKey);
|
||||
CSMSettings::UserSettings::instance().settingValue (mSettingKey);
|
||||
|
||||
updateDisplayMode(value);
|
||||
}
|
||||
|
@ -140,7 +141,7 @@ CSVWorld::CommandDelegate *CSVWorld::DataDisplayDelegateFactory::makeDelegate (Q
|
|||
QObject *parent) const
|
||||
{
|
||||
|
||||
return new DataDisplayDelegate (mValues, mIcons, undoStack, "", parent);
|
||||
return new DataDisplayDelegate (mValues, mIcons, undoStack, "", "", parent);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -41,7 +41,8 @@ namespace CSVWorld
|
|||
explicit DataDisplayDelegate (const ValueList & values,
|
||||
const IconList & icons,
|
||||
QUndoStack& undoStack,
|
||||
const QString &settingKey,
|
||||
const QString &pageName,
|
||||
const QString &settingName,
|
||||
QObject *parent);
|
||||
|
||||
~DataDisplayDelegate();
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
CSVWorld::IdTypeDelegate::IdTypeDelegate
|
||||
(const ValueList &values, const IconList &icons, QUndoStack& undoStack, QObject *parent)
|
||||
: DataDisplayDelegate (values, icons, undoStack,
|
||||
"Display Format.Referenceable ID Type Display",
|
||||
"Display Format", "Referenceable ID Type Display",
|
||||
parent)
|
||||
{}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ CSVWorld::RecordStatusDelegate::RecordStatusDelegate(const ValueList& values,
|
|||
const IconList & icons,
|
||||
QUndoStack &undoStack, QObject *parent)
|
||||
: DataDisplayDelegate (values, icons, undoStack,
|
||||
"Display Format.Record Status Display",
|
||||
"Display Format", "Record Status Display",
|
||||
parent)
|
||||
{}
|
||||
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
[Editor]
|
||||
Record Status Display = Icon and Text
|
||||
[Window Size]
|
||||
Width = 640
|
||||
Height = 480
|
7
files/opencs.ini
Normal file
7
files/opencs.ini
Normal file
|
@ -0,0 +1,7 @@
|
|||
[Display%20Format]
|
||||
Record%20Status%20Display=Icon Only
|
||||
Referenceable%20ID%20Type%20Display=Text Only
|
||||
|
||||
[Window%20Size]
|
||||
Height=900
|
||||
Width=1440
|
Loading…
Reference in a new issue