Commit 4ca99877 authored by SfietKonstantin's avatar SfietKonstantin

Merge pull request #2 from SfietKonstantin/devel

Added support for C++ theming components
parents 5a1e772b e9073375
*.pro.user
*.pyc
...@@ -51,11 +51,11 @@ Item { ...@@ -51,11 +51,11 @@ Item {
anchors.centerIn: parent anchors.centerIn: parent
Button { Button {
property bool isGlacier: Theme.name == "Glacier"
anchors.margins: 20 anchors.margins: 20
text: (Theme.themeName == NemoControls.themes[0]) ? "Set Ugly Theme" text: isGlacier ? "Set Ugly Theme" : "Set Nice Theme"
: "Set Nice Theme" onClicked: isGlacier ? Theme.loadFromFile("ugly.json")
onClicked: NemoControls.setTheme((Theme.themeName == NemoControls.themes[0]) ? NemoControls.themes[1] : Theme.loadFromFile("glacier.json")
: NemoControls.themes[0])
} }
Button { Button {
......
<!DOCTYPE RCC><RCC version="1.0"> <RCC>
<qresource prefix="/"> <qresource prefix="/">
<file>main.qml</file> <file>main.qml</file>
<file>content/AndroidDelegate.qml</file> <file>content/AndroidDelegate.qml</file>
<file>content/ButtonPage.qml</file> <file>content/ButtonPage.qml</file>
...@@ -15,5 +15,5 @@ ...@@ -15,5 +15,5 @@
<file>images/tabs_standard.png</file> <file>images/tabs_standard.png</file>
<file>images/textinput.png</file> <file>images/textinput.png</file>
<file>images/toolbar.png</file> <file>images/toolbar.png</file>
</qresource> </qresource>
</RCC> </RCC>
...@@ -3,17 +3,13 @@ CONFIG += qt plugin ...@@ -3,17 +3,13 @@ CONFIG += qt plugin
QT += qml quick QT += qml quick
TARGET=nemocontrolsplugin TARGET=nemocontrolsplugin
PLUGIN_IMPORT_PATH = QtQuick/Controls/Nemo PLUGIN_IMPORT_PATH = QtQuick/Controls/Nemo
THEME_IMPORT_PATH = QtQuick/Controls/Styles/Nemo/themes
# Added/Reimplemented Controls # Added/Reimplemented Controls
QML_FILES += \ QML_FILES += \
Button.qml Button.qml
# Private files OTHER_FILES += qmldir
QML_FILES += \
private/NemoControls.qml
OTHER_FILES += qmldir \
$$QML_FILES
HEADERS += \ HEADERS += \
qquicknemocontrolsextensionplugin.h \ qquicknemocontrolsextensionplugin.h \
...@@ -29,10 +25,4 @@ qmlfiles.files = $$_PRO_FILE_PWD_/*.qml ...@@ -29,10 +25,4 @@ qmlfiles.files = $$_PRO_FILE_PWD_/*.qml
qmlfiles.files += $$_PRO_FILE_PWD_/qmldir qmlfiles.files += $$_PRO_FILE_PWD_/qmldir
qmlfiles.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH qmlfiles.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH
privatefiles.files = $$_PRO_FILE_PWD_/private/*.qml INSTALLS += target qmlfiles
privatefiles.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH/private
INSTALLS += target privatefiles qmlfiles
#RESOURCES += \
# internal_resources.qrc
<RCC>
<qresource prefix="/QtQuick/Controls/Nemo">
<file>private/NemoControls.qml</file>
</qresource>
</RCC>
...@@ -27,24 +27,6 @@ QQuickNemoControlsExtensionPlugin::QQuickNemoControlsExtensionPlugin(QObject *pa ...@@ -27,24 +27,6 @@ QQuickNemoControlsExtensionPlugin::QQuickNemoControlsExtensionPlugin(QObject *pa
{ {
} }
static QObject *nemo_controls_singletontype_provider(QQmlEngine *engine, QJSEngine */*scriptEngine*/)
{
QObject *ret = 0;
QQmlComponent c(engine,QUrl("/usr/lib/qt5/qml/QtQuick/Controls/Nemo/private/NemoControls.qml"),QQmlComponent::PreferSynchronous);
if (c.status() == QQmlComponent::Ready) {
ret = c.create();
if (!ret) {
qWarning() << "Can't create NemoControls Singleton Object:"<<c.errorString();
}
} else {
qWarning() << "NemoControls Singleton Component not Ready:"<<c.errorString();
}
return ret;
}
static QObject *nemo_hacks_singletontype_provider(QQmlEngine *engine, QJSEngine */*scriptEngine*/) static QObject *nemo_hacks_singletontype_provider(QQmlEngine *engine, QJSEngine */*scriptEngine*/)
{ {
QObject *ret = new Hacks(engine); QObject *ret = new Hacks(engine);
...@@ -54,7 +36,6 @@ static QObject *nemo_hacks_singletontype_provider(QQmlEngine *engine, QJSEngine ...@@ -54,7 +36,6 @@ static QObject *nemo_hacks_singletontype_provider(QQmlEngine *engine, QJSEngine
void QQuickNemoControlsExtensionPlugin::registerTypes(const char *uri) void QQuickNemoControlsExtensionPlugin::registerTypes(const char *uri)
{ {
Q_ASSERT(uri == QLatin1String("QtQuick.Controls.Nemo")); Q_ASSERT(uri == QLatin1String("QtQuick.Controls.Nemo"));
qmlRegisterSingletonType<QObject>(uri, 1, 0, "NemoControls", nemo_controls_singletontype_provider);
qmlRegisterSingletonType<QObject>(uri, 1, 0, "NemoHacks", nemo_hacks_singletontype_provider); qmlRegisterSingletonType<QObject>(uri, 1, 0, "NemoHacks", nemo_hacks_singletontype_provider);
} }
......
...@@ -33,8 +33,8 @@ ButtonStyle { ...@@ -33,8 +33,8 @@ ButtonStyle {
implicitWidth: 240 implicitWidth: 240
implicitHeight: 50 implicitHeight: 50
clip: true clip: true
color: control.primary ? Theme.primaryButton.backgroundColor color: control.primary ? Theme.primaryButton.background
: Theme.button.backgroundColor : Theme.button.background
Image { Image {
id: disabledImg id: disabledImg
anchors.fill: parent anchors.fill: parent
......
...@@ -24,11 +24,11 @@ Component { ...@@ -24,11 +24,11 @@ Component {
Rectangle { Rectangle {
implicitHeight: 16 implicitHeight: 16
implicitWidth: 440 implicitWidth: 440
color: Theme.groove.backgroundColor color: Theme.groove.background
Rectangle { Rectangle {
antialiasing: true antialiasing: true
radius: 1 radius: 1
color: Theme.groove.foregroundColor color: Theme.groove.foreground
height: parent.height height: parent.height
width: parent.width * control.value / control.maximumValue width: parent.width * control.value / control.maximumValue
} }
......
This diff is collapsed.
/*
* Copyright (C) 2013 Lucien Xu <sfietkonstantin@free.fr>
*
* 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.
*/
// This class is autogenerated using themehelper.py
// Any modification done in this file will be overridden
#ifndef NEMOTHEME_H
#define NEMOTHEME_H
#include <QtCore/QObject>
#include <QtCore/QString>
#include "nemothemebutton.h"
#include "nemothemegroove.h"
#include "nemothemetextfield.h"
class NemoTheme: public QObject
{
Q_OBJECT
Q_PROPERTY(QString name READ name NOTIFY nameChanged)
Q_PROPERTY(QString description READ description NOTIFY descriptionChanged)
Q_PROPERTY(NemoThemeButton * button READ button CONSTANT)
Q_PROPERTY(NemoThemeButton * primaryButton READ primaryButton CONSTANT)
Q_PROPERTY(NemoThemeGroove * groove READ groove CONSTANT)
Q_PROPERTY(NemoThemeTextField * textField READ textField CONSTANT)
Q_PROPERTY(QString fontFamily READ fontFamily CONSTANT)
public:
explicit NemoTheme(QObject *parent = 0);
QString name() const;
void setName(const QString &name);
QString description() const;
void setDescription(const QString &description);
NemoThemeButton * button() const;
NemoThemeButton * primaryButton() const;
NemoThemeGroove * groove() const;
NemoThemeTextField * textField() const;
QString fontFamily() const;
public Q_SLOTS:
void loadFromFile(const QString &fileName);
Q_SIGNALS:
void nameChanged();
void descriptionChanged();
private:
QString m_name;
QString m_description;
NemoThemeButton * m_button;
NemoThemeButton * m_primaryButton;
NemoThemeGroove * m_groove;
NemoThemeTextField * m_textField;
QString m_fontFamily;
};
#endif //NEMOTHEME_H
/*
* Copyright (C) 2013 Lucien Xu <sfietkonstantin@free.fr>
*
* 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.
*/
// This class is autogenerated using themehelper.py
// Any modification done in this file will be overridden
#include "nemothemebutton.h"
NemoThemeButton::NemoThemeButton(QObject *parent)
: QObject(parent)
, m_text(new NemoThemeButtonText(this))
, m_pressedGradient(new NemoThemeButtonPressedGradient(this))
{
}
QColor NemoThemeButton::background() const
{
return m_background;
}
void NemoThemeButton::setBackground(const QColor &background)
{
if (m_background != background) {
m_background = background;
emit backgroundChanged();
}
}
NemoThemeButtonText * NemoThemeButton::text() const
{
return m_text;
}
NemoThemeButtonPressedGradient * NemoThemeButton::pressedGradient() const
{
return m_pressedGradient;
}
/*
* Copyright (C) 2013 Lucien Xu <sfietkonstantin@free.fr>
*
* 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.
*/
// This class is autogenerated using themehelper.py
// Any modification done in this file will be overridden
#ifndef NEMOTHEMEBUTTON_H
#define NEMOTHEMEBUTTON_H
#include <QtCore/QObject>
#include <QtGui/QColor>
#include "nemothemebuttontext.h"
#include "nemothemebuttonpressedgradient.h"
class NemoThemeButton: public QObject
{
Q_OBJECT
Q_PROPERTY(QColor background READ background NOTIFY backgroundChanged)
Q_PROPERTY(NemoThemeButtonText * text READ text CONSTANT)
Q_PROPERTY(NemoThemeButtonPressedGradient * pressedGradient READ pressedGradient CONSTANT)
public:
explicit NemoThemeButton(QObject *parent = 0);
QColor background() const;
void setBackground(const QColor &background);
NemoThemeButtonText * text() const;
NemoThemeButtonPressedGradient * pressedGradient() const;
Q_SIGNALS:
void backgroundChanged();
private:
QColor m_background;
NemoThemeButtonText * m_text;
NemoThemeButtonPressedGradient * m_pressedGradient;
};
#endif //NEMOTHEMEBUTTON_H
/*
* Copyright (C) 2013 Lucien Xu <sfietkonstantin@free.fr>
*
* 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.
*/
// This class is autogenerated using themehelper.py
// Any modification done in this file will be overridden
#include "nemothemebuttonpressedgradient.h"
NemoThemeButtonPressedGradient::NemoThemeButtonPressedGradient(QObject *parent)
: QObject(parent)
, m_width(240)
, m_height(240)
, m_center(0.29)
, m_edge(0.5)
{
}
QColor NemoThemeButtonPressedGradient::centerColor() const
{
return m_centerColor;
}
void NemoThemeButtonPressedGradient::setCenterColor(const QColor &centerColor)
{
if (m_centerColor != centerColor) {
m_centerColor = centerColor;
emit centerColorChanged();
}
}
QColor NemoThemeButtonPressedGradient::edgeColor() const
{
return m_edgeColor;
}
void NemoThemeButtonPressedGradient::setEdgeColor(const QColor &edgeColor)
{
if (m_edgeColor != edgeColor) {
m_edgeColor = edgeColor;
emit edgeColorChanged();
}
}
int NemoThemeButtonPressedGradient::width() const
{
return m_width;
}
void NemoThemeButtonPressedGradient::setWidth(int width)
{
if (m_width != width) {
m_width = width;
emit widthChanged();
}
}
int NemoThemeButtonPressedGradient::height() const
{
return m_height;
}
void NemoThemeButtonPressedGradient::setHeight(int height)
{
if (m_height != height) {
m_height = height;
emit heightChanged();
}
}
double NemoThemeButtonPressedGradient::center() const
{
return m_center;
}
void NemoThemeButtonPressedGradient::setCenter(double center)
{
if (m_center != center) {
m_center = center;
emit centerChanged();
}
}
double NemoThemeButtonPressedGradient::edge() const
{
return m_edge;
}
void NemoThemeButtonPressedGradient::setEdge(double edge)
{
if (m_edge != edge) {
m_edge = edge;
emit edgeChanged();
}
}
/*
* Copyright (C) 2013 Lucien Xu <sfietkonstantin@free.fr>
*
* 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.
*/
// This class is autogenerated using themehelper.py
// Any modification done in this file will be overridden
#ifndef NEMOTHEMEBUTTONPRESSEDGRADIENT_H
#define NEMOTHEMEBUTTONPRESSEDGRADIENT_H
#include <QtCore/QObject>
#include <QtGui/QColor>
class NemoThemeButtonPressedGradient: public QObject
{
Q_OBJECT
Q_PROPERTY(QColor centerColor READ centerColor NOTIFY centerColorChanged)
Q_PROPERTY(QColor edgeColor READ edgeColor NOTIFY edgeColorChanged)
Q_PROPERTY(int width READ width NOTIFY widthChanged)
Q_PROPERTY(int height READ height NOTIFY heightChanged)
Q_PROPERTY(double center READ center NOTIFY centerChanged)
Q_PROPERTY(double edge READ edge NOTIFY edgeChanged)
public:
explicit NemoThemeButtonPressedGradient(QObject *parent = 0);
QColor centerColor() const;
void setCenterColor(const QColor &centerColor);
QColor edgeColor() const;
void setEdgeColor(const QColor &edgeColor);
int width() const;
void setWidth(int width);
int height() const;
void setHeight(int height);
double center() const;
void setCenter(double center);
double edge() const;
void setEdge(double edge);
Q_SIGNALS:
void centerColorChanged();
void edgeColorChanged();
void widthChanged();
void heightChanged();
void centerChanged();
void edgeChanged();
private:
QColor m_centerColor;
QColor m_edgeColor;
int m_width;
int m_height;
double m_center;
double m_edge;
};
#endif //NEMOTHEMEBUTTONPRESSEDGRADIENT_H
/*
* Copyright (C) 2013 Lucien Xu <sfietkonstantin@free.fr>
*
* 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.
*/
// This class is autogenerated using themehelper.py
// Any modification done in this file will be overridden
#include "nemothemebuttontext.h"
NemoThemeButtonText::NemoThemeButtonText(QObject *parent)
: QObject(parent)
, m_font(new NemoThemeFont(this))
{
}
QColor NemoThemeButtonText::color() const
{
return m_color;
}
void NemoThemeButtonText::setColor(const QColor &color)
{
if (m_color != color) {
m_color = color;
emit colorChanged();
}
}
NemoThemeFont * NemoThemeButtonText::font() const
{
return m_font;
}
/*
* Copyright (C) 2013 Lucien Xu <sfietkonstantin@free.fr>
*
* 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.
*/
// This class is autogenerated using themehelper.py
// Any modification done in this file will be overridden
#ifndef NEMOTHEMEBUTTONTEXT_H
#define NEMOTHEMEBUTTONTEXT_H
#include <QtCore/QObject>
#include <QtGui/QColor>
#include "nemothemefont.h"
class NemoThemeButtonText: public QObject
{
Q_OBJECT
Q_PROPERTY(QColor color READ color NOTIFY colorChanged)
Q_PROPERTY(NemoThemeFont * font READ font CONSTANT)
public:
explicit NemoThemeButtonText(QObject *parent = 0);
QColor color() const;
void setColor(const QColor &color);
NemoThemeFont * font() const;
Q_SIGNALS:
void colorChanged();
private:
QColor m_color;
NemoThemeFont * m_font;
};
#endif //NEMOTHEMEBUTTONTEXT_H
/* /*
* Copyright (C) 2013 Andrea Bernabei <and.bernabei@gmail.com> * Copyright (C) 2013 Lucien Xu <sfietkonstantin@free.fr>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public * modify it under the terms of the GNU Library General Public
...@@ -17,40 +17,40 @@ ...@@ -17,40 +17,40 @@
* Boston, MA 02110-1301, USA. * Boston, MA 02110-1301, USA.
*/ */
import QtQml 2.1 // This class is autogenerated using themehelper.py
import "../../Styles/Nemo/themes/Theme1.js" as Theme1 // Any modification done in this file will be overridden
import "../../Styles/Nemo/themes/Theme2.js" as Theme2
QtObject { #include "nemothemefont.h"
readonly property var themes: [Theme1.themeName, Theme2.themeName]
//THIS IS WHAT IS RESPONSIBLE FOR THE THEME CHANGE, changing this will change all the rest NemoThemeFont::NemoThemeFont(QObject *parent)
//THEME CONFIG IS THE REFERENCE TO THE .JS FILE HOLDING THE THEME CONFIGS : QObject(parent)
property var currentThemeConfig: Theme1 , m_pointSize(24)
, m_weight(25)
{
}
function setTheme(theme) { int NemoThemeFont::pointSize() const
if (themes.indexOf(theme) >= 0) { {
var newThemeConfig = getThemeConfigOf(theme) return m_pointSize;
if (newThemeConfig !== undefined) { }
currentThemeConfig = newThemeConfig
} else {
console.log("Theme config not handled, the theme was not changed")
}
} else {
console.log("Theme " + theme + " is not handled");
}
}
function getThemeConfigOf(theme) { void NemoThemeFont::setPointSize(int pointSize)
switch (theme) { {
case Theme1.themeName: if (m_pointSize != pointSize) {
return Theme1 m_pointSize = pointSize;
case Theme2.themeName: emit pointSizeChanged();
return Theme2
default:
console.log("There is no theme config for the theme " + theme)
return undefined
}
} }
} }
int NemoThemeFont::weight() const
{
return m_weight;
}
void NemoThemeFont::setWeight(int weight)
{
if (m_weight != weight) {
m_weight = weight;
emit weightChanged();
}
}
/*
* Copyright (C) 2013 Lucien Xu <sfietkonstantin@free.fr>
*
* 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.
*/
// This class is autogenerated using themehelper.py
// Any modification done in this file will be overridden
#ifndef NEMOTHEMEFONT_H
#define NEMOTHEMEFONT_H
#include <QtCore/QObject>
class NemoThemeFont: public QObject
{
Q_OBJECT
Q_PROPERTY(int pointSize READ pointSize NOTIFY pointSizeChanged)
Q_PROPERTY(int weight READ weight NOTIFY weightChanged)
public:
explicit NemoThemeFont(QObject *parent = 0);
int pointSize() const;
void setPointSize(int pointSize);
int weight() const;
void setWeight(int weight);
Q_SIGNALS:
void pointSizeChanged();
void weightChanged();
private:
int m_pointSize;
int m_weight;
};
#endif //NEMOTHEMEFONT_H
/*
* Copyright (C) 2013 Lucien Xu <sfietkonstantin@free.fr>
*
* 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.
*/
// This class is autogenerated using themehelper.py
// Any modification done in this file will be overridden
#include "nemothemegroove.h"
NemoThemeGroove::NemoThemeGroove(QObject *parent)
: QObject(parent)
{
}
QColor NemoThemeGroove::background() const
{
return m_background;
}
void NemoThemeGroove::setBackground(const QColor &background)
{
if (m_background != background) {
m_background = background;
emit backgroundChanged();
}
}
QColor NemoThemeGroove::foreground() const
{
return m_foreground;
}
void NemoThemeGroove::setForeground(const QColor &foreground)
{
if (m_foreground != foreground) {
m_foreground = foreground;
emit foregroundChanged();
}
}
/*
* Copyright (C) 2013 Lucien Xu <sfietkonstantin@free.fr>
*
* 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.
*/
// This class is autogenerated using themehelper.py
// Any modification done in this file will be overridden
#ifndef NEMOTHEMEGROOVE_H
#define NEMOTHEMEGROOVE_H
#include <QtCore/QObject>
#include <QtGui/QColor>
class NemoThemeGroove: public QObject
{
Q_OBJECT
Q_PROPERTY(QColor background READ background NOTIFY backgroundChanged)
Q_PROPERTY(QColor foreground READ foreground NOTIFY foregroundChanged)
public:
explicit NemoThemeGroove(QObject *parent = 0);
QColor background() const;
void setBackground(const QColor &background);
QColor foreground() const;
void setForeground(const QColor &foreground);
Q_SIGNALS:
void backgroundChanged();
void foregroundChanged();
private:
QColor m_background;
QColor m_foreground;
};
#endif //NEMOTHEMEGROOVE_H
/*
* Copyright (C) 2013 Lucien Xu <sfietkonstantin@free.fr>
*
* 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.
*/
// This class is autogenerated using themehelper.py
// Any modification done in this file will be overridden
#include "nemothemetextfield.h"
NemoThemeTextField::NemoThemeTextField(QObject *parent)
: QObject(parent)
{
}
QColor NemoThemeTextField::selectedTextColor() const
{
return m_selectedTextColor;
}
void NemoThemeTextField::setSelectedTextColor(const QColor &selectedTextColor)
{
if (m_selectedTextColor != selectedTextColor) {
m_selectedTextColor = selectedTextColor;
emit selectedTextColorChanged();
}
}
QColor NemoThemeTextField::selectionColor() const
{
return m_selectionColor;
}
void NemoThemeTextField::setSelectionColor(const QColor &selectionColor)
{
if (m_selectionColor != selectionColor) {
m_selectionColor = selectionColor;
emit selectionColorChanged();
}
}
/*
* Copyright (C) 2013 Lucien Xu <sfietkonstantin@free.fr>
*
* 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.
*/
// This class is autogenerated using themehelper.py
// Any modification done in this file will be overridden
#ifndef NEMOTHEMETEXTFIELD_H
#define NEMOTHEMETEXTFIELD_H
#include <QtCore/QObject>
#include <QtGui/QColor>
class NemoThemeTextField: public QObject
{
Q_OBJECT
Q_PROPERTY(QColor selectedTextColor READ selectedTextColor NOTIFY selectedTextColorChanged)
Q_PROPERTY(QColor selectionColor READ selectionColor NOTIFY selectionColorChanged)
public:
explicit NemoThemeTextField(QObject *parent = 0);
QColor selectedTextColor() const;
void setSelectedTextColor(const QColor &selectedTextColor);
QColor selectionColor() const;
void setSelectionColor(const QColor &selectionColor);
Q_SIGNALS:
void selectedTextColorChanged();
void selectionColorChanged();
private:
QColor m_selectedTextColor;
QColor m_selectionColor;
};
#endif //NEMOTHEMETEXTFIELD_H
/*
* 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,36 +20,32 @@ ...@@ -20,36 +20,32 @@
#include "qquicknemostyleextensionplugin.h" #include "qquicknemostyleextensionplugin.h"
#include <QtQml> #include <QtQml>
#include "autogenerated/nemotheme.h"
QQuickNemoStyleExtensionPlugin::QQuickNemoStyleExtensionPlugin(QObject *parent) : QQuickNemoStyleExtensionPlugin::QQuickNemoStyleExtensionPlugin(QObject *parent) :
QQmlExtensionPlugin(parent) QQmlExtensionPlugin(parent)
{ {
} }
static QObject *nemo_style_singletontype_provider(QQmlEngine *engine, QJSEngine */*scriptEngine*/) static QObject * nemo_theme_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
{ {
QObject *ret = 0; Q_UNUSED(engine)
Q_UNUSED(scriptEngine)
qWarning() << QFileInfo("private/ControlsStyleConfig.qml").absoluteFilePath(); return new NemoTheme();
qWarning() << QDir::currentPath();
QQmlComponent c(engine,QUrl::fromLocalFile("/usr/lib/qt5/qml/QtQuick/Controls/Styles/Nemo/private/ControlsStyleConfig.qml"),QQmlComponent::PreferSynchronous);
if (c.status() == QQmlComponent::Ready) {
ret = c.create();
if (!ret) {
qWarning() << "Can't create Controls Style Config Singleton Object:"<<c.errorString();
}
} else {
qWarning() << "Controls Style Config Component not Ready:"<<c.errorString();
}
return ret;
} }
void QQuickNemoStyleExtensionPlugin::registerTypes(const char *uri) void QQuickNemoStyleExtensionPlugin::registerTypes(const char *uri)
{ {
Q_ASSERT(uri == QLatin1String("QtQuick.Controls.Styles.Nemo")); Q_ASSERT(uri == QLatin1String("QtQuick.Controls.Styles.Nemo"));
qmlRegisterSingletonType<QObject>(uri,1,0,"Theme",nemo_style_singletontype_provider); QString reason = QString("Cannot be created");
qmlRegisterUncreatableType<NemoTheme>(uri, 1, 0, "NemoTheme", reason);
qmlRegisterUncreatableType<NemoThemeButton>(uri, 1, 0, "NemoThemeButton", reason);
qmlRegisterUncreatableType<NemoThemeButtonPressedGradient>(uri, 1, 0, "NemoThemeButtonPressedGradient", reason);
qmlRegisterUncreatableType<NemoThemeButtonText>(uri, 1, 0, "NemoThemeButtonText", reason);
qmlRegisterUncreatableType<NemoThemeFont>(uri, 1, 0, "NemoThemeFont", reason);
qmlRegisterUncreatableType<NemoThemeGroove>(uri, 1, 0, "NemoThemeGroove", reason);
qmlRegisterUncreatableType<NemoThemeTextField>(uri, 1, 0, "NemoThemeTextField", reason);
qmlRegisterSingletonType<QObject>(uri, 1, 0, "Theme", nemo_theme_provider);
} }
void QQuickNemoStyleExtensionPlugin::initializeEngine(QQmlEngine *engine, const char *uri) void QQuickNemoStyleExtensionPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
......
...@@ -23,6 +23,9 @@ ...@@ -23,6 +23,9 @@
#include <QtQml/QQmlExtensionPlugin> #include <QtQml/QQmlExtensionPlugin>
class QQmlEngine;
class QJSEngine;
class NemoThemeGlobal;
class QQuickNemoStyleExtensionPlugin : public QQmlExtensionPlugin class QQuickNemoStyleExtensionPlugin : public QQmlExtensionPlugin
{ {
Q_OBJECT Q_OBJECT
......
...@@ -28,10 +28,6 @@ QML_FILES = \ ...@@ -28,10 +28,6 @@ QML_FILES = \
ToolBarStyle.qml \ ToolBarStyle.qml \
ToolButtonStyle.qml ToolButtonStyle.qml
# Private files
QML_FILES += \
private/ControlsStyleConfig.qml
# Images # Images
#QML_FILES += \ #QML_FILES += \
# images/480x854/*.png # images/480x854/*.png
...@@ -64,6 +60,8 @@ QML_FILES += \ ...@@ -64,6 +60,8 @@ QML_FILES += \
OTHER_FILES += qmldir \ OTHER_FILES += qmldir \
themes/Theme1.js \ themes/Theme1.js \
themes/Theme2.js \ themes/Theme2.js \
themes/glacier.json \
themes/ugly.json \
$$QML_FILES $$QML_FILES
target.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH target.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH
...@@ -72,23 +70,33 @@ qmlfiles.files = $$_PRO_FILE_PWD_/*.qml ...@@ -72,23 +70,33 @@ qmlfiles.files = $$_PRO_FILE_PWD_/*.qml
qmlfiles.files += $$_PRO_FILE_PWD_/qmldir qmlfiles.files += $$_PRO_FILE_PWD_/qmldir
qmlfiles.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH qmlfiles.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH
privatefiles.files = $$_PRO_FILE_PWD_/private/*.qml themes.files = $$_PRO_FILE_PWD_/themes/*.json
privatefiles.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH/private
themes.files = $$_PRO_FILE_PWD_/themes/*.js
themes.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH/themes themes.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH/themes
images.files = $$_PRO_FILE_PWD_/images images.files = $$_PRO_FILE_PWD_/images
images.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH images.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH
HEADERS += \ HEADERS += \
qquicknemostyleextensionplugin.h qquicknemostyleextensionplugin.h \
autogenerated/nemotheme.h \
autogenerated/nemothemebutton.h \
autogenerated/nemothemebuttonpressedgradient.h \
autogenerated/nemothemebuttontext.h \
autogenerated/nemothemefont.h \
autogenerated/nemothemegroove.h \
autogenerated/nemothemetextfield.h
SOURCES += \ SOURCES += \
qquicknemostyleextensionplugin.cpp qquicknemostyleextensionplugin.cpp \
autogenerated/nemotheme.cpp \
INSTALLS += target images qmlfiles themes privatefiles autogenerated/nemothemebutton.cpp \
autogenerated/nemothemebuttonpressedgradient.cpp \
# RESOURCES += \ autogenerated/nemothemebuttontext.cpp \
# rsc.qrc autogenerated/nemothemefont.cpp \
autogenerated/nemothemegroove.cpp \
autogenerated/nemothemetextfield.cpp
INSTALLS += target images qmlfiles themes
DEFINES += 'THEME_DIR=\'\"$$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH/themes"\''
{
"name": "Glacier",
"description": "Glacier theme",
"defines": {
"accentColor": "#0091e5",
"fillColor": "#474747",
"fillColorDark": "#313131"
},
"styles": {
"button": {
"background": "fillColor",
"text": {
"color": "white"
},
"pressedGradient": {
"centerColor": "accentColor",
"edgeColor": "transparent"
}
},
"primaryButton": {
"background": "accentColor",
"text": {
"color": "white",
"font": {
"weight": 63
}
},
"pressedGradient": {
"centerColor": "white",
"edgeColor": "accentColor"
}
},
"groove": {
"foreground": "accentColor",
"background": "fillColorDark"
},
"textField": {
"selectedTextColor": "#ffffff",
"selectionColor": "#0091e5"
}
}
}
{
"name": "Ugly",
"description": "Ugly test theme",
"defines": {
"accentColor": "#FF7F00",
"fillColor": "#474747",
"fillColorDark": "#202020"
},
"styles": {
"button": {
"background": "fillColor",
"text": {
"color": "blue"
},
"pressedGradient": {
"centerColor": "accentColor",
"edgeColor": "transparent"
}
},
"primaryButton": {
"background": "accentColor",
"text": {
"color": "blue",
"font": {
"weight": 63
}
},
"pressedGradient": {
"centerColor": "white",
"edgeColor": "accentColor"
}
},
"groove": {
"foreground": "accentColor",
"background": "fillColorDark"
},
"textField": {
"selectedTextColor": "#ffffff",
"selectionColor": "#0091e5"
}
}
}
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
This diff is collapsed.
{
"components": [
{
"name": "Button",
"properties": [
{
"name": "background",
"type": "QColor"
},
{
"name": "text",
"object": "ButtonText"
},
{
"name": "pressedGradient",
"object": "ButtonPressedGradient"
}
]
},
{
"name": "Groove",
"properties": [
{
"name": "background",
"type": "QColor"
},
{
"name": "foreground",
"type": "QColor"
}
]
},
{
"name": "TextField",
"properties": [
{
"name": "selectedTextColor",
"type": "QColor"
},
{
"name": "selectionColor",
"type": "QColor"
}
]
},
{
"name": "ButtonPressedGradient",
"properties": [
{
"name": "centerColor",
"type": "QColor"
},
{
"name": "edgeColor",
"type": "QColor"
},
{
"name": "width",
"type": "int",
"default": 240
},
{
"name": "height",
"type": "int",
"default": 240
},
{
"name": "center",
"type": "double",
"default": 0.29
},
{
"name": "edge",
"type": "double",
"default": 0.5
}
]
},
{
"name": "ButtonText",
"properties": [
{
"name": "color",
"type": "QColor"
},
{
"name": "font",
"object": "Font"
}
]
},
{
"name": "Font",
"properties": [
{
"name": "pointSize",
"type": "int",
"default": 24
},
{
"name": "weight",
"type": "int",
"default": 25
}
]
},
],
"properties": [
{
"name": "button",
"object": "Button"
},
{
"name": "primaryButton",
"object": "Button"
},
{
"name": "groove",
"object": "Groove"
},
{
"name": "textField",
"object": "TextField"
}
],
"font": "/usr/share/fonts/google-opensans/OpenSans-Regular.ttf"
}
# Copyright (C) 2013 Jolla Ltd. <chris.adams@jollamobile.com>
#
# 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."
def includeGuard(name):
return name.replace("_", "").upper() + "_H"
def upperCamelCase(name):
camelCased = camelCase(split(name))
return camelCased[0].upper() + camelCased[1:]
def camelCase(name):
splitted = split(name)
newSplitted = []
for splittedWord in splitted:
splittedWord = splittedWord.lower()
splittedWord = splittedWord[0].upper() + splittedWord[1:]
newSplitted.append(splittedWord)
camelCase = "".join(newSplitted)
camelCase = camelCase[0].lower() + camelCase[1:]
return camelCase
def split(name):
return name.split("_")
def addSpaces(string, size):
spacesToAdd = max(size - len(string), 0)
return string + (" " * spacesToAdd)
#!/usr/bin/python
# 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."
# 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 classgenerator
import argparse
def generate(descriptionFile):
# First, we try to open JSON description file
try:
f = open(descriptionFile)
except:
print "Failed to open " + descriptionFile
return
data = json.load(f)
classgenerator.generate(data, True)
for componentData in data["components"]:
classgenerator.generate(componentData)
# Main
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Theme helper')
parser.add_argument('description_file', metavar='description_file', type=str,
help="""Input description file (JSON)""")
args = parser.parse_args()
description_file = args.description_file
generate(description_file)
\ No newline at end of file
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