Commit aed0a925 authored by Simonas Leleiva's avatar Simonas Leleiva

Merge pull request #13 from locusf/label

[label] Label with example page.
parents b4d6b34c c6d70475
/****************************************************************************************
**
** Copyright (C) 2013 Aleksi Suomalainen <suomalainen.aleksi@gmail.com>
** All rights reserved.
**
** You may use this file under the terms of 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 the author 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 HOLDERS 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.
**
****************************************************************************************/
import QtQuick 2.1
import QtQuick.Controls 1.0 //needed for the Stack attached property
import QtQuick.Controls.Nemo 1.0
import QtQuick.Controls.Styles.Nemo 1.0
Page {
id: root
tools: ToolBarLayoutExample { title: "Label" }
Column {
spacing: 40
anchors.centerIn: parent
Label {
text: "Test label"
color: "white"
}
}
}
...@@ -91,6 +91,10 @@ ApplicationWindow { ...@@ -91,6 +91,10 @@ ApplicationWindow {
title: "Spinner" title: "Spinner"
page: "content/SpinnerPage.qml" page: "content/SpinnerPage.qml"
} }
ListElement {
title: "Labels"
page: "content/LabelPage.qml"
}
} }
......
...@@ -18,5 +18,6 @@ ...@@ -18,5 +18,6 @@
<file>content/LiveCoding.qml</file> <file>content/LiveCoding.qml</file>
<file>content/ToolBarLayoutExample.qml</file> <file>content/ToolBarLayoutExample.qml</file>
<file>content/SpinnerPage.qml</file> <file>content/SpinnerPage.qml</file>
<file>content/LabelPage.qml</file>
</qresource> </qresource>
</RCC> </RCC>
...@@ -19,7 +19,8 @@ OTHER_FILES += \ ...@@ -19,7 +19,8 @@ OTHER_FILES += \
content/TextInputPage.qml \ content/TextInputPage.qml \
content/LiveCoding.qml \ content/LiveCoding.qml \
content/ToolBarLayoutExample.qml \ content/ToolBarLayoutExample.qml \
content/SpinnerPage.qml content/SpinnerPage.qml \
content/LabelPage.qml
RESOURCES += \ RESOURCES += \
resources.qrc resources.qrc
......
/****************************************************************************************
**
** Copyright (C) 2013 Aleksi Suomalainen <suomalainen.aleksi@gmail.com>
** All rights reserved.
**
** You may use this file under the terms of 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 the author 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 HOLDERS 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.
**
****************************************************************************************/
import QtQuick 2.1
import QtQuick.Controls.Styles.Nemo 1.0
Text {
renderType: Text.NativeRendering
font.family: Theme.fontFamily
color: Theme.label.color
}
...@@ -10,7 +10,8 @@ QML_FILES += \ ...@@ -10,7 +10,8 @@ QML_FILES += \
Button.qml \ Button.qml \
ApplicationWindow.qml \ ApplicationWindow.qml \
Page.qml \ Page.qml \
Spinner.qml Spinner.qml \
Label.qml
OTHER_FILES += qmldir \ OTHER_FILES += qmldir \
$$QML_FILES $$QML_FILES
......
...@@ -12,6 +12,7 @@ Button 1.0 Button.qml ...@@ -12,6 +12,7 @@ Button 1.0 Button.qml
ApplicationWindow 1.0 ApplicationWindow.qml ApplicationWindow 1.0 ApplicationWindow.qml
Page 1.0 Page.qml Page 1.0 Page.qml
Spinner 1.0 Spinner.qml Spinner 1.0 Spinner.qml
Label 1.0 Label.qml
# MIRRORED CONTROLS: # MIRRORED CONTROLS:
# These are the controls that we take directly from official QQC. # These are the controls that we take directly from official QQC.
...@@ -25,7 +26,7 @@ Spinner 1.0 Spinner.qml ...@@ -25,7 +26,7 @@ Spinner 1.0 Spinner.qml
CheckBox 1.0 ../CheckBox.qml CheckBox 1.0 ../CheckBox.qml
ComboBox 1.0 ../ComboBox.qml ComboBox 1.0 ../ComboBox.qml
GroupBox 1.0 ../GroupBox.qml GroupBox 1.0 ../GroupBox.qml
Label 1.0 ../Label.qml
MenuBar 1.0 ../MenuBar.qml MenuBar 1.0 ../MenuBar.qml
Menu 1.0 ../Menu.qml Menu 1.0 ../Menu.qml
StackView 1.0 ../StackView.qml StackView 1.0 ../StackView.qml
......
...@@ -46,6 +46,7 @@ NemoTheme::NemoTheme(QObject *parent) ...@@ -46,6 +46,7 @@ NemoTheme::NemoTheme(QObject *parent)
, m_window(new NemoThemeWindow(this)) , m_window(new NemoThemeWindow(this))
, m_page(new NemoThemePage(this)) , m_page(new NemoThemePage(this))
, m_spinner(new NemoThemeSpinner(this)) , m_spinner(new NemoThemeSpinner(this))
, m_label(new NemoThemeLabel(this))
{ {
loadFromFile(GLACIER_THEME); loadFromFile(GLACIER_THEME);
int id = QFontDatabase::addApplicationFont("/usr/share/fonts/google-opensans/OpenSans-Regular.ttf"); int id = QFontDatabase::addApplicationFont("/usr/share/fonts/google-opensans/OpenSans-Regular.ttf");
...@@ -123,6 +124,11 @@ NemoThemeSpinner * NemoTheme::spinner() const ...@@ -123,6 +124,11 @@ NemoThemeSpinner * NemoTheme::spinner() const
return m_spinner; return m_spinner;
} }
NemoThemeLabel * NemoTheme::label() const
{
return m_label;
}
QString NemoTheme::fontFamily() const QString NemoTheme::fontFamily() const
{ {
return m_fontFamily; return m_fontFamily;
...@@ -368,4 +374,9 @@ void NemoTheme::loadFromFile(const QString &fileName) ...@@ -368,4 +374,9 @@ void NemoTheme::loadFromFile(const QString &fileName)
if (stylesSpinner.contains("transitionDuration")) { if (stylesSpinner.contains("transitionDuration")) {
m_spinner->setTransitionDuration(jsonToInt(styles.value("spinner"), defines)); m_spinner->setTransitionDuration(jsonToInt(styles.value("spinner"), defines));
} }
// Setting properties for label
QJsonObject stylesLabel = styles.value("label").toObject();
if (stylesLabel.contains("color")) {
m_label->setColor(jsonToColor(styles.value("label"), defines));
}
} }
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "nemothemewindow.h" #include "nemothemewindow.h"
#include "nemothemepage.h" #include "nemothemepage.h"
#include "nemothemespinner.h" #include "nemothemespinner.h"
#include "nemothemelabel.h"
class NemoTheme: public QObject class NemoTheme: public QObject
{ {
...@@ -46,6 +47,7 @@ class NemoTheme: public QObject ...@@ -46,6 +47,7 @@ class NemoTheme: public QObject
Q_PROPERTY(NemoThemeWindow * window READ window CONSTANT) Q_PROPERTY(NemoThemeWindow * window READ window CONSTANT)
Q_PROPERTY(NemoThemePage * page READ page CONSTANT) Q_PROPERTY(NemoThemePage * page READ page CONSTANT)
Q_PROPERTY(NemoThemeSpinner * spinner READ spinner CONSTANT) Q_PROPERTY(NemoThemeSpinner * spinner READ spinner CONSTANT)
Q_PROPERTY(NemoThemeLabel * label READ label CONSTANT)
Q_PROPERTY(QString fontFamily READ fontFamily CONSTANT) Q_PROPERTY(QString fontFamily READ fontFamily CONSTANT)
public: public:
explicit NemoTheme(QObject *parent = 0); explicit NemoTheme(QObject *parent = 0);
...@@ -61,6 +63,7 @@ public: ...@@ -61,6 +63,7 @@ public:
NemoThemeWindow * window() const; NemoThemeWindow * window() const;
NemoThemePage * page() const; NemoThemePage * page() const;
NemoThemeSpinner * spinner() const; NemoThemeSpinner * spinner() const;
NemoThemeLabel * label() const;
QString fontFamily() const; QString fontFamily() const;
public Q_SLOTS: public Q_SLOTS:
void loadFromFile(const QString &fileName); void loadFromFile(const QString &fileName);
...@@ -78,6 +81,7 @@ private: ...@@ -78,6 +81,7 @@ private:
NemoThemeWindow * m_window; NemoThemeWindow * m_window;
NemoThemePage * m_page; NemoThemePage * m_page;
NemoThemeSpinner * m_spinner; NemoThemeSpinner * m_spinner;
NemoThemeLabel * m_label;
QString m_fontFamily; QString m_fontFamily;
}; };
......
/*
* 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 "nemothemelabel.h"
NemoThemeLabel::NemoThemeLabel(QObject *parent)
: QObject(parent)
, m_color("white")
{
}
QColor NemoThemeLabel::color() const
{
return m_color;
}
void NemoThemeLabel::setColor(const QColor &color)
{
if (m_color != color) {
m_color = color;
emit colorChanged();
}
}
/*
* 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 NEMOTHEMELABEL_H
#define NEMOTHEMELABEL_H
#include <QtCore/QObject>
#include <QtGui/QColor>
class NemoThemeLabel: public QObject
{
Q_OBJECT
Q_PROPERTY(QColor color READ color NOTIFY colorChanged)
public:
explicit NemoThemeLabel(QObject *parent = 0);
QColor color() const;
void setColor(const QColor &color);
Q_SIGNALS:
void colorChanged();
private:
QColor m_color;
};
#endif //NEMOTHEMELABEL_H
...@@ -50,6 +50,7 @@ void QQuickNemoStyleExtensionPlugin::registerTypes(const char *uri) ...@@ -50,6 +50,7 @@ void QQuickNemoStyleExtensionPlugin::registerTypes(const char *uri)
qmlRegisterUncreatableType<NemoThemePage>(uri, 1, 0, "NemoThemePage", reason); qmlRegisterUncreatableType<NemoThemePage>(uri, 1, 0, "NemoThemePage", reason);
qmlRegisterUncreatableType<NemoThemePageDimmer>(uri, 1, 0, "NemoThemePageDimmer", reason); qmlRegisterUncreatableType<NemoThemePageDimmer>(uri, 1, 0, "NemoThemePageDimmer", reason);
qmlRegisterUncreatableType<NemoThemeSpinner>(uri, 1, 0, "NemoThemeSpinner", reason); qmlRegisterUncreatableType<NemoThemeSpinner>(uri, 1, 0, "NemoThemeSpinner", reason);
qmlRegisterUncreatableType<NemoThemeLabel>(uri, 1, 0, "NemoThemeLabel", reason);
qmlRegisterSingletonType<QObject>(uri, 1, 0, "Theme", nemo_theme_provider); qmlRegisterSingletonType<QObject>(uri, 1, 0, "Theme", nemo_theme_provider);
......
...@@ -26,7 +26,8 @@ QML_FILES = \ ...@@ -26,7 +26,8 @@ QML_FILES = \
TabViewStyle.qml \ TabViewStyle.qml \
TextFieldStyle.qml \ TextFieldStyle.qml \
ToolBarStyle.qml \ ToolBarStyle.qml \
ToolButtonStyle.qml ToolButtonStyle.qml \
LabelStyle.qml
# Images # Images
#QML_FILES += \ #QML_FILES += \
...@@ -89,7 +90,8 @@ HEADERS += \ ...@@ -89,7 +90,8 @@ HEADERS += \
autogenerated/nemothemewindow.h \ autogenerated/nemothemewindow.h \
autogenerated/nemothemepage.h \ autogenerated/nemothemepage.h \
autogenerated/nemothemepagedimmer.h \ autogenerated/nemothemepagedimmer.h \
autogenerated/nemothemespinner.h autogenerated/nemothemespinner.h \
autogenerated/nemothemelabel.h
SOURCES += \ SOURCES += \
qquicknemostyleextensionplugin.cpp \ qquicknemostyleextensionplugin.cpp \
...@@ -104,7 +106,8 @@ SOURCES += \ ...@@ -104,7 +106,8 @@ SOURCES += \
autogenerated/nemothemewindow.cpp \ autogenerated/nemothemewindow.cpp \
autogenerated/nemothemepage.cpp \ autogenerated/nemothemepage.cpp \
autogenerated/nemothemepagedimmer.cpp \ autogenerated/nemothemepagedimmer.cpp \
autogenerated/nemothemespinner.cpp autogenerated/nemothemespinner.cpp \
autogenerated/nemothemelabel.cpp
INSTALLS += target images qmlfiles themes INSTALLS += target images qmlfiles themes
......
...@@ -54,6 +54,9 @@ ...@@ -54,6 +54,9 @@
"spinner": { "spinner": {
"primaryColor": "#ffffff", "primaryColor": "#ffffff",
"secondaryColor": "#0091e5" "secondaryColor": "#0091e5"
},
"label": {
"color": "white"
} }
} }
} }
...@@ -201,6 +201,16 @@ ...@@ -201,6 +201,16 @@
"default": 500 "default": 500
} }
] ]
},
{
"name": "Label",
"properties": [
{
"name":"color",
"type":"QColor",
"default": "white"
}
]
} }
], ],
"properties": [ "properties": [
...@@ -235,6 +245,10 @@ ...@@ -235,6 +245,10 @@
{ {
"name": "spinner", "name": "spinner",
"object": "Spinner" "object": "Spinner"
},
{
"name": "label",
"object": "Label"
} }
], ],
"font": "/usr/share/fonts/google-opensans/OpenSans-Regular.ttf" "font": "/usr/share/fonts/google-opensans/OpenSans-Regular.ttf"
......
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