Commit 13bb333f authored by Lucien XU's avatar Lucien XU

[Bugfix] Bugfixed the generator

The class generator used to provide wrong values for
properties that have a default value. This bugfix
also includes the capability to restore a default
value when switching from a theme providing an
overridden value to a theme providing no value.
Before, since there were no value, the old value
from the old theme was kept.
parent cbcd78ba
This diff is collapsed.
......@@ -70,6 +70,14 @@ void NemoThemeButtonPressedGradient::setWidth(int width)
}
}
void NemoThemeButtonPressedGradient::setWidthDefault()
{
if (m_width != 240) {
m_width = 240;
emit widthChanged();
}
}
int NemoThemeButtonPressedGradient::height() const
{
return m_height;
......@@ -83,6 +91,14 @@ void NemoThemeButtonPressedGradient::setHeight(int height)
}
}
void NemoThemeButtonPressedGradient::setHeightDefault()
{
if (m_height != 240) {
m_height = 240;
emit heightChanged();
}
}
double NemoThemeButtonPressedGradient::center() const
{
return m_center;
......@@ -96,6 +112,14 @@ void NemoThemeButtonPressedGradient::setCenter(double center)
}
}
void NemoThemeButtonPressedGradient::setCenterDefault()
{
if (m_center != 0.29) {
m_center = 0.29;
emit centerChanged();
}
}
double NemoThemeButtonPressedGradient::edge() const
{
return m_edge;
......@@ -108,3 +132,11 @@ void NemoThemeButtonPressedGradient::setEdge(double edge)
emit edgeChanged();
}
}
void NemoThemeButtonPressedGradient::setEdgeDefault()
{
if (m_edge != 0.5) {
m_edge = 0.5;
emit edgeChanged();
}
}
......@@ -43,12 +43,16 @@ public:
void setEdgeColor(const QColor &edgeColor);
int width() const;
void setWidth(int width);
void setWidthDefault();
int height() const;
void setHeight(int height);
void setHeightDefault();
double center() const;
void setCenter(double center);
void setCenterDefault();
double edge() const;
void setEdge(double edge);
void setEdgeDefault();
Q_SIGNALS:
void centerColorChanged();
void edgeColorChanged();
......
......@@ -42,6 +42,14 @@ void NemoThemeFont::setPointSize(int pointSize)
}
}
void NemoThemeFont::setPointSizeDefault()
{
if (m_pointSize != 24) {
m_pointSize = 24;
emit pointSizeChanged();
}
}
int NemoThemeFont::weight() const
{
return m_weight;
......@@ -54,3 +62,11 @@ void NemoThemeFont::setWeight(int weight)
emit weightChanged();
}
}
void NemoThemeFont::setWeightDefault()
{
if (m_weight != 25) {
m_weight = 25;
emit weightChanged();
}
}
......@@ -34,8 +34,10 @@ public:
explicit NemoThemeFont(QObject *parent = 0);
int pointSize() const;
void setPointSize(int pointSize);
void setPointSizeDefault();
int weight() const;
void setWeight(int weight);
void setWeightDefault();
Q_SIGNALS:
void pointSizeChanged();
void weightChanged();
......
......@@ -53,3 +53,11 @@ void NemoThemeLabel::setPointSize(int pointSize)
emit pointSizeChanged();
}
}
void NemoThemeLabel::setPointSizeDefault()
{
if (m_pointSize != 24) {
m_pointSize = 24;
emit pointSizeChanged();
}
}
......@@ -37,6 +37,7 @@ public:
void setColor(const QColor &color);
int pointSize() const;
void setPointSize(int pointSize);
void setPointSizeDefault();
Q_SIGNALS:
void colorChanged();
void pointSizeChanged();
......
......@@ -69,6 +69,14 @@ void NemoThemePageDimmer::setHeight(int height)
}
}
void NemoThemePageDimmer::setHeightDefault()
{
if (m_height != 15) {
m_height = 15;
emit heightChanged();
}
}
double NemoThemePageDimmer::startPosition() const
{
return m_startPosition;
......@@ -82,6 +90,14 @@ void NemoThemePageDimmer::setStartPosition(double startPosition)
}
}
void NemoThemePageDimmer::setStartPositionDefault()
{
if (m_startPosition != 0) {
m_startPosition = 0;
emit startPositionChanged();
}
}
double NemoThemePageDimmer::endPosition() const
{
return m_endPosition;
......@@ -94,3 +110,11 @@ void NemoThemePageDimmer::setEndPosition(double endPosition)
emit endPositionChanged();
}
}
void NemoThemePageDimmer::setEndPositionDefault()
{
if (m_endPosition != 1.0) {
m_endPosition = 1.0;
emit endPositionChanged();
}
}
......@@ -42,10 +42,13 @@ public:
void setEndColor(const QColor &endColor);
int height() const;
void setHeight(int height);
void setHeightDefault();
double startPosition() const;
void setStartPosition(double startPosition);
void setStartPositionDefault();
double endPosition() const;
void setEndPosition(double endPosition);
void setEndPositionDefault();
Q_SIGNALS:
void startColorChanged();
void endColorChanged();
......
......@@ -45,6 +45,14 @@ void NemoThemeSpinner::setRadius(int radius)
}
}
void NemoThemeSpinner::setRadiusDefault()
{
if (m_radius != 32) {
m_radius = 32;
emit radiusChanged();
}
}
QColor NemoThemeSpinner::primaryColor() const
{
return m_primaryColor;
......@@ -84,6 +92,14 @@ void NemoThemeSpinner::setHorizontalSpacing(int horizontalSpacing)
}
}
void NemoThemeSpinner::setHorizontalSpacingDefault()
{
if (m_horizontalSpacing != 15) {
m_horizontalSpacing = 15;
emit horizontalSpacingChanged();
}
}
int NemoThemeSpinner::verticalSpacing() const
{
return m_verticalSpacing;
......@@ -97,6 +113,14 @@ void NemoThemeSpinner::setVerticalSpacing(int verticalSpacing)
}
}
void NemoThemeSpinner::setVerticalSpacingDefault()
{
if (m_verticalSpacing != 15) {
m_verticalSpacing = 15;
emit verticalSpacingChanged();
}
}
int NemoThemeSpinner::initialStateDuration() const
{
return m_initialStateDuration;
......@@ -110,6 +134,14 @@ void NemoThemeSpinner::setInitialStateDuration(int initialStateDuration)
}
}
void NemoThemeSpinner::setInitialStateDurationDefault()
{
if (m_initialStateDuration != 1500) {
m_initialStateDuration = 1500;
emit initialStateDurationChanged();
}
}
int NemoThemeSpinner::transitionDuration() const
{
return m_transitionDuration;
......@@ -122,3 +154,11 @@ void NemoThemeSpinner::setTransitionDuration(int transitionDuration)
emit transitionDurationChanged();
}
}
void NemoThemeSpinner::setTransitionDurationDefault()
{
if (m_transitionDuration != 500) {
m_transitionDuration = 500;
emit transitionDurationChanged();
}
}
......@@ -40,18 +40,23 @@ public:
explicit NemoThemeSpinner(QObject *parent = 0);
int radius() const;
void setRadius(int radius);
void setRadiusDefault();
QColor primaryColor() const;
void setPrimaryColor(const QColor &primaryColor);
QColor secondaryColor() const;
void setSecondaryColor(const QColor &secondaryColor);
int horizontalSpacing() const;
void setHorizontalSpacing(int horizontalSpacing);
void setHorizontalSpacingDefault();
int verticalSpacing() const;
void setVerticalSpacing(int verticalSpacing);
void setVerticalSpacingDefault();
int initialStateDuration() const;
void setInitialStateDuration(int initialStateDuration);
void setInitialStateDurationDefault();
int transitionDuration() const;
void setTransitionDuration(int transitionDuration);
void setTransitionDurationDefault();
Q_SIGNALS:
void radiusChanged();
void primaryColorChanged();
......
......@@ -66,3 +66,11 @@ void NemoThemeTextField::setPointSize(int pointSize)
emit pointSizeChanged();
}
}
void NemoThemeTextField::setPointSizeDefault()
{
if (m_pointSize != 24) {
m_pointSize = 24;
emit pointSizeChanged();
}
}
......@@ -40,6 +40,7 @@ public:
void setSelectionColor(const QColor &selectionColor);
int pointSize() const;
void setPointSize(int pointSize);
void setPointSizeDefault();
Q_SIGNALS:
void selectedTextColorChanged();
void selectionColorChanged();
......
......@@ -38,6 +38,9 @@
"selectedTextColor": "#ffffff",
"selectionColor": "#0091e5"
},
"toolBar": {
"background": "#000000"
},
"window": {
"background": "#000000"
},
......@@ -47,6 +50,17 @@
"startColor": "black",
"endColor": "transparent"
}
},
"spinner": {
"primaryColor": "accentColor",
"secondaryColor": "transparent"
},
"label": {
"color": "#ffffff"
},
"checkbox": {
"back1": "#0091e5",
"back2": "#313131"
}
}
}
......@@ -106,6 +106,10 @@ def _getGetterSetter(property):
if "type" in property:
header += " void set" + _getUpper(propertyName)
header += "(" + _getArgumentType(property) + propertyName + ");\n"
if "default" in property:
header += " void set" + _getUpper(propertyName) + "Default"
header += "();\n"
return header
def _getGetterSetterImpl(name, property):
......@@ -126,6 +130,21 @@ def _getGetterSetterImpl(name, property):
source += " }\n"
source += "}\n"
source += "\n"
if "default" in property:
default = str(property["default"])
if isinstance(property["default"], str) or isinstance(property["default"], unicode):
default = "\"" + default + "\""
source += "void " + name + "::set" + _getUpper(propertyName) + "Default"
source += "()\n"
source += "{\n"
source += " if (m_" + propertyName + " != " + default + ") {\n"
source += " m_" + propertyName + " = " + default + ";\n"
source += " emit " + propertyName + "Changed();\n"
source += " }\n"
source += "}\n"
source += "\n"
return source
def _getSignal(property):
......@@ -292,7 +311,7 @@ def _getCasted(property, jsonObject, name, cppObject):
value = "jsonValue(" + jsonObject + _getUpper(name) + ", \""
value += property["name"] + "\", \"" + name + "\")"
if "default" in property:
value = jsonObject + ".value(\"" + name + "\")"
value = jsonObject + _getUpper(name) + ".value(\"" + property["name"] + "\")"
if type == "QString":
castedValue = "jsonToString(" + value + ", defines)"
......@@ -313,6 +332,8 @@ def _getCasted(property, jsonObject, name, cppObject):
data += property["name"] + "\")) {\n"
data += " " + cppObject + "->set" + _getUpper(property["name"])
data += "(" + castedValue + ");\n"
data += " } else {\n"
data += " " + cppObject + "->set" + _getUpper(property["name"]) + "Default();\n"
data += " }\n"
return data
else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment