forked from mirror/openmw-tes3mp
split off settings page label from internal section name
This commit is contained in:
parent
720ba2c0d8
commit
c94c1adaf3
6 changed files with 48 additions and 25 deletions
|
@ -50,7 +50,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
|||
{
|
||||
QString section;
|
||||
|
||||
declareSection ("Objects");
|
||||
declareSection ("Objects", "Objects");
|
||||
{
|
||||
Setting *numLights = createSetting (Type_SpinBox, "num_lights", "num_lights");
|
||||
numLights->setDefaultValue(8);
|
||||
|
@ -58,10 +58,9 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
|||
|
||||
Setting *shaders = createSetting (Type_CheckBox, "shaders", "Enable Shaders");
|
||||
shaders->setDefaultValue("true");
|
||||
// shaders->setSpecialValueText("Enable Shaders");
|
||||
}
|
||||
|
||||
declareSection ("Scene");
|
||||
declareSection ("Scene", "Scene");
|
||||
{
|
||||
Setting *fastFactor = createSetting (Type_SpinBox, "fast factor", "fast factor");
|
||||
fastFactor->setDefaultValue(4);
|
||||
|
@ -76,7 +75,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
|||
timerStart->setRange (1, 100);
|
||||
}
|
||||
|
||||
declareSection ("SubView");
|
||||
declareSection ("SubView", "SubView");
|
||||
{
|
||||
Setting *maxSubView = createSetting (Type_SpinBox, "max subviews", "max subviews");
|
||||
maxSubView->setDefaultValue(256);
|
||||
|
@ -91,7 +90,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
|||
// reuse->setSpecialValueText("Reuse SubView");
|
||||
}
|
||||
|
||||
declareSection ("Window Size");
|
||||
declareSection ("Window Size", "Window Size");
|
||||
{
|
||||
Setting *width = createSetting (Type_LineEdit, "Width", "Width");
|
||||
Setting *height = createSetting (Type_LineEdit, "Height", "Height");
|
||||
|
@ -124,7 +123,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
|||
);
|
||||
}
|
||||
|
||||
declareSection ("Display Format");
|
||||
declareSection ("Display Format", "Display Format");
|
||||
{
|
||||
QString defaultValue = "Icon and Text";
|
||||
|
||||
|
@ -139,7 +138,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
|||
ritd->setDeclaredValues (values);
|
||||
}
|
||||
|
||||
declareSection ("Video");
|
||||
declareSection ("Video", "Video");
|
||||
{
|
||||
QString defaultValue = "None";
|
||||
QStringList values = QStringList()
|
||||
|
@ -480,7 +479,23 @@ 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;
|
||||
}
|
||||
|
@ -532,9 +547,10 @@ CSMSettings::Setting *CSMSettings::UserSettings::createSetting
|
|||
return setting;
|
||||
}
|
||||
|
||||
void CSMSettings::UserSettings::declareSection (const QString& page)
|
||||
void CSMSettings::UserSettings::declareSection (const QString& page, const QString& label)
|
||||
{
|
||||
mSection = page;
|
||||
mSectionLabels[page] = label;
|
||||
}
|
||||
|
||||
QStringList CSMSettings::UserSettings::definitions (const QString &viewKey) const
|
||||
|
|
|
@ -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,7 +25,7 @@ class QSettings;
|
|||
namespace CSMSettings {
|
||||
|
||||
class Setting;
|
||||
typedef QMap <QString, QList <Setting *> > SettingPageMap;
|
||||
typedef QMap <QString, QPair<QString, QList <Setting *> > > SettingPageMap;
|
||||
|
||||
class UserSettings: public QObject
|
||||
{
|
||||
|
@ -36,7 +39,7 @@ namespace CSMSettings {
|
|||
QSettings *mSettingCfgDefinitions;
|
||||
QList <Setting *> mSettings;
|
||||
QString mSection;
|
||||
|
||||
std::map<QString, QString> mSectionLabels;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -91,7 +94,7 @@ namespace CSMSettings {
|
|||
/// Set the section for createSetting calls.
|
||||
///
|
||||
/// Sections can be declared multiple times.
|
||||
void declareSection (const QString& page);
|
||||
void declareSection (const QString& page, const QString& label);
|
||||
|
||||
signals:
|
||||
|
||||
|
|
|
@ -67,11 +67,9 @@ void CSVSettings::Dialog::buildPages()
|
|||
|
||||
foreach (Page *page, SettingWindow::pages())
|
||||
{
|
||||
QString pageName = page->objectName();
|
||||
maxWidth = std::max (maxWidth, fm.width(page->getLabel()));
|
||||
|
||||
maxWidth = std::max (maxWidth, fm.width(pageName));
|
||||
|
||||
new QListWidgetItem (pageName, mPageListWidget);
|
||||
new QListWidgetItem (page->getLabel(), mPageListWidget);
|
||||
|
||||
mStackedWidget->addWidget (page);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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++)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue