Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Label with example page.
  • Loading branch information
locusf committed Nov 18, 2013
1 parent 041b885 commit a2ebde3
Show file tree
Hide file tree
Showing 14 changed files with 255 additions and 6 deletions.
50 changes: 50 additions & 0 deletions examples/touch/content/LabelPage.qml
@@ -0,0 +1,50 @@
/****************************************************************************************
**
** 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"
}
}

}
4 changes: 4 additions & 0 deletions examples/touch/main.qml
Expand Up @@ -91,6 +91,10 @@ ApplicationWindow {
title: "Spinner"
page: "content/SpinnerPage.qml"
}
ListElement {
title: "Labels"
page: "content/LabelPage.qml"
}
}


Expand Down
3 changes: 2 additions & 1 deletion examples/touch/touch.pro
Expand Up @@ -19,7 +19,8 @@ OTHER_FILES += \
content/TextInputPage.qml \
content/LiveCoding.qml \
content/ToolBarLayoutExample.qml \
content/SpinnerPage.qml
content/SpinnerPage.qml \
content/LabelPage.qml

RESOURCES += \
resources.qrc
Expand Down
40 changes: 40 additions & 0 deletions src/controls/Label.qml
@@ -0,0 +1,40 @@
/****************************************************************************************
**
** 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
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
color: Theme.label.color
font.family: Theme.fontFamily
}
3 changes: 2 additions & 1 deletion src/controls/controls.pro
Expand Up @@ -10,7 +10,8 @@ QML_FILES += \
Button.qml \
ApplicationWindow.qml \
Page.qml \
Spinner.qml
Spinner.qml \
Label.qml

OTHER_FILES += qmldir \
$$QML_FILES
Expand Down
3 changes: 2 additions & 1 deletion src/controls/qmldir
Expand Up @@ -12,6 +12,7 @@ Button 1.0 Button.qml
ApplicationWindow 1.0 ApplicationWindow.qml
Page 1.0 Page.qml
Spinner 1.0 Spinner.qml
Label 1.0 Label.qml

# MIRRORED CONTROLS:
# These are the controls that we take directly from official QQC.
Expand All @@ -25,7 +26,7 @@ Spinner 1.0 Spinner.qml
CheckBox 1.0 ../CheckBox.qml
ComboBox 1.0 ../ComboBox.qml
GroupBox 1.0 ../GroupBox.qml
Label 1.0 ../Label.qml

MenuBar 1.0 ../MenuBar.qml
Menu 1.0 ../Menu.qml
StackView 1.0 ../StackView.qml
Expand Down
36 changes: 36 additions & 0 deletions src/styles/LabelStyle.qml
@@ -0,0 +1,36 @@
/****************************************************************************************
**
** 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 1.0

LabelStyle {
}

9 changes: 9 additions & 0 deletions src/styles/autogenerated/nemotheme.cpp
Expand Up @@ -46,6 +46,7 @@ NemoTheme::NemoTheme(QObject *parent)
, m_window(new NemoThemeWindow(this))
, m_page(new NemoThemePage(this))
, m_spinner(new NemoThemeSpinner(this))
, m_label(new NemoThemeLabel(this))
{
loadFromFile(GLACIER_THEME);
int id = QFontDatabase::addApplicationFont("/usr/share/fonts/google-opensans/OpenSans-Regular.ttf");
Expand Down Expand Up @@ -123,6 +124,11 @@ NemoThemeSpinner * NemoTheme::spinner() const
return m_spinner;
}

NemoThemeLabel * NemoTheme::label() const
{
return m_label;
}

QString NemoTheme::fontFamily() const
{
return m_fontFamily;
Expand Down Expand Up @@ -368,4 +374,7 @@ void NemoTheme::loadFromFile(const QString &fileName)
if (stylesSpinner.contains("transitionDuration")) {
m_spinner->setTransitionDuration(jsonToInt(styles.value("spinner"), defines));
}
// Setting properties for label
QJsonObject stylesLabel = styles.value("label").toObject();
m_label->setColor(jsonToColor(jsonValue(stylesLabel, "color", "label"), defines));
}
4 changes: 4 additions & 0 deletions src/styles/autogenerated/nemotheme.h
Expand Up @@ -32,6 +32,7 @@
#include "nemothemewindow.h"
#include "nemothemepage.h"
#include "nemothemespinner.h"
#include "nemothemelabel.h"

class NemoTheme: public QObject
{
Expand All @@ -46,6 +47,7 @@ class NemoTheme: public QObject
Q_PROPERTY(NemoThemeWindow * window READ window CONSTANT)
Q_PROPERTY(NemoThemePage * page READ page CONSTANT)
Q_PROPERTY(NemoThemeSpinner * spinner READ spinner CONSTANT)
Q_PROPERTY(NemoThemeLabel * label READ label CONSTANT)
Q_PROPERTY(QString fontFamily READ fontFamily CONSTANT)
public:
explicit NemoTheme(QObject *parent = 0);
Expand All @@ -61,6 +63,7 @@ class NemoTheme: public QObject
NemoThemeWindow * window() const;
NemoThemePage * page() const;
NemoThemeSpinner * spinner() const;
NemoThemeLabel * label() const;
QString fontFamily() const;
public Q_SLOTS:
void loadFromFile(const QString &fileName);
Expand All @@ -78,6 +81,7 @@ public Q_SLOTS:
NemoThemeWindow * m_window;
NemoThemePage * m_page;
NemoThemeSpinner * m_spinner;
NemoThemeLabel * m_label;
QString m_fontFamily;
};

Expand Down
41 changes: 41 additions & 0 deletions src/styles/autogenerated/nemothemelabel.cpp
@@ -0,0 +1,41 @@
/*
* 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)
{
}

QColor NemoThemeLabel::color() const
{
return m_color;
}

void NemoThemeLabel::setColor(const QColor &color)
{
if (m_color != color) {
m_color = color;
emit colorChanged();
}
}
43 changes: 43 additions & 0 deletions src/styles/autogenerated/nemothemelabel.h
@@ -0,0 +1,43 @@
/*
* 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
9 changes: 6 additions & 3 deletions src/styles/styles.pro
Expand Up @@ -26,7 +26,8 @@ QML_FILES = \
TabViewStyle.qml \
TextFieldStyle.qml \
ToolBarStyle.qml \
ToolButtonStyle.qml
ToolButtonStyle.qml \
LabelStyle.qml

# Images
#QML_FILES += \
Expand Down Expand Up @@ -89,7 +90,8 @@ HEADERS += \
autogenerated/nemothemewindow.h \
autogenerated/nemothemepage.h \
autogenerated/nemothemepagedimmer.h \
autogenerated/nemothemespinner.h
autogenerated/nemothemespinner.h \
autogenerated/nemothemelabel.h

SOURCES += \
qquicknemostyleextensionplugin.cpp \
Expand All @@ -104,7 +106,8 @@ SOURCES += \
autogenerated/nemothemewindow.cpp \
autogenerated/nemothemepage.cpp \
autogenerated/nemothemepagedimmer.cpp \
autogenerated/nemothemespinner.cpp
autogenerated/nemothemespinner.cpp \
autogenerated/nemothemelabel.cpp

INSTALLS += target images qmlfiles themes

Expand Down
3 changes: 3 additions & 0 deletions src/styles/themes/glacier.json
Expand Up @@ -54,6 +54,9 @@
"spinner": {
"primaryColor": "#ffffff",
"secondaryColor": "#0091e5"
},
"label": {
"color": "white"
}
}
}
13 changes: 13 additions & 0 deletions tools/themehelper/components.json
Expand Up @@ -201,6 +201,15 @@
"default": 500
}
]
},
{
"name": "Label",
"properties": [
{
"name":"color",
"type":"QColor"
}
]
}
],
"properties": [
Expand Down Expand Up @@ -235,6 +244,10 @@
{
"name": "spinner",
"object": "Spinner"
},
{
"name": "label",
"object": "Label"
}
],
"font": "/usr/share/fonts/google-opensans/OpenSans-Regular.ttf"
Expand Down

0 comments on commit a2ebde3

Please sign in to comment.