mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-04-01 15:06:43 +00:00
Implemented slider widget in rangeView class
This commit is contained in:
parent
306c9e840c
commit
4f876574c1
6 changed files with 151 additions and 19 deletions
|
@ -239,6 +239,36 @@ QString CSMSettings::Setting::suffix() const
|
||||||
return property (Property_Suffix).at(0);
|
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)
|
void CSMSettings::Setting::setType (int settingType)
|
||||||
{
|
{
|
||||||
setProperty (Property_SettingType, settingType);
|
setProperty (Property_SettingType, settingType);
|
||||||
|
|
|
@ -65,6 +65,14 @@ namespace CSMSettings
|
||||||
void setMask (const QString &value);
|
void setMask (const QString &value);
|
||||||
QString mask() const;
|
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);
|
void setName (const QString &value);
|
||||||
QString name() const;
|
QString name() const;
|
||||||
|
|
||||||
|
@ -92,13 +100,14 @@ namespace CSMSettings
|
||||||
void setSuffix (const QString &value);
|
void setSuffix (const QString &value);
|
||||||
QString suffix() const;
|
QString suffix() const;
|
||||||
|
|
||||||
void setMaximum (int value);
|
void setTickInterval (int value);
|
||||||
void setMaximum (double value);
|
int tickInterval() const;
|
||||||
QString maximum() const;
|
|
||||||
|
|
||||||
void setMinimum (int value);
|
void setTicksAbove (bool state);
|
||||||
void setMinimum (double value);
|
bool ticksAbove() const;
|
||||||
QString minimum() const;
|
|
||||||
|
void setTicksBelow (bool state);
|
||||||
|
bool ticksBelow() const;
|
||||||
|
|
||||||
void setViewColumn (int value);
|
void setViewColumn (int value);
|
||||||
int viewColumn() const;
|
int viewColumn() const;
|
||||||
|
|
|
@ -44,12 +44,15 @@ namespace CSMSettings
|
||||||
Property_Suffix = 16,
|
Property_Suffix = 16,
|
||||||
Property_SingleStep = 17,
|
Property_SingleStep = 17,
|
||||||
Property_Wrapping = 18,
|
Property_Wrapping = 18,
|
||||||
|
Property_TickInterval = 19,
|
||||||
|
Property_TicksAbove = 20,
|
||||||
|
Property_TicksBelow = 21,
|
||||||
|
|
||||||
//Stringlists should always be the last items
|
//Stringlists should always be the last items
|
||||||
Property_DefaultValues = 19,
|
Property_DefaultValues = 22,
|
||||||
Property_DeclaredValues = 20,
|
Property_DeclaredValues = 23,
|
||||||
Property_DefinedValues = 21,
|
Property_DefinedValues = 24,
|
||||||
Property_Proxies = 22
|
Property_Proxies = 25
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SettingType
|
enum SettingType
|
||||||
|
@ -122,6 +125,7 @@ namespace CSMSettings
|
||||||
"is_multi_line", "widget_width", "view_row", "view_column", "delimiter",
|
"is_multi_line", "widget_width", "view_row", "view_column", "delimiter",
|
||||||
"is_serializable","column_span", "row_span", "minimum", "maximum",
|
"is_serializable","column_span", "row_span", "minimum", "maximum",
|
||||||
"special_value_text", "prefix", "suffix", "single_step", "wrapping",
|
"special_value_text", "prefix", "suffix", "single_step", "wrapping",
|
||||||
|
"tick_interval", "ticks_above", "ticks_below",
|
||||||
"defaults", "declarations", "definitions", "proxies"
|
"defaults", "declarations", "definitions", "proxies"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -146,6 +150,9 @@ namespace CSMSettings
|
||||||
"", //prefix
|
"", //prefix
|
||||||
"", //suffix
|
"", //suffix
|
||||||
"false", //wrapping
|
"false", //wrapping
|
||||||
|
"1", //tick interval
|
||||||
|
"false", //ticks above
|
||||||
|
"true", //ticks below
|
||||||
"", //default values
|
"", //default values
|
||||||
"", //declared values
|
"", //declared values
|
||||||
"", //defined values
|
"", //defined values
|
||||||
|
|
|
@ -127,10 +127,10 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||||
* proxy slave settings, but must match any declared values the proxy
|
* proxy slave settings, but must match any declared values the proxy
|
||||||
* slave has, if any.
|
* slave has, if any.
|
||||||
*******************************************************************/
|
*******************************************************************/
|
||||||
/*
|
|
||||||
//create setting objects, specifying the basic widget type,
|
//create setting objects, specifying the basic widget type,
|
||||||
//the page name, and the view name
|
//the page name, and the view name
|
||||||
|
/*
|
||||||
Setting *masterBoolean = createSetting (Type_RadioButton, section,
|
Setting *masterBoolean = createSetting (Type_RadioButton, section,
|
||||||
"Master Proxy");
|
"Master Proxy");
|
||||||
|
|
||||||
|
@ -152,6 +152,8 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||||
Setting *slaveDoubleSpinbox = createSetting (Type_DoubleSpinBox,
|
Setting *slaveDoubleSpinbox = createSetting (Type_DoubleSpinBox,
|
||||||
section, "Double Spinbox");
|
section, "Double Spinbox");
|
||||||
|
|
||||||
|
Setting *slaveSlider = createSetting (Type_Slider, section, "Slider");
|
||||||
|
|
||||||
//set declared values for selected views
|
//set declared values for selected views
|
||||||
masterBoolean->setDeclaredValues (QStringList()
|
masterBoolean->setDeclaredValues (QStringList()
|
||||||
<< "Profile One" << "Profile Two"
|
<< "Profile One" << "Profile Two"
|
||||||
|
@ -203,6 +205,13 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||||
<< (QStringList() << "0.51")
|
<< (QStringList() << "0.51")
|
||||||
<< (QStringList() << "0.68"));
|
<< (QStringList() << "0.68"));
|
||||||
|
|
||||||
|
masterBoolean->addProxy (slaveSlider, QList <QStringList> ()
|
||||||
|
<< (QStringList() << "25")
|
||||||
|
<< (QStringList() << "50")
|
||||||
|
<< (QStringList() << "75")
|
||||||
|
<< (QStringList() << "100")
|
||||||
|
);
|
||||||
|
|
||||||
//settings with proxies are not serialized by default
|
//settings with proxies are not serialized by default
|
||||||
//other settings non-serialized for demo purposes
|
//other settings non-serialized for demo purposes
|
||||||
slaveBoolean->setSerializable (false);
|
slaveBoolean->setSerializable (false);
|
||||||
|
@ -211,6 +220,7 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||||
slaveAlphaSpinbox->setSerializable (false);
|
slaveAlphaSpinbox->setSerializable (false);
|
||||||
slaveIntegerSpinbox->setSerializable (false);
|
slaveIntegerSpinbox->setSerializable (false);
|
||||||
slaveDoubleSpinbox->setSerializable (false);
|
slaveDoubleSpinbox->setSerializable (false);
|
||||||
|
slaveSlider->setSerializable (false);
|
||||||
|
|
||||||
slaveBoolean->setDefaultValues (QStringList()
|
slaveBoolean->setDefaultValues (QStringList()
|
||||||
<< "One" << "Three" << "Five");
|
<< "One" << "Three" << "Five");
|
||||||
|
@ -240,7 +250,13 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
||||||
slaveDoubleSpinbox->setDefaultValue ("0.51");
|
slaveDoubleSpinbox->setDefaultValue ("0.51");
|
||||||
slaveDoubleSpinbox->setSingleStep(0.17);
|
slaveDoubleSpinbox->setSingleStep(0.17);
|
||||||
slaveDoubleSpinbox->setMaximum(4.0);
|
slaveDoubleSpinbox->setMaximum(4.0);
|
||||||
*/
|
|
||||||
|
slaveSlider->setMinimum (0);
|
||||||
|
slaveSlider->setMaximum (100);
|
||||||
|
slaveSlider->setDefaultValue ("75");
|
||||||
|
slaveSlider->setWidgetWidth (100);
|
||||||
|
slaveSlider->setTicksAbove (true);
|
||||||
|
slaveSlider->setTickInterval (25);*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,9 @@
|
||||||
#include <QSpinBox>
|
#include <QSpinBox>
|
||||||
#include <QDoubleSpinBox>
|
#include <QDoubleSpinBox>
|
||||||
#include <QAbstractSpinBox>
|
#include <QAbstractSpinBox>
|
||||||
|
#include <QAbstractSlider>
|
||||||
|
#include <QDial>
|
||||||
|
#include <QSlider>
|
||||||
|
|
||||||
#include "rangeview.hpp"
|
#include "rangeview.hpp"
|
||||||
#include "spinbox.hpp"
|
#include "spinbox.hpp"
|
||||||
|
@ -20,7 +23,21 @@ CSVSettings::RangeView::RangeView (CSMSettings::Setting *setting,
|
||||||
if (isMultiValue())
|
if (isMultiValue())
|
||||||
return;
|
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->setFixedWidth (widgetWidth (setting->widgetWidth()));
|
||||||
mRangeWidget->setObjectName (setting->name());
|
mRangeWidget->setObjectName (setting->name());
|
||||||
|
@ -28,6 +45,48 @@ CSVSettings::RangeView::RangeView (CSMSettings::Setting *setting,
|
||||||
addWidget (mRangeWidget);
|
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)
|
void CSVSettings::RangeView::buildSpinBox (CSMSettings::Setting *setting)
|
||||||
{
|
{
|
||||||
SpinBox *sb = 0;
|
SpinBox *sb = 0;
|
||||||
|
@ -77,13 +136,18 @@ void CSVSettings::RangeView::buildSpinBox (CSMSettings::Setting *setting)
|
||||||
void CSVSettings::RangeView::slotUpdateView (int value)
|
void CSVSettings::RangeView::slotUpdateView (int value)
|
||||||
{
|
{
|
||||||
QString textValue = "";
|
QString textValue = "";
|
||||||
|
QStringList list;
|
||||||
|
|
||||||
if (mRangeType == CSMSettings::Type_SpinBox)
|
switch (mRangeType)
|
||||||
{
|
{
|
||||||
QStringList list =
|
case CSMSettings::Type_SpinBox:
|
||||||
static_cast <SpinBox *> (mRangeWidget)->valueList();
|
list = static_cast <SpinBox *> (mRangeWidget)->valueList();
|
||||||
if (!list.isEmpty())
|
if (!list.isEmpty())
|
||||||
textValue = list.at(value);
|
textValue = list.at(value);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (textValue.isEmpty())
|
if (textValue.isEmpty())
|
||||||
|
@ -92,7 +156,6 @@ void CSVSettings::RangeView::slotUpdateView (int value)
|
||||||
setSelectedValue (textValue, false);
|
setSelectedValue (textValue, false);
|
||||||
|
|
||||||
View::updateView();
|
View::updateView();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVSettings::RangeView::slotUpdateView (double value)
|
void CSVSettings::RangeView::slotUpdateView (double value)
|
||||||
|
@ -119,6 +182,12 @@ void CSVSettings::RangeView::updateView (bool signalUpdate) const
|
||||||
static_cast <QDoubleSpinBox *> (mRangeWidget)->setValue (value.toDouble());
|
static_cast <QDoubleSpinBox *> (mRangeWidget)->setValue (value.toDouble());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case CSMSettings::Type_Slider:
|
||||||
|
case CSMSettings::Type_Dial:
|
||||||
|
mRangeWidget->setProperty ("value", value.toInt());
|
||||||
|
mRangeWidget->setProperty ("sliderPosition", value.toInt());
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace CSVSettings
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
QAbstractSpinBox *mRangeWidget;
|
QWidget *mRangeWidget;
|
||||||
CSMSettings::SettingType mRangeType;
|
CSMSettings::SettingType mRangeType;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -23,6 +23,7 @@ namespace CSVSettings
|
||||||
protected:
|
protected:
|
||||||
void updateView (bool signalUpdate = true) const;
|
void updateView (bool signalUpdate = true) const;
|
||||||
|
|
||||||
|
void buildSlider (CSMSettings::Setting *setting);
|
||||||
void buildSpinBox (CSMSettings::Setting *setting);
|
void buildSpinBox (CSMSettings::Setting *setting);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
Loading…
Reference in a new issue