From bc6197c5523fc7cc8879910ee9b6d45d154e03e6 Mon Sep 17 00:00:00 2001 From: graffy76 Date: Sat, 3 May 2014 18:57:34 -0500 Subject: [PATCH 1/6] Added custom spin box class --- apps/opencs/view/settings/spinbox.cpp | 51 +++++++++++++++++++++++++++ apps/opencs/view/settings/spinbox.hpp | 31 ++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 apps/opencs/view/settings/spinbox.cpp create mode 100644 apps/opencs/view/settings/spinbox.hpp diff --git a/apps/opencs/view/settings/spinbox.cpp b/apps/opencs/view/settings/spinbox.cpp new file mode 100644 index 000000000..bfb166370 --- /dev/null +++ b/apps/opencs/view/settings/spinbox.cpp @@ -0,0 +1,51 @@ +#include "spinbox.hpp" + +#include +#include + +CSVSettings::SpinBox::SpinBox(QWidget *parent) + : mValueList(QStringList()), QSpinBox(parent) +{ + setRange (0, 0); +} + +QString CSVSettings::SpinBox::textFromValue(int val) const +{ + if (mValueList.isEmpty()) + return QVariant (val).toString(); + + QString value = ""; + + if (val < mValueList.size()) + value = mValueList.at (val); + + return value; +} + +int CSVSettings::SpinBox::valueFromText(const QString &text) const +{ + if (mValueList.isEmpty()) + return -1; + + if (mValueList.contains (text)) + return mValueList.indexOf(text); + + return -1; +} + +void CSVSettings::SpinBox::setValue (const QString &value) +{ + if (!mValueList.isEmpty()) + { + lineEdit()->setText (value); + QSpinBox::setValue(valueFromText(value)); + } + else + QSpinBox::setValue (value.toInt()); +} + +void CSVSettings::SpinBox::setValueList (const QStringList &list) +{ + mValueList = list; + setMaximum (list.size() - 1); +} diff --git a/apps/opencs/view/settings/spinbox.hpp b/apps/opencs/view/settings/spinbox.hpp new file mode 100644 index 000000000..f8e59fa05 --- /dev/null +++ b/apps/opencs/view/settings/spinbox.hpp @@ -0,0 +1,31 @@ +#ifndef CSVSETTINGS_SPINBOX_HPP +#define CSVSETTINGS_SPINBOX_HPP + +#include +#include +#include + +namespace CSVSettings +{ + class SpinBox : public QSpinBox + { + Q_OBJECT + + QStringList mValueList; + + public: + explicit SpinBox(QWidget *parent = 0); + + void setObjectName (const QString &name); + + void setValue (const QString &value); + void setValueList (const QStringList &list); + const QStringList &valueList() const { return mValueList; } + + protected: + + QString textFromValue (int val) const; + int valueFromText (const QString &text) const; + }; +} +#endif // CSVSETTINGS_SPINBOX_HPP From 1c26741c5618c29321748d15b979813b5ee1618e Mon Sep 17 00:00:00 2001 From: graffy76 Date: Sat, 3 May 2014 18:58:43 -0500 Subject: [PATCH 2/6] Implemented rangeview with spinbox as only control. Simplified setting class constructor. --- apps/opencs/CMakeLists.txt | 1 + apps/opencs/model/settings/setting.cpp | 135 ++++++++++++---- apps/opencs/model/settings/setting.hpp | 43 ++++-- apps/opencs/model/settings/settingmanager.cpp | 6 +- apps/opencs/model/settings/settingmanager.hpp | 3 +- apps/opencs/model/settings/support.hpp | 43 ++++-- apps/opencs/model/settings/usersettings.cpp | 144 ++++++++++++------ apps/opencs/view/settings/booleanview.cpp | 13 +- apps/opencs/view/settings/dialog.cpp | 2 - apps/opencs/view/settings/frame.cpp | 2 + apps/opencs/view/settings/page.cpp | 2 + apps/opencs/view/settings/rangeview.cpp | 139 +++++++++++------ apps/opencs/view/settings/rangeview.hpp | 14 +- apps/opencs/view/settings/textview.cpp | 14 +- apps/opencs/view/settings/textview.hpp | 6 - apps/opencs/view/settings/view.cpp | 1 + apps/opencs/view/settings/view.hpp | 2 +- 17 files changed, 393 insertions(+), 177 deletions(-) diff --git a/apps/opencs/CMakeLists.txt b/apps/opencs/CMakeLists.txt index 680c8f8b7..38075ac53 100644 --- a/apps/opencs/CMakeLists.txt +++ b/apps/opencs/CMakeLists.txt @@ -97,6 +97,7 @@ opencs_units (view/settings listview rangeview resizeablestackedwidget + spinbox ) opencs_units_noqt (view/settings diff --git a/apps/opencs/model/settings/setting.cpp b/apps/opencs/model/settings/setting.cpp index ca682b454..1b265759c 100644 --- a/apps/opencs/model/settings/setting.cpp +++ b/apps/opencs/model/settings/setting.cpp @@ -1,13 +1,8 @@ #include "setting.hpp" #include "support.hpp" -CSMSettings::Setting::Setting() -{ - buildDefaultSetting(); -} - CSMSettings::Setting::Setting(SettingType typ, const QString &settingName, - const QString &pageName, const QStringList &values) + const QString &pageName) : mIsEditorSetting (false) { buildDefaultSetting(); @@ -19,10 +14,9 @@ CSMSettings::Setting::Setting(SettingType typ, const QString &settingName, setProperty (Property_IsMultiValue, QVariant(true).toString()); //view type is related to setting type by an order of magnitude - setProperty (Property_ViewType, QVariant (settingType / 10).toString()); + setProperty (Property_SettingType, QVariant (settingType).toString()); setProperty (Property_Page, pageName); setProperty (Property_Name, settingName); - setProperty (Property_DeclaredValues, values); } void CSMSettings::Setting::buildDefaultSetting() @@ -73,6 +67,11 @@ int CSMSettings::Setting::columnSpan() const return property (Property_ColumnSpan).at(0).toInt(); } +void CSMSettings::Setting::setDeclaredValues (QStringList list) +{ + setProperty (Property_DeclaredValues, list); +} + QStringList CSMSettings::Setting::declaredValues() const { return property (Property_DeclaredValues); @@ -165,6 +164,16 @@ bool CSMSettings::Setting::serializable() const return (property (Property_Serializable).at(0) == "true"); } +void CSMSettings::Setting::setSpecialValueText(const QString &text) +{ + setProperty (Property_SpecialValueText, text); +} + +QString CSMSettings::Setting::specialValueText() const +{ + return property (Property_SpecialValueText).at(0); +} + void CSMSettings::Setting::setName (const QString &value) { setProperty (Property_Name, value); @@ -185,6 +194,16 @@ QString CSMSettings::Setting::page() const return property (Property_Page).at(0); } +void CSMSettings::Setting::setPrefix (const QString &value) +{ + setProperty (Property_Prefix, value); +} + +QString CSMSettings::Setting::prefix() const +{ + return property (Property_Prefix).at(0); +} + void CSMSettings::Setting::setRowSpan (const int value) { setProperty (Property_RowSpan, value); @@ -195,15 +214,76 @@ int CSMSettings::Setting::rowSpan () const return property (Property_RowSpan).at(0).toInt(); } -void CSMSettings::Setting::setViewType (int vType) +void CSMSettings::Setting::setSingleStep (int value) +{ + setProperty (Property_SingleStep, value); +} + +void CSMSettings::Setting::setSingleStep (double value) +{ + setProperty (Property_SingleStep, value); +} + +QString CSMSettings::Setting::singleStep() const +{ + return property (Property_SingleStep).at(0); +} + +void CSMSettings::Setting::setSuffix (const QString &value) +{ + setProperty (Property_Suffix, value); +} + +QString CSMSettings::Setting::suffix() const +{ + return property (Property_Suffix).at(0); +} + +void CSMSettings::Setting::setType (int settingType) +{ + setProperty (Property_SettingType, settingType); +} + +CSMSettings::SettingType CSMSettings::Setting::type() const { - setProperty (Property_ViewType, vType); + return static_cast ( property ( + Property_SettingType).at(0).toInt()); +} + +void CSMSettings::Setting::setMaximum (int value) +{ + setProperty (Property_Maximum, value); +} + +void CSMSettings::Setting::setMaximum (double value) +{ + setProperty (Property_Maximum, value); +} + +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); } CSVSettings::ViewType CSMSettings::Setting::viewType() const { - return static_cast - (property(Property_ViewType).at(0).toInt()); + return static_cast ( property ( + Property_SettingType).at(0).toInt() / 10); } void CSMSettings::Setting::setViewColumn (int value) @@ -241,6 +321,17 @@ int CSMSettings::Setting::widgetWidth() const { return property (Property_WidgetWidth).at(0).toInt(); } + +void CSMSettings::Setting::setWrapping (bool state) +{ + setProperty (Property_Wrapping, state); +} + +bool CSMSettings::Setting::wrapping() const +{ + return (property (Property_Wrapping).at(0) == "true"); +} + void CSMSettings::Setting::setProperty (SettingProperty prop, bool value) { setProperty (prop, QStringList() << QVariant (value).toString()); @@ -251,6 +342,11 @@ void CSMSettings::Setting::setProperty (SettingProperty prop, int value) setProperty (prop, QStringList() << QVariant (value).toString()); } +void CSMSettings::Setting::setProperty (SettingProperty prop, double value) +{ + setProperty (prop, QStringList() << QVariant (value).toString()); +} + void CSMSettings::Setting::setProperty (SettingProperty prop, const QString &value) { @@ -263,18 +359,3 @@ void CSMSettings::Setting::setProperty (SettingProperty prop, if (prop < mProperties.size()) mProperties.replace (prop, value); } - -QDataStream &operator <<(QDataStream &stream, const CSMSettings::Setting& setting) -{ - // stream << setting.properties(); - - // stream << setting.proxies(); - return stream; -} - -QDataStream &operator >>(QDataStream& stream, CSMSettings::Setting& setting) -{ - // stream >> setting.properties(); - // stream >> setting.proxies(); - return stream; -} diff --git a/apps/opencs/model/settings/setting.hpp b/apps/opencs/model/settings/setting.hpp index 1463e4d7d..4e28a2348 100644 --- a/apps/opencs/model/settings/setting.hpp +++ b/apps/opencs/model/settings/setting.hpp @@ -27,12 +27,8 @@ namespace CSMSettings public: - - explicit Setting(); - explicit Setting(SettingType typ, const QString &settingName, - const QString &pageName, - const QStringList &values = QStringList()); + const QString &pageName); void addProxy (const Setting *setting, const QStringList &vals); void addProxy (const Setting *setting, const QList &list); @@ -66,12 +62,18 @@ namespace CSMSettings void setIsMultiValue (bool state); bool isMultiValue() const; + void setMask (const QString &value); + QString mask() const; + void setName (const QString &value); QString name() const; void setPage (const QString &value); QString page() const; + void setPrefix (const QString &value); + QString prefix() const; + void setRowSpan (const int value); int rowSpan() const; @@ -80,6 +82,24 @@ namespace CSMSettings void setSerializable (bool state); bool serializable() const; + void setSpecialValueText (const QString &text); + QString specialValueText() const; + + void setSingleStep (int value); + void setSingleStep (double value); + QString singleStep() const; + + void setSuffix (const QString &value); + QString suffix() const; + + void setMaximum (int value); + void setMaximum (double value); + QString maximum() const; + + void setMinimum (int value); + void setMinimum (double value); + QString minimum() const; + void setViewColumn (int value); int viewColumn() const; @@ -88,9 +108,14 @@ namespace CSMSettings void setViewRow (int value); int viewRow() const; - void setViewType (int vType); + void setType (int settingType); + CSMSettings::SettingType type() const; + CSVSettings::ViewType viewType() const; + void setWrapping (bool state); + bool wrapping() const; + void setWidgetWidth (int value); int widgetWidth() const; @@ -100,6 +125,7 @@ namespace CSMSettings ///boilerplate code to convert setting values of common types void setProperty (SettingProperty prop, bool value); void setProperty (SettingProperty prop, int value); + void setProperty (SettingProperty prop, double value); void setProperty (SettingProperty prop, const QString &value); void setProperty (SettingProperty prop, const QStringList &value); @@ -111,9 +137,4 @@ namespace CSMSettings }; } -Q_DECLARE_METATYPE(CSMSettings::Setting) - -QDataStream &operator <<(QDataStream &stream, const CSMSettings::Setting& setting); -QDataStream &operator >>(QDataStream &stream, CSMSettings::Setting& setting); - #endif // CSMSETTINGS_SETTING_HPP diff --git a/apps/opencs/model/settings/settingmanager.cpp b/apps/opencs/model/settings/settingmanager.cpp index eec4c54cf..36ca1ae03 100644 --- a/apps/opencs/model/settings/settingmanager.cpp +++ b/apps/opencs/model/settings/settingmanager.cpp @@ -30,8 +30,7 @@ void CSMSettings::SettingManager::dumpModel() } CSMSettings::Setting *CSMSettings::SettingManager::createSetting - (CSMSettings::SettingType typ, const QString &page, const QString &name, - const QStringList &values) + (CSMSettings::SettingType typ, const QString &page, const QString &name) { //get list of all settings for the current setting name if (findSetting (page, name)) @@ -41,7 +40,8 @@ CSMSettings::Setting *CSMSettings::SettingManager::createSetting return 0; } - Setting *setting = new Setting (typ, name, page, values); + Setting *setting = new Setting (typ, name, page); + //add declaration to the model mSettings.append (setting); diff --git a/apps/opencs/model/settings/settingmanager.hpp b/apps/opencs/model/settings/settingmanager.hpp index ca8a2cc7b..2efc2929f 100644 --- a/apps/opencs/model/settings/settingmanager.hpp +++ b/apps/opencs/model/settings/settingmanager.hpp @@ -46,8 +46,7 @@ namespace CSMSettings ///add a new setting to the model and return it Setting *createSetting (CSMSettings::SettingType typ, - const QString &page, const QString &name, - const QStringList &values = QStringList()); + const QString &page, const QString &name); ///add definitions to the settings specified in the page map void addDefinitions (DefinitionPageMap &pageMap); diff --git a/apps/opencs/model/settings/support.hpp b/apps/opencs/model/settings/support.hpp index ce808587f..be5a407ad 100644 --- a/apps/opencs/model/settings/support.hpp +++ b/apps/opencs/model/settings/support.hpp @@ -27,7 +27,7 @@ namespace CSMSettings { Property_Name = 0, Property_Page = 1, - Property_ViewType = 2, + Property_SettingType = 2, Property_IsMultiValue = 3, Property_IsMultiLine = 4, Property_WidgetWidth = 5, @@ -37,12 +37,19 @@ namespace CSMSettings Property_Serializable = 9, Property_ColumnSpan = 10, Property_RowSpan = 11, + Property_Minimum = 12, + Property_Maximum = 13, + Property_SpecialValueText = 14, + Property_Prefix = 15, + Property_Suffix = 16, + Property_SingleStep = 17, + Property_Wrapping = 18, //Stringlists should always be the last items - Property_DefaultValues = 12, - Property_DeclaredValues = 13, - Property_DefinedValues = 14, - Property_Proxies = 15 + Property_DefaultValues = 19, + Property_DeclaredValues = 20, + Property_DefinedValues = 21, + Property_Proxies = 22 }; enum SettingType @@ -64,10 +71,12 @@ namespace CSMSettings Type_ListView = 10, Type_ComboBox = 11, Type_SpinBox = 21, - Type_Slider = 23, - Type_Dial = 24, + Type_DoubleSpinBox = 23, + Type_Slider = 25, + Type_Dial = 27, Type_TextArea = 30, - Type_LineEdit = 31 + Type_LineEdit = 31, + Type_Undefined = 40 }; enum MergeMethod @@ -97,7 +106,7 @@ namespace CSVSettings }; } -// + namespace CSMSettings { struct PropertyDefaultValues @@ -109,9 +118,10 @@ namespace CSMSettings const QString sPropertyNames[] = { - "name", "page", "view_type", "is_multi_value", + "name", "page", "setting_type", "is_multi_value", "is_multi_line", "widget_width", "view_row", "view_column", "delimiter", - "is_serializable","column_span", "row_span", + "is_serializable","column_span", "row_span", "minimum", "maximum", + "special_value_text", "prefix", "suffix", "single_step", "wrapping", "defaults", "declarations", "definitions", "proxies" }; @@ -119,16 +129,23 @@ namespace CSMSettings { "", //name "", //page - "0", //view type + "40", //setting type "false", //multivalue "false", //multiline - "0", //widget width + "7", //widget width "-1", //view row "-1", //view column ",", //delimiter "true", //serialized "1", //column span "1", //row span + "0", //value range + "0", //value minimum + "0", //value maximum + "", //special text + "", //prefix + "", //suffix + "false", //wrapping "", //default values "", //declared values "", //defined values diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 2f8e8098d..17448f168 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -51,7 +51,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() Setting *height = createSetting (Type_LineEdit, section, "Height"); width->setWidgetWidth (5); - height->setWidgetWidth (5); + height->setWidgetWidth (8); width->setDefaultValues (QStringList() << "1024"); height->setDefaultValues (QStringList() << "768"); @@ -66,13 +66,10 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() *Create the proxy setting for predefined values */ Setting *preDefined = createSetting (Type_ComboBox, section, - "Pre-Defined", - QStringList() - << "640 x 480" - << "800 x 600" - << "1024 x 768" - << "1440 x 900" - ); + "Pre-Defined"); + + preDefined->setDeclaredValues (QStringList() << "640 x 480" + << "800 x 600" << "1024 x 768" << "1440 x 900"); preDefined->setViewLocation (1, 1); preDefined->setWidgetWidth (10); @@ -95,12 +92,13 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() << defaultValue << "Icon Only" << "Text Only"; Setting *rsd = createSetting (Type_RadioButton, - section, "Record Status Display", - values); + section, "Record Status Display"); Setting *ritd = createSetting (Type_RadioButton, - section, "Referenceable ID Type Display", - values); + section, "Referenceable ID Type Display"); + + rsd->setDeclaredValues (values); + ritd->setDeclaredValues (values); rsd->setEditorSetting (true); ritd->setEditorSetting (true); @@ -108,44 +106,63 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() section = "Proxy Selection Test"; { - //create three setting objects, specifying the basic widget type, - //the setting view name, the page name, and the default value + /****************************************************************** + * There are three types of values: + * + * Declared values + * + * Pre-determined values, typically for + * combobox drop downs and boolean (radiobutton / checkbox) labels. + * These values represent the total possible list of values that + * may define a setting. No other values are allowed. + * + * Defined values + * + * Values which represent the actual, current value of + * a setting. For settings with declared values, this must be one or + * several declared values, as appropriate. + * + * Proxy values - values the proxy master updates the proxy slave when + * it's own definition is set / changed. These are definitions for + * proxy slave settings, but must match any declared values the proxy + * slave has, if any. + *******************************************************************/ + + //create setting objects, specifying the basic widget type, + //the page name, and the view name + Setting *masterBoolean = createSetting (Type_RadioButton, section, - "Master Proxy", - QStringList() - << "Profile One" << "Profile Two" - << "Profile Three" << "Profile Four" - ); + "Master Proxy"); Setting *slaveBoolean = createSetting (Type_CheckBox, section, - "Proxy Checkboxes", - QStringList() << "One" << "Two" - << "Three" << "Four" << "Five" - ); + "Proxy Checkboxes"); Setting *slaveSingleText = createSetting (Type_LineEdit, section, - "Proxy TextBox 1" - ); + "Proxy TextBox 1"); Setting *slaveMultiText = createSetting (Type_LineEdit, section, - "ProxyTextBox 2" - ); - - // There are three types of values: - // - // Declared values - Pre-determined values, typically for - // combobox drop downs and boolean (radiobutton / checkbox) labels. - // These values represent the total possible list of values that may - // define a setting. No other values are allowed. - // - // Defined values - Values which represent the atual, current value of - // a setting. For settings with declared values, this must be one or - // several declared values, as appropriate. - // - // Proxy values - values the proxy master updates the proxy slave when - // it's own definition is set / changed. These are definitions for - // proxy slave settings, but must match any declared values the proxy - // slave has, if any. + "ProxyTextBox 2"); + + Setting *slaveAlphaSpinbox = createSetting (Type_SpinBox, section, + "Alpha Spinbox"); + + Setting *slaveIntegerSpinbox = createSetting (Type_SpinBox, section, + "Int Spinbox"); + + Setting *slaveDoubleSpinbox = createSetting (Type_DoubleSpinBox, + section, "Double Spinbox"); + + //set declared values for selected views + masterBoolean->setDeclaredValues (QStringList() + << "Profile One" << "Profile Two" + << "Profile Three" << "Profile Four"); + + slaveBoolean->setDeclaredValues (QStringList() + << "One" << "Two" << "Three" << "Four" << "Five"); + + slaveAlphaSpinbox->setDeclaredValues (QStringList() + << "One" << "Two" << "Three" << "Four"); + masterBoolean->addProxy (slaveBoolean, QList () << (QStringList() << "One" << "Three") @@ -168,11 +185,32 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() << (QStringList() << "Two" << "Four") ); + masterBoolean->addProxy (slaveAlphaSpinbox, QList () + << (QStringList() << "Four") + << (QStringList() << "Three") + << (QStringList() << "Two") + << (QStringList() << "One")); + + masterBoolean->addProxy (slaveIntegerSpinbox, QList () + << (QStringList() << "0") + << (QStringList() << "7") + << (QStringList() << "14") + << (QStringList() << "21")); + + masterBoolean->addProxy (slaveDoubleSpinbox, QList () + << (QStringList() << "0.17") + << (QStringList() << "0.34") + << (QStringList() << "0.51") + << (QStringList() << "0.68")); + //settings with proxies are not serialized by default //other settings non-serialized for demo purposes slaveBoolean->setSerializable (false); slaveSingleText->setSerializable (false); slaveMultiText->setSerializable (false); + slaveAlphaSpinbox->setSerializable (false); + slaveIntegerSpinbox->setSerializable (false); + slaveDoubleSpinbox->setSerializable (false); slaveBoolean->setDefaultValues (QStringList() << "One" << "Three" << "Five"); @@ -184,7 +222,25 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() slaveSingleText->setWidgetWidth (24); slaveMultiText->setWidgetWidth (24); - } + + slaveAlphaSpinbox->setDefaultValue ("Two"); + slaveAlphaSpinbox->setWidgetWidth (20); + //slaveAlphaSpinbox->setPrefix ("No. "); + //slaveAlphaSpinbox->setSuffix ("!"); + slaveAlphaSpinbox->setWrapping (true); + + slaveIntegerSpinbox->setDefaultValue ("14"); + slaveIntegerSpinbox->setMinimum (0); + slaveIntegerSpinbox->setMaximum (58); + slaveIntegerSpinbox->setPrefix ("$"); + slaveIntegerSpinbox->setSuffix (".00"); + slaveIntegerSpinbox->setWidgetWidth (10); + slaveIntegerSpinbox->setSpecialValueText ("Nothing!"); + + slaveDoubleSpinbox->setDefaultValue ("0.51"); + slaveDoubleSpinbox->setSingleStep(0.17); + slaveDoubleSpinbox->setMaximum(4.0); + } } CSMSettings::UserSettings::~UserSettings() diff --git a/apps/opencs/view/settings/booleanview.cpp b/apps/opencs/view/settings/booleanview.cpp index 1c48199d1..2a3f0cba6 100644 --- a/apps/opencs/view/settings/booleanview.cpp +++ b/apps/opencs/view/settings/booleanview.cpp @@ -18,10 +18,19 @@ CSVSettings::BooleanView::BooleanView (CSMSettings::Setting *setting, { QAbstractButton *button = 0; - if (isMultiValue()) + switch (setting->type()) + { + case CSMSettings::Type_CheckBox: button = new QCheckBox (value, this); - else + break; + + case CSMSettings::Type_RadioButton: button = new QRadioButton (value, this); + break; + + default: + break; + } connect (button, SIGNAL (clicked (bool)), this, SLOT (slotToggled (bool))); diff --git a/apps/opencs/view/settings/dialog.cpp b/apps/opencs/view/settings/dialog.cpp index d9d5830d9..3ed4d3b09 100644 --- a/apps/opencs/view/settings/dialog.cpp +++ b/apps/opencs/view/settings/dialog.cpp @@ -123,10 +123,8 @@ void CSVSettings::Dialog::show() { if (pages().isEmpty()) buildPages(); - QPoint screenCenter = QApplication::desktop()->screenGeometry().center(); move (screenCenter - geometry().center()); - QWidget::show(); } diff --git a/apps/opencs/view/settings/frame.cpp b/apps/opencs/view/settings/frame.cpp index db5091999..019024776 100644 --- a/apps/opencs/view/settings/frame.cpp +++ b/apps/opencs/view/settings/frame.cpp @@ -60,8 +60,10 @@ void CSVSettings::Frame::showWidgets() QWidget *widg = static_cast (obj); if (widg->property("sizePolicy").isValid()) + { widg->setSizePolicy (QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); + } } layout()->activate(); setFixedSize(minimumSizeHint()); diff --git a/apps/opencs/view/settings/page.cpp b/apps/opencs/view/settings/page.cpp index e67445873..afd4bff5e 100644 --- a/apps/opencs/view/settings/page.cpp +++ b/apps/opencs/view/settings/page.cpp @@ -7,6 +7,8 @@ #include "../../model/settings/usersettings.hpp" #include "../../model/settings/connector.hpp" +#include "../../model/settings/support.hpp" + #include "settingwindow.hpp" QMap diff --git a/apps/opencs/view/settings/rangeview.cpp b/apps/opencs/view/settings/rangeview.cpp index 2bb5863bc..ac9a5da8b 100644 --- a/apps/opencs/view/settings/rangeview.cpp +++ b/apps/opencs/view/settings/rangeview.cpp @@ -1,88 +1,129 @@ #include #include - -#include -#include #include - -#include +#include +#include +#include #include "rangeview.hpp" +#include "spinbox.hpp" #include "../../model/settings/setting.hpp" - - -#include +#include "../../model/settings/support.hpp" CSVSettings::RangeView::RangeView (CSMSettings::Setting *setting, Page *parent) - : View (setting, parent) + : mRangeWidget (0), mRangeType (setting->type()), View (setting, parent) +{ + + mRangeWidget = 0; + + if (isMultiValue()) + return; + + buildSpinBox (setting); + + mRangeWidget->setFixedWidth (widgetWidth (setting->widgetWidth())); + mRangeWidget->setObjectName (setting->name()); + + addWidget (mRangeWidget); +} + +void CSVSettings::RangeView::buildSpinBox (CSMSettings::Setting *setting) { - foreach (const QString &value, setting->declaredValues()) + SpinBox *sb = 0; + + switch (setting->type()) { - QAbstractButton *button = 0; + case CSMSettings::Type_SpinBox: - if (isMultiValue()) - button = new QCheckBox (value, this); - else - button = new QRadioButton (value, this); + sb = new SpinBox (this); - connect (button, SIGNAL (clicked (bool)), - this, SLOT (slotToggled (bool))); + if (!setting->declaredValues().isEmpty()) + sb->setValueList (setting->declaredValues()); - button->setObjectName (value); + mRangeWidget = sb; - addWidget (button); + connect (mRangeWidget, SIGNAL (valueChanged (int)), + this, SLOT (slotUpdateView (int))); + break; - mButtons[value] = button; + case CSMSettings::Type_DoubleSpinBox: + mRangeWidget = new QDoubleSpinBox (this); + + connect (mRangeWidget, SIGNAL (valueChanged (double)), + this, SLOT (slotUpdateView (double))); + break; + + default: + break; } + + //min / max values are set automatically in AlphaSpinBox + if (setting->declaredValues().isEmpty()) + { + 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()); + mRangeWidget->setProperty ("suffix", setting->suffix()); + mRangeWidget->setProperty ("wrapping", setting->wrapping()); + } -void CSVSettings::RangeView::slotToggled (bool state) +void CSVSettings::RangeView::slotUpdateView (int value) { - //test only for true to avoid multiple selection updates with radiobuttons - if (!isMultiValue() && !state) - return; - - QStringList values; + QString textValue = ""; - foreach (QString key, mButtons.keys()) + if (mRangeType == CSMSettings::Type_SpinBox) { - if (mButtons.value(key)->isChecked()) - values.append (key); + QStringList list = + static_cast (mRangeWidget)->valueList(); + if (!list.isEmpty()) + textValue = list.at(value); } - setSelectedValues (values, false); + + if (textValue.isEmpty()) + textValue = QVariant (value).toString(); + + setSelectedValue (textValue, false); View::updateView(); + } -void CSVSettings::RangeView::updateView (bool signalUpdate) const +void CSVSettings::RangeView::slotUpdateView (double value) { + setSelectedValue (QVariant(value).toString(), false); - QStringList values = selectedValues(); - - foreach (const QString &buttonName, mButtons.keys()) - { - QAbstractButton *button = mButtons[buttonName]; + View::updateView(); +} - //if the value is not found in the list, the widget is checked false - bool buttonValue = values.contains(buttonName); +void CSVSettings::RangeView::updateView (bool signalUpdate) const +{ + QString value; - //skip if the butotn value will not change - if (button->isChecked() == buttonValue) - continue; + if (!selectedValues().isEmpty()) + value = selectedValues().at(0); - //disable autoexclusive if it's enabled and we're setting - //the button value to false - bool switchExclusive = (!buttonValue && button->autoExclusive()); + switch (mRangeType) + { + case CSMSettings::Type_SpinBox: + static_cast (mRangeWidget)->setValue (value); + break; - if (switchExclusive) - button->setAutoExclusive (false); + case CSMSettings::Type_DoubleSpinBox: + static_cast (mRangeWidget)->setValue (value.toDouble()); + break; - button->setChecked (buttonValue); + default: + break; - if (switchExclusive) - button->setAutoExclusive(true); } + View::updateView (signalUpdate); } diff --git a/apps/opencs/view/settings/rangeview.hpp b/apps/opencs/view/settings/rangeview.hpp index 1df0c7bd6..6515c9168 100644 --- a/apps/opencs/view/settings/rangeview.hpp +++ b/apps/opencs/view/settings/rangeview.hpp @@ -1,13 +1,11 @@ #ifndef CSVSETTINGS_RANGEVIEW_HPP #define CSVSETTINGS_RANGEVIEW_HPP -#include -#include - #include "view.hpp" #include "../../model/settings/support.hpp" class QStringListModel; +class QAbstractSpinBox; namespace CSVSettings { @@ -15,7 +13,8 @@ namespace CSVSettings { Q_OBJECT - QMap mButtons; + QAbstractSpinBox *mRangeWidget; + CSMSettings::SettingType mRangeType; public: explicit RangeView (CSMSettings::Setting *setting, @@ -24,8 +23,13 @@ namespace CSVSettings protected: void updateView (bool signalUpdate = true) const; + void buildSpinBox (CSMSettings::Setting *setting); + private slots: - void slotToggled (bool state); + + void slotUpdateView (int value); + void slotUpdateView (double value); + }; class RangeViewFactory : public QObject, public IViewFactory diff --git a/apps/opencs/view/settings/textview.cpp b/apps/opencs/view/settings/textview.cpp index 5e10c346f..6886732db 100644 --- a/apps/opencs/view/settings/textview.cpp +++ b/apps/opencs/view/settings/textview.cpp @@ -28,11 +28,6 @@ bool CSVSettings::TextView::isEquivalent return (lhs.trimmed() == rhs.trimmed()); } -void CSVSettings::TextView::setWidgetText (const QString &value) const -{ - mTextWidget->setProperty ("text", value); -} - void CSVSettings::TextView::slotTextEdited (QString value) { QStringList values = value.split (mDelimiter, QString::SkipEmptyParts); @@ -51,19 +46,14 @@ void CSVSettings::TextView::updateView(bool signalUpdate) const { QString values = selectedValues().join (mDelimiter); - if (isEquivalent (widgetText(), values)) + if (isEquivalent (mTextWidget->property("text").toString(), values)) return; - setWidgetText (values); + mTextWidget->setProperty("text", values); View::updateView (signalUpdate); } -QString CSVSettings::TextView::widgetText() const -{ - return mTextWidget->property("text").toString(); -} - CSVSettings::TextView *CSVSettings::TextViewFactory::createView (CSMSettings::Setting *setting, Page *parent) diff --git a/apps/opencs/view/settings/textview.hpp b/apps/opencs/view/settings/textview.hpp index 6d718aad8..c485e7fcf 100644 --- a/apps/opencs/view/settings/textview.hpp +++ b/apps/opencs/view/settings/textview.hpp @@ -32,12 +32,6 @@ namespace CSVSettings ///Comparison function that returns true if the trimmed() strings ///are equal bool isEquivalent (const QString &lhs, const QString &rhs) const; - - ///Convenience function to return the text of the widget - QString widgetText() const; - - ///Convenience function to set the text of the widget - void setWidgetText (const QString &value) const; }; class TextViewFactory : public QObject, public IViewFactory diff --git a/apps/opencs/view/settings/view.cpp b/apps/opencs/view/settings/view.cpp index 4f93b1c0f..2a70152c2 100644 --- a/apps/opencs/view/settings/view.cpp +++ b/apps/opencs/view/settings/view.cpp @@ -192,6 +192,7 @@ bool CSVSettings::View::stringListsMatch ( QList CSVSettings::View::toStandardItemList (const QStringList &list) const { + QList itemList; foreach (const QString &value, list) diff --git a/apps/opencs/view/settings/view.hpp b/apps/opencs/view/settings/view.hpp index c99879762..23357e45f 100644 --- a/apps/opencs/view/settings/view.hpp +++ b/apps/opencs/view/settings/view.hpp @@ -101,7 +101,7 @@ namespace CSVSettings void showEvent ( QShowEvent * event ); ///Virtual for updating a specific View subclass - ///bool indicates whether a signal is emitted that the view was updated + ///bool indicates whether viewUpdated() signal is emitted virtual void updateView (bool signalUpdate = true) const; ///Returns the pixel width corresponding to the specified number of From c4a9c180452bdf6a343ef059b78882548b1f350f Mon Sep 17 00:00:00 2001 From: graffy76 Date: Sat, 3 May 2014 19:36:52 -0500 Subject: [PATCH 3/6] Commented out "proxy selection test" demo page in user settings --- apps/opencs/model/settings/usersettings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 6e05e9dff..92ac627c4 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -127,7 +127,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() * proxy slave settings, but must match any declared values the proxy * slave has, if any. *******************************************************************/ - +/* //create setting objects, specifying the basic widget type, //the page name, and the view name @@ -240,7 +240,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() slaveDoubleSpinbox->setDefaultValue ("0.51"); slaveDoubleSpinbox->setSingleStep(0.17); slaveDoubleSpinbox->setMaximum(4.0); - } + }*/ } CSMSettings::UserSettings::~UserSettings() From 0a3ab3dcd13eeaec25d2404f050243b5ed7991be Mon Sep 17 00:00:00 2001 From: graffy76 Date: Sat, 3 May 2014 19:36:52 -0500 Subject: [PATCH 4/6] Commented out "proxy selection test" demo page in user settings --- apps/opencs/model/settings/usersettings.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 6e05e9dff..8bfdadf15 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -127,7 +127,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() * proxy slave settings, but must match any declared values the proxy * slave has, if any. *******************************************************************/ - +/* //create setting objects, specifying the basic widget type, //the page name, and the view name @@ -240,6 +240,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() slaveDoubleSpinbox->setDefaultValue ("0.51"); slaveDoubleSpinbox->setSingleStep(0.17); slaveDoubleSpinbox->setMaximum(4.0); +*/ } } From 4f876574c15e05a152baeb9788fa21f8dcab65fb Mon Sep 17 00:00:00 2001 From: graffy76 Date: Sat, 3 May 2014 21:50:08 -0500 Subject: [PATCH 5/6] Implemented slider widget in rangeView class --- apps/opencs/model/settings/setting.cpp | 30 ++++++++ apps/opencs/model/settings/setting.hpp | 21 ++++-- apps/opencs/model/settings/support.hpp | 15 ++-- apps/opencs/model/settings/usersettings.cpp | 22 +++++- apps/opencs/view/settings/rangeview.cpp | 79 +++++++++++++++++++-- apps/opencs/view/settings/rangeview.hpp | 3 +- 6 files changed, 151 insertions(+), 19 deletions(-) diff --git a/apps/opencs/model/settings/setting.cpp b/apps/opencs/model/settings/setting.cpp index 1b265759c..fe5a26bbc 100644 --- a/apps/opencs/model/settings/setting.cpp +++ b/apps/opencs/model/settings/setting.cpp @@ -239,6 +239,36 @@ QString CSMSettings::Setting::suffix() const return property (Property_Suffix).at(0); } +void CSMSettings::Setting::setTickInterval (int value) +{ + setProperty (Property_TickInterval, value); +} + +int CSMSettings::Setting::tickInterval () const +{ + return property (Property_TickInterval).at(0).toInt(); +} + +void CSMSettings::Setting::setTicksAbove (bool state) +{ + setProperty (Property_TicksAbove, state); +} + +bool CSMSettings::Setting::ticksAbove() const +{ + return (property (Property_TicksAbove).at(0) == "true"); +} + +void CSMSettings::Setting::setTicksBelow (bool state) +{ + setProperty (Property_TicksBelow, state); +} + +bool CSMSettings::Setting::ticksBelow() const +{ + return (property (Property_TicksBelow).at(0) == "true"); +} + void CSMSettings::Setting::setType (int settingType) { setProperty (Property_SettingType, settingType); diff --git a/apps/opencs/model/settings/setting.hpp b/apps/opencs/model/settings/setting.hpp index 4e28a2348..8efe33034 100644 --- a/apps/opencs/model/settings/setting.hpp +++ b/apps/opencs/model/settings/setting.hpp @@ -65,6 +65,14 @@ namespace CSMSettings void setMask (const QString &value); QString mask() const; + void setMaximum (int value); + void setMaximum (double value); + QString maximum() const; + + void setMinimum (int value); + void setMinimum (double value); + QString minimum() const; + void setName (const QString &value); QString name() const; @@ -92,13 +100,14 @@ namespace CSMSettings void setSuffix (const QString &value); QString suffix() const; - void setMaximum (int value); - void setMaximum (double value); - QString maximum() const; + void setTickInterval (int value); + int tickInterval() const; - void setMinimum (int value); - void setMinimum (double value); - QString minimum() const; + void setTicksAbove (bool state); + bool ticksAbove() const; + + void setTicksBelow (bool state); + bool ticksBelow() const; void setViewColumn (int value); int viewColumn() const; diff --git a/apps/opencs/model/settings/support.hpp b/apps/opencs/model/settings/support.hpp index be5a407ad..d65de2b91 100644 --- a/apps/opencs/model/settings/support.hpp +++ b/apps/opencs/model/settings/support.hpp @@ -44,12 +44,15 @@ namespace CSMSettings Property_Suffix = 16, Property_SingleStep = 17, Property_Wrapping = 18, + Property_TickInterval = 19, + Property_TicksAbove = 20, + Property_TicksBelow = 21, //Stringlists should always be the last items - Property_DefaultValues = 19, - Property_DeclaredValues = 20, - Property_DefinedValues = 21, - Property_Proxies = 22 + Property_DefaultValues = 22, + Property_DeclaredValues = 23, + Property_DefinedValues = 24, + Property_Proxies = 25 }; enum SettingType @@ -122,6 +125,7 @@ namespace CSMSettings "is_multi_line", "widget_width", "view_row", "view_column", "delimiter", "is_serializable","column_span", "row_span", "minimum", "maximum", "special_value_text", "prefix", "suffix", "single_step", "wrapping", + "tick_interval", "ticks_above", "ticks_below", "defaults", "declarations", "definitions", "proxies" }; @@ -146,6 +150,9 @@ namespace CSMSettings "", //prefix "", //suffix "false", //wrapping + "1", //tick interval + "false", //ticks above + "true", //ticks below "", //default values "", //declared values "", //defined values diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 8bfdadf15..787e26650 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -127,10 +127,10 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() * proxy slave settings, but must match any declared values the proxy * slave has, if any. *******************************************************************/ -/* + //create setting objects, specifying the basic widget type, //the page name, and the view name - +/* Setting *masterBoolean = createSetting (Type_RadioButton, section, "Master Proxy"); @@ -152,6 +152,8 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() Setting *slaveDoubleSpinbox = createSetting (Type_DoubleSpinBox, section, "Double Spinbox"); + Setting *slaveSlider = createSetting (Type_Slider, section, "Slider"); + //set declared values for selected views masterBoolean->setDeclaredValues (QStringList() << "Profile One" << "Profile Two" @@ -203,6 +205,13 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() << (QStringList() << "0.51") << (QStringList() << "0.68")); + masterBoolean->addProxy (slaveSlider, QList () + << (QStringList() << "25") + << (QStringList() << "50") + << (QStringList() << "75") + << (QStringList() << "100") + ); + //settings with proxies are not serialized by default //other settings non-serialized for demo purposes slaveBoolean->setSerializable (false); @@ -211,6 +220,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() slaveAlphaSpinbox->setSerializable (false); slaveIntegerSpinbox->setSerializable (false); slaveDoubleSpinbox->setSerializable (false); + slaveSlider->setSerializable (false); slaveBoolean->setDefaultValues (QStringList() << "One" << "Three" << "Five"); @@ -240,7 +250,13 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() slaveDoubleSpinbox->setDefaultValue ("0.51"); slaveDoubleSpinbox->setSingleStep(0.17); slaveDoubleSpinbox->setMaximum(4.0); -*/ + + slaveSlider->setMinimum (0); + slaveSlider->setMaximum (100); + slaveSlider->setDefaultValue ("75"); + slaveSlider->setWidgetWidth (100); + slaveSlider->setTicksAbove (true); + slaveSlider->setTickInterval (25);*/ } } diff --git a/apps/opencs/view/settings/rangeview.cpp b/apps/opencs/view/settings/rangeview.cpp index ac9a5da8b..b2701c7bf 100644 --- a/apps/opencs/view/settings/rangeview.cpp +++ b/apps/opencs/view/settings/rangeview.cpp @@ -4,6 +4,9 @@ #include #include #include +#include +#include +#include #include "rangeview.hpp" #include "spinbox.hpp" @@ -20,7 +23,21 @@ CSVSettings::RangeView::RangeView (CSMSettings::Setting *setting, if (isMultiValue()) return; - buildSpinBox (setting); + switch (mRangeType) + { + case CSMSettings::Type_SpinBox: + case CSMSettings::Type_DoubleSpinBox: + buildSpinBox (setting); + break; + + case CSMSettings::Type_Dial: + case CSMSettings::Type_Slider: + buildSlider (setting); + break; + + default: + break; + } mRangeWidget->setFixedWidth (widgetWidth (setting->widgetWidth())); mRangeWidget->setObjectName (setting->name()); @@ -28,6 +45,48 @@ CSVSettings::RangeView::RangeView (CSMSettings::Setting *setting, addWidget (mRangeWidget); } +void CSVSettings::RangeView::buildSlider (CSMSettings::Setting *setting) +{ + switch (setting->type()) + { + case CSMSettings::Type_Slider: + mRangeWidget = new QSlider (Qt::Horizontal, this); + mRangeWidget->setProperty ("tickInterval", setting->tickInterval()); + + if (setting->ticksAbove()) + { + if (setting->ticksBelow()) + mRangeWidget->setProperty ("tickPosition", QSlider::TicksBothSides); + else + mRangeWidget->setProperty ("tickPosition", QSlider::TicksAbove); + } + else if (setting->ticksBelow()) + mRangeWidget->setProperty ("tickPosition", QSlider::TicksBelow); + else + mRangeWidget->setProperty ("tickPosition", QSlider::NoTicks); + + break; + + case CSMSettings::Type_Dial: + mRangeWidget = new QDial (this); + mRangeWidget->setProperty ("wrapping", setting->wrapping()); + mRangeWidget->setProperty ("notchesVisible", + (setting->ticksAbove() || setting->ticksBelow())); + break; + + default: + break; + } + + mRangeWidget->setProperty ("minimum", setting->minimum()); + mRangeWidget->setProperty ("maximum", setting->maximum()); + mRangeWidget->setProperty ("tracking", false); + mRangeWidget->setProperty ("singleStep", setting->singleStep()); + + connect (mRangeWidget, SIGNAL (valueChanged (int)), + this, SLOT (slotUpdateView (int))); +} + void CSVSettings::RangeView::buildSpinBox (CSMSettings::Setting *setting) { SpinBox *sb = 0; @@ -77,13 +136,18 @@ void CSVSettings::RangeView::buildSpinBox (CSMSettings::Setting *setting) void CSVSettings::RangeView::slotUpdateView (int value) { QString textValue = ""; + QStringList list; - if (mRangeType == CSMSettings::Type_SpinBox) + switch (mRangeType) { - QStringList list = - static_cast (mRangeWidget)->valueList(); + case CSMSettings::Type_SpinBox: + list = static_cast (mRangeWidget)->valueList(); if (!list.isEmpty()) textValue = list.at(value); + break; + + default: + break; } if (textValue.isEmpty()) @@ -92,7 +156,6 @@ void CSVSettings::RangeView::slotUpdateView (int value) setSelectedValue (textValue, false); View::updateView(); - } void CSVSettings::RangeView::slotUpdateView (double value) @@ -119,6 +182,12 @@ void CSVSettings::RangeView::updateView (bool signalUpdate) const static_cast (mRangeWidget)->setValue (value.toDouble()); break; + case CSMSettings::Type_Slider: + case CSMSettings::Type_Dial: + mRangeWidget->setProperty ("value", value.toInt()); + mRangeWidget->setProperty ("sliderPosition", value.toInt()); + break; + default: break; diff --git a/apps/opencs/view/settings/rangeview.hpp b/apps/opencs/view/settings/rangeview.hpp index 6515c9168..e8d6df88e 100644 --- a/apps/opencs/view/settings/rangeview.hpp +++ b/apps/opencs/view/settings/rangeview.hpp @@ -13,7 +13,7 @@ namespace CSVSettings { Q_OBJECT - QAbstractSpinBox *mRangeWidget; + QWidget *mRangeWidget; CSMSettings::SettingType mRangeType; public: @@ -23,6 +23,7 @@ namespace CSVSettings protected: void updateView (bool signalUpdate = true) const; + void buildSlider (CSMSettings::Setting *setting); void buildSpinBox (CSMSettings::Setting *setting); private slots: From 3f737bbb44c73fd6833bea73bfadcc05b9eda6fa Mon Sep 17 00:00:00 2001 From: graffy76 Date: Sat, 3 May 2014 22:02:16 -0500 Subject: [PATCH 6/6] implemented QDial into RangeView class --- apps/opencs/model/settings/setting.cpp | 10 ++++++ apps/opencs/model/settings/setting.hpp | 2 ++ apps/opencs/model/settings/usersettings.cpp | 36 +++++++++++++++------ 3 files changed, 38 insertions(+), 10 deletions(-) diff --git a/apps/opencs/model/settings/setting.cpp b/apps/opencs/model/settings/setting.cpp index fe5a26bbc..fe15cf7f6 100644 --- a/apps/opencs/model/settings/setting.cpp +++ b/apps/opencs/model/settings/setting.cpp @@ -95,6 +95,16 @@ QStringList CSMSettings::Setting::property (SettingProperty prop) const return mProperties.at(prop); } +void CSMSettings::Setting::setDefaultValue (int value) +{ + setDefaultValues (QStringList() << QVariant (value).toString()); +} + +void CSMSettings::Setting::setDefaultValue (double value) +{ + setDefaultValues (QStringList() << QVariant (value).toString()); +} + void CSMSettings::Setting::setDefaultValue (const QString &value) { setDefaultValues (QStringList() << value); diff --git a/apps/opencs/model/settings/setting.hpp b/apps/opencs/model/settings/setting.hpp index 8efe33034..cf5dd2a06 100644 --- a/apps/opencs/model/settings/setting.hpp +++ b/apps/opencs/model/settings/setting.hpp @@ -45,6 +45,8 @@ namespace CSMSettings void setDefinedValues (QStringList list); QStringList definedValues() const; + void setDefaultValue (int value); + void setDefaultValue (double value); void setDefaultValue (const QString &value); void setDefaultValues (const QStringList &values); diff --git a/apps/opencs/model/settings/usersettings.cpp b/apps/opencs/model/settings/usersettings.cpp index 787e26650..a8fd752e3 100644 --- a/apps/opencs/model/settings/usersettings.cpp +++ b/apps/opencs/model/settings/usersettings.cpp @@ -132,28 +132,30 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() //the page name, and the view name /* Setting *masterBoolean = createSetting (Type_RadioButton, section, - "Master Proxy"); + "Master Proxy"); Setting *slaveBoolean = createSetting (Type_CheckBox, section, - "Proxy Checkboxes"); + "Proxy Checkboxes"); Setting *slaveSingleText = createSetting (Type_LineEdit, section, - "Proxy TextBox 1"); + "Proxy TextBox 1"); Setting *slaveMultiText = createSetting (Type_LineEdit, section, - "ProxyTextBox 2"); + "ProxyTextBox 2"); Setting *slaveAlphaSpinbox = createSetting (Type_SpinBox, section, - "Alpha Spinbox"); + "Alpha Spinbox"); Setting *slaveIntegerSpinbox = createSetting (Type_SpinBox, section, - "Int Spinbox"); + "Int Spinbox"); Setting *slaveDoubleSpinbox = createSetting (Type_DoubleSpinBox, section, "Double Spinbox"); Setting *slaveSlider = createSetting (Type_Slider, section, "Slider"); + Setting *slaveDial = createSetting (Type_Dial, section, "Dial"); + //set declared values for selected views masterBoolean->setDeclaredValues (QStringList() << "Profile One" << "Profile Two" @@ -212,6 +214,13 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() << (QStringList() << "100") ); + masterBoolean->addProxy (slaveDial, QList () + << (QStringList() << "25") + << (QStringList() << "50") + << (QStringList() << "75") + << (QStringList() << "100") + ); + //settings with proxies are not serialized by default //other settings non-serialized for demo purposes slaveBoolean->setSerializable (false); @@ -239,7 +248,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() //slaveAlphaSpinbox->setSuffix ("!"); slaveAlphaSpinbox->setWrapping (true); - slaveIntegerSpinbox->setDefaultValue ("14"); + slaveIntegerSpinbox->setDefaultValue (14); slaveIntegerSpinbox->setMinimum (0); slaveIntegerSpinbox->setMaximum (58); slaveIntegerSpinbox->setPrefix ("$"); @@ -247,16 +256,23 @@ void CSMSettings::UserSettings::buildSettingModelDefaults() slaveIntegerSpinbox->setWidgetWidth (10); slaveIntegerSpinbox->setSpecialValueText ("Nothing!"); - slaveDoubleSpinbox->setDefaultValue ("0.51"); + slaveDoubleSpinbox->setDefaultValue (0.51); slaveDoubleSpinbox->setSingleStep(0.17); slaveDoubleSpinbox->setMaximum(4.0); slaveSlider->setMinimum (0); slaveSlider->setMaximum (100); - slaveSlider->setDefaultValue ("75"); + slaveSlider->setDefaultValue (75); slaveSlider->setWidgetWidth (100); slaveSlider->setTicksAbove (true); - slaveSlider->setTickInterval (25);*/ + slaveSlider->setTickInterval (25); + + slaveDial->setMinimum (0); + slaveDial->setMaximum (100); + slaveDial->setSingleStep (5); + slaveDial->setDefaultValue (75); + slaveDial->setTickInterval (25); +*/ } }