1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 18:35:20 +00:00

Added workarounds to add QLabel. Add stylesheet option to apply to View's QGroupBox. RangeViews are now right aligned. Added content margins to the page/tab's layout.

This commit is contained in:
cc9cii 2014-09-22 12:19:18 +10:00
parent 02f8f54192
commit 71a3880884
8 changed files with 59 additions and 10 deletions

View File

@ -205,6 +205,16 @@ QString CSMSettings::Setting::section() const
return property (Property_Section).at(0); return property (Property_Section).at(0);
} }
void CSMSettings::Setting::setStyleSheet (const QString &value)
{
setProperty (Property_StyleSheet, value);
}
QString CSMSettings::Setting::styleSheet() const
{
return property (Property_StyleSheet).at(0);
}
void CSMSettings::Setting::setPrefix (const QString &value) void CSMSettings::Setting::setPrefix (const QString &value)
{ {
setProperty (Property_Prefix, value); setProperty (Property_Prefix, value);

View File

@ -83,6 +83,9 @@ namespace CSMSettings
void setSection (const QString &value); void setSection (const QString &value);
QString section() const; QString section() const;
void setStyleSheet (const QString &value);
QString styleSheet() const;
void setPrefix (const QString &value); void setPrefix (const QString &value);
QString prefix() const; QString prefix() const;

View File

@ -36,12 +36,13 @@ namespace CSMSettings
Property_TicksAbove = 20, Property_TicksAbove = 20,
Property_TicksBelow = 21, Property_TicksBelow = 21,
Property_Section = 22, Property_Section = 22,
Property_StyleSheet = 23,
//Stringlists should always be the last items //Stringlists should always be the last items
Property_DefaultValues = 23, Property_DefaultValues = 24,
Property_DeclaredValues = 24, Property_DeclaredValues = 25,
Property_DefinedValues = 25, Property_DefinedValues = 26,
Property_Proxies = 26 Property_Proxies = 27
}; };
///Basic setting widget types. ///Basic setting widget types.
@ -107,7 +108,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", "section", "tick_interval", "ticks_above", "ticks_below", "section", "stylesheet",
"defaults", "declarations", "definitions", "proxies" "defaults", "declarations", "definitions", "proxies"
}; };
@ -137,6 +138,7 @@ namespace CSMSettings
"false", //ticks above "false", //ticks above
"true", //ticks below "true", //ticks below
"", //Section "", //Section
"", //StyleSheet
"", //default values "", //default values
"", //declared values "", //declared values
"", //defined values "", //defined values

View File

@ -66,6 +66,7 @@ void UserSettings::buildSettingModelDefaults()
fog->setSpecialValueText("Enable Fog"); fog->setSpecialValueText("Enable Fog");
fog->setWidgetWidth(15); fog->setWidgetWidth(15);
fog->setColumnSpan (2); fog->setColumnSpan (2);
fog->setStyleSheet ("QGroupBox { border: 0px; }");
fog->setViewLocation(1, 1); fog->setViewLocation(1, 1);
Setting *shadows = createSetting (Type_CheckBox, page, "shadows"); Setting *shadows = createSetting (Type_CheckBox, page, "shadows");
@ -75,6 +76,7 @@ void UserSettings::buildSettingModelDefaults()
shadows->setSpecialValueText("Enable Shadows"); shadows->setSpecialValueText("Enable Shadows");
shadows->setWidgetWidth(15); shadows->setWidgetWidth(15);
//shadows->setColumnSpan (2); //shadows->setColumnSpan (2);
shadows->setStyleSheet ("QGroupBox { border: 0px; }");
shadows->setViewLocation(2, 1); shadows->setViewLocation(2, 1);
Setting *shadows_pssm = createSetting (Type_CheckBox, page, "shadows_pssm"); Setting *shadows_pssm = createSetting (Type_CheckBox, page, "shadows_pssm");
@ -84,6 +86,7 @@ void UserSettings::buildSettingModelDefaults()
shadows_pssm->setSpecialValueText("Enable PSSM Shadows"); shadows_pssm->setSpecialValueText("Enable PSSM Shadows");
shadows_pssm->setWidgetWidth(15); shadows_pssm->setWidgetWidth(15);
//shadows_pssm->setColumnSpan (2); //shadows_pssm->setColumnSpan (2);
shadows_pssm->setStyleSheet ("QGroupBox { border: 0px; }");
shadows_pssm->setViewLocation(3, 1); shadows_pssm->setViewLocation(3, 1);
// FIXME: add option to put label elsewhere (i.e. no frame text) // FIXME: add option to put label elsewhere (i.e. no frame text)
@ -93,7 +96,7 @@ void UserSettings::buildSettingModelDefaults()
numLights->setColumnSpan (2); numLights->setColumnSpan (2);
numLights->setMinimum (0); numLights->setMinimum (0);
numLights->setMaximum (100); // FIXME: not sure what the max value should be numLights->setMaximum (100); // FIXME: not sure what the max value should be
numLights->setWidgetWidth (15); numLights->setWidgetWidth (10);
numLights->setSpecialValueText ("Nothing!"); // text to display when value is 0 numLights->setSpecialValueText ("Nothing!"); // text to display when value is 0
numLights->setViewLocation(4, 1); numLights->setViewLocation(4, 1);
@ -104,6 +107,7 @@ void UserSettings::buildSettingModelDefaults()
simpleWater->setSpecialValueText("Enable Simple Water"); simpleWater->setSpecialValueText("Enable Simple Water");
simpleWater->setWidgetWidth(15); simpleWater->setWidgetWidth(15);
simpleWater->setColumnSpan (2); simpleWater->setColumnSpan (2);
simpleWater->setStyleSheet ("QGroupBox { border: 0px; }");
simpleWater->setViewLocation(2, 4); simpleWater->setViewLocation(2, 4);
Setting *waterEnabled = createSetting (Type_DoubleSpinBox, page, "waterEnabled"); Setting *waterEnabled = createSetting (Type_DoubleSpinBox, page, "waterEnabled");
@ -112,7 +116,7 @@ void UserSettings::buildSettingModelDefaults()
//waterEnabled->setColumnSpan (2); //waterEnabled->setColumnSpan (2);
waterEnabled->setMinimum (0); waterEnabled->setMinimum (0);
waterEnabled->setMaximum (100.00); // FIXME: not sure what the max value should be waterEnabled->setMaximum (100.00); // FIXME: not sure what the max value should be
waterEnabled->setWidgetWidth (15); waterEnabled->setWidgetWidth (10);
waterEnabled->setViewLocation(3, 4); waterEnabled->setViewLocation(3, 4);
Setting *waterLevel = createSetting (Type_DoubleSpinBox, page, "waterLevel"); Setting *waterLevel = createSetting (Type_DoubleSpinBox, page, "waterLevel");
@ -121,7 +125,7 @@ void UserSettings::buildSettingModelDefaults()
//waterLevel->setColumnSpan (2); //waterLevel->setColumnSpan (2);
waterLevel->setMinimum (0); waterLevel->setMinimum (0);
waterLevel->setMaximum (100.00); // FIXME: not sure what the max value should be waterLevel->setMaximum (100.00); // FIXME: not sure what the max value should be
waterLevel->setWidgetWidth (15); waterLevel->setWidgetWidth (10);
waterLevel->setViewLocation(4, 4); waterLevel->setViewLocation(4, 4);
Setting *waterTimer = createSetting (Type_DoubleSpinBox, page, "waterTimer"); Setting *waterTimer = createSetting (Type_DoubleSpinBox, page, "waterTimer");
@ -130,9 +134,17 @@ void UserSettings::buildSettingModelDefaults()
//waterTimer->setColumnSpan (2); //waterTimer->setColumnSpan (2);
waterTimer->setMinimum (0); waterTimer->setMinimum (0);
waterTimer->setMaximum (100.00); // FIXME: not sure what the max value should be waterTimer->setMaximum (100.00); // FIXME: not sure what the max value should be
waterTimer->setWidgetWidth (15); waterTimer->setWidgetWidth (10);
waterTimer->setViewLocation(5, 4); waterTimer->setViewLocation(5, 4);
Setting *text = createSetting (Type_Undefined, page, "text");
text->setSpecialValueText("This is a test"); // hack to place text labels
text->setEditorSetting(false);
text->setSerializable (false);
//text->setColumnSpan (1);
text->setWidgetWidth (15);
text->setViewLocation(5, 1);
#if 0 #if 0
sh::Factory::getInstance().setGlobalSetting ("shadows_pssm", "false"); sh::Factory::getInstance().setGlobalSetting ("shadows_pssm", "false");

View File

@ -14,7 +14,11 @@ CSVSettings::Frame::Frame (bool isVisible, const QString &title,
mVisibleBoxStyle = styleSheet(); mVisibleBoxStyle = styleSheet();
if (!isVisible) if (!isVisible)
{
// must be Page, not a View
setStyleSheet (sInvisibleBoxStyle); setStyleSheet (sInvisibleBoxStyle);
mLayout->setContentsMargins(10, 15, 10, 15);
}
setLayout (mLayout); setLayout (mLayout);
} }

View File

@ -1,4 +1,7 @@
#include "page.hpp" #include "page.hpp"
#include <QLabel>
#include "view.hpp" #include "view.hpp"
#include "booleanview.hpp" #include "booleanview.hpp"
#include "textview.hpp" #include "textview.hpp"
@ -38,7 +41,18 @@ void CSVSettings::Page::setupViews
void CSVSettings::Page::addView (CSMSettings::Setting *setting) void CSVSettings::Page::addView (CSMSettings::Setting *setting)
{ {
if (setting->viewType() == ViewType_Undefined) if (setting->viewType() == ViewType_Undefined)
return; {
if(setting->specialValueText() != "")
{
// hack to put a label
addWidget(new QLabel(setting->specialValueText()),
setting->viewRow(), setting->viewColumn(),
setting->rowSpan(), setting->columnSpan());
return;
}
else
return;
}
View *view = mViewFactories[setting->viewType()]->createView(setting, this); View *view = mViewFactories[setting->viewType()]->createView(setting, this);

View File

@ -127,6 +127,7 @@ void CSVSettings::RangeView::buildSpinBox (CSMSettings::Setting *setting)
mRangeWidget->setProperty ("prefix", setting->prefix()); mRangeWidget->setProperty ("prefix", setting->prefix());
mRangeWidget->setProperty ("suffix", setting->suffix()); mRangeWidget->setProperty ("suffix", setting->suffix());
mRangeWidget->setProperty ("wrapping", setting->wrapping()); mRangeWidget->setProperty ("wrapping", setting->wrapping());
dynamic_cast<QAbstractSpinBox *> (mRangeWidget)->setAlignment(Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter);
} }

View File

@ -22,6 +22,9 @@ CSVSettings::View::View(CSMSettings::Setting *setting,
setObjectName (setting->name()); setObjectName (setting->name());
buildView(); buildView();
buildModel (setting); buildModel (setting);
// apply stylesheet to view's frame if exists
if(setting->styleSheet() != "")
Frame::setStyleSheet (setting->styleSheet());
} }
void CSVSettings::View::buildModel (const CSMSettings::Setting *setting) void CSVSettings::View::buildModel (const CSMSettings::Setting *setting)