Commit e9073375 authored by Lucien XU's avatar Lucien XU

Comments and cleanups

parent aafd0897
...@@ -56,10 +56,6 @@ Item { ...@@ -56,10 +56,6 @@ Item {
text: isGlacier ? "Set Ugly Theme" : "Set Nice Theme" text: isGlacier ? "Set Ugly Theme" : "Set Nice Theme"
onClicked: isGlacier ? Theme.loadFromFile("ugly.json") onClicked: isGlacier ? Theme.loadFromFile("ugly.json")
: Theme.loadFromFile("glacier.json") : Theme.loadFromFile("glacier.json")
// NemoControls.setTheme((Theme.themeName == NemoControls.themes[0]) ? NemoControls.themes[1]
// : NemoControls.themes[0])
} }
Button { Button {
......
...@@ -58,7 +58,7 @@ QString NemoTheme::name() const ...@@ -58,7 +58,7 @@ QString NemoTheme::name() const
return m_name; return m_name;
} }
void NemoTheme::setName(QString name) void NemoTheme::setName(const QString &name)
{ {
if (m_name != name) { if (m_name != name) {
m_name = name; m_name = name;
...@@ -71,7 +71,7 @@ QString NemoTheme::description() const ...@@ -71,7 +71,7 @@ QString NemoTheme::description() const
return m_description; return m_description;
} }
void NemoTheme::setDescription(QString description) void NemoTheme::setDescription(const QString &description)
{ {
if (m_description != description) { if (m_description != description) {
m_description = description; m_description = description;
...@@ -109,9 +109,9 @@ static inline QJsonValue jsonValue(const QJsonObject &object, const QString &key ...@@ -109,9 +109,9 @@ static inline QJsonValue jsonValue(const QJsonObject &object, const QString &key
{ {
if (!object.contains(key)) { if (!object.contains(key)) {
if (objectName.isEmpty()) { if (objectName.isEmpty()) {
qWarning() << "W" << "Root JSON object do not have value" << key; qWarning() << "W" << "Root JSON object does not have value" << key;
} else { } else {
qWarning() << "W" << "JSON Object" << objectName << "do not have value" << key; qWarning() << "W" << "JSON Object" << objectName << "does not have value" << key;
} }
return QJsonValue(); return QJsonValue();
} }
...@@ -137,7 +137,9 @@ static inline QColor jsonToColor(const QJsonValue &value, ...@@ -137,7 +137,9 @@ static inline QColor jsonToColor(const QJsonValue &value,
color = defines.value(color).toString(); color = defines.value(color).toString();
} }
if (!QColor::isValidColor(color)) { // We need to skip the warning caused by a null value,
// so we check if the color is not empty
if (!QColor::isValidColor(color) && !color.isEmpty()) {
qWarning() << "W" << color << "is not a valid color"; qWarning() << "W" << color << "is not a valid color";
return QColor(); return QColor();
} }
......
...@@ -42,9 +42,9 @@ class NemoTheme: public QObject ...@@ -42,9 +42,9 @@ class NemoTheme: public QObject
public: public:
explicit NemoTheme(QObject *parent = 0); explicit NemoTheme(QObject *parent = 0);
QString name() const; QString name() const;
void setName(QString name); void setName(const QString &name);
QString description() const; QString description() const;
void setDescription(QString description); void setDescription(const QString &description);
NemoThemeButton * button() const; NemoThemeButton * button() const;
NemoThemeButton * primaryButton() const; NemoThemeButton * primaryButton() const;
NemoThemeGroove * groove() const; NemoThemeGroove * groove() const;
......
...@@ -34,7 +34,7 @@ QColor NemoThemeButton::background() const ...@@ -34,7 +34,7 @@ QColor NemoThemeButton::background() const
return m_background; return m_background;
} }
void NemoThemeButton::setBackground(QColor background) void NemoThemeButton::setBackground(const QColor &background)
{ {
if (m_background != background) { if (m_background != background) {
m_background = background; m_background = background;
......
...@@ -37,7 +37,7 @@ class NemoThemeButton: public QObject ...@@ -37,7 +37,7 @@ class NemoThemeButton: public QObject
public: public:
explicit NemoThemeButton(QObject *parent = 0); explicit NemoThemeButton(QObject *parent = 0);
QColor background() const; QColor background() const;
void setBackground(QColor background); void setBackground(const QColor &background);
NemoThemeButtonText * text() const; NemoThemeButtonText * text() const;
NemoThemeButtonPressedGradient * pressedGradient() const; NemoThemeButtonPressedGradient * pressedGradient() const;
Q_SIGNALS: Q_SIGNALS:
......
...@@ -36,7 +36,7 @@ QColor NemoThemeButtonPressedGradient::centerColor() const ...@@ -36,7 +36,7 @@ QColor NemoThemeButtonPressedGradient::centerColor() const
return m_centerColor; return m_centerColor;
} }
void NemoThemeButtonPressedGradient::setCenterColor(QColor centerColor) void NemoThemeButtonPressedGradient::setCenterColor(const QColor &centerColor)
{ {
if (m_centerColor != centerColor) { if (m_centerColor != centerColor) {
m_centerColor = centerColor; m_centerColor = centerColor;
...@@ -49,7 +49,7 @@ QColor NemoThemeButtonPressedGradient::edgeColor() const ...@@ -49,7 +49,7 @@ QColor NemoThemeButtonPressedGradient::edgeColor() const
return m_edgeColor; return m_edgeColor;
} }
void NemoThemeButtonPressedGradient::setEdgeColor(QColor edgeColor) void NemoThemeButtonPressedGradient::setEdgeColor(const QColor &edgeColor)
{ {
if (m_edgeColor != edgeColor) { if (m_edgeColor != edgeColor) {
m_edgeColor = edgeColor; m_edgeColor = edgeColor;
...@@ -62,7 +62,7 @@ int NemoThemeButtonPressedGradient::width() const ...@@ -62,7 +62,7 @@ int NemoThemeButtonPressedGradient::width() const
return m_width; return m_width;
} }
void NemoThemeButtonPressedGradient::setWidth(const int &width) void NemoThemeButtonPressedGradient::setWidth(int width)
{ {
if (m_width != width) { if (m_width != width) {
m_width = width; m_width = width;
...@@ -75,7 +75,7 @@ int NemoThemeButtonPressedGradient::height() const ...@@ -75,7 +75,7 @@ int NemoThemeButtonPressedGradient::height() const
return m_height; return m_height;
} }
void NemoThemeButtonPressedGradient::setHeight(const int &height) void NemoThemeButtonPressedGradient::setHeight(int height)
{ {
if (m_height != height) { if (m_height != height) {
m_height = height; m_height = height;
...@@ -88,7 +88,7 @@ double NemoThemeButtonPressedGradient::center() const ...@@ -88,7 +88,7 @@ double NemoThemeButtonPressedGradient::center() const
return m_center; return m_center;
} }
void NemoThemeButtonPressedGradient::setCenter(const double &center) void NemoThemeButtonPressedGradient::setCenter(double center)
{ {
if (m_center != center) { if (m_center != center) {
m_center = center; m_center = center;
...@@ -101,7 +101,7 @@ double NemoThemeButtonPressedGradient::edge() const ...@@ -101,7 +101,7 @@ double NemoThemeButtonPressedGradient::edge() const
return m_edge; return m_edge;
} }
void NemoThemeButtonPressedGradient::setEdge(const double &edge) void NemoThemeButtonPressedGradient::setEdge(double edge)
{ {
if (m_edge != edge) { if (m_edge != edge) {
m_edge = edge; m_edge = edge;
......
...@@ -38,17 +38,17 @@ class NemoThemeButtonPressedGradient: public QObject ...@@ -38,17 +38,17 @@ class NemoThemeButtonPressedGradient: public QObject
public: public:
explicit NemoThemeButtonPressedGradient(QObject *parent = 0); explicit NemoThemeButtonPressedGradient(QObject *parent = 0);
QColor centerColor() const; QColor centerColor() const;
void setCenterColor(QColor centerColor); void setCenterColor(const QColor &centerColor);
QColor edgeColor() const; QColor edgeColor() const;
void setEdgeColor(QColor edgeColor); void setEdgeColor(const QColor &edgeColor);
int width() const; int width() const;
void setWidth(const int &width); void setWidth(int width);
int height() const; int height() const;
void setHeight(const int &height); void setHeight(int height);
double center() const; double center() const;
void setCenter(const double &center); void setCenter(double center);
double edge() const; double edge() const;
void setEdge(const double &edge); void setEdge(double edge);
Q_SIGNALS: Q_SIGNALS:
void centerColorChanged(); void centerColorChanged();
void edgeColorChanged(); void edgeColorChanged();
......
...@@ -33,7 +33,7 @@ QColor NemoThemeButtonText::color() const ...@@ -33,7 +33,7 @@ QColor NemoThemeButtonText::color() const
return m_color; return m_color;
} }
void NemoThemeButtonText::setColor(QColor color) void NemoThemeButtonText::setColor(const QColor &color)
{ {
if (m_color != color) { if (m_color != color) {
m_color = color; m_color = color;
......
...@@ -35,7 +35,7 @@ class NemoThemeButtonText: public QObject ...@@ -35,7 +35,7 @@ class NemoThemeButtonText: public QObject
public: public:
explicit NemoThemeButtonText(QObject *parent = 0); explicit NemoThemeButtonText(QObject *parent = 0);
QColor color() const; QColor color() const;
void setColor(QColor color); void setColor(const QColor &color);
NemoThemeFont * font() const; NemoThemeFont * font() const;
Q_SIGNALS: Q_SIGNALS:
void colorChanged(); void colorChanged();
......
...@@ -34,7 +34,7 @@ int NemoThemeFont::pointSize() const ...@@ -34,7 +34,7 @@ int NemoThemeFont::pointSize() const
return m_pointSize; return m_pointSize;
} }
void NemoThemeFont::setPointSize(const int &pointSize) void NemoThemeFont::setPointSize(int pointSize)
{ {
if (m_pointSize != pointSize) { if (m_pointSize != pointSize) {
m_pointSize = pointSize; m_pointSize = pointSize;
...@@ -47,7 +47,7 @@ int NemoThemeFont::weight() const ...@@ -47,7 +47,7 @@ int NemoThemeFont::weight() const
return m_weight; return m_weight;
} }
void NemoThemeFont::setWeight(const int &weight) void NemoThemeFont::setWeight(int weight)
{ {
if (m_weight != weight) { if (m_weight != weight) {
m_weight = weight; m_weight = weight;
......
...@@ -33,9 +33,9 @@ class NemoThemeFont: public QObject ...@@ -33,9 +33,9 @@ class NemoThemeFont: public QObject
public: public:
explicit NemoThemeFont(QObject *parent = 0); explicit NemoThemeFont(QObject *parent = 0);
int pointSize() const; int pointSize() const;
void setPointSize(const int &pointSize); void setPointSize(int pointSize);
int weight() const; int weight() const;
void setWeight(const int &weight); void setWeight(int weight);
Q_SIGNALS: Q_SIGNALS:
void pointSizeChanged(); void pointSizeChanged();
void weightChanged(); void weightChanged();
......
...@@ -32,7 +32,7 @@ QColor NemoThemeGroove::background() const ...@@ -32,7 +32,7 @@ QColor NemoThemeGroove::background() const
return m_background; return m_background;
} }
void NemoThemeGroove::setBackground(QColor background) void NemoThemeGroove::setBackground(const QColor &background)
{ {
if (m_background != background) { if (m_background != background) {
m_background = background; m_background = background;
...@@ -45,7 +45,7 @@ QColor NemoThemeGroove::foreground() const ...@@ -45,7 +45,7 @@ QColor NemoThemeGroove::foreground() const
return m_foreground; return m_foreground;
} }
void NemoThemeGroove::setForeground(QColor foreground) void NemoThemeGroove::setForeground(const QColor &foreground)
{ {
if (m_foreground != foreground) { if (m_foreground != foreground) {
m_foreground = foreground; m_foreground = foreground;
......
...@@ -34,9 +34,9 @@ class NemoThemeGroove: public QObject ...@@ -34,9 +34,9 @@ class NemoThemeGroove: public QObject
public: public:
explicit NemoThemeGroove(QObject *parent = 0); explicit NemoThemeGroove(QObject *parent = 0);
QColor background() const; QColor background() const;
void setBackground(QColor background); void setBackground(const QColor &background);
QColor foreground() const; QColor foreground() const;
void setForeground(QColor foreground); void setForeground(const QColor &foreground);
Q_SIGNALS: Q_SIGNALS:
void backgroundChanged(); void backgroundChanged();
void foregroundChanged(); void foregroundChanged();
......
...@@ -32,7 +32,7 @@ QColor NemoThemeTextField::selectedTextColor() const ...@@ -32,7 +32,7 @@ QColor NemoThemeTextField::selectedTextColor() const
return m_selectedTextColor; return m_selectedTextColor;
} }
void NemoThemeTextField::setSelectedTextColor(QColor selectedTextColor) void NemoThemeTextField::setSelectedTextColor(const QColor &selectedTextColor)
{ {
if (m_selectedTextColor != selectedTextColor) { if (m_selectedTextColor != selectedTextColor) {
m_selectedTextColor = selectedTextColor; m_selectedTextColor = selectedTextColor;
...@@ -45,7 +45,7 @@ QColor NemoThemeTextField::selectionColor() const ...@@ -45,7 +45,7 @@ QColor NemoThemeTextField::selectionColor() const
return m_selectionColor; return m_selectionColor;
} }
void NemoThemeTextField::setSelectionColor(QColor selectionColor) void NemoThemeTextField::setSelectionColor(const QColor &selectionColor)
{ {
if (m_selectionColor != selectionColor) { if (m_selectionColor != selectionColor) {
m_selectionColor = selectionColor; m_selectionColor = selectionColor;
......
...@@ -34,9 +34,9 @@ class NemoThemeTextField: public QObject ...@@ -34,9 +34,9 @@ class NemoThemeTextField: public QObject
public: public:
explicit NemoThemeTextField(QObject *parent = 0); explicit NemoThemeTextField(QObject *parent = 0);
QColor selectedTextColor() const; QColor selectedTextColor() const;
void setSelectedTextColor(QColor selectedTextColor); void setSelectedTextColor(const QColor &selectedTextColor);
QColor selectionColor() const; QColor selectionColor() const;
void setSelectionColor(QColor selectionColor); void setSelectionColor(const QColor &selectionColor);
Q_SIGNALS: Q_SIGNALS:
void selectedTextColorChanged(); void selectedTextColorChanged();
void selectionColorChanged(); void selectionColorChanged();
......
/*
* Copyright (C) 2013 Tomasz Olszak <olszak.tomasz@gmail.com>
* Copyright (C) 2013 Andrea Bernabei <and.bernabei@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
import QtQuick 2.1
import QtQuick.Controls.Nemo 1.0
QtObject {
readonly property string fontFamily: fontLoader.name
property QtObject fontLoader: FontLoader {
source: "/usr/share/fonts/google-opensans/OpenSans-Regular.ttf"
}
// The binding updates this var when NemoControls.setTheme succeeds
readonly property var themeConfig: NemoControls.currentThemeConfig
readonly property string themeName: themeConfig.themeName
onThemeNameChanged: console.log("Theme successfully updated to " + themeName)
// ({ }) is QML notation for assigning JS object to a var property
// Automagically updated when themeConfig is updated
property var button :
({
backgroundColor: themeConfig.button.background,
text: {
color: themeConfig.button.text,
font: {
pointSize: 24,
weight: 25 //Font.Light
}
},
pressedGradient: {
width: 240,
height: 240,
center: 0.29,
edge: 0.5,
centerColor: themeConfig.button.pressedGradient.centerColor,
edgeColor: themeConfig.button.pressedGradient.edgeColor
}
})
// Only holds special styling for the primary button, the rest is in button
property var primaryButton:
({
backgroundColor: themeConfig.primaryButton.background,
text: {
font: {
weight: 63 //Font.DemiBold
}
},
pressedGradient: {
centerColor: themeConfig.primaryButton.pressedGradient.centerColor,
edgeColor: themeConfig.primaryButton.pressedGradient.edgeColor
}
})
property var groove:
({
foregroundColor: themeConfig.groove.foreground,
backgroundColor: themeConfig.groove.background,
})
property var textField:
({
selectionColor: themeConfig.textField.selectionColor,
selectedTextColor: themeConfig.textField.selectedTextColor,
})
}
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "qquicknemostyleextensionplugin.h" #include "qquicknemostyleextensionplugin.h"
#include <QtQml> #include <QtQml>
#include "nemotheme.h" #include "autogenerated/nemotheme.h"
QQuickNemoStyleExtensionPlugin::QQuickNemoStyleExtensionPlugin(QObject *parent) : QQuickNemoStyleExtensionPlugin::QQuickNemoStyleExtensionPlugin(QObject *parent) :
QQmlExtensionPlugin(parent) QQmlExtensionPlugin(parent)
......
...@@ -78,23 +78,23 @@ images.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH ...@@ -78,23 +78,23 @@ images.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH
HEADERS += \ HEADERS += \
qquicknemostyleextensionplugin.h \ qquicknemostyleextensionplugin.h \
nemothemebutton.h \ autogenerated/nemotheme.h \
nemothemebuttonpressedgradient.h \ autogenerated/nemothemebutton.h \
nemothemebuttontext.h \ autogenerated/nemothemebuttonpressedgradient.h \
nemothemefont.h \ autogenerated/nemothemebuttontext.h \
nemothemegroove.h \ autogenerated/nemothemefont.h \
nemothemetextfield.h \ autogenerated/nemothemegroove.h \
nemotheme.h autogenerated/nemothemetextfield.h
SOURCES += \ SOURCES += \
qquicknemostyleextensionplugin.cpp \ qquicknemostyleextensionplugin.cpp \
nemothemebutton.cpp \ autogenerated/nemotheme.cpp \
nemothemebuttonpressedgradient.cpp \ autogenerated/nemothemebutton.cpp \
nemothemebuttontext.cpp \ autogenerated/nemothemebuttonpressedgradient.cpp \
nemothemefont.cpp \ autogenerated/nemothemebuttontext.cpp \
nemothemegroove.cpp \ autogenerated/nemothemefont.cpp \
nemothemetextfield.cpp \ autogenerated/nemothemegroove.cpp \
nemotheme.cpp autogenerated/nemothemetextfield.cpp
INSTALLS += target images qmlfiles themes INSTALLS += target images qmlfiles themes
......
How to use the components generator
1. Have python 2 installed (the script don't work with Python 3 yet)
2. Add the components in "components.json"
3. call "./themehelper.py components.json"
4. copy all the generated files to the style folder in src
5. qmlRegisterUncreatableType the new created components in qquicknemostyleextensionplugin.cpp and
adds them in the style.pro file
6. update theme files if needed
...@@ -53,8 +53,11 @@ license = """/* ...@@ -53,8 +53,11 @@ license = """/*
// Any modification done in this file will be overridden // Any modification done in this file will be overridden
""" """
# Used by formatting functions
basicTypes = ["int", "float", "double"] basicTypes = ["int", "float", "double"]
# Formatting functions
def _getType(property): def _getType(property):
if "type" in property: if "type" in property:
return property["type"] return property["type"]
...@@ -64,7 +67,7 @@ def _getType(property): ...@@ -64,7 +67,7 @@ def _getType(property):
def _getArgumentType(property): def _getArgumentType(property):
if "type" in property: if "type" in property:
type = property["type"] type = property["type"]
if type in basicTypes: if type not in basicTypes:
return "const " + type + " &" return "const " + type + " &"
return type + " " return type + " "
if "object" in property: if "object" in property:
...@@ -73,6 +76,8 @@ def _getArgumentType(property): ...@@ -73,6 +76,8 @@ def _getArgumentType(property):
def _getUpper(name): def _getUpper(name):
return name[0].upper() + name[1:] return name[0].upper() + name[1:]
# Generates some basic entries
# (includes, Q_PROPERTY macro, getter or setters etc)
def _getInclude(property): def _getInclude(property):
if "type" in property: if "type" in property:
type = property["type"] type = property["type"]
...@@ -136,9 +141,9 @@ static inline QJsonValue jsonValue(const QJsonObject &object, const QString &key ...@@ -136,9 +141,9 @@ static inline QJsonValue jsonValue(const QJsonObject &object, const QString &key
{ {
if (!object.contains(key)) { if (!object.contains(key)) {
if (objectName.isEmpty()) { if (objectName.isEmpty()) {
qWarning() << "W" << "Root JSON object do not have value" << key; qWarning() << "W" << "Root JSON object does not have value" << key;
} else { } else {
qWarning() << "W" << "JSON Object" << objectName << "do not have value" << key; qWarning() << "W" << "JSON Object" << objectName << "does not have value" << key;
} }
return QJsonValue(); return QJsonValue();
} }
...@@ -164,7 +169,9 @@ static inline QColor jsonToColor(const QJsonValue &value, ...@@ -164,7 +169,9 @@ static inline QColor jsonToColor(const QJsonValue &value,
color = defines.value(color).toString(); color = defines.value(color).toString();
} }
if (!QColor::isValidColor(color)) { // We need to skip the warning caused by a null value,
// so we check if the color is not empty
if (!QColor::isValidColor(color) && !color.isEmpty()) {
qWarning() << "W" << color << "is not a valid color"; qWarning() << "W" << color << "is not a valid color";
return QColor(); return QColor();
} }
...@@ -203,6 +210,7 @@ static inline int jsonToDouble(const QJsonValue &value, ...@@ -203,6 +210,7 @@ static inline int jsonToDouble(const QJsonValue &value,
""" """
# Generate the method that loads from file
source += "void " + name + "::loadFromFile(const QString &fileName)\n" source += "void " + name + "::loadFromFile(const QString &fileName)\n"
source += """{ source += """{
QDir dir (THEME_DIR); QDir dir (THEME_DIR);
...@@ -263,7 +271,8 @@ static inline int jsonToDouble(const QJsonValue &value, ...@@ -263,7 +271,8 @@ static inline int jsonToDouble(const QJsonValue &value,
return; return;
} }
""" """
# We create a map of components # We create a map of components that can be used
# to quickly retrieve a component based on the name
components = {} components = {}
for component in data["components"]: for component in data["components"]:
components[component["name"]] = component["properties"] components[component["name"]] = component["properties"]
...@@ -312,6 +321,10 @@ def _getCasted(property, jsonObject, name, cppObject): ...@@ -312,6 +321,10 @@ def _getCasted(property, jsonObject, name, cppObject):
return data return data
# This method is used to generate the tree of components and set calls
# it will start with a root component property, try to load all properties
# from theme file (and ignore those already defined), and continue
# with children components.
def _getSetObject(jsonObject, cppObject, name, properties, components): def _getSetObject(jsonObject, cppObject, name, properties, components):
data = " // Setting properties for " + name + "\n" data = " // Setting properties for " + name + "\n"
data += " QJsonObject " + jsonObject + _getUpper(name) + " = " + jsonObject data += " QJsonObject " + jsonObject + _getUpper(name) + " = " + jsonObject
......
...@@ -17,6 +17,39 @@ ...@@ -17,6 +17,39 @@
} }
] ]
}, },
{
"name": "Groove",
"properties": [
{
"name": "background",
"type": "QColor"
},
{
"name": "foreground",
"type": "QColor"
}
]
},
{
"name": "TextField",
"properties": [
{
"name": "selectedTextColor",
"type": "QColor"
},
{
"name": "selectionColor",
"type": "QColor"
}
]
},
{ {
"name": "ButtonPressedGradient", "name": "ButtonPressedGradient",
"properties": [ "properties": [
...@@ -78,33 +111,6 @@ ...@@ -78,33 +111,6 @@
} }
] ]
}, },
{
"name": "Groove",
"properties": [
{
"name": "background",
"type": "QColor"
},
{
"name": "foreground",
"type": "QColor"
}
]
},
{
"name": "TextField",
"properties": [
{
"name": "selectedTextColor",
"type": "QColor"
},
{
"name": "selectionColor",
"type": "QColor"
}
]
}
], ],
"properties": [ "properties": [
{ {
......
#!/bin/bash
# Copyright (C) 2013 Lucien Xu <sfietkonstantin@free.fr>
#
# You may use this file under the terms of the BSD license as follows:
#
# "Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# * Neither the name of Nemo Mobile nor the names of its contributors
# may be used to endorse or promote products derived from this
# software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
themehelper.py components.json
\ No newline at end of file
...@@ -28,6 +28,51 @@ ...@@ -28,6 +28,51 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
# Generates components from a JSON description file
#
# This script generates components from a JSON description file.
# The JSON description file have the following organization
# {
# "components": [
# list of components
# ],
# "properties": [ list of properties ],
# "font": "/path/to/some_font.ttf"
# }
#
# The "components" is the list of components that should be generated.
# Each component have a "name", and a list of "properties". A property
# is a list of objects defined this way:
# {
# "name": "someName",
# "type": "some_type",
# ["default": some_value]
# }
# or
# {
# "name": "someName",
# "object": "some_object"
# }
#
# The first variation defines a simple property. "type" field should
# contain the name of either a basic type, like int, or float, or
# a Qt object, like QColor and QString. The optional "default" field
# contains a default value that is embedded in the component.
# Properties with default values don't need to be defined in the
# theme file.
#
# The second variation contains an object definition. Usually, an
# object defines a complex type, that needs several basic types to be
# defined, like a gradient, that needs 2 colors, and maybe a radius.
#
# The "properties" field of the root object behave the same, and
# describes the properties that the Theme object have. Note that
# "name" and "description" are automatically provided by the
# script, and don't need to be defined in the properties.
#
# The last field is the font. It provides the default font that
# is available from the Theme object.
import json import json
import classgenerator import classgenerator
import argparse import argparse
......
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