forked from teamnwah/openmw-tes3coop
Merge branch 'settings'
This commit is contained in:
commit
94ae222f0e
20 changed files with 262 additions and 267 deletions
|
@ -344,7 +344,7 @@ std::auto_ptr<sh::Factory> CS::Editor::setupGraphics()
|
|||
|
||||
factory->loadAllFiles();
|
||||
|
||||
bool shaders = mUserSettings.setting("Objects/shaders", QString("true")) == "true" ? true : false;
|
||||
bool shaders = mUserSettings.setting("3d-render/shaders", QString("true")) == "true" ? true : false;
|
||||
sh::Factory::getInstance ().setShadersEnabled (shaders);
|
||||
|
||||
std::string fog = mUserSettings.setting("Shader/fog", QString("true")).toStdString();
|
||||
|
@ -363,7 +363,7 @@ std::auto_ptr<sh::Factory> CS::Editor::setupGraphics()
|
|||
// internal setting - may be switched on or off by the use of shader configurations
|
||||
sh::Factory::getInstance ().setGlobalSetting ("viewproj_fix", "false");
|
||||
|
||||
std::string num_lights = mUserSettings.setting("Objects/num_lights", QString("8")).toStdString();
|
||||
std::string num_lights = mUserSettings.setting("3d-render-adv/num_lights", QString("8")).toStdString();
|
||||
sh::Factory::getInstance ().setGlobalSetting ("num_lights", num_lights);
|
||||
|
||||
/// \todo add more configurable shiny settings
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
#include "support.hpp"
|
||||
|
||||
CSMSettings::Setting::Setting(SettingType typ, const QString &settingName,
|
||||
const QString &pageName)
|
||||
: mIsEditorSetting (false)
|
||||
const QString &pageName, const QString& label)
|
||||
: mIsEditorSetting (true)
|
||||
{
|
||||
buildDefaultSetting();
|
||||
|
||||
|
@ -17,6 +17,7 @@ CSMSettings::Setting::Setting(SettingType typ, const QString &settingName,
|
|||
setProperty (Property_SettingType, QVariant (settingType).toString());
|
||||
setProperty (Property_Page, pageName);
|
||||
setProperty (Property_Name, settingName);
|
||||
setProperty (Property_Label, label.isEmpty() ? settingName : label);
|
||||
}
|
||||
|
||||
void CSMSettings::Setting::buildDefaultSetting()
|
||||
|
@ -290,14 +291,16 @@ CSMSettings::SettingType CSMSettings::Setting::type() const
|
|||
Property_SettingType).at(0).toInt());
|
||||
}
|
||||
|
||||
void CSMSettings::Setting::setMaximum (int value)
|
||||
void CSMSettings::Setting::setRange (int min, int max)
|
||||
{
|
||||
setProperty (Property_Maximum, value);
|
||||
setProperty (Property_Minimum, min);
|
||||
setProperty (Property_Maximum, max);
|
||||
}
|
||||
|
||||
void CSMSettings::Setting::setMaximum (double value)
|
||||
void CSMSettings::Setting::setRange (double min, double max)
|
||||
{
|
||||
setProperty (Property_Maximum, value);
|
||||
setProperty (Property_Minimum, min);
|
||||
setProperty (Property_Maximum, max);
|
||||
}
|
||||
|
||||
QString CSMSettings::Setting::maximum() const
|
||||
|
@ -305,16 +308,6 @@ QString CSMSettings::Setting::maximum() const
|
|||
return property (Property_Maximum).at(0);
|
||||
}
|
||||
|
||||
void CSMSettings::Setting::setMinimum (int value)
|
||||
{
|
||||
setProperty (Property_Minimum, value);
|
||||
}
|
||||
|
||||
void CSMSettings::Setting::setMinimum (double value)
|
||||
{
|
||||
setProperty (Property_Minimum, value);
|
||||
}
|
||||
|
||||
QString CSMSettings::Setting::minimum() const
|
||||
{
|
||||
return property (Property_Minimum).at(0);
|
||||
|
@ -372,6 +365,26 @@ bool CSMSettings::Setting::wrapping() const
|
|||
return (property (Property_Wrapping).at(0) == "true");
|
||||
}
|
||||
|
||||
void CSMSettings::Setting::setLabel (const QString& label)
|
||||
{
|
||||
setProperty (Property_Label, label);
|
||||
}
|
||||
|
||||
QString CSMSettings::Setting::getLabel() const
|
||||
{
|
||||
return property (Property_Label).at (0);
|
||||
}
|
||||
|
||||
void CSMSettings::Setting::setToolTip (const QString& toolTip)
|
||||
{
|
||||
setProperty (Property_ToolTip, toolTip);
|
||||
}
|
||||
|
||||
QString CSMSettings::Setting::getToolTip() const
|
||||
{
|
||||
return property (Property_ToolTip).at (0);
|
||||
}
|
||||
|
||||
void CSMSettings::Setting::setProperty (SettingProperty prop, bool value)
|
||||
{
|
||||
setProperty (prop, QStringList() << QVariant (value).toString());
|
||||
|
|
|
@ -29,8 +29,8 @@ namespace CSMSettings
|
|||
|
||||
public:
|
||||
|
||||
explicit Setting(SettingType typ, const QString &settingName,
|
||||
const QString &pageName);
|
||||
Setting(SettingType typ, const QString &settingName,
|
||||
const QString &pageName, const QString& label = "");
|
||||
|
||||
void addProxy (const Setting *setting, const QStringList &vals);
|
||||
void addProxy (const Setting *setting, const QList <QStringList> &list);
|
||||
|
@ -66,12 +66,11 @@ namespace CSMSettings
|
|||
void setMask (const QString &value);
|
||||
QString mask() const;
|
||||
|
||||
void setMaximum (int value);
|
||||
void setMaximum (double value);
|
||||
void setRange (int min, int max);
|
||||
void setRange (double min, double max);
|
||||
|
||||
QString maximum() const;
|
||||
|
||||
void setMinimum (int value);
|
||||
void setMinimum (double value);
|
||||
QString minimum() const;
|
||||
|
||||
void setName (const QString &value);
|
||||
|
@ -132,6 +131,13 @@ namespace CSMSettings
|
|||
void setWidgetWidth (int value);
|
||||
int widgetWidth() const;
|
||||
|
||||
/// This is the text the user gets to see.
|
||||
void setLabel (const QString& label);
|
||||
QString getLabel() const;
|
||||
|
||||
void setToolTip (const QString& toolTip);
|
||||
QString getToolTip() const;
|
||||
|
||||
///returns the specified property value
|
||||
QStringList property (SettingProperty prop) const;
|
||||
|
||||
|
|
|
@ -36,12 +36,14 @@ namespace CSMSettings
|
|||
Property_TicksAbove = 20,
|
||||
Property_TicksBelow = 21,
|
||||
Property_StyleSheet = 22,
|
||||
Property_Label = 23,
|
||||
Property_ToolTip = 24,
|
||||
|
||||
//Stringlists should always be the last items
|
||||
Property_DefaultValues = 23,
|
||||
Property_DeclaredValues = 24,
|
||||
Property_DefinedValues = 25,
|
||||
Property_Proxies = 26
|
||||
Property_DefaultValues = 25,
|
||||
Property_DeclaredValues = 26,
|
||||
Property_DefinedValues = 27,
|
||||
Property_Proxies = 28
|
||||
};
|
||||
|
||||
///Basic setting widget types.
|
||||
|
|
|
@ -30,183 +30,127 @@ namespace boost
|
|||
} /* namespace boost */
|
||||
#endif /* (BOOST_VERSION <= 104600) */
|
||||
|
||||
CSMSettings::UserSettings *CSMSettings::UserSettings::mUserSettingsInstance = 0;
|
||||
CSMSettings::UserSettings *CSMSettings::UserSettings::sUserSettingsInstance = 0;
|
||||
|
||||
CSMSettings::UserSettings::UserSettings (const Files::ConfigurationManager& configurationManager)
|
||||
: mCfgMgr (configurationManager)
|
||||
, mSettingDefinitions(NULL)
|
||||
, mSettingCfgDefinitions(NULL)
|
||||
{
|
||||
assert(!mUserSettingsInstance);
|
||||
mUserSettingsInstance = this;
|
||||
assert(!sUserSettingsInstance);
|
||||
sUserSettingsInstance = this;
|
||||
|
||||
buildSettingModelDefaults();
|
||||
|
||||
// for overriding opencs.ini settings with those from settings.cfg
|
||||
mSettingCfgDefinitions = new QSettings(QSettings::IniFormat, QSettings::UserScope, "", QString(), this);
|
||||
}
|
||||
|
||||
void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||
{
|
||||
QString section;
|
||||
|
||||
section = "Objects";
|
||||
declareSection ("3d-render", "3D Rendering");
|
||||
{
|
||||
Setting *numLights = createSetting (Type_SpinBox, section, "num_lights");
|
||||
numLights->setDefaultValue(8);
|
||||
numLights->setEditorSetting(true);
|
||||
numLights->setColumnSpan (1);
|
||||
numLights->setMinimum (0);
|
||||
numLights->setMaximum (100); // FIXME: not sure what the max value should be
|
||||
numLights->setWidgetWidth (10);
|
||||
numLights->setViewLocation(1, 2);
|
||||
Setting *shaders = createSetting (Type_CheckBox, "shaders", "Enable Shaders");
|
||||
shaders->setDefaultValue ("true");
|
||||
|
||||
Setting *shaders = createSetting (Type_CheckBox, section, "shaders");
|
||||
shaders->setDeclaredValues(QStringList() << "true" << "false");
|
||||
shaders->setDefaultValue("true");
|
||||
shaders->setEditorSetting(true);
|
||||
shaders->setSpecialValueText("Enable Shaders");
|
||||
shaders->setWidgetWidth(25);
|
||||
shaders->setColumnSpan (3);
|
||||
shaders->setStyleSheet ("QGroupBox { border: 0px; }");
|
||||
shaders->setViewLocation(2, 1);
|
||||
Setting *farClipDist = createSetting (Type_DoubleSpinBox, "far-clip-distance", "Far clipping distance");
|
||||
farClipDist->setDefaultValue (300000);
|
||||
farClipDist->setRange (0, 1000000);
|
||||
farClipDist->setToolTip ("The maximum distance objects are still rendered at.");
|
||||
|
||||
QString defaultValue = "None";
|
||||
Setting *antialiasing = createSetting (Type_ComboBox, "antialiasing", "Antialiasing");
|
||||
antialiasing->setDeclaredValues (QStringList()
|
||||
<< defaultValue << "MSAA 2" << "MSAA 4" << "MSAA 8" << "MSAA 16");
|
||||
antialiasing->setDefaultValue (defaultValue);
|
||||
}
|
||||
|
||||
section = "Scene";
|
||||
declareSection ("3d-render-adv", "3D Rendering (Advanced)");
|
||||
{
|
||||
Setting *fastFactor = createSetting (Type_SpinBox, section, "fast factor");
|
||||
fastFactor->setDefaultValue(4);
|
||||
fastFactor->setEditorSetting(true);
|
||||
fastFactor->setColumnSpan (1);
|
||||
fastFactor->setMinimum (1);
|
||||
fastFactor->setSpecialValueText ("1"); // FIXME: workaround
|
||||
fastFactor->setMaximum (100); // FIXME: not sure what the max value should be
|
||||
fastFactor->setWidgetWidth (10);
|
||||
fastFactor->setViewLocation(1, 2);
|
||||
|
||||
Setting *farClipDist = createSetting (Type_DoubleSpinBox, section, "far clip distance");
|
||||
farClipDist->setDefaultValue(300000);
|
||||
farClipDist->setEditorSetting(true);
|
||||
farClipDist->setColumnSpan (1);
|
||||
farClipDist->setMinimum (0);
|
||||
farClipDist->setMaximum (1000000); // FIXME: not sure what the max value should be
|
||||
farClipDist->setWidgetWidth (10);
|
||||
farClipDist->setViewLocation(2, 2);
|
||||
|
||||
Setting *timerStart = createSetting (Type_SpinBox, section, "timer start");
|
||||
timerStart->setDefaultValue(20);
|
||||
timerStart->setEditorSetting(true);
|
||||
timerStart->setColumnSpan (1);
|
||||
timerStart->setMinimum (0);
|
||||
timerStart->setMaximum (100); // FIXME: not sure what the max value should be
|
||||
timerStart->setWidgetWidth (10);
|
||||
timerStart->setViewLocation(3, 2);
|
||||
Setting *numLights = createSetting (Type_SpinBox, "num_lights",
|
||||
"Number of lights per pass");
|
||||
numLights->setDefaultValue (8);
|
||||
numLights->setRange (1, 100);
|
||||
}
|
||||
|
||||
section = "SubView";
|
||||
declareSection ("scene-input", "Scene Input");
|
||||
{
|
||||
Setting *maxSubView = createSetting (Type_SpinBox, section, "max subviews");
|
||||
maxSubView->setDefaultValue(256);
|
||||
maxSubView->setEditorSetting(true);
|
||||
maxSubView->setColumnSpan (1);
|
||||
maxSubView->setMinimum (1);
|
||||
maxSubView->setSpecialValueText ("1");
|
||||
maxSubView->setMaximum (256); // FIXME: not sure what the max value should be
|
||||
maxSubView->setWidgetWidth (10);
|
||||
maxSubView->setViewLocation(1, 2);
|
||||
Setting *timer = createSetting (Type_SpinBox, "timer", "Input responsiveness");
|
||||
timer->setDefaultValue (20);
|
||||
timer->setRange (1, 100);
|
||||
timer->setToolTip ("The time between two checks for user input in milliseconds.<p>"
|
||||
"Lower value result in higher responsiveness.");
|
||||
|
||||
Setting *minWidth = createSetting (Type_SpinBox, section, "minimum width");
|
||||
minWidth->setDefaultValue(325);
|
||||
minWidth->setEditorSetting(true);
|
||||
minWidth->setColumnSpan (1);
|
||||
minWidth->setMinimum (50);
|
||||
minWidth->setSpecialValueText ("50");
|
||||
minWidth->setMaximum (10000); // FIXME: not sure what the max value should be
|
||||
minWidth->setWidgetWidth (10);
|
||||
minWidth->setViewLocation(2, 2);
|
||||
|
||||
Setting *reuse = createSetting (Type_CheckBox, section, "reuse");
|
||||
reuse->setDeclaredValues(QStringList() << "true" << "false");
|
||||
reuse->setDefaultValue("true");
|
||||
reuse->setEditorSetting(true);
|
||||
reuse->setSpecialValueText("Reuse SubView");
|
||||
reuse->setWidgetWidth(25);
|
||||
reuse->setColumnSpan (3);
|
||||
reuse->setStyleSheet ("QGroupBox { border: 0px; }");
|
||||
reuse->setViewLocation(3, 2);
|
||||
Setting *fastFactor = createSetting (Type_SpinBox, "fast-factor",
|
||||
"Fast movement factor");
|
||||
fastFactor->setDefaultValue (4);
|
||||
fastFactor->setRange (1, 100);
|
||||
fastFactor->setToolTip (
|
||||
"Factor by which movement is speed up while the shift key is held down.");
|
||||
}
|
||||
|
||||
section = "Window Size";
|
||||
declareSection ("window", "Window");
|
||||
{
|
||||
Setting *width = createSetting (Type_LineEdit, section, "Width");
|
||||
Setting *height = createSetting (Type_LineEdit, section, "Height");
|
||||
|
||||
width->setWidgetWidth (5);
|
||||
height->setWidgetWidth (8);
|
||||
|
||||
width->setDefaultValues (QStringList() << "1024");
|
||||
height->setDefaultValues (QStringList() << "768");
|
||||
|
||||
width->setEditorSetting (true);
|
||||
height->setEditorSetting (true);
|
||||
|
||||
height->setViewLocation (2,2);
|
||||
width->setViewLocation (2,1);
|
||||
|
||||
/*
|
||||
*Create the proxy setting for predefined values
|
||||
*/
|
||||
Setting *preDefined = createSetting (Type_ComboBox, section,
|
||||
"Pre-Defined");
|
||||
|
||||
preDefined->setDeclaredValues (QStringList() << "640 x 480"
|
||||
<< "800 x 600" << "1024 x 768" << "1440 x 900");
|
||||
|
||||
Setting *preDefined = createSetting (Type_ComboBox, "pre-defined",
|
||||
"Default window size");
|
||||
preDefined->setEditorSetting (false);
|
||||
preDefined->setDeclaredValues (
|
||||
QStringList() << "640 x 480" << "800 x 600" << "1024 x 768" << "1440 x 900");
|
||||
preDefined->setViewLocation (1, 1);
|
||||
preDefined->setWidgetWidth (10);
|
||||
preDefined->setColumnSpan (2);
|
||||
preDefined->setToolTip ("Newly opened top-level windows will open with this size "
|
||||
"(picked from a list of pre-defined values)");
|
||||
|
||||
preDefined->addProxy (width,
|
||||
QStringList() << "640" << "800" << "1024" << "1440"
|
||||
);
|
||||
Setting *width = createSetting (Type_LineEdit, "default-width",
|
||||
"Default window width");
|
||||
width->setDefaultValues (QStringList() << "1024");
|
||||
width->setViewLocation (2, 1);
|
||||
width->setColumnSpan (1);
|
||||
width->setToolTip ("Newly opened top-level windows will open with this width.");
|
||||
preDefined->addProxy (width, QStringList() << "640" << "800" << "1024" << "1440");
|
||||
|
||||
preDefined->addProxy (height,
|
||||
QStringList() << "480" << "600" << "768" << "900"
|
||||
);
|
||||
Setting *height = createSetting (Type_LineEdit, "default-height",
|
||||
"Default window height");
|
||||
height->setDefaultValues (QStringList() << "768");
|
||||
height->setViewLocation (2, 2);
|
||||
height->setColumnSpan (1);
|
||||
height->setToolTip ("Newly opened top-level windows will open with this height.");
|
||||
preDefined->addProxy (height, QStringList() << "480" << "600" << "768" << "900");
|
||||
|
||||
Setting *reuse = createSetting (Type_CheckBox, "reuse", "Reuse Subviews");
|
||||
reuse->setDefaultValue ("true");
|
||||
reuse->setToolTip ("When a new subview is requested and a matching subview already "
|
||||
" exist, do not open a new subview and use the existing one instead.");
|
||||
|
||||
Setting *maxSubView = createSetting (Type_SpinBox, "max-subviews",
|
||||
"Maximum number of subviews per top-level window");
|
||||
maxSubView->setDefaultValue (256);
|
||||
maxSubView->setRange (1, 256);
|
||||
maxSubView->setToolTip ("If the maximum number is reached and a new subview is opened "
|
||||
"it will be placed into a new top-level window.");
|
||||
|
||||
Setting *minWidth = createSetting (Type_SpinBox, "minimum-width",
|
||||
"Minimum subview width");
|
||||
minWidth->setDefaultValue (325);
|
||||
minWidth->setRange (50, 10000);
|
||||
minWidth->setToolTip ("Minimum width of subviews.");
|
||||
}
|
||||
|
||||
section = "Display Format";
|
||||
declareSection ("records", "Records");
|
||||
{
|
||||
QString defaultValue = "Icon and Text";
|
||||
QStringList values = QStringList() << defaultValue << "Icon Only" << "Text Only";
|
||||
|
||||
QStringList values = QStringList()
|
||||
<< defaultValue << "Icon Only" << "Text Only";
|
||||
|
||||
Setting *rsd = createSetting (Type_RadioButton,
|
||||
section, "Record Status Display");
|
||||
|
||||
Setting *ritd = createSetting (Type_RadioButton,
|
||||
section, "Referenceable ID Type Display");
|
||||
|
||||
Setting *rsd = createSetting (Type_RadioButton, "status-format",
|
||||
"Modification status display format");
|
||||
rsd->setDefaultValue (defaultValue);
|
||||
rsd->setDeclaredValues (values);
|
||||
|
||||
Setting *ritd = createSetting (Type_RadioButton, "type-format",
|
||||
"ID type display format");
|
||||
ritd->setDefaultValue (defaultValue);
|
||||
ritd->setDeclaredValues (values);
|
||||
|
||||
rsd->setEditorSetting (true);
|
||||
ritd->setEditorSetting (true);
|
||||
}
|
||||
|
||||
section = "Video";
|
||||
{
|
||||
QString defaultValue = "None";
|
||||
QStringList values = QStringList()
|
||||
<< defaultValue << "MSAA 2" << "MSAA 4" << "MSAA 8" << "MSAA 16";
|
||||
Setting *antialiasing = createSetting (Type_SpinBox, section, "antialiasing");
|
||||
antialiasing->setDeclaredValues (values);
|
||||
antialiasing->setEditorSetting (true);
|
||||
antialiasing->setWidgetWidth(15);
|
||||
}
|
||||
|
||||
section = "Proxy Selection Test";
|
||||
{
|
||||
/******************************************************************
|
||||
* There are three types of values:
|
||||
|
@ -382,7 +326,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
|||
|
||||
CSMSettings::UserSettings::~UserSettings()
|
||||
{
|
||||
mUserSettingsInstance = 0;
|
||||
sUserSettingsInstance = 0;
|
||||
}
|
||||
|
||||
void CSMSettings::UserSettings::loadSettings (const QString &fileName)
|
||||
|
@ -411,13 +355,9 @@ void CSMSettings::UserSettings::loadSettings (const QString &fileName)
|
|||
|
||||
mSettingDefinitions = new QSettings
|
||||
(QSettings::IniFormat, QSettings::UserScope, "opencs", QString(), this);
|
||||
|
||||
// check if override entry exists (default: disabled)
|
||||
if(!mSettingDefinitions->childGroups().contains("Video", Qt::CaseInsensitive))
|
||||
mSettingDefinitions->setValue("Video/use settings.cfg", "false");
|
||||
}
|
||||
|
||||
// if the key is not found create one with a defaut value
|
||||
// if the key is not found create one with a default value
|
||||
QString CSMSettings::UserSettings::setting(const QString &viewKey, const QString &value)
|
||||
{
|
||||
if(mSettingDefinitions->contains(viewKey))
|
||||
|
@ -451,23 +391,10 @@ QString CSMSettings::UserSettings::settingValue (const QString &settingKey)
|
|||
{
|
||||
QStringList defs;
|
||||
|
||||
// check if video settings are overriden
|
||||
if(settingKey.contains(QRegExp("^Video\\b", Qt::CaseInsensitive)) &&
|
||||
mSettingDefinitions->value("Video/use settings.cfg") == "true" &&
|
||||
settingKey.contains(QRegExp("^Video/\\brender|antialiasing|vsync|fullscreen\\b", Qt::CaseInsensitive)))
|
||||
{
|
||||
if (!mSettingCfgDefinitions->contains (settingKey))
|
||||
return QString();
|
||||
else
|
||||
defs = mSettingCfgDefinitions->value (settingKey).toStringList();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!mSettingDefinitions->contains (settingKey))
|
||||
return QString();
|
||||
if (!mSettingDefinitions->contains (settingKey))
|
||||
return QString();
|
||||
|
||||
defs = mSettingDefinitions->value (settingKey).toStringList();
|
||||
}
|
||||
defs = mSettingDefinitions->value (settingKey).toStringList();
|
||||
|
||||
if (defs.isEmpty())
|
||||
return QString();
|
||||
|
@ -477,8 +404,8 @@ QString CSMSettings::UserSettings::settingValue (const QString &settingKey)
|
|||
|
||||
CSMSettings::UserSettings& CSMSettings::UserSettings::instance()
|
||||
{
|
||||
assert(mUserSettingsInstance);
|
||||
return *mUserSettingsInstance;
|
||||
assert(sUserSettingsInstance);
|
||||
return *sUserSettingsInstance;
|
||||
}
|
||||
|
||||
void CSMSettings::UserSettings::updateUserSetting(const QString &settingKey,
|
||||
|
@ -486,11 +413,11 @@ void CSMSettings::UserSettings::updateUserSetting(const QString &settingKey,
|
|||
{
|
||||
mSettingDefinitions->setValue (settingKey ,list);
|
||||
|
||||
if(settingKey == "Objects/num_lights" && !list.empty())
|
||||
if(settingKey == "3d-render-adv/num_lights" && !list.empty())
|
||||
{
|
||||
sh::Factory::getInstance ().setGlobalSetting ("num_lights", list.at(0).toStdString());
|
||||
}
|
||||
else if(settingKey == "Objects/shaders" && !list.empty())
|
||||
else if(settingKey == "3d-render/shaders" && !list.empty())
|
||||
{
|
||||
sh::Factory::getInstance ().setShadersEnabled (list.at(0).toStdString() == "true" ? true : false);
|
||||
}
|
||||
|
@ -539,24 +466,57 @@ CSMSettings::SettingPageMap CSMSettings::UserSettings::settingPageMap() const
|
|||
SettingPageMap pageMap;
|
||||
|
||||
foreach (Setting *setting, mSettings)
|
||||
pageMap[setting->page()].append (setting);
|
||||
{
|
||||
SettingPageMap::iterator iter = pageMap.find (setting->page());
|
||||
|
||||
if (iter==pageMap.end())
|
||||
{
|
||||
QPair<QString, QList <Setting *> > value;
|
||||
|
||||
std::map<QString, QString>::const_iterator iter2 =
|
||||
mSectionLabels.find (setting->page());
|
||||
|
||||
value.first = iter2!=mSectionLabels.end() ? iter2->second : "";
|
||||
|
||||
iter = pageMap.insert (setting->page(), value);
|
||||
}
|
||||
|
||||
iter->second.append (setting);
|
||||
}
|
||||
|
||||
return pageMap;
|
||||
}
|
||||
|
||||
CSMSettings::Setting *CSMSettings::UserSettings::createSetting
|
||||
(CSMSettings::SettingType typ, const QString &page, const QString &name)
|
||||
(CSMSettings::SettingType type, const QString &name, const QString& label)
|
||||
{
|
||||
//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 (type, name, mSection, label);
|
||||
|
||||
Setting *setting = new Setting (typ, name, page);
|
||||
// set useful defaults
|
||||
int row = 1;
|
||||
|
||||
if (!mSettings.empty())
|
||||
row = mSettings.back()->viewRow()+1;
|
||||
|
||||
setting->setViewLocation (row, 1);
|
||||
|
||||
setting->setColumnSpan (3);
|
||||
|
||||
int width = 10;
|
||||
|
||||
if (type==Type_CheckBox)
|
||||
width = 40;
|
||||
|
||||
setting->setWidgetWidth (width);
|
||||
|
||||
if (type==Type_CheckBox)
|
||||
setting->setStyleSheet ("QGroupBox { border: 0px; }");
|
||||
|
||||
if (type==Type_CheckBox)
|
||||
setting->setDeclaredValues(QStringList() << "true" << "false");
|
||||
|
||||
if (type==Type_CheckBox)
|
||||
setting->setSpecialValueText (setting->getLabel());
|
||||
|
||||
//add declaration to the model
|
||||
mSettings.append (setting);
|
||||
|
@ -564,6 +524,12 @@ CSMSettings::Setting *CSMSettings::UserSettings::createSetting
|
|||
return setting;
|
||||
}
|
||||
|
||||
void CSMSettings::UserSettings::declareSection (const QString& page, const QString& label)
|
||||
{
|
||||
mSection = page;
|
||||
mSectionLabels[page] = label;
|
||||
}
|
||||
|
||||
QStringList CSMSettings::UserSettings::definitions (const QString &viewKey) const
|
||||
{
|
||||
if (mSettingDefinitions->contains (viewKey))
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
#ifndef USERSETTINGS_HPP
|
||||
#define USERSETTINGS_HPP
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <QList>
|
||||
#include <QStringList>
|
||||
#include <QString>
|
||||
#include <QMap>
|
||||
#include <QPair>
|
||||
|
||||
#include <boost/filesystem/path.hpp>
|
||||
#include "support.hpp"
|
||||
|
@ -22,20 +25,20 @@ class QSettings;
|
|||
namespace CSMSettings {
|
||||
|
||||
class Setting;
|
||||
typedef QMap <QString, QList <Setting *> > SettingPageMap;
|
||||
typedef QMap <QString, QPair<QString, QList <Setting *> > > SettingPageMap;
|
||||
|
||||
class UserSettings: public QObject
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
static UserSettings *mUserSettingsInstance;
|
||||
static UserSettings *sUserSettingsInstance;
|
||||
const Files::ConfigurationManager& mCfgMgr;
|
||||
|
||||
QSettings *mSettingDefinitions;
|
||||
QSettings *mSettingCfgDefinitions;
|
||||
QList <Setting *> mSettings;
|
||||
|
||||
QString mSection;
|
||||
std::map<QString, QString> mSectionLabels;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -64,7 +67,7 @@ namespace CSMSettings {
|
|||
void removeSetting
|
||||
(const QString &pageName, const QString &settingName);
|
||||
|
||||
///Retreive a map of the settings, keyed by page name
|
||||
///Retrieve a map of the settings, keyed by page name
|
||||
SettingPageMap settingPageMap() const;
|
||||
|
||||
///Returns a string list of defined vlaues for the specified setting
|
||||
|
@ -84,8 +87,13 @@ namespace CSMSettings {
|
|||
void buildSettingModelDefaults();
|
||||
|
||||
///add a new setting to the model and return it
|
||||
Setting *createSetting (CSMSettings::SettingType typ,
|
||||
const QString &page, const QString &name);
|
||||
Setting *createSetting (CSMSettings::SettingType type, const QString &name,
|
||||
const QString& label);
|
||||
|
||||
/// Set the section for createSetting calls.
|
||||
///
|
||||
/// Sections can be declared multiple times.
|
||||
void declareSection (const QString& page, const QString& label);
|
||||
|
||||
signals:
|
||||
|
||||
|
|
|
@ -369,10 +369,10 @@ CSVDoc::View::View (ViewManager& viewManager, CSMDoc::Document *document, int to
|
|||
mViewTotal (totalViews)
|
||||
{
|
||||
QString width = CSMSettings::UserSettings::instance().settingValue
|
||||
("Window Size/Width");
|
||||
("window/default-width");
|
||||
|
||||
QString height = CSMSettings::UserSettings::instance().settingValue
|
||||
("Window Size/Height");
|
||||
("window/default-height");
|
||||
|
||||
// trick to get the window decorations and their sizes
|
||||
show();
|
||||
|
@ -459,7 +459,7 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin
|
|||
|
||||
// User setting to reuse sub views (on a per top level view basis)
|
||||
bool reuse =
|
||||
userSettings.setting("SubView/reuse", QString("true")) == "true" ? true : false;
|
||||
userSettings.setting ("window/reuse", QString("true")) == "true" ? true : false;
|
||||
if(reuse)
|
||||
{
|
||||
foreach(SubView *sb, mSubViews)
|
||||
|
@ -478,7 +478,7 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin
|
|||
//
|
||||
// If the sub view limit setting is one, the sub view title bar is hidden and the
|
||||
// text in the main title bar is adjusted accordingly
|
||||
int maxSubView = userSettings.setting("SubView/max subviews", QString("256")).toInt();
|
||||
int maxSubView = userSettings.setting("window/max-subviews", QString("256")).toInt();
|
||||
if(mSubViews.size() >= maxSubView) // create a new top level view
|
||||
{
|
||||
mViewManager.addView(mDocument, id, hint);
|
||||
|
@ -501,7 +501,7 @@ void CSVDoc::View::addSubView (const CSMWorld::UniversalId& id, const std::strin
|
|||
if (!hint.empty())
|
||||
view->useHint (hint);
|
||||
|
||||
int minWidth = userSettings.setting("SubView/minimum width", QString("325")).toInt();
|
||||
int minWidth = userSettings.setting ("window/minimum-width", QString("325")).toInt();
|
||||
view->setMinimumWidth(minWidth);
|
||||
|
||||
view->setStatusBar (mShowStatusBar->isChecked());
|
||||
|
|
|
@ -52,10 +52,10 @@ namespace CSVRender
|
|||
|
||||
CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance();
|
||||
|
||||
float farClipDist = userSettings.setting("Scene/far clip distance", QString("300000")).toFloat();
|
||||
float farClipDist = userSettings.setting("3d-render/far-clip-distance", QString("300000")).toFloat();
|
||||
mCamera->setFarClipDistance (farClipDist);
|
||||
|
||||
mFastFactor = userSettings.setting("Scene/fast factor", QString("4")).toInt();
|
||||
mFastFactor = userSettings.setting("scene-input/fast-factor", QString("4")).toInt();
|
||||
|
||||
mCamera->roll (Ogre::Degree (90));
|
||||
|
||||
|
@ -68,7 +68,7 @@ namespace CSVRender
|
|||
|
||||
connect (timer, SIGNAL (timeout()), this, SLOT (update()));
|
||||
|
||||
int timerStart = userSettings.setting("Scene/timer start", QString("20")).toInt();
|
||||
int timerStart = userSettings.setting("scene-input/timer", QString("20")).toInt();
|
||||
timer->start (timerStart);
|
||||
|
||||
/// \todo make shortcut configurable
|
||||
|
@ -137,7 +137,7 @@ namespace CSVRender
|
|||
params.insert(std::make_pair("title", windowTitle.str()));
|
||||
|
||||
std::string antialiasing =
|
||||
CSMSettings::UserSettings::instance().settingValue("Video/antialiasing").toStdString();
|
||||
CSMSettings::UserSettings::instance().settingValue("3d-render/antialiasing").toStdString();
|
||||
if(antialiasing == "MSAA 16") antialiasing = "16";
|
||||
else if(antialiasing == "MSAA 8") antialiasing = "8";
|
||||
else if(antialiasing == "MSAA 4") antialiasing = "4";
|
||||
|
@ -440,14 +440,14 @@ namespace CSVRender
|
|||
if(key.contains(QRegExp("^\\b(Objects|Shader|Scene)", Qt::CaseInsensitive)))
|
||||
flagAsModified();
|
||||
|
||||
if(key == "Scene/far clip distance" && !list.empty())
|
||||
if(key == "3d-render/far-clip-distance" && !list.empty())
|
||||
{
|
||||
if(mCamera->getFarClipDistance() != list.at(0).toFloat())
|
||||
mCamera->setFarClipDistance(list.at(0).toFloat());
|
||||
}
|
||||
|
||||
// minimise unnecessary ogre window creation by updating only when there is a change
|
||||
if(key == "Video/antialiasing")
|
||||
if(key == "3d-render/antialiasing")
|
||||
{
|
||||
unsigned int aa = mWindow->getFSAA();
|
||||
unsigned int antialiasing = 0;
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
#include "dialog.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <QListWidgetItem>
|
||||
#include <QApplication>
|
||||
#include <QWidget>
|
||||
#include <QStackedWidget>
|
||||
#include <QtGui>
|
||||
#include <QSplitter>
|
||||
|
||||
#include "../../model/settings/usersettings.hpp"
|
||||
|
||||
|
@ -12,8 +15,6 @@
|
|||
|
||||
#include <QApplication>
|
||||
|
||||
#include <QSplitter>
|
||||
|
||||
#include <QTreeView>
|
||||
#include <QListView>
|
||||
#include <QTableView>
|
||||
|
@ -26,6 +27,10 @@ CSVSettings::Dialog::Dialog(QMainWindow *parent)
|
|||
{
|
||||
setWindowTitle(QString::fromUtf8 ("User Settings"));
|
||||
|
||||
setSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
|
||||
setMinimumSize (600, 400);
|
||||
|
||||
setupDialog();
|
||||
|
||||
connect (mPageListWidget,
|
||||
|
@ -39,20 +44,14 @@ void CSVSettings::Dialog::slotChangePage
|
|||
{
|
||||
mStackedWidget->changePage
|
||||
(mPageListWidget->row (cur), mPageListWidget->row (prev));
|
||||
|
||||
layout()->activate();
|
||||
setFixedSize(minimumSizeHint());
|
||||
}
|
||||
|
||||
void CSVSettings::Dialog::setupDialog()
|
||||
{
|
||||
//create central widget with it's layout and immediate children
|
||||
QWidget *centralWidget = new QGroupBox (this);
|
||||
QSplitter *centralWidget = new QSplitter (this);
|
||||
centralWidget->setSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
||||
|
||||
centralWidget->setLayout (new QHBoxLayout());
|
||||
centralWidget->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Preferred);
|
||||
setCentralWidget (centralWidget);
|
||||
setDockOptions (QMainWindow::AllowNestedDocks);
|
||||
|
||||
buildPageListWidget (centralWidget);
|
||||
buildStackedWidget (centralWidget);
|
||||
|
@ -64,37 +63,39 @@ void CSVSettings::Dialog::buildPages()
|
|||
|
||||
QFontMetrics fm (QApplication::font());
|
||||
|
||||
int maxWidth = 1;
|
||||
|
||||
foreach (Page *page, SettingWindow::pages())
|
||||
{
|
||||
QString pageName = page->objectName();
|
||||
maxWidth = std::max (maxWidth, fm.width(page->getLabel()));
|
||||
|
||||
int textWidth = fm.width(pageName);
|
||||
new QListWidgetItem (page->getLabel(), mPageListWidget);
|
||||
|
||||
new QListWidgetItem (pageName, mPageListWidget);
|
||||
mPageListWidget->setFixedWidth (textWidth + 50);
|
||||
|
||||
mStackedWidget->addWidget (&dynamic_cast<QWidget &>(*(page)));
|
||||
mStackedWidget->addWidget (page);
|
||||
}
|
||||
|
||||
mPageListWidget->setMaximumWidth (maxWidth + 10);
|
||||
|
||||
resize (mStackedWidget->sizeHint());
|
||||
}
|
||||
|
||||
void CSVSettings::Dialog::buildPageListWidget (QWidget *centralWidget)
|
||||
void CSVSettings::Dialog::buildPageListWidget (QSplitter *centralWidget)
|
||||
{
|
||||
mPageListWidget = new QListWidget (centralWidget);
|
||||
mPageListWidget->setMinimumWidth(50);
|
||||
mPageListWidget->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Expanding);
|
||||
mPageListWidget->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
|
||||
mPageListWidget->setSelectionBehavior (QAbstractItemView::SelectItems);
|
||||
|
||||
centralWidget->layout()->addWidget(mPageListWidget);
|
||||
centralWidget->addWidget(mPageListWidget);
|
||||
}
|
||||
|
||||
void CSVSettings::Dialog::buildStackedWidget (QWidget *centralWidget)
|
||||
void CSVSettings::Dialog::buildStackedWidget (QSplitter *centralWidget)
|
||||
{
|
||||
mStackedWidget = new ResizeableStackedWidget (centralWidget);
|
||||
mStackedWidget->setSizePolicy (QSizePolicy::Preferred, QSizePolicy::Expanding);
|
||||
|
||||
centralWidget->layout()->addWidget (mStackedWidget);
|
||||
centralWidget->addWidget (mStackedWidget);
|
||||
}
|
||||
|
||||
void CSVSettings::Dialog::closeEvent (QCloseEvent *event)
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
class QStackedWidget;
|
||||
class QListWidget;
|
||||
class QListWidgetItem;
|
||||
class QSplitter;
|
||||
|
||||
namespace CSVSettings {
|
||||
|
||||
|
@ -39,8 +40,8 @@ namespace CSVSettings {
|
|||
private:
|
||||
|
||||
void buildPages();
|
||||
void buildPageListWidget (QWidget *centralWidget);
|
||||
void buildStackedWidget (QWidget *centralWidget);
|
||||
void buildPageListWidget (QSplitter *centralWidget);
|
||||
void buildStackedWidget (QSplitter *centralWidget);
|
||||
|
||||
public slots:
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ CSVSettings::Frame::Frame (bool isVisible, const QString &title,
|
|||
{
|
||||
// must be Page, not a View
|
||||
setStyleSheet (sInvisibleBoxStyle);
|
||||
mLayout->setContentsMargins(10, 15, 10, 15);
|
||||
}
|
||||
|
||||
setLayout (mLayout);
|
||||
|
@ -39,7 +38,7 @@ void CSVSettings::Frame::hideWidgets()
|
|||
|
||||
QWidget *widg = static_cast <QWidget *> (obj);
|
||||
if (widg->property("sizePolicy").isValid())
|
||||
widg->setSizePolicy (QSizePolicy::Ignored, QSizePolicy::Ignored);
|
||||
widg->setSizePolicy (QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||||
}
|
||||
|
||||
layout()->activate();
|
||||
|
|
|
@ -17,10 +17,9 @@
|
|||
QMap <CSVSettings::ViewType, CSVSettings::IViewFactory *>
|
||||
CSVSettings::Page::mViewFactories;
|
||||
|
||||
CSVSettings::Page::Page(const QString &pageName,
|
||||
QList <CSMSettings::Setting *> settingList,
|
||||
SettingWindow *parent) :
|
||||
mParent(parent), mIsEditorPage (false), Frame(false, "", parent)
|
||||
CSVSettings::Page::Page (const QString &pageName, QList <CSMSettings::Setting *> settingList,
|
||||
SettingWindow *parent, const QString& label)
|
||||
: mParent(parent), mIsEditorPage (false), Frame(false, "", parent), mLabel (label)
|
||||
{
|
||||
setObjectName (pageName);
|
||||
|
||||
|
@ -104,3 +103,8 @@ void CSVSettings::Page::buildFactories()
|
|||
mViewFactories[ViewType_List] = new ListViewFactory (this);
|
||||
mViewFactories[ViewType_Range] = new RangeViewFactory (this);
|
||||
}
|
||||
|
||||
QString CSVSettings::Page::getLabel() const
|
||||
{
|
||||
return mLabel;
|
||||
}
|
||||
|
|
|
@ -25,11 +25,11 @@ namespace CSVSettings
|
|||
SettingWindow *mParent;
|
||||
static QMap <ViewType, IViewFactory *> mViewFactories;
|
||||
bool mIsEditorPage;
|
||||
QString mLabel;
|
||||
|
||||
public:
|
||||
explicit Page(const QString &pageName,
|
||||
QList <CSMSettings::Setting *> settingList,
|
||||
SettingWindow *parent);
|
||||
Page (const QString &pageName, QList <CSMSettings::Setting *> settingList,
|
||||
SettingWindow *parent, const QString& label);
|
||||
|
||||
///Creates a new view based on the passed setting and adds it to
|
||||
///the page.
|
||||
|
@ -42,6 +42,8 @@ namespace CSVSettings
|
|||
///returns the list of views associated with the page
|
||||
const QList <View *> &views () const { return mViews; }
|
||||
|
||||
QString getLabel() const;
|
||||
|
||||
private:
|
||||
|
||||
///Creates views based on the passed setting list
|
||||
|
|
|
@ -126,8 +126,6 @@ void CSVSettings::RangeView::buildSpinBox (CSMSettings::Setting *setting)
|
|||
mRangeWidget->setProperty ("minimum", setting->minimum());
|
||||
mRangeWidget->setProperty ("maximum", setting->maximum());
|
||||
mRangeWidget->setProperty ("singleStep", setting->singleStep());
|
||||
mRangeWidget->setProperty ("specialValueText",
|
||||
setting->specialValueText());
|
||||
}
|
||||
|
||||
mRangeWidget->setProperty ("prefix", setting->prefix());
|
||||
|
|
|
@ -34,7 +34,6 @@ void CSVSettings::ResizeableStackedWidget::changePage
|
|||
curPage->showWidgets();
|
||||
|
||||
layout()->activate();
|
||||
setFixedSize(minimumSizeHint());
|
||||
|
||||
setCurrentIndex (current);
|
||||
}
|
||||
|
|
|
@ -20,9 +20,9 @@ void CSVSettings::SettingWindow::createPages()
|
|||
|
||||
foreach (const QString &pageName, pageMap.keys())
|
||||
{
|
||||
QList <CSMSettings::Setting *> pageSettings = pageMap.value (pageName);
|
||||
QList <CSMSettings::Setting *> pageSettings = pageMap.value (pageName).second;
|
||||
|
||||
mPages.append (new Page (pageName, pageSettings, this));
|
||||
mPages.append (new Page (pageName, pageSettings, this, pageMap.value (pageName).first));
|
||||
|
||||
for (int i = 0; i < pageSettings.size(); i++)
|
||||
{
|
||||
|
|
|
@ -17,8 +17,11 @@ CSVSettings::View::View(CSMSettings::Setting *setting,
|
|||
mIsMultiValue (setting->isMultiValue()),
|
||||
mViewKey (setting->page() + '/' + setting->name()),
|
||||
mSerializable (setting->serializable()),
|
||||
Frame(true, setting->name(), parent)
|
||||
Frame(true, setting->getLabel(), parent)
|
||||
{
|
||||
if (!setting->getToolTip().isEmpty())
|
||||
setToolTip (setting->getToolTip());
|
||||
|
||||
setObjectName (setting->name());
|
||||
buildView();
|
||||
buildModel (setting);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
CSVWorld::IdTypeDelegate::IdTypeDelegate
|
||||
(const ValueList &values, const IconList &icons, CSMDoc::Document& document, QObject *parent)
|
||||
: DataDisplayDelegate (values, icons, document,
|
||||
"Display Format", "Referenceable ID Type Display",
|
||||
"records", "type-format",
|
||||
parent)
|
||||
{}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ CSVWorld::RecordStatusDelegate::RecordStatusDelegate(const ValueList& values,
|
|||
const IconList & icons,
|
||||
CSMDoc::Document& document, QObject *parent)
|
||||
: DataDisplayDelegate (values, icons, document,
|
||||
"Display Format", "Record Status Display",
|
||||
"records", "status-format",
|
||||
parent)
|
||||
{}
|
||||
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
[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