forked from teamnwah/openmw-tes3coop
Three primary changes:
1. Declared QStringPair::isEmpty() const 2. Split the CsSettings namespace into two: CSMSettings and CSVSettings. (Required splitting the support.hpp file) 3. Declared several classes as _noqt in CMakeLists.txt for OpenCS
This commit is contained in:
parent
8d0f350446
commit
a8b45e0a13
36 changed files with 335 additions and 325 deletions
|
@ -73,29 +73,33 @@ opencs_units_noqt (view/tools
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_units (view/settings
|
opencs_units (view/settings
|
||||||
customblock
|
|
||||||
proxyblock
|
|
||||||
groupbox
|
|
||||||
abstractblock
|
abstractblock
|
||||||
settingwidget
|
proxyblock
|
||||||
itemblock
|
|
||||||
groupblock
|
|
||||||
toggleblock
|
|
||||||
usersettingsdialog
|
|
||||||
abstractpage
|
|
||||||
abstractwidget
|
abstractwidget
|
||||||
blankpage
|
usersettingsdialog
|
||||||
editorpage
|
editorpage
|
||||||
)
|
)
|
||||||
|
|
||||||
|
opencs_units_noqt (view/settings
|
||||||
|
abstractpage
|
||||||
|
blankpage
|
||||||
|
groupblock
|
||||||
|
customblock
|
||||||
|
groupbox
|
||||||
|
itemblock
|
||||||
|
settingwidget
|
||||||
|
toggleblock
|
||||||
|
support
|
||||||
|
)
|
||||||
|
|
||||||
opencs_units (model/settings
|
opencs_units (model/settings
|
||||||
settingcontainer
|
settingcontainer
|
||||||
settingsitem
|
|
||||||
)
|
)
|
||||||
|
|
||||||
opencs_units_noqt (model/settings
|
opencs_units_noqt (model/settings
|
||||||
support
|
support
|
||||||
usersettings
|
usersettings
|
||||||
|
settingsitem
|
||||||
)
|
)
|
||||||
|
|
||||||
set (OPENCS_US
|
set (OPENCS_US
|
||||||
|
|
|
@ -2,17 +2,17 @@
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
CsSettings::SettingContainer::SettingContainer(QObject *parent) :
|
CSMSettings::SettingContainer::SettingContainer(QObject *parent) :
|
||||||
QObject(parent), mValue (0), mValues (0)
|
QObject(parent), mValue (0), mValues (0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CsSettings::SettingContainer::SettingContainer(const QString &value, QObject *parent) :
|
CSMSettings::SettingContainer::SettingContainer(const QString &value, QObject *parent) :
|
||||||
QObject(parent), mValue (new QString (value)), mValues (0)
|
QObject(parent), mValue (new QString (value)), mValues (0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::SettingContainer::insert (const QString &value)
|
void CSMSettings::SettingContainer::insert (const QString &value)
|
||||||
{
|
{
|
||||||
if (mValue)
|
if (mValue)
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,7 @@ void CsSettings::SettingContainer::insert (const QString &value)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::SettingContainer::update (const QString &value, int index)
|
void CSMSettings::SettingContainer::update (const QString &value, int index)
|
||||||
{
|
{
|
||||||
if (isEmpty())
|
if (isEmpty())
|
||||||
mValue = new QString(value);
|
mValue = new QString(value);
|
||||||
|
@ -43,7 +43,7 @@ void CsSettings::SettingContainer::update (const QString &value, int index)
|
||||||
mValues->replace(index, value);
|
mValues->replace(index, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CsSettings::SettingContainer::getValue (int index) const
|
QString CSMSettings::SettingContainer::getValue (int index) const
|
||||||
{
|
{
|
||||||
QString retVal("");
|
QString retVal("");
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ QString CsSettings::SettingContainer::getValue (int index) const
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CsSettings::SettingContainer::count () const
|
int CSMSettings::SettingContainer::count () const
|
||||||
{
|
{
|
||||||
int retVal = 0;
|
int retVal = 0;
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
class QStringList;
|
class QStringList;
|
||||||
|
|
||||||
namespace CsSettings
|
namespace CSMSettings
|
||||||
{
|
{
|
||||||
class SettingContainer : public QObject
|
class SettingContainer : public QObject
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "settingsitem.hpp"
|
#include "settingsitem.hpp"
|
||||||
|
|
||||||
bool CsSettings::SettingsItem::updateItem (const QStringList *values)
|
bool CSMSettings::SettingsItem::updateItem (const QStringList *values)
|
||||||
{
|
{
|
||||||
QStringList::ConstIterator it = values->begin();
|
QStringList::ConstIterator it = values->begin();
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ bool CsSettings::SettingsItem::updateItem (const QStringList *values)
|
||||||
return isValid;
|
return isValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CsSettings::SettingsItem::updateItem (const QString &value)
|
bool CSMSettings::SettingsItem::updateItem (const QString &value)
|
||||||
{
|
{
|
||||||
//takes a value or a SettingsContainer and updates itself accordingly
|
//takes a value or a SettingsContainer and updates itself accordingly
|
||||||
//after validating the data against it's own definition
|
//after validating the data against it's own definition
|
||||||
|
@ -52,7 +52,7 @@ bool CsSettings::SettingsItem::updateItem (const QString &value)
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CsSettings::SettingsItem::updateItem(int valueListIndex)
|
bool CSMSettings::SettingsItem::updateItem(int valueListIndex)
|
||||||
{
|
{
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ bool CsSettings::SettingsItem::updateItem(int valueListIndex)
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CsSettings::SettingsItem::validate (const QString &value)
|
bool CSMSettings::SettingsItem::validate (const QString &value)
|
||||||
{
|
{
|
||||||
bool isValid = true;
|
bool isValid = true;
|
||||||
|
|
||||||
|
@ -90,13 +90,13 @@ bool CsSettings::SettingsItem::validate (const QString &value)
|
||||||
return isValid;
|
return isValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::SettingsItem::setDefaultValue (const QString &value)
|
void CSMSettings::SettingsItem::setDefaultValue (const QString &value)
|
||||||
{
|
{
|
||||||
mDefaultValue = value;
|
mDefaultValue = value;
|
||||||
update (value);
|
update (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CsSettings::SettingsItem::getDefaultValue() const
|
QString CSMSettings::SettingsItem::getDefaultValue() const
|
||||||
{
|
{
|
||||||
return mDefaultValue;
|
return mDefaultValue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include "support.hpp"
|
#include "support.hpp"
|
||||||
#include "settingcontainer.hpp"
|
#include "settingcontainer.hpp"
|
||||||
|
|
||||||
namespace CsSettings
|
namespace CSMSettings
|
||||||
{
|
{
|
||||||
class SettingsItem : public SettingContainer
|
class SettingsItem : public SettingContainer
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#ifndef SUPPORT_HPP
|
#ifndef MODEL_SUPPORT_HPP
|
||||||
#define SUPPORT_HPP
|
#define MODEL_SUPPORT_HPP
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
@ -8,48 +8,13 @@ class QLayout;
|
||||||
class QWidget;
|
class QWidget;
|
||||||
class QListWidgetItem;
|
class QListWidgetItem;
|
||||||
|
|
||||||
namespace CsSettings
|
namespace CSMSettings
|
||||||
{
|
{
|
||||||
|
|
||||||
class SettingContainer;
|
class SettingContainer;
|
||||||
struct WidgetDef;
|
|
||||||
class ItemBlock;
|
|
||||||
class GroupBlock;
|
|
||||||
struct GroupBlockDef;
|
|
||||||
|
|
||||||
typedef QList<GroupBlockDef *> GroupBlockDefList;
|
|
||||||
typedef QList<GroupBlock *> GroupBlockList;
|
|
||||||
typedef QList<ItemBlock *> ItemBlockList;
|
|
||||||
typedef QList<SettingContainer *> SettingList;
|
typedef QList<SettingContainer *> SettingList;
|
||||||
typedef QMap<QString, SettingContainer *> SettingMap;
|
typedef QMap<QString, SettingContainer *> SettingMap;
|
||||||
typedef QMap<QString, SettingMap *> SectionMap;
|
typedef QMap<QString, SettingMap *> SectionMap;
|
||||||
typedef QList<QStringList *> ProxyList;
|
|
||||||
typedef QList<WidgetDef *> WidgetList;
|
|
||||||
typedef QMap<QString, ItemBlock *> ItemBlockMap;
|
|
||||||
|
|
||||||
enum OcsWidgetOrientation
|
|
||||||
{
|
|
||||||
OCS_HORIZONTAL,
|
|
||||||
OCS_VERTICAL
|
|
||||||
};
|
|
||||||
|
|
||||||
enum OcsWidgetType
|
|
||||||
{
|
|
||||||
OCS_CHECK_WIDGET,
|
|
||||||
OCS_COMBO_WIDGET,
|
|
||||||
OCS_TEXT_WIDGET,
|
|
||||||
OCS_LIST_WIDGET,
|
|
||||||
OCS_RADIO_WIDGET,
|
|
||||||
OCS_SPIN_WIDGET,
|
|
||||||
OCS_UNDEFINED_WIDGET
|
|
||||||
};
|
|
||||||
|
|
||||||
enum OcsAlignment
|
|
||||||
{
|
|
||||||
OCS_LEFT = Qt::AlignLeft,
|
|
||||||
OCS_CENTER = Qt::AlignHCenter,
|
|
||||||
OCS_RIGHT = Qt::AlignRight
|
|
||||||
};
|
|
||||||
|
|
||||||
struct QStringPair
|
struct QStringPair
|
||||||
{
|
{
|
||||||
|
@ -67,104 +32,8 @@ namespace CsSettings
|
||||||
QString left;
|
QString left;
|
||||||
QString right;
|
QString right;
|
||||||
|
|
||||||
bool isEmpty()
|
bool isEmpty() const
|
||||||
{ return (left.isEmpty() && right.isEmpty()); }
|
{ return (left.isEmpty() && right.isEmpty()); }
|
||||||
};
|
};
|
||||||
|
|
||||||
//template for defining the widget of a property.
|
|
||||||
struct WidgetDef
|
|
||||||
{
|
|
||||||
OcsWidgetType type; //type of widget providing input
|
|
||||||
int labelWidth; //width of caption label
|
|
||||||
int widgetWidth; //width of input widget
|
|
||||||
OcsWidgetOrientation orientation; //label / widget orientation (horizontal / vertical)
|
|
||||||
QString inputMask; //input mask (line edit)
|
|
||||||
QString caption; //label caption. Leave empty for multiple items. See BlockDef::captionList
|
|
||||||
QString value; //widget value. Leave empty for multiple items. See BlockDef::valueList
|
|
||||||
QStringPair *minMax; //Min/Max QString value pair. If empty, assigned to property item value pair.
|
|
||||||
QStringList *valueList; //value list for list widgets. If left empty, is assigned to property item value list during block build().
|
|
||||||
bool isDefault; //isDefault - determined at runtime.
|
|
||||||
OcsAlignment valueAlignment; //left / center / right-justify text in widget
|
|
||||||
OcsAlignment widgetAlignment; //left / center / right-justify widget in group box
|
|
||||||
|
|
||||||
|
|
||||||
WidgetDef() : labelWidth (-1), widgetWidth (-1),
|
|
||||||
orientation (OCS_HORIZONTAL),
|
|
||||||
isDefault (true), valueAlignment (OCS_CENTER),
|
|
||||||
widgetAlignment (OCS_RIGHT),
|
|
||||||
inputMask (""), value (""),
|
|
||||||
caption (""), valueList (0)
|
|
||||||
{}
|
|
||||||
|
|
||||||
WidgetDef (OcsWidgetType widgType)
|
|
||||||
: type (widgType), orientation (OCS_HORIZONTAL),
|
|
||||||
caption (""), value (""), valueAlignment (OCS_CENTER),
|
|
||||||
widgetAlignment (OCS_RIGHT),
|
|
||||||
labelWidth (-1), widgetWidth (-1),
|
|
||||||
valueList (0), isDefault (true)
|
|
||||||
{}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
//Defines the attributes of the property as it is represented in the config file
|
|
||||||
//as well as the UI elements (group box and widget) that serve it.
|
|
||||||
//Only one widget may serve as the input widget for the property.
|
|
||||||
struct SettingsItemDef
|
|
||||||
{
|
|
||||||
QString name; //property name
|
|
||||||
QStringList *valueList; //list of valid values for the property.
|
|
||||||
//Used to populate option widget captions or list widget item lists (see WidgetDef::caption / value)
|
|
||||||
QString defaultValue;
|
|
||||||
bool hasMultipleValues;
|
|
||||||
QStringPair minMax; //minimum / maximum value pair
|
|
||||||
WidgetDef widget; //definition of the input widget for this setting
|
|
||||||
OcsWidgetOrientation orientation; //general orientation of the widget / label for this property
|
|
||||||
ProxyList *proxyList; //list of property and corresponding default values for proxy widget
|
|
||||||
|
|
||||||
SettingsItemDef() : name (""), defaultValue (""), orientation (OCS_VERTICAL), hasMultipleValues (false)
|
|
||||||
{}
|
|
||||||
|
|
||||||
SettingsItemDef (QString propName, QString propDefault, OcsWidgetOrientation propOrient = OCS_VERTICAL)
|
|
||||||
: name (propName), defaultValue (propDefault), orientation (propOrient),
|
|
||||||
hasMultipleValues(false), valueList (new QStringList), proxyList ( new ProxyList)
|
|
||||||
{}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
//Hierarchically, this is a "sub-section" of properties within a section, solely for UI organization.
|
|
||||||
//Does not correlate to config file structure.
|
|
||||||
struct GroupBlockDef
|
|
||||||
{
|
|
||||||
QString title; //title of the block containing the property or properties of this sub-section
|
|
||||||
QStringList captions; //list of captions for widgets at the block level (not associated with any particular property)
|
|
||||||
WidgetList widgets; //list of widgets at the block level (not associated with any particular property)
|
|
||||||
QList<SettingsItemDef *> properties; //list of the property(ies) which are subordinate to the property block.
|
|
||||||
OcsWidgetOrientation widgetOrientation; //general orientation of widgets in group block
|
|
||||||
bool isVisible; //determines whether or not box border/title are visible
|
|
||||||
bool isProxy; //indicates whether or not this block defines a proxy block
|
|
||||||
QString defaultValue; //generic default value attribute
|
|
||||||
|
|
||||||
GroupBlockDef (): title(""), widgetOrientation (OCS_VERTICAL), isVisible (true), isProxy (false), defaultValue ("")
|
|
||||||
{}
|
|
||||||
|
|
||||||
GroupBlockDef (QString blockTitle)
|
|
||||||
: title (blockTitle), widgetOrientation (OCS_VERTICAL), isProxy (false), isVisible (true), defaultValue ("")
|
|
||||||
{}
|
|
||||||
};
|
|
||||||
|
|
||||||
struct CustomBlockDef
|
|
||||||
{
|
|
||||||
QString title;
|
|
||||||
QString defaultValue; //default value for widgets unique to the custom block
|
|
||||||
GroupBlockDefList blockDefList; //list of settings groups that comprise the settings within the custom block
|
|
||||||
OcsWidgetOrientation blockOrientation;
|
|
||||||
|
|
||||||
CustomBlockDef (): title (""), defaultValue (""), blockOrientation (OCS_HORIZONTAL)
|
|
||||||
{}
|
|
||||||
|
|
||||||
CustomBlockDef (const QString &blockTitle)
|
|
||||||
: title (blockTitle), defaultValue (""), blockOrientation (OCS_HORIZONTAL)
|
|
||||||
{}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
#endif // SUPPORT_HPP
|
#endif // MODEL_SUPPORT_HPP
|
||||||
|
|
|
@ -30,16 +30,16 @@ namespace boost
|
||||||
#endif /* (BOOST_VERSION <= 104600) */
|
#endif /* (BOOST_VERSION <= 104600) */
|
||||||
|
|
||||||
|
|
||||||
CsSettings::UserSettings::UserSettings(Files::ConfigurationManager &cfg)
|
CSMSettings::UserSettings::UserSettings(Files::ConfigurationManager &cfg)
|
||||||
: mCfgMgr(cfg)
|
: mCfgMgr(cfg)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CsSettings::UserSettings::~UserSettings()
|
CSMSettings::UserSettings::~UserSettings()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile *CsSettings::UserSettings::openFile (const QString &filename)
|
QFile *CSMSettings::UserSettings::openFile (const QString &filename)
|
||||||
{
|
{
|
||||||
QFile *file = new QFile(filename);
|
QFile *file = new QFile(filename);
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ QFile *CsSettings::UserSettings::openFile (const QString &filename)
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CsSettings::UserSettings::writeFile(QFile *file, QMap<QString, CsSettings::SettingList *> &settings)
|
bool CSMSettings::UserSettings::writeFile(QFile *file, QMap<QString, CSMSettings::SettingList *> &settings)
|
||||||
{
|
{
|
||||||
if (!file)
|
if (!file)
|
||||||
return false;
|
return false;
|
||||||
|
@ -88,7 +88,7 @@ bool CsSettings::UserSettings::writeFile(QFile *file, QMap<QString, CsSettings::
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::UserSettings::getSettings(QTextStream &stream, SectionMap §ions)
|
void CSMSettings::UserSettings::getSettings(QTextStream &stream, SectionMap §ions)
|
||||||
{
|
{
|
||||||
//looks for a square bracket, "'\\["
|
//looks for a square bracket, "'\\["
|
||||||
//that has one or more "not nothing" in it, "([^]]+)"
|
//that has one or more "not nothing" in it, "([^]]+)"
|
||||||
|
@ -102,7 +102,7 @@ void CsSettings::UserSettings::getSettings(QTextStream &stream, SectionMap §
|
||||||
|
|
||||||
QRegExp keyRe("^([^=]+)\\s*=\\s*(.+)$");
|
QRegExp keyRe("^([^=]+)\\s*=\\s*(.+)$");
|
||||||
|
|
||||||
CsSettings::SettingMap *settings = 0;
|
CSMSettings::SettingMap *settings = 0;
|
||||||
QString section = "none";
|
QString section = "none";
|
||||||
|
|
||||||
while (!stream.atEnd())
|
while (!stream.atEnd())
|
||||||
|
|
|
@ -15,7 +15,7 @@ namespace Files { typedef std::vector<boost::filesystem::path> PathContainer;
|
||||||
|
|
||||||
class QFile;
|
class QFile;
|
||||||
|
|
||||||
namespace CsSettings {
|
namespace CSMSettings {
|
||||||
|
|
||||||
class UserSettings
|
class UserSettings
|
||||||
{
|
{
|
||||||
|
|
|
@ -257,7 +257,7 @@ QDockWidget *CSVDoc::View::getOperations() const
|
||||||
|
|
||||||
void CSVDoc::View::showUserSettings()
|
void CSVDoc::View::showUserSettings()
|
||||||
{
|
{
|
||||||
CsSettings::UserSettingsDialog *settingsDialog = new CsSettings::UserSettingsDialog(this);
|
CSVSettings::UserSettingsDialog *settingsDialog = new CSVSettings::UserSettingsDialog(this);
|
||||||
|
|
||||||
connect (settingsDialog, SIGNAL (signalUpdateEditorSetting (const QString &, const QString &)),
|
connect (settingsDialog, SIGNAL (signalUpdateEditorSetting (const QString &, const QString &)),
|
||||||
this, SLOT (slotUpdateEditorSetting (const QString &, const QString &)) );
|
this, SLOT (slotUpdateEditorSetting (const QString &, const QString &)) );
|
||||||
|
@ -271,11 +271,7 @@ void CSVDoc::View::slotUpdateEditorSetting(const QString &settingName, const QSt
|
||||||
|
|
||||||
if (lastValue != settingValue)
|
if (lastValue != settingValue)
|
||||||
{
|
{
|
||||||
if (settingName == "Undo Stack Size");
|
//evaluate settingName against tokens to determine which function to call to update Editor application.
|
||||||
|
|
||||||
if (settingName == "Top-Level Window Count");
|
|
||||||
|
|
||||||
if (settingName == "Reuse Subwindows");
|
|
||||||
|
|
||||||
lastValue = settingValue;
|
lastValue = settingValue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
#include "abstractblock.hpp"
|
#include "abstractblock.hpp"
|
||||||
|
|
||||||
CsSettings::AbstractBlock::AbstractBlock(QWidget* parent)
|
CSVSettings::AbstractBlock::AbstractBlock(QWidget* parent)
|
||||||
: QObject (parent), mBox ( new GroupBox (parent) ), mWidgetParent (parent)
|
: QObject (parent), mBox ( new GroupBox (parent) ), mWidgetParent (parent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CsSettings::AbstractBlock::AbstractBlock(bool isVisible, QWidget* parent)
|
CSVSettings::AbstractBlock::AbstractBlock(bool isVisible, QWidget* parent)
|
||||||
: QObject (parent), mBox ( new GroupBox (isVisible, parent)), mWidgetParent (parent)
|
: QObject (parent), mBox ( new GroupBox (isVisible, parent)), mWidgetParent (parent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
QLayout *CsSettings::AbstractBlock::createLayout (OcsWidgetOrientation direction, bool isZeroMargin, QWidget* parent)
|
QLayout *CSVSettings::AbstractBlock::createLayout (OcsWidgetOrientation direction,
|
||||||
|
bool isZeroMargin, QWidget* parent)
|
||||||
{
|
{
|
||||||
QLayout *layout = 0;
|
QLayout *layout = 0;
|
||||||
|
|
||||||
|
@ -23,12 +24,12 @@ QLayout *CsSettings::AbstractBlock::createLayout (OcsWidgetOrientation direction
|
||||||
return layout;
|
return layout;
|
||||||
}
|
}
|
||||||
|
|
||||||
QGroupBox *CsSettings::AbstractBlock::getGroupBox()
|
QGroupBox *CSVSettings::AbstractBlock::getGroupBox()
|
||||||
{
|
{
|
||||||
return mBox;
|
return mBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
CsSettings::AbstractWidget *CsSettings::AbstractBlock::buildWidget (const QString& widgetName, WidgetDef &def,
|
CSVSettings::AbstractWidget *CSVSettings::AbstractBlock::buildWidget (const QString& widgetName, WidgetDef &def,
|
||||||
QLayout *layout, bool isConnected) const
|
QLayout *layout, bool isConnected) const
|
||||||
{
|
{
|
||||||
AbstractWidget *widg = 0;
|
AbstractWidget *widg = 0;
|
||||||
|
@ -76,32 +77,32 @@ CsSettings::AbstractWidget *CsSettings::AbstractBlock::buildWidget (const QStrin
|
||||||
return widg;
|
return widg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::AbstractBlock::setVisible (bool isVisible)
|
void CSVSettings::AbstractBlock::setVisible (bool isVisible)
|
||||||
{
|
{
|
||||||
mBox->setBorderVisibility (isVisible);
|
mBox->setBorderVisibility (isVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CsSettings::AbstractBlock::isVisible () const
|
bool CSVSettings::AbstractBlock::isVisible () const
|
||||||
{
|
{
|
||||||
return mBox->borderVisibile();
|
return mBox->borderVisibile();
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *CsSettings::AbstractBlock::getParent() const
|
QWidget *CSVSettings::AbstractBlock::getParent() const
|
||||||
{
|
{
|
||||||
return mWidgetParent;
|
return mWidgetParent;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::AbstractBlock::slotUpdate (const QString &value)
|
void CSVSettings::AbstractBlock::slotUpdate (const QString &value)
|
||||||
{
|
{
|
||||||
slotUpdateSetting (objectName(), value);
|
slotUpdateSetting (objectName(), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::AbstractBlock::slotSetEnabled(bool value)
|
void CSVSettings::AbstractBlock::slotSetEnabled(bool value)
|
||||||
{
|
{
|
||||||
mBox->setEnabled(value);
|
mBox->setEnabled(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::AbstractBlock::slotUpdateSetting (const QString &settingName, const QString &settingValue)
|
void CSVSettings::AbstractBlock::slotUpdateSetting (const QString &settingName, const QString &settingValue)
|
||||||
{
|
{
|
||||||
bool doEmit = true;
|
bool doEmit = true;
|
||||||
updateBySignal (settingName, settingValue, doEmit);
|
updateBySignal (settingName, settingValue, doEmit);
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include "../../model/settings/settingsitem.hpp"
|
#include "../../model/settings/settingsitem.hpp"
|
||||||
#include "groupbox.hpp"
|
#include "groupbox.hpp"
|
||||||
|
|
||||||
namespace CsSettings
|
namespace CSVSettings
|
||||||
{
|
{
|
||||||
|
|
||||||
class AbstractBlock : public QObject
|
class AbstractBlock : public QObject
|
||||||
|
@ -17,7 +17,7 @@ namespace CsSettings
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
typedef QMap<QString, SettingsItem*> SettingsItemMap;
|
typedef QMap<QString, CSMSettings::SettingsItem*> SettingsItemMap;
|
||||||
GroupBox *mBox;
|
GroupBox *mBox;
|
||||||
QWidget *mWidgetParent;
|
QWidget *mWidgetParent;
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@ namespace CsSettings
|
||||||
void setVisible (bool isVisible);
|
void setVisible (bool isVisible);
|
||||||
bool isVisible() const;
|
bool isVisible() const;
|
||||||
|
|
||||||
virtual SettingList *getSettings() = 0;
|
virtual CSMSettings::SettingList *getSettings() = 0;
|
||||||
virtual bool updateSettings (const SettingMap &settings) = 0;
|
virtual bool updateSettings (const CSMSettings::SettingMap &settings) = 0;
|
||||||
virtual bool updateBySignal (const QString &name, const QString &value, bool &doEmit)
|
virtual bool updateBySignal (const QString &name, const QString &value, bool &doEmit)
|
||||||
{ return false; }
|
{ return false; }
|
||||||
|
|
||||||
|
|
|
@ -10,28 +10,28 @@
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QMargins>
|
#include <QMargins>
|
||||||
|
|
||||||
CsSettings::AbstractPage::AbstractPage(QWidget *parent):
|
CSVSettings::AbstractPage::AbstractPage(QWidget *parent):
|
||||||
QWidget(parent)
|
QWidget(parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CsSettings::AbstractPage::AbstractPage(const QString &pageName, QWidget *parent):
|
CSVSettings::AbstractPage::AbstractPage(const QString &pageName, QWidget *parent):
|
||||||
QWidget(parent)
|
QWidget(parent)
|
||||||
{
|
{
|
||||||
QWidget::setObjectName (pageName);
|
QWidget::setObjectName (pageName);
|
||||||
}
|
}
|
||||||
|
|
||||||
CsSettings::AbstractPage::~AbstractPage()
|
CSVSettings::AbstractPage::~AbstractPage()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CsSettings::SettingList *CsSettings::AbstractPage::getSettings()
|
CSMSettings::SettingList *CSVSettings::AbstractPage::getSettings()
|
||||||
{
|
{
|
||||||
SettingList *settings = new SettingList();
|
CSMSettings::SettingList *settings = new CSMSettings::SettingList();
|
||||||
|
|
||||||
foreach (AbstractBlock *block, mAbstractBlocks)
|
foreach (AbstractBlock *block, mAbstractBlocks)
|
||||||
{
|
{
|
||||||
SettingList *groupSettings = block->getSettings();
|
CSMSettings::SettingList *groupSettings = block->getSettings();
|
||||||
settings->append (*groupSettings);
|
settings->append (*groupSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,15 +10,13 @@
|
||||||
class SettingMap;
|
class SettingMap;
|
||||||
class SettingList;
|
class SettingList;
|
||||||
|
|
||||||
namespace CsSettings {
|
namespace CSVSettings {
|
||||||
|
|
||||||
typedef QList<AbstractBlock *> AbstractBlockList;
|
typedef QList<AbstractBlock *> AbstractBlockList;
|
||||||
|
|
||||||
class AbstractPage: public QWidget
|
class AbstractPage: public QWidget
|
||||||
{
|
{
|
||||||
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
AbstractBlockList mAbstractBlocks;
|
AbstractBlockList mAbstractBlocks;
|
||||||
|
@ -32,9 +30,9 @@ namespace CsSettings {
|
||||||
|
|
||||||
virtual void setupUi()=0;
|
virtual void setupUi()=0;
|
||||||
|
|
||||||
virtual void initializeWidgets (const SettingMap &settings) = 0;
|
virtual void initializeWidgets (const CSMSettings::SettingMap &settings) = 0;
|
||||||
|
|
||||||
SettingList *getSettings();
|
CSMSettings::SettingList *getSettings();
|
||||||
|
|
||||||
void setObjectName();
|
void setObjectName();
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
|
||||||
void CsSettings::AbstractWidget::build(QWidget *widget, WidgetDef &def, bool noLabel)
|
void CSVSettings::AbstractWidget::build(QWidget *widget, WidgetDef &def, bool noLabel)
|
||||||
{
|
{
|
||||||
if (!mLayout)
|
if (!mLayout)
|
||||||
createLayout(def.orientation, true);
|
createLayout(def.orientation, true);
|
||||||
|
@ -12,7 +12,7 @@ void CsSettings::AbstractWidget::build(QWidget *widget, WidgetDef &def, bool noL
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::AbstractWidget::buildLabelAndWidget (QWidget *widget, WidgetDef &def, bool noLabel)
|
void CSVSettings::AbstractWidget::buildLabelAndWidget (QWidget *widget, WidgetDef &def, bool noLabel)
|
||||||
{
|
{
|
||||||
if (def.widgetWidth > -1)
|
if (def.widgetWidth > -1)
|
||||||
widget->setFixedWidth (def.widgetWidth);
|
widget->setFixedWidth (def.widgetWidth);
|
||||||
|
@ -31,7 +31,7 @@ void CsSettings::AbstractWidget::buildLabelAndWidget (QWidget *widget, WidgetDef
|
||||||
mLayout->setAlignment (widget, getAlignment (def.widgetAlignment));
|
mLayout->setAlignment (widget, getAlignment (def.widgetAlignment));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::AbstractWidget::createLayout
|
void CSVSettings::AbstractWidget::createLayout
|
||||||
(OcsWidgetOrientation direction, bool isZeroMargin)
|
(OcsWidgetOrientation direction, bool isZeroMargin)
|
||||||
{
|
{
|
||||||
if (direction == OCS_VERTICAL)
|
if (direction == OCS_VERTICAL)
|
||||||
|
@ -43,36 +43,36 @@ void CsSettings::AbstractWidget::createLayout
|
||||||
mLayout->setContentsMargins(0, 0, 0, 0);
|
mLayout->setContentsMargins(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
QFlags<Qt::AlignmentFlag> CsSettings::AbstractWidget::getAlignment (CsSettings::OcsAlignment flag)
|
QFlags<Qt::AlignmentFlag> CSVSettings::AbstractWidget::getAlignment (CSVSettings::OcsAlignment flag)
|
||||||
{
|
{
|
||||||
return QFlags<Qt::AlignmentFlag>(static_cast<int>(flag));
|
return QFlags<Qt::AlignmentFlag>(static_cast<int>(flag));
|
||||||
}
|
}
|
||||||
|
|
||||||
QLayout *CsSettings::AbstractWidget::getLayout()
|
QLayout *CSVSettings::AbstractWidget::getLayout()
|
||||||
{
|
{
|
||||||
return mLayout;
|
return mLayout;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::AbstractWidget::slotUpdateWidget (const QString &value)
|
void CSVSettings::AbstractWidget::slotUpdateWidget (const QString &value)
|
||||||
{
|
{
|
||||||
updateWidget (value);
|
updateWidget (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::AbstractWidget::slotUpdateItem(const QString &value)
|
void CSVSettings::AbstractWidget::slotUpdateItem(const QString &value)
|
||||||
{
|
{
|
||||||
emit signalUpdateItem (value);
|
emit signalUpdateItem (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::AbstractWidget::slotUpdateItem(bool value)
|
void CSVSettings::AbstractWidget::slotUpdateItem(bool value)
|
||||||
{
|
{
|
||||||
if (value)
|
if (value)
|
||||||
emit signalUpdateItem (widget()->objectName());
|
emit signalUpdateItem (widget()->objectName());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::AbstractWidget::slotUpdateItem(int value)
|
void CSVSettings::AbstractWidget::slotUpdateItem(int value)
|
||||||
{
|
{
|
||||||
emit signalUpdateItem (QString::number(value));
|
emit signalUpdateItem (QString::number(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::AbstractWidget::slotUpdateItem (QListWidgetItem* current, QListWidgetItem* previous)
|
void CSVSettings::AbstractWidget::slotUpdateItem (QListWidgetItem* current, QListWidgetItem* previous)
|
||||||
{}
|
{}
|
||||||
|
|
|
@ -2,11 +2,11 @@
|
||||||
#define ABSTRACTWIDGET_HPP
|
#define ABSTRACTWIDGET_HPP
|
||||||
|
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include "../../model/settings/support.hpp"
|
#include "support.hpp"
|
||||||
|
|
||||||
class QLayout;
|
class QLayout;
|
||||||
|
|
||||||
namespace CsSettings
|
namespace CSVSettings
|
||||||
{
|
{
|
||||||
class AbstractWidget : public QObject
|
class AbstractWidget : public QObject
|
||||||
{
|
{
|
||||||
|
@ -35,12 +35,12 @@ namespace CsSettings
|
||||||
virtual void updateWidget (const QString &value) = 0;
|
virtual void updateWidget (const QString &value) = 0;
|
||||||
|
|
||||||
//converts user-defined enum to Qt equivalents
|
//converts user-defined enum to Qt equivalents
|
||||||
QFlags<Qt::AlignmentFlag> getAlignment (CsSettings::OcsAlignment flag);
|
QFlags<Qt::AlignmentFlag> getAlignment (OcsAlignment flag);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//widget initialization utilities
|
//widget initialization utilities
|
||||||
void createLayout (CsSettings::OcsWidgetOrientation direction, bool isZeroMargin);
|
void createLayout (OcsWidgetOrientation direction, bool isZeroMargin);
|
||||||
void buildLabelAndWidget (QWidget *widget, WidgetDef &def, bool noLabel);
|
void buildLabelAndWidget (QWidget *widget, WidgetDef &def, bool noLabel);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,19 +17,19 @@
|
||||||
#include "groupblock.hpp"
|
#include "groupblock.hpp"
|
||||||
#include "toggleblock.hpp"
|
#include "toggleblock.hpp"
|
||||||
|
|
||||||
CsSettings::BlankPage::BlankPage(QWidget *parent):
|
CSVSettings::BlankPage::BlankPage(QWidget *parent):
|
||||||
AbstractPage("Blank", parent)
|
AbstractPage("Blank", parent)
|
||||||
{
|
{
|
||||||
initPage();
|
initPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
CsSettings::BlankPage::BlankPage(const QString &title, QWidget *parent):
|
CSVSettings::BlankPage::BlankPage(const QString &title, QWidget *parent):
|
||||||
AbstractPage(title, parent)
|
AbstractPage(title, parent)
|
||||||
{
|
{
|
||||||
initPage();
|
initPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::BlankPage::initPage()
|
void CSVSettings::BlankPage::initPage()
|
||||||
{
|
{
|
||||||
// Hacks to get the stylesheet look properly
|
// Hacks to get the stylesheet look properly
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
|
@ -40,7 +40,7 @@ void CsSettings::BlankPage::initPage()
|
||||||
setupUi();
|
setupUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::BlankPage::setupUi()
|
void CSVSettings::BlankPage::setupUi()
|
||||||
{
|
{
|
||||||
QGroupBox *pageBox = new QGroupBox(this);
|
QGroupBox *pageBox = new QGroupBox(this);
|
||||||
QLayout* pageLayout = new QVBoxLayout();
|
QLayout* pageLayout = new QVBoxLayout();
|
||||||
|
@ -49,7 +49,7 @@ void CsSettings::BlankPage::setupUi()
|
||||||
pageLayout->addWidget(pageBox);
|
pageLayout->addWidget(pageBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::BlankPage::initializeWidgets (const SettingMap &settings)
|
void CSVSettings::BlankPage::initializeWidgets (const CSMSettings::SettingMap &settings)
|
||||||
{
|
{
|
||||||
//iterate each item in each blocks in this section
|
//iterate each item in each blocks in this section
|
||||||
//validate the corresponding setting against the defined valuelist if any.
|
//validate the corresponding setting against the defined valuelist if any.
|
||||||
|
|
|
@ -5,14 +5,13 @@
|
||||||
|
|
||||||
class QGroupBox;
|
class QGroupBox;
|
||||||
|
|
||||||
namespace CsSettings {
|
namespace CSVSettings {
|
||||||
|
|
||||||
class UserSettings;
|
class UserSettings;
|
||||||
class AbstractBlock;
|
class AbstractBlock;
|
||||||
|
|
||||||
class BlankPage : public AbstractPage
|
class BlankPage : public AbstractPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -20,7 +19,7 @@ namespace CsSettings {
|
||||||
BlankPage (const QString &title, QWidget *parent);
|
BlankPage (const QString &title, QWidget *parent);
|
||||||
|
|
||||||
void setupUi();
|
void setupUi();
|
||||||
void initializeWidgets (const SettingMap &settings);
|
void initializeWidgets (const CSMSettings::SettingMap &settings);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void initPage();
|
void initPage();
|
||||||
|
|
|
@ -3,11 +3,11 @@
|
||||||
#include "itemblock.hpp"
|
#include "itemblock.hpp"
|
||||||
#include "proxyblock.hpp"
|
#include "proxyblock.hpp"
|
||||||
|
|
||||||
CsSettings::CustomBlock::CustomBlock (QWidget *parent) : AbstractBlock (parent)
|
CSVSettings::CustomBlock::CustomBlock (QWidget *parent) : AbstractBlock (parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int CsSettings::CustomBlock::build(GroupBlockDefList &defList, GroupBlockDefList::iterator *it)
|
int CSVSettings::CustomBlock::build(GroupBlockDefList &defList, GroupBlockDefList::iterator *it)
|
||||||
{
|
{
|
||||||
int retVal = 0;
|
int retVal = 0;
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ int CsSettings::CustomBlock::build(GroupBlockDefList &defList, GroupBlockDefList
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
CsSettings::GroupBox *CsSettings::CustomBlock::buildGroupBox (CsSettings::OcsWidgetOrientation orientation)
|
CSVSettings::GroupBox *CSVSettings::CustomBlock::buildGroupBox (OcsWidgetOrientation orientation)
|
||||||
{
|
{
|
||||||
GroupBox *box = new GroupBox (false, mBox);
|
GroupBox *box = new GroupBox (false, mBox);
|
||||||
QLayout *layout = createLayout (orientation, true, box);
|
QLayout *layout = createLayout (orientation, true, box);
|
||||||
|
@ -45,7 +45,7 @@ CsSettings::GroupBox *CsSettings::CustomBlock::buildGroupBox (CsSettings::OcsWid
|
||||||
return box;
|
return box;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CsSettings::CustomBlock::buildGroupBlock(GroupBlockDef &def)
|
int CSVSettings::CustomBlock::buildGroupBlock(GroupBlockDef &def)
|
||||||
{
|
{
|
||||||
GroupBlock *block = new GroupBlock (getParent());
|
GroupBlock *block = new GroupBlock (getParent());
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ int CsSettings::CustomBlock::buildGroupBlock(GroupBlockDef &def)
|
||||||
return block->build(def);
|
return block->build(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CsSettings::CustomBlock::buildProxyBlock(GroupBlockDef& def, ProxyBlock *block)
|
int CSVSettings::CustomBlock::buildProxyBlock(GroupBlockDef& def, ProxyBlock *block)
|
||||||
{
|
{
|
||||||
if (def.properties.size() != 1)
|
if (def.properties.size() != 1)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -91,13 +91,13 @@ int CsSettings::CustomBlock::buildProxyBlock(GroupBlockDef& def, ProxyBlock *blo
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CsSettings::SettingList *CsSettings::CustomBlock::getSettings()
|
CSMSettings::SettingList *CSVSettings::CustomBlock::getSettings()
|
||||||
{
|
{
|
||||||
SettingList *settings = new SettingList();
|
CSMSettings::SettingList *settings = new CSMSettings::SettingList();
|
||||||
|
|
||||||
foreach (GroupBlock *block, mGroupList)
|
foreach (GroupBlock *block, mGroupList)
|
||||||
{
|
{
|
||||||
SettingList *groupSettings = block->getSettings();
|
CSMSettings::SettingList *groupSettings = block->getSettings();
|
||||||
|
|
||||||
if (groupSettings)
|
if (groupSettings)
|
||||||
settings->append(*groupSettings);
|
settings->append(*groupSettings);
|
||||||
|
@ -106,7 +106,7 @@ CsSettings::SettingList *CsSettings::CustomBlock::getSettings()
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CsSettings::CustomBlock::updateSettings (const SettingMap &settings)
|
bool CSVSettings::CustomBlock::updateSettings (const CSMSettings::SettingMap &settings)
|
||||||
{
|
{
|
||||||
bool success = true;
|
bool success = true;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "abstractblock.hpp"
|
#include "abstractblock.hpp"
|
||||||
|
|
||||||
namespace CsSettings
|
namespace CSVSettings
|
||||||
{
|
{
|
||||||
|
|
||||||
class ProxyBlock;
|
class ProxyBlock;
|
||||||
|
@ -19,8 +19,8 @@ namespace CsSettings
|
||||||
|
|
||||||
explicit CustomBlock (QWidget *parent = 0);
|
explicit CustomBlock (QWidget *parent = 0);
|
||||||
|
|
||||||
bool updateSettings (const SettingMap &settings);
|
bool updateSettings (const CSMSettings::SettingMap &settings);
|
||||||
SettingList *getSettings();
|
CSMSettings::SettingList *getSettings();
|
||||||
int build (GroupBlockDefList &defList, GroupBlockDefList::Iterator *it = 0);
|
int build (GroupBlockDefList &defList, GroupBlockDefList::Iterator *it = 0);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "groupblock.hpp"
|
#include "groupblock.hpp"
|
||||||
#include "toggleblock.hpp"
|
#include "toggleblock.hpp"
|
||||||
|
|
||||||
CsSettings::EditorPage::EditorPage(QWidget *parent):
|
CSVSettings::EditorPage::EditorPage(QWidget *parent):
|
||||||
AbstractPage("Editor", parent)
|
AbstractPage("Editor", parent)
|
||||||
{
|
{
|
||||||
// Hacks to get the stylesheet look properly
|
// Hacks to get the stylesheet look properly
|
||||||
|
@ -29,7 +29,7 @@ CsSettings::EditorPage::EditorPage(QWidget *parent):
|
||||||
setupUi();
|
setupUi();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::EditorPage::setupUi()
|
void CSVSettings::EditorPage::setupUi()
|
||||||
{
|
{
|
||||||
GroupBlockDef undoStack (QString("Undo Stack Size"));
|
GroupBlockDef undoStack (QString("Undo Stack Size"));
|
||||||
GroupBlockDef topLevelWindowCount (QString("Maximum Top-Level Window Count"));
|
GroupBlockDef topLevelWindowCount (QString("Maximum Top-Level Window Count"));
|
||||||
|
@ -153,7 +153,7 @@ void CsSettings::EditorPage::setupUi()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::EditorPage::initializeWidgets (const SettingMap &settings)
|
void CSVSettings::EditorPage::initializeWidgets (const CSMSettings::SettingMap &settings)
|
||||||
{
|
{
|
||||||
//iterate each item in each blocks in this section
|
//iterate each item in each blocks in this section
|
||||||
//validate the corresponding setting against the defined valuelist if any.
|
//validate the corresponding setting against the defined valuelist if any.
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
class QGroupBox;
|
class QGroupBox;
|
||||||
|
|
||||||
namespace CsSettings {
|
namespace CSVSettings {
|
||||||
|
|
||||||
class UserSettings;
|
class UserSettings;
|
||||||
class AbstractBlock;
|
class AbstractBlock;
|
||||||
|
@ -19,7 +19,7 @@ namespace CsSettings {
|
||||||
EditorPage(QWidget *parent = 0);
|
EditorPage(QWidget *parent = 0);
|
||||||
|
|
||||||
void setupUi();
|
void setupUi();
|
||||||
void initializeWidgets (const SettingMap &settings);
|
void initializeWidgets (const CSMSettings::SettingMap &settings);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void signalUpdateEditorSetting (const QString &settingName, const QString &settingValue);
|
void signalUpdateEditorSetting (const QString &settingName, const QString &settingValue);
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
#include "groupblock.hpp"
|
#include "groupblock.hpp"
|
||||||
#include "itemblock.hpp"
|
#include "itemblock.hpp"
|
||||||
|
|
||||||
CsSettings::GroupBlock::GroupBlock (QWidget* parent)
|
CSVSettings::GroupBlock::GroupBlock (QWidget* parent)
|
||||||
: AbstractBlock (parent)
|
: AbstractBlock (parent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
CsSettings::GroupBlock::GroupBlock (bool isVisible, QWidget *parent)
|
CSVSettings::GroupBlock::GroupBlock (bool isVisible, QWidget *parent)
|
||||||
: AbstractBlock (isVisible, parent)
|
: AbstractBlock (isVisible, parent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
int CsSettings::GroupBlock::build (GroupBlockDef &def)
|
int CSVSettings::GroupBlock::build (GroupBlockDef &def)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (def.properties.size() == 0)
|
if (def.properties.size() == 0)
|
||||||
|
@ -44,14 +44,14 @@ int CsSettings::GroupBlock::build (GroupBlockDef &def)
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
CsSettings::SettingList *CsSettings::GroupBlock::getSettings()
|
CSMSettings::SettingList *CSVSettings::GroupBlock::getSettings()
|
||||||
{
|
{
|
||||||
SettingList *settings = 0;
|
CSMSettings::SettingList *settings = 0;
|
||||||
|
|
||||||
foreach (ItemBlock *block, mItemBlockList)
|
foreach (ItemBlock *block, mItemBlockList)
|
||||||
{
|
{
|
||||||
if (!settings)
|
if (!settings)
|
||||||
settings = new SettingList();
|
settings = new CSMSettings::SettingList();
|
||||||
|
|
||||||
settings->append(*(block->getSettings ()));
|
settings->append(*(block->getSettings ()));
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ CsSettings::SettingList *CsSettings::GroupBlock::getSettings()
|
||||||
return settings;
|
return settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
CsSettings::ItemBlock *CsSettings::GroupBlock::getItemBlock (const QString &name, ItemBlockList *blockList)
|
CSVSettings::ItemBlock *CSVSettings::GroupBlock::getItemBlock (const QString &name, ItemBlockList *blockList)
|
||||||
{
|
{
|
||||||
ItemBlock *retBlock = 0;
|
ItemBlock *retBlock = 0;
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ CsSettings::ItemBlock *CsSettings::GroupBlock::getItemBlock (const QString &name
|
||||||
return retBlock;
|
return retBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
CsSettings::ItemBlock *CsSettings::GroupBlock::getItemBlock (int index)
|
CSVSettings::ItemBlock *CSVSettings::GroupBlock::getItemBlock (int index)
|
||||||
{
|
{
|
||||||
ItemBlock *retBlock = 0;
|
ItemBlock *retBlock = 0;
|
||||||
|
|
||||||
|
@ -88,14 +88,14 @@ CsSettings::ItemBlock *CsSettings::GroupBlock::getItemBlock (int index)
|
||||||
return retBlock;
|
return retBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CsSettings::GroupBlock::updateSettings (const SettingMap &settings)
|
bool CSVSettings::GroupBlock::updateSettings (const CSMSettings::SettingMap &settings)
|
||||||
{
|
{
|
||||||
bool success = true;
|
bool success = true;
|
||||||
|
|
||||||
//update all non-proxy settings
|
//update all non-proxy settings
|
||||||
foreach (ItemBlock *block, mItemBlockList)
|
foreach (ItemBlock *block, mItemBlockList)
|
||||||
{
|
{
|
||||||
SettingContainer *setting = settings[block->objectName()];
|
CSMSettings::SettingContainer *setting = settings[block->objectName()];
|
||||||
|
|
||||||
if (setting)
|
if (setting)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include "abstractblock.hpp"
|
#include "abstractblock.hpp"
|
||||||
|
|
||||||
namespace CsSettings
|
namespace CSVSettings
|
||||||
{
|
{
|
||||||
class ItemBlock;
|
class ItemBlock;
|
||||||
|
|
||||||
|
@ -18,9 +18,9 @@ namespace CsSettings
|
||||||
|
|
||||||
int build (GroupBlockDef &def);
|
int build (GroupBlockDef &def);
|
||||||
|
|
||||||
bool updateSettings (const SettingMap &settings);
|
bool updateSettings (const CSMSettings::SettingMap &settings);
|
||||||
|
|
||||||
SettingList *getSettings();
|
CSMSettings::SettingList *getSettings();
|
||||||
ItemBlock *getItemBlock (const QString &name, ItemBlockList *blockList = 0);
|
ItemBlock *getItemBlock (const QString &name, ItemBlockList *blockList = 0);
|
||||||
ItemBlock *getItemBlock (int index);
|
ItemBlock *getItemBlock (int index);
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
#include "groupbox.hpp"
|
#include "groupbox.hpp"
|
||||||
|
|
||||||
const QString CsSettings::GroupBox::INVISIBLE_BOX_STYLE =
|
const QString CSVSettings::GroupBox::INVISIBLE_BOX_STYLE =
|
||||||
QString::fromUtf8("QGroupBox { border: 0px; padding 0px; margin: 0px;}");
|
QString::fromUtf8("QGroupBox { border: 0px; padding 0px; margin: 0px;}");
|
||||||
|
|
||||||
CsSettings::GroupBox::GroupBox(QWidget *parent) :
|
CSVSettings::GroupBox::GroupBox(QWidget *parent) :
|
||||||
QGroupBox (parent)
|
QGroupBox (parent)
|
||||||
{
|
{
|
||||||
initBox();
|
initBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
CsSettings::GroupBox::GroupBox (bool isVisible, QWidget *parent) :
|
CSVSettings::GroupBox::GroupBox (bool isVisible, QWidget *parent) :
|
||||||
QGroupBox (parent)
|
QGroupBox (parent)
|
||||||
{
|
{
|
||||||
initBox(isVisible);
|
initBox(isVisible);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::GroupBox::initBox(bool isVisible)
|
void CSVSettings::GroupBox::initBox(bool isVisible)
|
||||||
{
|
{
|
||||||
setFlat (true);
|
setFlat (true);
|
||||||
VISIBLE_BOX_STYLE = styleSheet();
|
VISIBLE_BOX_STYLE = styleSheet();
|
||||||
|
@ -24,12 +24,12 @@ void CsSettings::GroupBox::initBox(bool isVisible)
|
||||||
setStyleSheet (INVISIBLE_BOX_STYLE);
|
setStyleSheet (INVISIBLE_BOX_STYLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CsSettings::GroupBox::borderVisibile() const
|
bool CSVSettings::GroupBox::borderVisibile() const
|
||||||
{
|
{
|
||||||
return (styleSheet() != INVISIBLE_BOX_STYLE);
|
return (styleSheet() != INVISIBLE_BOX_STYLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::GroupBox::setTitle (const QString &title)
|
void CSVSettings::GroupBox::setTitle (const QString &title)
|
||||||
{
|
{
|
||||||
if (borderVisibile() )
|
if (borderVisibile() )
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,7 @@ void CsSettings::GroupBox::setTitle (const QString &title)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::GroupBox::setBorderVisibility (bool value)
|
void CSVSettings::GroupBox::setBorderVisibility (bool value)
|
||||||
{
|
{
|
||||||
if (value)
|
if (value)
|
||||||
setStyleSheet(VISIBLE_BOX_STYLE);
|
setStyleSheet(VISIBLE_BOX_STYLE);
|
||||||
|
@ -46,7 +46,7 @@ void CsSettings::GroupBox::setBorderVisibility (bool value)
|
||||||
setStyleSheet(INVISIBLE_BOX_STYLE);
|
setStyleSheet(INVISIBLE_BOX_STYLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::GroupBox::setMinimumWidth()
|
void CSVSettings::GroupBox::setMinimumWidth()
|
||||||
{
|
{
|
||||||
//set minimum width to accommodate title, if needed
|
//set minimum width to accommodate title, if needed
|
||||||
//1.5 multiplier to account for bold title.
|
//1.5 multiplier to account for bold title.
|
||||||
|
|
|
@ -3,12 +3,10 @@
|
||||||
|
|
||||||
#include <QGroupBox>
|
#include <QGroupBox>
|
||||||
|
|
||||||
namespace CsSettings
|
namespace CSVSettings
|
||||||
{
|
{
|
||||||
class GroupBox : public QGroupBox
|
class GroupBox : public QGroupBox
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
static const QString INVISIBLE_BOX_STYLE;
|
static const QString INVISIBLE_BOX_STYLE;
|
||||||
QString VISIBLE_BOX_STYLE; //not a const...
|
QString VISIBLE_BOX_STYLE; //not a const...
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,12 @@
|
||||||
|
|
||||||
#include <QFontMetrics>
|
#include <QFontMetrics>
|
||||||
|
|
||||||
CsSettings::ItemBlock::ItemBlock (QWidget* parent)
|
CSVSettings::ItemBlock::ItemBlock (QWidget* parent)
|
||||||
: mSetting (0), AbstractBlock (false, parent)
|
: mSetting (0), AbstractBlock (false, parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
int CsSettings::ItemBlock::build(SettingsItemDef &iDef)
|
int CSVSettings::ItemBlock::build(SettingsItemDef &iDef)
|
||||||
{
|
{
|
||||||
buildItemBlock (iDef);
|
buildItemBlock (iDef);
|
||||||
buildItemBlockWidgets (iDef);
|
buildItemBlockWidgets (iDef);
|
||||||
|
@ -15,7 +15,7 @@ int CsSettings::ItemBlock::build(SettingsItemDef &iDef)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::ItemBlock::buildItemBlockWidgets (SettingsItemDef &iDef)
|
void CSVSettings::ItemBlock::buildItemBlockWidgets (SettingsItemDef &iDef)
|
||||||
{
|
{
|
||||||
WidgetDef wDef = iDef.widget;
|
WidgetDef wDef = iDef.widget;
|
||||||
QLayout *blockLayout = 0;
|
QLayout *blockLayout = 0;
|
||||||
|
@ -56,13 +56,13 @@ void CsSettings::ItemBlock::buildItemBlockWidgets (SettingsItemDef &iDef)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::ItemBlock::buildItemBlock (SettingsItemDef &iDef)
|
void CSVSettings::ItemBlock::buildItemBlock (SettingsItemDef &iDef)
|
||||||
{
|
{
|
||||||
QString defaultValue = iDef.defaultValue;
|
QString defaultValue = iDef.defaultValue;
|
||||||
|
|
||||||
setObjectName(iDef.name);
|
setObjectName(iDef.name);
|
||||||
|
|
||||||
mSetting = new SettingsItem (objectName(),
|
mSetting = new CSMSettings::SettingsItem (objectName(),
|
||||||
iDef.hasMultipleValues, iDef.defaultValue,
|
iDef.hasMultipleValues, iDef.defaultValue,
|
||||||
parent());
|
parent());
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ void CsSettings::ItemBlock::buildItemBlock (SettingsItemDef &iDef)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CsSettings::ItemBlock::update (const QString &value)
|
bool CSVSettings::ItemBlock::update (const QString &value)
|
||||||
{
|
{
|
||||||
bool success = updateItem (value);
|
bool success = updateItem (value);
|
||||||
|
|
||||||
|
@ -85,13 +85,13 @@ bool CsSettings::ItemBlock::update (const QString &value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CsSettings::ItemBlock::updateItem (const QString &value)
|
bool CSVSettings::ItemBlock::updateItem (const QString &value)
|
||||||
{
|
{
|
||||||
return mSetting->updateItem(value);
|
return mSetting->updateItem(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool CsSettings::ItemBlock::updateBySignal(const QString &name, const QString &value, bool &doEmit)
|
bool CSVSettings::ItemBlock::updateBySignal(const QString &name, const QString &value, bool &doEmit)
|
||||||
{
|
{
|
||||||
bool success = (mSetting->getValue() != value);
|
bool success = (mSetting->getValue() != value);
|
||||||
|
|
||||||
|
@ -101,15 +101,15 @@ bool CsSettings::ItemBlock::updateBySignal(const QString &name, const QString &v
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
CsSettings::SettingList *CsSettings::ItemBlock::getSettings ()
|
CSMSettings::SettingList *CSVSettings::ItemBlock::getSettings ()
|
||||||
{
|
{
|
||||||
SettingList *list = new SettingList();
|
CSMSettings::SettingList *list = new CSMSettings::SettingList();
|
||||||
list->push_back(mSetting);
|
list->push_back(mSetting);
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CsSettings::ItemBlock::getValue() const
|
QString CSVSettings::ItemBlock::getValue() const
|
||||||
{
|
{
|
||||||
return mSetting->getValue();
|
return mSetting->getValue();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,21 +3,21 @@
|
||||||
|
|
||||||
#include "abstractblock.hpp"
|
#include "abstractblock.hpp"
|
||||||
|
|
||||||
namespace CsSettings
|
namespace CSVSettings
|
||||||
{
|
{
|
||||||
|
|
||||||
class ItemBlock : public AbstractBlock
|
class ItemBlock : public AbstractBlock
|
||||||
{
|
{
|
||||||
SettingsItem *mSetting;
|
CSMSettings::SettingsItem *mSetting;
|
||||||
WidgetList mWidgetList;
|
WidgetList mWidgetList;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
ItemBlock (QWidget* parent = 0);
|
ItemBlock (QWidget* parent = 0);
|
||||||
|
|
||||||
bool updateSettings (const SettingMap &settings) { return false; }
|
bool updateSettings (const CSMSettings::SettingMap &settings) { return false; }
|
||||||
|
|
||||||
SettingList *getSettings ();
|
CSMSettings::SettingList *getSettings ();
|
||||||
QString getValue () const;
|
QString getValue () const;
|
||||||
|
|
||||||
int getSettingCount();
|
int getSettingCount();
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#include "proxyblock.hpp"
|
#include "proxyblock.hpp"
|
||||||
#include "itemblock.hpp"
|
#include "itemblock.hpp"
|
||||||
|
|
||||||
CsSettings::ProxyBlock::ProxyBlock (QWidget *parent)
|
CSVSettings::ProxyBlock::ProxyBlock (QWidget *parent)
|
||||||
: GroupBlock (parent)
|
: GroupBlock (parent)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
int CsSettings::ProxyBlock::build (GroupBlockDef &proxyDef)
|
int CSVSettings::ProxyBlock::build (GroupBlockDef &proxyDef)
|
||||||
{
|
{
|
||||||
//get the list of pre-defined values for the proxy
|
//get the list of pre-defined values for the proxy
|
||||||
mValueList = proxyDef.properties.at(0)->valueList;
|
mValueList = proxyDef.properties.at(0)->valueList;
|
||||||
|
@ -19,7 +19,7 @@ int CsSettings::ProxyBlock::build (GroupBlockDef &proxyDef)
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::ProxyBlock::addSetting (ItemBlock *settingBlock, QStringList *proxyList)
|
void CSVSettings::ProxyBlock::addSetting (ItemBlock *settingBlock, QStringList *proxyList)
|
||||||
{
|
{
|
||||||
//connect the item block of the proxied seting to the generic update slot
|
//connect the item block of the proxied seting to the generic update slot
|
||||||
connect (settingBlock, SIGNAL (signalUpdateSetting(const QString &, const QString &)),
|
connect (settingBlock, SIGNAL (signalUpdateSetting(const QString &, const QString &)),
|
||||||
|
@ -29,23 +29,23 @@ void CsSettings::ProxyBlock::addSetting (ItemBlock *settingBlock, QStringList *p
|
||||||
mProxyList << proxyList;
|
mProxyList << proxyList;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CsSettings::ProxyBlock::updateSettings (const SettingMap &settings)
|
bool CSVSettings::ProxyBlock::updateSettings (const CSMSettings::SettingMap &settings)
|
||||||
{
|
{
|
||||||
return updateByProxiedSettings(&settings);
|
return updateByProxiedSettings(&settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CsSettings::ProxyBlock::updateBySignal(const QString &name, const QString &value, bool &doEmit)
|
bool CSVSettings::ProxyBlock::updateBySignal(const QString &name, const QString &value, bool &doEmit)
|
||||||
{
|
{
|
||||||
doEmit = false;
|
doEmit = false;
|
||||||
return updateProxiedSettings();
|
return updateProxiedSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::ProxyBlock::slotUpdateProxySetting (const QString &name, const QString &value)
|
void CSVSettings::ProxyBlock::slotUpdateProxySetting (const QString &name, const QString &value)
|
||||||
{
|
{
|
||||||
updateByProxiedSettings();
|
updateByProxiedSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CsSettings::ProxyBlock::updateProxiedSettings()
|
bool CSVSettings::ProxyBlock::updateProxiedSettings()
|
||||||
{
|
{
|
||||||
foreach (ItemBlock *block, mProxiedItemBlockList)
|
foreach (ItemBlock *block, mProxiedItemBlockList)
|
||||||
{
|
{
|
||||||
|
@ -74,7 +74,7 @@ bool CsSettings::ProxyBlock::updateProxiedSettings()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CsSettings::ProxyBlock::updateByProxiedSettings(const SettingMap *settings)
|
bool CSVSettings::ProxyBlock::updateByProxiedSettings(const CSMSettings::SettingMap *settings)
|
||||||
{
|
{
|
||||||
bool success = false;
|
bool success = false;
|
||||||
int commonIndex = -1;
|
int commonIndex = -1;
|
||||||
|
@ -143,7 +143,7 @@ bool CsSettings::ProxyBlock::updateByProxiedSettings(const SettingMap *settings)
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
CsSettings::ItemBlock *CsSettings::ProxyBlock::getProxiedItemBlock (const QString &name)
|
CSVSettings::ItemBlock *CSVSettings::ProxyBlock::getProxiedItemBlock (const QString &name)
|
||||||
{
|
{
|
||||||
return getItemBlock (name, &mProxiedItemBlockList);
|
return getItemBlock (name, &mProxiedItemBlockList);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "groupblock.hpp"
|
#include "groupblock.hpp"
|
||||||
|
|
||||||
namespace CsSettings
|
namespace CSVSettings
|
||||||
{
|
{
|
||||||
class ProxyBlock : public GroupBlock
|
class ProxyBlock : public GroupBlock
|
||||||
{
|
{
|
||||||
|
@ -23,14 +23,14 @@ namespace CsSettings
|
||||||
void addSetting (ItemBlock* settingBlock, QStringList *proxyList);
|
void addSetting (ItemBlock* settingBlock, QStringList *proxyList);
|
||||||
int build (GroupBlockDef &def);
|
int build (GroupBlockDef &def);
|
||||||
|
|
||||||
SettingList *getSettings() { return 0; }
|
CSMSettings::SettingList *getSettings() { return 0; }
|
||||||
bool updateSettings (const SettingMap &settings);
|
bool updateSettings (const CSMSettings::SettingMap &settings);
|
||||||
bool updateBySignal (const QString &name, const QString &value, bool &doEmit);
|
bool updateBySignal (const QString &name, const QString &value, bool &doEmit);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
ItemBlock *getProxiedItemBlock (const QString &name);
|
ItemBlock *getProxiedItemBlock (const QString &name);
|
||||||
bool updateByProxiedSettings(const SettingMap *settings = 0);
|
bool updateByProxiedSettings(const CSMSettings::SettingMap *settings = 0);
|
||||||
bool updateProxiedSettings();
|
bool updateProxiedSettings();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
#include "abstractwidget.hpp"
|
#include "abstractwidget.hpp"
|
||||||
|
|
||||||
namespace CsSettings
|
namespace CSVSettings
|
||||||
{
|
{
|
||||||
//VALID FOR RADIOBUTTON / CHECKBOX (or other toggle widget with it's own label)
|
//VALID FOR RADIOBUTTON / CHECKBOX (or other toggle widget with it's own label)
|
||||||
template <typename T1>
|
template <typename T1>
|
||||||
|
@ -25,7 +25,7 @@ namespace CsSettings
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit SettingWidget(WidgetDef &def, QLayout *layout, QWidget* parent = 0)
|
explicit SettingWidget (WidgetDef &def, QLayout *layout, QWidget* parent = 0)
|
||||||
: AbstractWidget (layout, parent), mWidget (new T1 (parent))
|
: AbstractWidget (layout, parent), mWidget (new T1 (parent))
|
||||||
{
|
{
|
||||||
mWidget->setText(def.caption);
|
mWidget->setText(def.caption);
|
||||||
|
@ -55,7 +55,7 @@ namespace CsSettings
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
SettingWidget(WidgetDef &def, QLayout *layout, QWidget *parent = 0)
|
SettingWidget (WidgetDef &def, QLayout *layout, QWidget *parent = 0)
|
||||||
: AbstractWidget (layout, parent), mWidget (new QSpinBox (parent))
|
: AbstractWidget (layout, parent), mWidget (new QSpinBox (parent))
|
||||||
{
|
{
|
||||||
def.caption += tr(" (%1 to %2)").arg(def.minMax->left).arg(def.minMax->right);
|
def.caption += tr(" (%1 to %2)").arg(def.minMax->left).arg(def.minMax->right);
|
||||||
|
@ -91,7 +91,7 @@ namespace CsSettings
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
class SettingWidget <QComboBox>: public CsSettings::AbstractWidget
|
class SettingWidget <QComboBox>: public CSVSettings::AbstractWidget
|
||||||
{
|
{
|
||||||
|
|
||||||
QComboBox *mWidget;
|
QComboBox *mWidget;
|
||||||
|
@ -143,7 +143,7 @@ namespace CsSettings
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
class SettingWidget <QLineEdit>: public CsSettings::AbstractWidget
|
class SettingWidget <QLineEdit>: public CSVSettings::AbstractWidget
|
||||||
{
|
{
|
||||||
|
|
||||||
QLineEdit *mWidget;
|
QLineEdit *mWidget;
|
||||||
|
@ -176,7 +176,7 @@ namespace CsSettings
|
||||||
};
|
};
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
class SettingWidget <QListWidget>: public CsSettings::AbstractWidget
|
class SettingWidget <QListWidget>: public CSVSettings::AbstractWidget
|
||||||
{
|
{
|
||||||
|
|
||||||
QListWidget *mWidget;
|
QListWidget *mWidget;
|
||||||
|
|
1
apps/opencs/view/settings/support.cpp
Normal file
1
apps/opencs/view/settings/support.cpp
Normal file
|
@ -0,0 +1 @@
|
||||||
|
#include "support.hpp"
|
144
apps/opencs/view/settings/support.hpp
Normal file
144
apps/opencs/view/settings/support.hpp
Normal file
|
@ -0,0 +1,144 @@
|
||||||
|
#ifndef VIEW_SUPPORT_HPP
|
||||||
|
#define VIEW_SUPPORT_HPP
|
||||||
|
|
||||||
|
#include <QList>
|
||||||
|
#include <QStringList>
|
||||||
|
|
||||||
|
#include "../../model/settings/support.hpp"
|
||||||
|
|
||||||
|
namespace CSVSettings
|
||||||
|
{
|
||||||
|
struct WidgetDef;
|
||||||
|
class ItemBlock;
|
||||||
|
class GroupBlock;
|
||||||
|
struct GroupBlockDef;
|
||||||
|
|
||||||
|
typedef QList<GroupBlockDef *> GroupBlockDefList;
|
||||||
|
typedef QList<GroupBlock *> GroupBlockList;
|
||||||
|
typedef QList<ItemBlock *> ItemBlockList;
|
||||||
|
typedef QList<QStringList *> ProxyList;
|
||||||
|
typedef QList<WidgetDef *> WidgetList;
|
||||||
|
typedef QMap<QString, ItemBlock *> ItemBlockMap;
|
||||||
|
|
||||||
|
enum OcsWidgetOrientation
|
||||||
|
{
|
||||||
|
OCS_HORIZONTAL,
|
||||||
|
OCS_VERTICAL
|
||||||
|
};
|
||||||
|
|
||||||
|
enum OcsWidgetType
|
||||||
|
{
|
||||||
|
OCS_CHECK_WIDGET,
|
||||||
|
OCS_COMBO_WIDGET,
|
||||||
|
OCS_TEXT_WIDGET,
|
||||||
|
OCS_LIST_WIDGET,
|
||||||
|
OCS_RADIO_WIDGET,
|
||||||
|
OCS_SPIN_WIDGET,
|
||||||
|
OCS_UNDEFINED_WIDGET
|
||||||
|
};
|
||||||
|
|
||||||
|
enum OcsAlignment
|
||||||
|
{
|
||||||
|
OCS_LEFT = Qt::AlignLeft,
|
||||||
|
OCS_CENTER = Qt::AlignHCenter,
|
||||||
|
OCS_RIGHT = Qt::AlignRight
|
||||||
|
};
|
||||||
|
|
||||||
|
//template for defining the widget of a property.
|
||||||
|
struct WidgetDef
|
||||||
|
{
|
||||||
|
OcsWidgetType type; //type of widget providing input
|
||||||
|
int labelWidth; //width of caption label
|
||||||
|
int widgetWidth; //width of input widget
|
||||||
|
OcsWidgetOrientation orientation; //label / widget orientation (horizontal / vertical)
|
||||||
|
QString inputMask; //input mask (line edit)
|
||||||
|
QString caption; //label caption. Leave empty for multiple items. See BlockDef::captionList
|
||||||
|
QString value; //widget value. Leave empty for multiple items. See BlockDef::valueList
|
||||||
|
CSMSettings::QStringPair *minMax; //Min/Max QString value pair. If empty, assigned to property item value pair.
|
||||||
|
QStringList *valueList; //value list for list widgets. If left empty, is assigned to property item value list during block build().
|
||||||
|
bool isDefault; //isDefault - determined at runtime.
|
||||||
|
OcsAlignment valueAlignment; //left / center / right-justify text in widget
|
||||||
|
OcsAlignment widgetAlignment; //left / center / right-justify widget in group box
|
||||||
|
|
||||||
|
|
||||||
|
WidgetDef() : labelWidth (-1), widgetWidth (-1),
|
||||||
|
orientation (OCS_HORIZONTAL),
|
||||||
|
isDefault (true), valueAlignment (OCS_CENTER),
|
||||||
|
widgetAlignment (OCS_RIGHT),
|
||||||
|
inputMask (""), value (""),
|
||||||
|
caption (""), valueList (0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
WidgetDef (OcsWidgetType widgType)
|
||||||
|
: type (widgType), orientation (OCS_HORIZONTAL),
|
||||||
|
caption (""), value (""), valueAlignment (OCS_CENTER),
|
||||||
|
widgetAlignment (OCS_RIGHT),
|
||||||
|
labelWidth (-1), widgetWidth (-1),
|
||||||
|
valueList (0), isDefault (true)
|
||||||
|
{}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
//Defines the attributes of the property as it is represented in the config file
|
||||||
|
//as well as the UI elements (group box and widget) that serve it.
|
||||||
|
//Only one widget may serve as the input widget for the property.
|
||||||
|
struct SettingsItemDef
|
||||||
|
{
|
||||||
|
QString name; //property name
|
||||||
|
QStringList *valueList; //list of valid values for the property.
|
||||||
|
//Used to populate option widget captions or list widget item lists (see WidgetDef::caption / value)
|
||||||
|
QString defaultValue;
|
||||||
|
bool hasMultipleValues;
|
||||||
|
CSMSettings::QStringPair minMax; //minimum / maximum value pair
|
||||||
|
WidgetDef widget; //definition of the input widget for this setting
|
||||||
|
OcsWidgetOrientation orientation; //general orientation of the widget / label for this property
|
||||||
|
ProxyList *proxyList; //list of property and corresponding default values for proxy widget
|
||||||
|
|
||||||
|
SettingsItemDef() : name (""), defaultValue (""), orientation (OCS_VERTICAL), hasMultipleValues (false)
|
||||||
|
{}
|
||||||
|
|
||||||
|
SettingsItemDef (QString propName, QString propDefault, OcsWidgetOrientation propOrient = OCS_VERTICAL)
|
||||||
|
: name (propName), defaultValue (propDefault), orientation (propOrient),
|
||||||
|
hasMultipleValues(false), valueList (new QStringList), proxyList ( new ProxyList)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//Hierarchically, this is a "sub-section" of properties within a section, solely for UI organization.
|
||||||
|
//Does not correlate to config file structure.
|
||||||
|
struct GroupBlockDef
|
||||||
|
{
|
||||||
|
QString title; //title of the block containing the property or properties of this sub-section
|
||||||
|
QStringList captions; //list of captions for widgets at the block level (not associated with any particular property)
|
||||||
|
WidgetList widgets; //list of widgets at the block level (not associated with any particular property)
|
||||||
|
QList<SettingsItemDef *> properties; //list of the property(ies) which are subordinate to the property block.
|
||||||
|
OcsWidgetOrientation widgetOrientation; //general orientation of widgets in group block
|
||||||
|
bool isVisible; //determines whether or not box border/title are visible
|
||||||
|
bool isProxy; //indicates whether or not this block defines a proxy block
|
||||||
|
QString defaultValue; //generic default value attribute
|
||||||
|
|
||||||
|
GroupBlockDef (): title(""), widgetOrientation (OCS_VERTICAL), isVisible (true), isProxy (false), defaultValue ("")
|
||||||
|
{}
|
||||||
|
|
||||||
|
GroupBlockDef (QString blockTitle)
|
||||||
|
: title (blockTitle), widgetOrientation (OCS_VERTICAL), isProxy (false), isVisible (true), defaultValue ("")
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CustomBlockDef
|
||||||
|
{
|
||||||
|
QString title;
|
||||||
|
QString defaultValue; //default value for widgets unique to the custom block
|
||||||
|
GroupBlockDefList blockDefList; //list of settings groups that comprise the settings within the custom block
|
||||||
|
OcsWidgetOrientation blockOrientation;
|
||||||
|
|
||||||
|
CustomBlockDef (): title (""), defaultValue (""), blockOrientation (OCS_HORIZONTAL)
|
||||||
|
{}
|
||||||
|
|
||||||
|
CustomBlockDef (const QString &blockTitle)
|
||||||
|
: title (blockTitle), defaultValue (""), blockOrientation (OCS_HORIZONTAL)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // VIEW_SUPPORT_HPP
|
|
@ -3,11 +3,11 @@
|
||||||
#include "groupbox.hpp"
|
#include "groupbox.hpp"
|
||||||
#include "itemblock.hpp"
|
#include "itemblock.hpp"
|
||||||
|
|
||||||
CsSettings::ToggleBlock::ToggleBlock(QWidget *parent) :
|
CSVSettings::ToggleBlock::ToggleBlock(QWidget *parent) :
|
||||||
CustomBlock(parent)
|
CustomBlock(parent)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
int CsSettings::ToggleBlock::build(CustomBlockDef &def)
|
int CSVSettings::ToggleBlock::build(CustomBlockDef &def)
|
||||||
{
|
{
|
||||||
if (def.blockDefList.size()==0)
|
if (def.blockDefList.size()==0)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -49,7 +49,7 @@ int CsSettings::ToggleBlock::build(CustomBlockDef &def)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CsSettings::GroupBox *CsSettings::ToggleBlock::buildToggleWidgets (GroupBlockDef &def, QString &defaultToggle)
|
CSVSettings::GroupBox *CSVSettings::ToggleBlock::buildToggleWidgets (GroupBlockDef &def, QString &defaultToggle)
|
||||||
{
|
{
|
||||||
GroupBox *box = new GroupBox (false, getParent());
|
GroupBox *box = new GroupBox (false, getParent());
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
#include "customblock.hpp"
|
#include "customblock.hpp"
|
||||||
|
|
||||||
namespace CsSettings
|
namespace CSVSettings
|
||||||
{
|
{
|
||||||
class GroupBlock;
|
class GroupBlock;
|
||||||
class GroupBox;
|
class GroupBox;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#include "settingwidget.hpp"
|
#include "settingwidget.hpp"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
CsSettings::UserSettingsDialog::UserSettingsDialog(QMainWindow *parent) :
|
CSVSettings::UserSettingsDialog::UserSettingsDialog(QMainWindow *parent) :
|
||||||
QMainWindow (parent), mUserSettings (mCfgMgr), mStackedWidget (0)
|
QMainWindow (parent), mUserSettings (mCfgMgr), mStackedWidget (0)
|
||||||
{
|
{
|
||||||
setWindowTitle(QString::fromUtf8 ("User Settings"));
|
setWindowTitle(QString::fromUtf8 ("User Settings"));
|
||||||
|
@ -31,22 +31,22 @@ CsSettings::UserSettingsDialog::UserSettingsDialog(QMainWindow *parent) :
|
||||||
SLOT (slotChangePage (QListWidgetItem*, QListWidgetItem*)));
|
SLOT (slotChangePage (QListWidgetItem*, QListWidgetItem*)));
|
||||||
}
|
}
|
||||||
|
|
||||||
CsSettings::UserSettingsDialog::~UserSettingsDialog()
|
CSVSettings::UserSettingsDialog::~UserSettingsDialog()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::UserSettingsDialog::closeEvent (QCloseEvent *event)
|
void CSVSettings::UserSettingsDialog::closeEvent (QCloseEvent *event)
|
||||||
{
|
{
|
||||||
writeSettings();
|
writeSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::UserSettingsDialog::setWidgetStates (SectionMap settingsMap)
|
void CSVSettings::UserSettingsDialog::setWidgetStates (CSMSettings::SectionMap settingsMap)
|
||||||
{
|
{
|
||||||
//iterate the tabWidget's pages (sections)
|
//iterate the tabWidget's pages (sections)
|
||||||
for (int i = 0; i < mStackedWidget->count(); i++)
|
for (int i = 0; i < mStackedWidget->count(); i++)
|
||||||
{
|
{
|
||||||
//get the settings defined for the entire section
|
//get the settings defined for the entire section
|
||||||
CsSettings::SettingMap *settings = settingsMap [mStackedWidget->widget(i)->objectName()];
|
CSMSettings::SettingMap *settings = settingsMap [mStackedWidget->widget(i)->objectName()];
|
||||||
|
|
||||||
//if found, initialize the page's widgets
|
//if found, initialize the page's widgets
|
||||||
if (settings)
|
if (settings)
|
||||||
|
@ -57,7 +57,7 @@ void CsSettings::UserSettingsDialog::setWidgetStates (SectionMap settingsMap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::UserSettingsDialog::buildPages()
|
void CSVSettings::UserSettingsDialog::buildPages()
|
||||||
{
|
{
|
||||||
//craete central widget with it's layout and immediate children
|
//craete central widget with it's layout and immediate children
|
||||||
QWidget *centralWidget = new QWidget (this);
|
QWidget *centralWidget = new QWidget (this);
|
||||||
|
@ -75,17 +75,17 @@ void CsSettings::UserSettingsDialog::buildPages()
|
||||||
setCentralWidget (centralWidget);
|
setCentralWidget (centralWidget);
|
||||||
setDockOptions (QMainWindow::AllowNestedDocks);
|
setDockOptions (QMainWindow::AllowNestedDocks);
|
||||||
//uncomment to test with sample editor page.
|
//uncomment to test with sample editor page.
|
||||||
//createSamplePage();
|
createSamplePage();
|
||||||
createPage<BlankPage>("Page1");
|
createPage<BlankPage>("Page1");
|
||||||
createPage<BlankPage>("Page2");
|
createPage<BlankPage>("Page2");
|
||||||
createPage<BlankPage>("Page3");
|
createPage<BlankPage>("Page3");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::UserSettingsDialog::createSamplePage()
|
void CSVSettings::UserSettingsDialog::createSamplePage()
|
||||||
{
|
{
|
||||||
//add pages to stackedwidget and items to listwidget
|
//add pages to stackedwidget and items to listwidget
|
||||||
CsSettings::AbstractPage *page
|
CSVSettings::AbstractPage *page
|
||||||
= new CsSettings::EditorPage(this);
|
= new CSVSettings::EditorPage(this);
|
||||||
|
|
||||||
mStackedWidget->addWidget (page);
|
mStackedWidget->addWidget (page);
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ void CsSettings::UserSettingsDialog::createSamplePage()
|
||||||
this, SIGNAL ( signalUpdateEditorSetting (const QString &, const QString &)));
|
this, SIGNAL ( signalUpdateEditorSetting (const QString &, const QString &)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::UserSettingsDialog::positionWindow ()
|
void CSVSettings::UserSettingsDialog::positionWindow ()
|
||||||
{
|
{
|
||||||
QRect scr = QApplication::desktop()->screenGeometry();
|
QRect scr = QApplication::desktop()->screenGeometry();
|
||||||
|
|
||||||
|
@ -103,14 +103,14 @@ void CsSettings::UserSettingsDialog::positionWindow ()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CsSettings::SectionMap CsSettings::UserSettingsDialog::loadSettings ()
|
CSMSettings::SectionMap CSVSettings::UserSettingsDialog::loadSettings ()
|
||||||
{
|
{
|
||||||
QString userPath = QString::fromStdString(mCfgMgr.getUserPath().string());
|
QString userPath = QString::fromStdString(mCfgMgr.getUserPath().string());
|
||||||
|
|
||||||
mPaths.append(QString("opencs.cfg"));
|
mPaths.append(QString("opencs.cfg"));
|
||||||
mPaths.append(userPath + QString("opencs.cfg"));
|
mPaths.append(userPath + QString("opencs.cfg"));
|
||||||
|
|
||||||
SectionMap settingsMap;
|
CSMSettings::SectionMap settingsMap;
|
||||||
|
|
||||||
foreach (const QString &path, mPaths)
|
foreach (const QString &path, mPaths)
|
||||||
{
|
{
|
||||||
|
@ -144,9 +144,9 @@ CsSettings::SectionMap CsSettings::UserSettingsDialog::loadSettings ()
|
||||||
return settingsMap;
|
return settingsMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::UserSettingsDialog::writeSettings()
|
void CSVSettings::UserSettingsDialog::writeSettings()
|
||||||
{
|
{
|
||||||
QMap<QString, SettingList *> settings;
|
QMap<QString, CSMSettings::SettingList *> settings;
|
||||||
|
|
||||||
for (int i = 0; i < mStackedWidget->count(); ++i)
|
for (int i = 0; i < mStackedWidget->count(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -158,12 +158,12 @@ void CsSettings::UserSettingsDialog::writeSettings()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CsSettings::AbstractPage *CsSettings::UserSettingsDialog::getAbstractPage (int index)
|
CSVSettings::AbstractPage *CSVSettings::UserSettingsDialog::getAbstractPage (int index)
|
||||||
{
|
{
|
||||||
return dynamic_cast<AbstractPage *>(mStackedWidget->widget(index));
|
return dynamic_cast<AbstractPage *>(mStackedWidget->widget(index));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CsSettings::UserSettingsDialog::slotChangePage(QListWidgetItem *current, QListWidgetItem *previous)
|
void CSVSettings::UserSettingsDialog::slotChangePage(QListWidgetItem *current, QListWidgetItem *previous)
|
||||||
{
|
{
|
||||||
if (!current)
|
if (!current)
|
||||||
current = previous;
|
current = previous;
|
||||||
|
|
|
@ -13,7 +13,7 @@ class AbstractWidget;
|
||||||
class QStackedWidget;
|
class QStackedWidget;
|
||||||
class QListWidget;
|
class QListWidget;
|
||||||
|
|
||||||
namespace CsSettings {
|
namespace CSVSettings {
|
||||||
|
|
||||||
class AbstractPage;
|
class AbstractPage;
|
||||||
class UserSettingsDialog : public QMainWindow
|
class UserSettingsDialog : public QMainWindow
|
||||||
|
@ -23,7 +23,7 @@ namespace CsSettings {
|
||||||
QStringList mPaths;
|
QStringList mPaths;
|
||||||
QListWidget *mListWidget;
|
QListWidget *mListWidget;
|
||||||
QStackedWidget *mStackedWidget;
|
QStackedWidget *mStackedWidget;
|
||||||
UserSettings mUserSettings;
|
CSMSettings::UserSettings mUserSettings;
|
||||||
Files::ConfigurationManager mCfgMgr;
|
Files::ConfigurationManager mCfgMgr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -34,10 +34,10 @@ namespace CsSettings {
|
||||||
|
|
||||||
void closeEvent (QCloseEvent *event);
|
void closeEvent (QCloseEvent *event);
|
||||||
AbstractPage *getAbstractPage (int index);
|
AbstractPage *getAbstractPage (int index);
|
||||||
void setWidgetStates (SectionMap settingsMap);
|
void setWidgetStates (CSMSettings::SectionMap settingsMap);
|
||||||
void buildPages();
|
void buildPages();
|
||||||
void positionWindow ();
|
void positionWindow ();
|
||||||
SectionMap loadSettings();
|
CSMSettings::SectionMap loadSettings();
|
||||||
void writeSettings();
|
void writeSettings();
|
||||||
void createSamplePage();
|
void createSamplePage();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue