Skip to content

Commit

Permalink
Button row, v0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
locusf committed Feb 25, 2014
1 parent 737679a commit a8d1b5f
Show file tree
Hide file tree
Showing 12 changed files with 168 additions and 5 deletions.
65 changes: 65 additions & 0 deletions examples/touch/content/ButtonRow.qml
@@ -0,0 +1,65 @@
/****************************************************************************************
**
** Copyright (C) 2014 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: "ButtonRow" }

Column {
spacing: 40
anchors.centerIn: parent
ButtonRow {
model: ListModel {
ListElement {
name: "swim"
}
ListElement {
name: "cruise"
}
ListElement {
name: "row"
}
ListElement {
name: "fish"
}
ListElement {
name: "dive"
}
}
}
}
}
4 changes: 4 additions & 0 deletions examples/touch/main.qml
Expand Up @@ -99,6 +99,10 @@ ApplicationWindow {
title: "Switches"
page: "content/CheckboxPage.qml"
}
ListElement {
title: "ButtonRow"
page: "content/ButtonRow.qml"
}
}


Expand Down
1 change: 1 addition & 0 deletions examples/touch/resources.qrc
Expand Up @@ -20,5 +20,6 @@
<file>content/SpinnerPage.qml</file>
<file>content/LabelPage.qml</file>
<file>content/CheckboxPage.qml</file>
<file>content/ButtonRow.qml</file>
</qresource>
</RCC>
3 changes: 2 additions & 1 deletion examples/touch/touch.pro
Expand Up @@ -21,7 +21,8 @@ OTHER_FILES += \
content/ToolBarLayoutExample.qml \
content/SpinnerPage.qml \
content/LabelPage.qml \
content/CheckboxPage.qml
content/CheckboxPage.qml \
content/ButtonRow.qml

RESOURCES += \
resources.qrc
Expand Down
54 changes: 54 additions & 0 deletions src/controls/ButtonRow.qml
@@ -0,0 +1,54 @@
/****************************************************************************************
**
** Copyright (C) 2014 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

Rectangle {
width: 440
color: "#313131"
height: 40
property ListModel model: rectangles.model
Row {
spacing: 5
Repeater {
id: rectangles
Rectangle {
height: 50
width: (440*2*10)/index+1
color: "#0091e5"
Label {
text: name
}
}
}
}
}
3 changes: 2 additions & 1 deletion src/controls/controls.pro
Expand Up @@ -15,7 +15,8 @@ QML_FILES += \
Checkbox.qml

OTHER_FILES += qmldir \
$$QML_FILES
$$QML_FILES \
ButtonRow.qml

HEADERS += \
qquicknemocontrolsextensionplugin.h \
Expand Down
2 changes: 1 addition & 1 deletion src/controls/qmldir
Expand Up @@ -14,7 +14,7 @@ Page 1.0 Page.qml
Spinner 1.0 Spinner.qml
Label 1.0 Label.qml
CheckBox 1.0 Checkbox.qml

ButtonRow 1.0 ButtonRow.qml
# MIRRORED CONTROLS:
# These are the controls that we take directly from official QQC.
# This is to avoid having to "import QtQuick.Controls" when using controls
Expand Down
10 changes: 10 additions & 0 deletions src/styles/autogenerated/nemotheme.cpp
Expand Up @@ -49,6 +49,7 @@ NemoTheme::NemoTheme(QObject *parent)
, m_spinner(new NemoThemeSpinner(this))
, m_label(new NemoThemeLabel(this))
, m_checkbox(new NemoThemeCheckbox(this))
, m_buttonRow(new NemoThemeButtonRow(this))
{
loadFromFile(GLACIER_THEME);
int id = QFontDatabase::addApplicationFont("/usr/share/fonts/google-opensans/OpenSans-Regular.ttf");
Expand Down Expand Up @@ -141,6 +142,11 @@ NemoThemeCheckbox * NemoTheme::checkbox() const
return m_checkbox;
}

NemoThemeButtonRow * NemoTheme::buttonRow() const
{
return m_buttonRow;
}

QString NemoTheme::fontFamily() const
{
return m_fontFamily;
Expand Down Expand Up @@ -450,4 +456,8 @@ void NemoTheme::loadFromFile(const QString &fileName)
QJsonObject stylesCheckbox = styles.value("checkbox").toObject();
m_checkbox->setBack1(jsonToColor(jsonValue(stylesCheckbox, "back1", "checkbox"), defines));
m_checkbox->setBack2(jsonToColor(jsonValue(stylesCheckbox, "back2", "checkbox"), defines));
// Setting properties for buttonRow
QJsonObject stylesButtonRow = styles.value("buttonRow").toObject();
m_buttonRow->setBackground(jsonToColor(jsonValue(stylesButtonRow, "background", "buttonRow"), defines));
m_buttonRow->setButtonColor(jsonToColor(jsonValue(stylesButtonRow, "buttonColor", "buttonRow"), defines));
}
4 changes: 4 additions & 0 deletions src/styles/autogenerated/nemotheme.h
Expand Up @@ -35,6 +35,7 @@
#include "nemothemespinner.h"
#include "nemothemelabel.h"
#include "nemothemecheckbox.h"
#include "nemothemebuttonrow.h"

class NemoTheme: public QObject
{
Expand All @@ -52,6 +53,7 @@ class NemoTheme: public QObject
Q_PROPERTY(NemoThemeSpinner * spinner READ spinner CONSTANT)
Q_PROPERTY(NemoThemeLabel * label READ label CONSTANT)
Q_PROPERTY(NemoThemeCheckbox * checkbox READ checkbox CONSTANT)
Q_PROPERTY(NemoThemeButtonRow * buttonRow READ buttonRow CONSTANT)
Q_PROPERTY(QString fontFamily READ fontFamily CONSTANT)
public:
explicit NemoTheme(QObject *parent = 0);
Expand All @@ -70,6 +72,7 @@ class NemoTheme: public QObject
NemoThemeSpinner * spinner() const;
NemoThemeLabel * label() const;
NemoThemeCheckbox * checkbox() const;
NemoThemeButtonRow * buttonRow() const;
QString fontFamily() const;
public Q_SLOTS:
void loadFromFile(const QString &fileName);
Expand All @@ -90,6 +93,7 @@ public Q_SLOTS:
NemoThemeSpinner * m_spinner;
NemoThemeLabel * m_label;
NemoThemeCheckbox * m_checkbox;
NemoThemeButtonRow * m_buttonRow;
QString m_fontFamily;
};

Expand Down
6 changes: 4 additions & 2 deletions src/styles/styles.pro
Expand Up @@ -87,7 +87,8 @@ HEADERS += \
autogenerated/nemothemespinner.h \
autogenerated/nemothemelabel.h \
autogenerated/nemothemecheckbox.h \
autogenerated/nemothemepagestack.h
autogenerated/nemothemepagestack.h \
autogenerated/nemothemebuttonrow.h

SOURCES += \
qquicknemostyleextensionplugin.cpp \
Expand All @@ -105,7 +106,8 @@ SOURCES += \
autogenerated/nemothemespinner.cpp \
autogenerated/nemothemelabel.cpp \
autogenerated/nemothemecheckbox.cpp \
autogenerated/nemothemepagestack.cpp
autogenerated/nemothemepagestack.cpp \
autogenerated/nemothemebuttonrow.cpp

INSTALLS += target images qmlfiles themes

Expand Down
4 changes: 4 additions & 0 deletions src/styles/themes/glacier.json
Expand Up @@ -61,6 +61,10 @@
"checkbox": {
"back1": "#0091e5",
"back2": "#313131"
},
"buttonRow": {
"background": "#313131",
"buttonColor": "#0091e5"
}
}
}
17 changes: 17 additions & 0 deletions tools/themehelper/components.json
Expand Up @@ -243,6 +243,19 @@
"default": 500
}
]
},
{
"name": "ButtonRow",
"properties": [
{
"name": "background",
"type": "QColor"
},
{
"name": "buttonColor",
"type": "QColor"
}
]
}
],
"properties": [
Expand Down Expand Up @@ -289,6 +302,10 @@
{
"name": "checkbox",
"object": "Checkbox"
},
{
"name": "buttonRow",
"object": "ButtonRow"
}
],
"font": "/usr/share/fonts/google-opensans/OpenSans-Regular.ttf"
Expand Down

0 comments on commit a8d1b5f

Please sign in to comment.