Commit 5e46005d authored by Simonas Leleiva's avatar Simonas Leleiva

Merge pull request #23 from locusf/buttonrow

Button row, v0.1
parents 737679a8 029a3da1
/****************************************************************************************
**
** 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 {
id: row
model: ListModel {
ListElement {
name: "swim"
}
ListElement {
name: "cruise"
}
ListElement {
name: "row"
}
ListElement {
name: "fish"
}
ListElement {
name: "dive"
}
}
}
Connections {
target: row
onSelected: {
selector.text = "Selected " + sel
}
}
Label {
id: selector
text: "Nothing selected"
}
ButtonRow {
id: row2
enabled: false
model: ListModel {
ListElement {
name: "swim"
}
ListElement {
name: "cruise"
}
ListElement {
name: "row"
}
ListElement {
name: "fish"
}
ListElement {
name: "dive"
}
}
}
}
}
...@@ -99,6 +99,10 @@ ApplicationWindow { ...@@ -99,6 +99,10 @@ ApplicationWindow {
title: "Switches" title: "Switches"
page: "content/CheckboxPage.qml" page: "content/CheckboxPage.qml"
} }
ListElement {
title: "ButtonRow"
page: "content/ButtonRowPage.qml"
}
} }
......
...@@ -20,5 +20,6 @@ ...@@ -20,5 +20,6 @@
<file>content/SpinnerPage.qml</file> <file>content/SpinnerPage.qml</file>
<file>content/LabelPage.qml</file> <file>content/LabelPage.qml</file>
<file>content/CheckboxPage.qml</file> <file>content/CheckboxPage.qml</file>
<file>content/ButtonRowPage.qml</file>
</qresource> </qresource>
</RCC> </RCC>
...@@ -21,7 +21,8 @@ OTHER_FILES += \ ...@@ -21,7 +21,8 @@ OTHER_FILES += \
content/ToolBarLayoutExample.qml \ content/ToolBarLayoutExample.qml \
content/SpinnerPage.qml \ content/SpinnerPage.qml \
content/LabelPage.qml \ content/LabelPage.qml \
content/CheckboxPage.qml content/CheckboxPage.qml \
content/ButtonRowPage.qml
RESOURCES += \ RESOURCES += \
resources.qrc resources.qrc
......
/****************************************************************************************
**
** 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 {
id: main
width: 440
color: "#313131"
height: 40
property ListModel model: ListModel {}
property bool enabled: true
signal selected(string sel)
Image {
anchors.fill: parent
visible: !main.enabled
source: "images/disabled-overlay.png"
fillMode: Image.Tile
}
Row {
spacing: 0
Repeater {
id: rectangles
model: main.model
delegate:
Rectangle {
property bool active: false
height: 50
width: 20*name.length
color: "transparent"
MouseArea {
enabled: main.enabled
width: parent.width
height: parent.height
onClicked: {
if (!parent.active) {
text.font.bold = true
parent.color = "#0091e5"
parent.active = true
} else {
text.font.bold = false
parent.color = "transparent"
parent.active = false
}
main.selected(name)
}
}
Label {
id: text
text: name
}
}
}
}
}
...@@ -12,10 +12,13 @@ QML_FILES += \ ...@@ -12,10 +12,13 @@ QML_FILES += \
Page.qml \ Page.qml \
Spinner.qml \ Spinner.qml \
Label.qml \ Label.qml \
Checkbox.qml Checkbox.qml\
images/disabled-overlay.png
images/disabled-overlay-inverse.png
OTHER_FILES += qmldir \ OTHER_FILES += qmldir \
$$QML_FILES $$QML_FILES \
ButtonRow.qml
HEADERS += \ HEADERS += \
qquicknemocontrolsextensionplugin.h \ qquicknemocontrolsextensionplugin.h \
...@@ -34,5 +37,6 @@ target.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH ...@@ -34,5 +37,6 @@ target.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH
qmlfiles.files = $$_PRO_FILE_PWD_/*.qml 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
images.files = $$_PRO_FILE_PWD_/images
INSTALLS += target qmlfiles images.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH
INSTALLS += target qmlfiles images
...@@ -14,7 +14,7 @@ Page 1.0 Page.qml ...@@ -14,7 +14,7 @@ Page 1.0 Page.qml
Spinner 1.0 Spinner.qml Spinner 1.0 Spinner.qml
Label 1.0 Label.qml Label 1.0 Label.qml
CheckBox 1.0 Checkbox.qml CheckBox 1.0 Checkbox.qml
ButtonRow 1.0 ButtonRow.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.
# This is to avoid having to "import QtQuick.Controls" when using controls # This is to avoid having to "import QtQuick.Controls" when using controls
......
...@@ -49,6 +49,7 @@ NemoTheme::NemoTheme(QObject *parent) ...@@ -49,6 +49,7 @@ NemoTheme::NemoTheme(QObject *parent)
, m_spinner(new NemoThemeSpinner(this)) , m_spinner(new NemoThemeSpinner(this))
, m_label(new NemoThemeLabel(this)) , m_label(new NemoThemeLabel(this))
, m_checkbox(new NemoThemeCheckbox(this)) , m_checkbox(new NemoThemeCheckbox(this))
, m_buttonRow(new NemoThemeButtonRow(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");
...@@ -141,6 +142,11 @@ NemoThemeCheckbox * NemoTheme::checkbox() const ...@@ -141,6 +142,11 @@ NemoThemeCheckbox * NemoTheme::checkbox() const
return m_checkbox; return m_checkbox;
} }
NemoThemeButtonRow * NemoTheme::buttonRow() const
{
return m_buttonRow;
}
QString NemoTheme::fontFamily() const QString NemoTheme::fontFamily() const
{ {
return m_fontFamily; return m_fontFamily;
...@@ -450,4 +456,8 @@ void NemoTheme::loadFromFile(const QString &fileName) ...@@ -450,4 +456,8 @@ void NemoTheme::loadFromFile(const QString &fileName)
QJsonObject stylesCheckbox = styles.value("checkbox").toObject(); QJsonObject stylesCheckbox = styles.value("checkbox").toObject();
m_checkbox->setBack1(jsonToColor(jsonValue(stylesCheckbox, "back1", "checkbox"), defines)); m_checkbox->setBack1(jsonToColor(jsonValue(stylesCheckbox, "back1", "checkbox"), defines));
m_checkbox->setBack2(jsonToColor(jsonValue(stylesCheckbox, "back2", "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));
} }
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "nemothemespinner.h" #include "nemothemespinner.h"
#include "nemothemelabel.h" #include "nemothemelabel.h"
#include "nemothemecheckbox.h" #include "nemothemecheckbox.h"
#include "nemothemebuttonrow.h"
class NemoTheme: public QObject class NemoTheme: public QObject
{ {
...@@ -52,6 +53,7 @@ class NemoTheme: public QObject ...@@ -52,6 +53,7 @@ class NemoTheme: public QObject
Q_PROPERTY(NemoThemeSpinner * spinner READ spinner CONSTANT) Q_PROPERTY(NemoThemeSpinner * spinner READ spinner CONSTANT)
Q_PROPERTY(NemoThemeLabel * label READ label CONSTANT) Q_PROPERTY(NemoThemeLabel * label READ label CONSTANT)
Q_PROPERTY(NemoThemeCheckbox * checkbox READ checkbox CONSTANT) Q_PROPERTY(NemoThemeCheckbox * checkbox READ checkbox CONSTANT)
Q_PROPERTY(NemoThemeButtonRow * buttonRow READ buttonRow 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);
...@@ -70,6 +72,7 @@ public: ...@@ -70,6 +72,7 @@ public:
NemoThemeSpinner * spinner() const; NemoThemeSpinner * spinner() const;
NemoThemeLabel * label() const; NemoThemeLabel * label() const;
NemoThemeCheckbox * checkbox() const; NemoThemeCheckbox * checkbox() const;
NemoThemeButtonRow * buttonRow() const;
QString fontFamily() const; QString fontFamily() const;
public Q_SLOTS: public Q_SLOTS:
void loadFromFile(const QString &fileName); void loadFromFile(const QString &fileName);
...@@ -90,6 +93,7 @@ private: ...@@ -90,6 +93,7 @@ private:
NemoThemeSpinner * m_spinner; NemoThemeSpinner * m_spinner;
NemoThemeLabel * m_label; NemoThemeLabel * m_label;
NemoThemeCheckbox * m_checkbox; NemoThemeCheckbox * m_checkbox;
NemoThemeButtonRow * m_buttonRow;
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 "nemothemebuttonrow.h"
NemoThemeButtonRow::NemoThemeButtonRow(QObject *parent)
: QObject(parent)
{
}
QColor NemoThemeButtonRow::background() const
{
return m_background;
}
void NemoThemeButtonRow::setBackground(const QColor &background)
{
if (m_background != background) {
m_background = background;
emit backgroundChanged();
}
}
QColor NemoThemeButtonRow::buttonColor() const
{
return m_buttonColor;
}
void NemoThemeButtonRow::setButtonColor(const QColor &buttonColor)
{
if (m_buttonColor != buttonColor) {
m_buttonColor = buttonColor;
emit buttonColorChanged();
}
}
/*
* 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 NEMOTHEMEBUTTONROW_H
#define NEMOTHEMEBUTTONROW_H
#include <QtCore/QObject>
#include <QtGui/QColor>
class NemoThemeButtonRow: public QObject
{
Q_OBJECT
Q_PROPERTY(QColor background READ background NOTIFY backgroundChanged)
Q_PROPERTY(QColor buttonColor READ buttonColor NOTIFY buttonColorChanged)
public:
explicit NemoThemeButtonRow(QObject *parent = 0);
QColor background() const;
void setBackground(const QColor &background);
QColor buttonColor() const;
void setButtonColor(const QColor &buttonColor);
Q_SIGNALS:
void backgroundChanged();
void buttonColorChanged();
private:
QColor m_background;
QColor m_buttonColor;
};
#endif //NEMOTHEMEBUTTONROW_H
...@@ -87,7 +87,8 @@ HEADERS += \ ...@@ -87,7 +87,8 @@ HEADERS += \
autogenerated/nemothemespinner.h \ autogenerated/nemothemespinner.h \
autogenerated/nemothemelabel.h \ autogenerated/nemothemelabel.h \
autogenerated/nemothemecheckbox.h \ autogenerated/nemothemecheckbox.h \
autogenerated/nemothemepagestack.h autogenerated/nemothemepagestack.h \
autogenerated/nemothemebuttonrow.h
SOURCES += \ SOURCES += \
qquicknemostyleextensionplugin.cpp \ qquicknemostyleextensionplugin.cpp \
...@@ -105,7 +106,8 @@ SOURCES += \ ...@@ -105,7 +106,8 @@ SOURCES += \
autogenerated/nemothemespinner.cpp \ autogenerated/nemothemespinner.cpp \
autogenerated/nemothemelabel.cpp \ autogenerated/nemothemelabel.cpp \
autogenerated/nemothemecheckbox.cpp \ autogenerated/nemothemecheckbox.cpp \
autogenerated/nemothemepagestack.cpp autogenerated/nemothemepagestack.cpp \
autogenerated/nemothemebuttonrow.cpp
INSTALLS += target images qmlfiles themes INSTALLS += target images qmlfiles themes
......
...@@ -61,6 +61,10 @@ ...@@ -61,6 +61,10 @@
"checkbox": { "checkbox": {
"back1": "#0091e5", "back1": "#0091e5",
"back2": "#313131" "back2": "#313131"
},
"buttonRow": {
"background": "#313131",
"buttonColor": "#0091e5"
} }
} }
} }
...@@ -243,6 +243,19 @@ ...@@ -243,6 +243,19 @@
"default": 500 "default": 500
} }
] ]
},
{
"name": "ButtonRow",
"properties": [
{
"name": "background",
"type": "QColor"
},
{
"name": "buttonColor",
"type": "QColor"
}
]
} }
], ],
"properties": [ "properties": [
...@@ -289,6 +302,10 @@ ...@@ -289,6 +302,10 @@
{ {
"name": "checkbox", "name": "checkbox",
"object": "Checkbox" "object": "Checkbox"
},
{
"name": "buttonRow",
"object": "ButtonRow"
} }
], ],
"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