Commit d570d470 authored by faenil's avatar faenil

Merge pull request #8 from faenil/applicationwindow

Add ApplicationWindow, ui rotation handling, and update examples accordingly
parents 4194c25d 4b0a9aa0
...@@ -45,6 +45,7 @@ ...@@ -45,6 +45,7 @@
#include <QtQml> #include <QtQml>
#include <QtQuick/QQuickView> #include <QtQuick/QQuickView>
#include <QtCore/QString> #include <QtCore/QString>
#include <QScreen>
#ifndef QT_NO_WIDGETS #ifndef QT_NO_WIDGETS
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
...@@ -64,6 +65,13 @@ QT_BEGIN_NAMESPACE ...@@ -64,6 +65,13 @@ QT_BEGIN_NAMESPACE
int main(int argc, char *argv[]) \ int main(int argc, char *argv[]) \
{ \ { \
Application app(argc, argv); \ Application app(argc, argv); \
QScreen* sc = app.primaryScreen(); \
if(sc){ \
sc->setOrientationUpdateMask(Qt::LandscapeOrientation \
| Qt::PortraitOrientation \
| Qt::InvertedLandscapeOrientation \
| Qt::InvertedPortraitOrientation); \
} \
QQmlApplicationEngine engine(QUrl(#url)); \ QQmlApplicationEngine engine(QUrl(#url)); \
QObject *topLevel = engine.rootObjects().value(0); \ QObject *topLevel = engine.rootObjects().value(0); \
QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel); \ QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel); \
......
...@@ -39,13 +39,59 @@ ...@@ -39,13 +39,59 @@
****************************************************************************/ ****************************************************************************/
import QtQuick 2.1 import QtQuick 2.1
import QtQuick.Controls 1.0 //needed for the Stack attached property
import QtQuick.Controls.Nemo 1.0 import QtQuick.Controls.Nemo 1.0
import QtQuick.Controls.Styles.Nemo 1.0 import QtQuick.Controls.Styles.Nemo 1.0
Item { Rectangle {
id: root
width: parent.width width: parent.width
height: parent.height height: parent.height
color: "black"
ToolBar {
id: toolbar
anchors.top: parent.top
Rectangle {
id: backButton
width: opacity ? 60 : 0
anchors.left: parent.left
anchors.leftMargin: 20
opacity: (root.Stack.view && (root.Stack.view.depth > 1)) ? 1 : 0
anchors.verticalCenter: parent.verticalCenter
antialiasing: true
height: 60
radius: 4
color: backmouse.pressed ? "#222" : "transparent"
Behavior on opacity { NumberAnimation{} }
Image {
anchors.verticalCenter: parent.verticalCenter
source: "../images/navigation_previous_item.png"
}
MouseArea {
id: backmouse
anchors.fill: parent
anchors.margins: -10
onClicked: root.Stack.view.pop()
}
}
Text {
font.pixelSize: 42
Behavior on x { NumberAnimation { easing.type: Easing.OutCubic } }
x: backButton.x + backButton.width + 20
anchors.verticalCenter: parent.verticalCenter
color: "white"
text: "Buttons"
}
}
Item {
anchors.top: toolbar.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
Column { Column {
spacing: 40 spacing: 40
anchors.centerIn: parent anchors.centerIn: parent
...@@ -70,7 +116,6 @@ Item { ...@@ -70,7 +116,6 @@ Item {
text: "Go back" text: "Go back"
onClicked: if (stackView) stackView.pop() onClicked: if (stackView) stackView.pop()
} }
}
} }
} }
...@@ -18,19 +18,64 @@ ...@@ -18,19 +18,64 @@
*/ */
import QtQuick 2.1 import QtQuick 2.1
import QtQuick.Controls 1.0 //needed for the Stack attached property
import QtQuick.Controls.Nemo 1.0 import QtQuick.Controls.Nemo 1.0
import QtQuick.Layouts 1.0 import QtQuick.Layouts 1.0
Item { Rectangle {
id: root id: root
width: parent.width width: parent.width
height: parent.height height: parent.height
color: "black"
property var oldItem property var oldItem
property var newItem property var newItem
SplitView { ToolBar {
id: toolbar
anchors.top: parent.top
Rectangle {
id: backButton
width: opacity ? 60 : 0
anchors.left: parent.left
anchors.leftMargin: 20
opacity: (root.Stack.view && (root.Stack.view.depth > 1)) ? 1 : 0
anchors.verticalCenter: parent.verticalCenter
antialiasing: true
height: 60
radius: 4
color: backmouse.pressed ? "#222" : "transparent"
Behavior on opacity { NumberAnimation{} }
Image {
anchors.verticalCenter: parent.verticalCenter
source: "../images/navigation_previous_item.png"
}
MouseArea {
id: backmouse
anchors.fill: parent anchors.fill: parent
anchors.margins: -10
onClicked: root.Stack.view.pop()
}
}
Text {
font.pixelSize: 42
Behavior on x { NumberAnimation { easing.type: Easing.OutCubic } }
x: backButton.x + backButton.width + 20
anchors.verticalCenter: parent.verticalCenter
color: "white"
text: "Live Coding Arena"
}
}
SplitView {
anchors.top: toolbar.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
//If we don't wrap ColumnLayout in an Item, the split view doesn't work :/ //If we don't wrap ColumnLayout in an Item, the split view doesn't work :/
Item { Item {
...@@ -160,7 +205,6 @@ Item { ...@@ -160,7 +205,6 @@ Item {
} }
} }
} }
} }
Item { Item {
......
...@@ -43,13 +43,16 @@ ...@@ -43,13 +43,16 @@
import QtQuick 2.1 import QtQuick 2.1
import QtQuick.Controls 1.0 //needed for the Stack attached property
import QtQuick.Controls.Nemo 1.0 import QtQuick.Controls.Nemo 1.0
import QtQuick.Controls.Styles.Nemo 1.0 import QtQuick.Controls.Styles.Nemo 1.0
Item { Rectangle {
id: root
width: parent.width width: parent.width
height: parent.height height: parent.height
color: "black"
property real progress: 0 property real progress: 0
SequentialAnimation on progress { SequentialAnimation on progress {
loops: Animation.Infinite loops: Animation.Infinite
...@@ -66,6 +69,49 @@ Item { ...@@ -66,6 +69,49 @@ Item {
} }
} }
ToolBar {
id: toolbar
anchors.top: parent.top
Rectangle {
id: backButton
width: opacity ? 60 : 0
anchors.left: parent.left
anchors.leftMargin: 20
opacity: (root.Stack.view && (root.Stack.view.depth > 1)) ? 1 : 0
anchors.verticalCenter: parent.verticalCenter
antialiasing: true
height: 60
radius: 4
color: backmouse.pressed ? "#222" : "transparent"
Behavior on opacity { NumberAnimation{} }
Image {
anchors.verticalCenter: parent.verticalCenter
source: "../images/navigation_previous_item.png"
}
MouseArea {
id: backmouse
anchors.fill: parent
anchors.margins: -10
onClicked: root.Stack.view.pop()
}
}
Text {
font.pixelSize: 42
Behavior on x { NumberAnimation { easing.type: Easing.OutCubic } }
x: backButton.x + backButton.width + 20
anchors.verticalCenter: parent.verticalCenter
color: "white"
text: "Progress Bars"
}
}
Item {
anchors.top: toolbar.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
Column { Column {
spacing: 40 spacing: 40
anchors.centerIn: parent anchors.centerIn: parent
...@@ -88,7 +134,7 @@ Item { ...@@ -88,7 +134,7 @@ Item {
value: 1 value: 1
width: 400 width: 400
} }
}
} }
Component { Component {
......
...@@ -43,13 +43,59 @@ ...@@ -43,13 +43,59 @@
import QtQuick 2.1 import QtQuick 2.1
import QtQuick.Controls 1.0 //needed for the Stack attached property
import QtQuick.Controls.Nemo 1.0 import QtQuick.Controls.Nemo 1.0
import QtQuick.Controls.Styles.Nemo 1.0 import QtQuick.Controls.Styles.Nemo 1.0
Item { Rectangle {
id: root
width: parent.width width: parent.width
height: parent.height height: parent.height
color: "black"
ToolBar {
id: toolbar
anchors.top: parent.top
Rectangle {
id: backButton
width: opacity ? 60 : 0
anchors.left: parent.left
anchors.leftMargin: 20
opacity: (root.Stack.view && (root.Stack.view.depth > 1)) ? 1 : 0
anchors.verticalCenter: parent.verticalCenter
antialiasing: true
height: 60
radius: 4
color: backmouse.pressed ? "#222" : "transparent"
Behavior on opacity { NumberAnimation{} }
Image {
anchors.verticalCenter: parent.verticalCenter
source: "../images/navigation_previous_item.png"
}
MouseArea {
id: backmouse
anchors.fill: parent
anchors.margins: -10
onClicked: root.Stack.view.pop()
}
}
Text {
font.pixelSize: 42
Behavior on x { NumberAnimation { easing.type: Easing.OutCubic } }
x: backButton.x + backButton.width + 20
anchors.verticalCenter: parent.verticalCenter
color: "white"
text: "Sliders"
}
}
Item {
anchors.top: toolbar.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
Column { Column {
spacing: 12 spacing: 12
anchors.centerIn: parent anchors.centerIn: parent
...@@ -69,7 +115,7 @@ Item { ...@@ -69,7 +115,7 @@ Item {
style: touchStyle style: touchStyle
value: 1.0 value: 1.0
} }
}
} }
Component { Component {
......
...@@ -43,15 +43,58 @@ ...@@ -43,15 +43,58 @@
import QtQuick 2.1 import QtQuick 2.1
import QtQuick.Controls 1.0 //needed for the Stack attached property
import QtQuick.Controls.Nemo 1.0 import QtQuick.Controls.Nemo 1.0
import QtQuick.Controls.Styles.Nemo 1.0 import QtQuick.Controls.Styles.Nemo 1.0
Item { Rectangle {
id: root
width: parent.width width: parent.width
height: parent.height height: parent.height
TabView { color: "black"
ToolBar {
id: toolbar
anchors.top: parent.top
Rectangle {
id: backButton
width: opacity ? 60 : 0
anchors.left: parent.left
anchors.leftMargin: 20
opacity: (root.Stack.view && (root.Stack.view.depth > 1)) ? 1 : 0
anchors.verticalCenter: parent.verticalCenter
antialiasing: true
height: 60
radius: 4
color: backmouse.pressed ? "#222" : "transparent"
Behavior on opacity { NumberAnimation{} }
Image {
anchors.verticalCenter: parent.verticalCenter
source: "../images/navigation_previous_item.png"
}
MouseArea {
id: backmouse
anchors.fill: parent anchors.fill: parent
anchors.margins: -10
onClicked: root.Stack.view.pop()
}
}
Text {
font.pixelSize: 42
Behavior on x { NumberAnimation { easing.type: Easing.OutCubic } }
x: backButton.x + backButton.width + 20
anchors.verticalCenter: parent.verticalCenter
color: "white"
text: "Tab Bars"
}
}
TabView {
anchors.top: toolbar.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
style: touchStyle style: touchStyle
Tab { Tab {
title: "Buttons" title: "Buttons"
......
...@@ -43,13 +43,16 @@ ...@@ -43,13 +43,16 @@
import QtQuick 2.1 import QtQuick 2.1
import QtQuick.Controls 1.0 //needed for the Stack attached property
import QtQuick.Controls.Nemo 1.0 import QtQuick.Controls.Nemo 1.0
import QtQuick.Controls.Styles.Nemo 1.0 import QtQuick.Controls.Styles.Nemo 1.0
Item { Rectangle {
id: root
width: parent.width width: parent.width
height: parent.height height: parent.height
color: "black"
property real progress: 0 property real progress: 0
SequentialAnimation on progress { SequentialAnimation on progress {
loops: Animation.Infinite loops: Animation.Infinite
...@@ -66,6 +69,49 @@ Item { ...@@ -66,6 +69,49 @@ Item {
} }
} }
ToolBar {
id: toolbar
anchors.top: parent.top
Rectangle {
id: backButton
width: opacity ? 60 : 0
anchors.left: parent.left
anchors.leftMargin: 20
opacity: (root.Stack.view && (root.Stack.view.depth > 1)) ? 1 : 0
anchors.verticalCenter: parent.verticalCenter
antialiasing: true
height: 60
radius: 4
color: backmouse.pressed ? "#222" : "transparent"
Behavior on opacity { NumberAnimation{} }
Image {
anchors.verticalCenter: parent.verticalCenter
source: "../images/navigation_previous_item.png"
}
MouseArea {
id: backmouse
anchors.fill: parent
anchors.margins: -10
onClicked: root.Stack.view.pop()
}
}
Text {
font.pixelSize: 42
Behavior on x { NumberAnimation { easing.type: Easing.OutCubic} }
x: backButton.x + backButton.width + 20
anchors.verticalCenter: parent.verticalCenter
color: "white"
text: "Text Input"
}
}
Item {
anchors.top: toolbar.bottom
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
Column { Column {
spacing: 40 spacing: 40
anchors.centerIn: parent anchors.centerIn: parent
...@@ -102,6 +148,8 @@ Item { ...@@ -102,6 +148,8 @@ Item {
readOnly: true readOnly: true
} }
} }
}
Component { Component {
id: touchStyle id: touchStyle
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
****************************************************************************/ ****************************************************************************/
import QtQuick 2.1 import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Controls.Nemo 1.0 import QtQuick.Controls.Nemo 1.0
import QtQuick.Controls.Styles.Nemo 1.0 import QtQuick.Controls.Styles.Nemo 1.0
import QtQuick.Window 2.1 import QtQuick.Window 2.1
...@@ -46,34 +47,64 @@ import "content" ...@@ -46,34 +47,64 @@ import "content"
ApplicationWindow { ApplicationWindow {
width: 854 id: appWindow
height: 480
Rectangle { contentOrientation: Screen.orientation
color: "#212126"
anchors.fill: parent
}
contentOrientation: Qt.PortraitOrientation
// Implements back key navigation // Implements back key navigation
Keys.onReleased: { Keys.onReleased: {
if (event.key === Qt.Key_Back) { if (event.key === Qt.Key_Back) {
if (stackView.depth > 1) { if (pageStack.depth > 1) {
stackView.pop(); pageStack.pop();
event.accepted = true; event.accepted = true;
} else { Qt.quit(); } } else { Qt.quit(); }
} }
} }
toolBar: ToolBar { ListModel {
id: pageModel
ListElement {
title: "Live-Coding Arena"
page: "content/LiveCoding.qml"
}
ListElement {
title: "Buttons"
page: "content/ButtonPage.qml"
}
ListElement {
title: "Sliders"
page: "content/SliderPage.qml"
}
ListElement {
title: "ProgressBar"
page: "content/ProgressBarPage.qml"
}
ListElement {
title: "Tabs"
page: "content/TabBarPage.qml"
}
ListElement {
title: "TextInput"
page: "content/TextInputPage.qml"
}
}
initialPage: Rectangle {
id: pageItem
width: parent.width width: parent.width
height: 100 height: parent.height
color: "black"
ToolBar {
id: toolbar
anchors.top: parent.top
Rectangle { Rectangle {
id: backButton id: backButton
width: opacity ? 60 : 0 width: opacity ? 60 : 0
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 20 anchors.leftMargin: 20
opacity: stackView.depth > 1 ? 1 : 0 opacity: pageItem.Stack.view.depth > 1 ? 1 : 0
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
antialiasing: true antialiasing: true
height: 60 height: 60
...@@ -88,7 +119,7 @@ ApplicationWindow { ...@@ -88,7 +119,7 @@ ApplicationWindow {
id: backmouse id: backmouse
anchors.fill: parent anchors.fill: parent
anchors.margins: -10 anchors.margins: -10
onClicked: stackView.pop() onClicked: pageItem.Stack.view.pop()
} }
} }
...@@ -101,51 +132,18 @@ ApplicationWindow { ...@@ -101,51 +132,18 @@ ApplicationWindow {
text: "Widget Gallery" text: "Widget Gallery"
} }
} }
ListModel {
id: pageModel
ListElement {
title: "Live-Coding Arena"
page: "content/LiveCoding.qml"
}
ListElement {
title: "Buttons"
page: "content/ButtonPage.qml"
}
ListElement {
title: "Sliders"
page: "content/SliderPage.qml"
}
ListElement {
title: "ProgressBar"
page: "content/ProgressBarPage.qml"
}
ListElement {
title: "Tabs"
page: "content/TabBarPage.qml"
}
ListElement {
title: "TextInput"
page: "content/TextInputPage.qml"
}
}
StackView {
id: stackView
anchors.fill: parent
initialItem: Item {
width: parent.width
height: parent.height
ListView { ListView {
model: pageModel model: pageModel
anchors.fill: parent anchors { top: toolbar.bottom; left: parent.left; right: parent.right; bottom: parent.bottom }
clip: true
delegate: AndroidDelegate { delegate: AndroidDelegate {
text: title text: title
onClicked: stackView.push(Qt.resolvedUrl(page)) onClicked: pageItem.Stack.view.push(Qt.resolvedUrl(page))
}
} }
} }
} }
} }
...@@ -9,9 +9,11 @@ Source0: %{name}-%{version}.tar.xz ...@@ -9,9 +9,11 @@ Source0: %{name}-%{version}.tar.xz
BuildRequires: qt5-qtcore-devel BuildRequires: qt5-qtcore-devel
BuildRequires: qt5-qtgui-devel BuildRequires: qt5-qtgui-devel
BuildRequires: qt5-qtdeclarative-devel BuildRequires: qt5-qtdeclarative-devel
BuildRequires: qt5-qtopengl-devel
BuildRequires: qt5-qtdeclarative-qtquick-devel BuildRequires: qt5-qtdeclarative-qtquick-devel
BuildRequires: qt5-qtv8-devel BuildRequires: qt5-qtv8-devel
BuildRequires: qt5-qmake BuildRequires: qt5-qmake
BuildRequires: pkgconfig(Qt5Quick)
BuildRequires: fdupes BuildRequires: fdupes
Requires: qt5-qtquickcontrols Requires: qt5-qtquickcontrols
Requires: qt5-qtgraphicaleffects Requires: qt5-qtgraphicaleffects
......
This diff is collapsed.
...@@ -7,18 +7,21 @@ THEME_IMPORT_PATH = QtQuick/Controls/Styles/Nemo/themes ...@@ -7,18 +7,21 @@ THEME_IMPORT_PATH = QtQuick/Controls/Styles/Nemo/themes
# Added/Reimplemented Controls # Added/Reimplemented Controls
QML_FILES += \ QML_FILES += \
Button.qml Button.qml \
ApplicationWindow.qml
OTHER_FILES += qmldir \ OTHER_FILES += qmldir \
$$QML_FILES $$QML_FILES
HEADERS += \ HEADERS += \
qquicknemocontrolsextensionplugin.h \ qquicknemocontrolsextensionplugin.h \
hacks.h hacks.h \
nemowindow.h
SOURCES += \ SOURCES += \
qquicknemocontrolsextensionplugin.cpp \ qquicknemocontrolsextensionplugin.cpp \
hacks.cpp hacks.cpp \
nemowindow.cpp
target.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH target.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH
......
/*
* 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.
*/
#include "nemowindow.h"
#include <QDebug>
NemoWindow::NemoWindow(QWindow *parent) :
QQuickWindow(parent)
{
}
Qt::ScreenOrientations NemoWindow::allowedOrientations() const {
return m_allowedOrientations;
}
void NemoWindow::setAllowedOrientations(Qt::ScreenOrientations allowed) {
//This way no invalid values can get assigned to allowedOrientations
//README: This is needed because otherwise you could assign it
//things like (Qt.PortraitOrientation | 444) from QML
Qt::ScreenOrientations max = (Qt::PortraitOrientation | Qt::LandscapeOrientation
| Qt::InvertedPortraitOrientation | Qt::InvertedLandscapeOrientation);
if (m_allowedOrientations != allowed && allowed <= max) {
m_allowedOrientations = allowed;
emit allowedOrientationsChanged();
}
}
#ifndef NEMOWINDOW_H
#define NEMOWINDOW_H
/*
* 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.
*/
#include <QQuickWindow>
#include <QtCore/qnamespace.h>
class NemoWindow : public QQuickWindow
{
Q_OBJECT
Q_ENUMS(Orientation)
Q_PROPERTY(Qt::ScreenOrientations allowedOrientations READ allowedOrientations WRITE setAllowedOrientations NOTIFY allowedOrientationsChanged)
public:
explicit NemoWindow(QWindow *parent = 0);
Qt::ScreenOrientations allowedOrientations() const;
void setAllowedOrientations(Qt::ScreenOrientations allowed);
signals:
void allowedOrientationsChanged();
public slots:
private:
Qt::ScreenOrientations m_allowedOrientations;
};
#endif // NEMOWINDOW_H
...@@ -9,6 +9,7 @@ plugin nemocontrolsplugin ...@@ -9,6 +9,7 @@ plugin nemocontrolsplugin
# GlacierSlider 1.0 GlacierSlider.qml # GlacierSlider 1.0 GlacierSlider.qml
Button 1.0 Button.qml Button 1.0 Button.qml
ApplicationWindow 1.0 ApplicationWindow.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.
...@@ -19,7 +20,6 @@ Button 1.0 Button.qml ...@@ -19,7 +20,6 @@ Button 1.0 Button.qml
# case Nemo plugin doesn't provide an overridden component) # case Nemo plugin doesn't provide an overridden component)
# NOTE: "../" here is assumed to be the relative path to the official QQC!! # NOTE: "../" here is assumed to be the relative path to the official QQC!!
ApplicationWindow 1.0 ../ApplicationWindow.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
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "qquicknemocontrolsextensionplugin.h" #include "qquicknemocontrolsextensionplugin.h"
#include <QtQml> #include <QtQml>
#include "hacks.h" #include "hacks.h"
#include "nemowindow.h"
QQuickNemoControlsExtensionPlugin::QQuickNemoControlsExtensionPlugin(QObject *parent) : QQuickNemoControlsExtensionPlugin::QQuickNemoControlsExtensionPlugin(QObject *parent) :
QQmlExtensionPlugin(parent) QQmlExtensionPlugin(parent)
...@@ -37,7 +38,7 @@ void QQuickNemoControlsExtensionPlugin::registerTypes(const char *uri) ...@@ -37,7 +38,7 @@ 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, "NemoHacks", nemo_hacks_singletontype_provider); qmlRegisterSingletonType<QObject>(uri, 1, 0, "NemoHacks", nemo_hacks_singletontype_provider);
qmlRegisterType<NemoWindow>(uri, 1, 0, "NemoWindow");
} }
void QQuickNemoControlsExtensionPlugin::initializeEngine(QQmlEngine *engine, const char *uri) void QQuickNemoControlsExtensionPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
......
...@@ -43,6 +43,7 @@ NemoTheme::NemoTheme(QObject *parent) ...@@ -43,6 +43,7 @@ NemoTheme::NemoTheme(QObject *parent)
, m_groove(new NemoThemeGroove(this)) , m_groove(new NemoThemeGroove(this))
, m_textField(new NemoThemeTextField(this)) , m_textField(new NemoThemeTextField(this))
, m_toolBar(new NemoThemeToolBar(this)) , m_toolBar(new NemoThemeToolBar(this))
, m_window(new NemoThemeWindow(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");
...@@ -105,6 +106,11 @@ NemoThemeToolBar * NemoTheme::toolBar() const ...@@ -105,6 +106,11 @@ NemoThemeToolBar * NemoTheme::toolBar() const
return m_toolBar; return m_toolBar;
} }
NemoThemeWindow * NemoTheme::window() const
{
return m_window;
}
QString NemoTheme::fontFamily() const QString NemoTheme::fontFamily() const
{ {
return m_fontFamily; return m_fontFamily;
...@@ -312,4 +318,7 @@ void NemoTheme::loadFromFile(const QString &fileName) ...@@ -312,4 +318,7 @@ void NemoTheme::loadFromFile(const QString &fileName)
// Setting properties for toolBar // Setting properties for toolBar
QJsonObject stylesToolBar = styles.value("toolBar").toObject(); QJsonObject stylesToolBar = styles.value("toolBar").toObject();
m_toolBar->setBackground(jsonToColor(jsonValue(stylesToolBar, "background", "toolBar"), defines)); m_toolBar->setBackground(jsonToColor(jsonValue(stylesToolBar, "background", "toolBar"), defines));
// Setting properties for window
QJsonObject stylesWindow = styles.value("window").toObject();
m_window->setBackground(jsonToColor(jsonValue(stylesWindow, "background", "window"), defines));
} }
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "nemothemegroove.h" #include "nemothemegroove.h"
#include "nemothemetextfield.h" #include "nemothemetextfield.h"
#include "nemothemetoolbar.h" #include "nemothemetoolbar.h"
#include "nemothemewindow.h"
class NemoTheme: public QObject class NemoTheme: public QObject
{ {
...@@ -40,6 +41,7 @@ class NemoTheme: public QObject ...@@ -40,6 +41,7 @@ class NemoTheme: public QObject
Q_PROPERTY(NemoThemeGroove * groove READ groove CONSTANT) Q_PROPERTY(NemoThemeGroove * groove READ groove CONSTANT)
Q_PROPERTY(NemoThemeTextField * textField READ textField CONSTANT) Q_PROPERTY(NemoThemeTextField * textField READ textField CONSTANT)
Q_PROPERTY(NemoThemeToolBar * toolBar READ toolBar CONSTANT) Q_PROPERTY(NemoThemeToolBar * toolBar READ toolBar CONSTANT)
Q_PROPERTY(NemoThemeWindow * window READ window 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);
...@@ -52,6 +54,7 @@ public: ...@@ -52,6 +54,7 @@ public:
NemoThemeGroove * groove() const; NemoThemeGroove * groove() const;
NemoThemeTextField * textField() const; NemoThemeTextField * textField() const;
NemoThemeToolBar * toolBar() const; NemoThemeToolBar * toolBar() const;
NemoThemeWindow * window() const;
QString fontFamily() const; QString fontFamily() const;
public Q_SLOTS: public Q_SLOTS:
void loadFromFile(const QString &fileName); void loadFromFile(const QString &fileName);
...@@ -66,6 +69,7 @@ private: ...@@ -66,6 +69,7 @@ private:
NemoThemeGroove * m_groove; NemoThemeGroove * m_groove;
NemoThemeTextField * m_textField; NemoThemeTextField * m_textField;
NemoThemeToolBar * m_toolBar; NemoThemeToolBar * m_toolBar;
NemoThemeWindow * m_window;
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 "nemothemewindow.h"
NemoThemeWindow::NemoThemeWindow(QObject *parent)
: QObject(parent)
{
}
QColor NemoThemeWindow::background() const
{
return m_background;
}
void NemoThemeWindow::setBackground(const QColor &background)
{
if (m_background != background) {
m_background = background;
emit backgroundChanged();
}
}
/*
* 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 NEMOTHEMEWINDOW_H
#define NEMOTHEMEWINDOW_H
#include <QtCore/QObject>
#include <QtGui/QColor>
class NemoThemeWindow: public QObject
{
Q_OBJECT
Q_PROPERTY(QColor background READ background NOTIFY backgroundChanged)
public:
explicit NemoThemeWindow(QObject *parent = 0);
QColor background() const;
void setBackground(const QColor &background);
Q_SIGNALS:
void backgroundChanged();
private:
QColor m_background;
};
#endif //NEMOTHEMEWINDOW_H
...@@ -46,6 +46,7 @@ void QQuickNemoStyleExtensionPlugin::registerTypes(const char *uri) ...@@ -46,6 +46,7 @@ void QQuickNemoStyleExtensionPlugin::registerTypes(const char *uri)
qmlRegisterUncreatableType<NemoThemeGroove>(uri, 1, 0, "NemoThemeGroove", reason); qmlRegisterUncreatableType<NemoThemeGroove>(uri, 1, 0, "NemoThemeGroove", reason);
qmlRegisterUncreatableType<NemoThemeTextField>(uri, 1, 0, "NemoThemeTextField", reason); qmlRegisterUncreatableType<NemoThemeTextField>(uri, 1, 0, "NemoThemeTextField", reason);
qmlRegisterUncreatableType<NemoThemeToolBar>(uri, 1, 0, "NemoThemeToolBar", reason); qmlRegisterUncreatableType<NemoThemeToolBar>(uri, 1, 0, "NemoThemeToolBar", reason);
qmlRegisterUncreatableType<NemoThemeWindow>(uri, 1, 0, "NemoThemeWindow", reason);
qmlRegisterSingletonType<QObject>(uri, 1, 0, "Theme", nemo_theme_provider); qmlRegisterSingletonType<QObject>(uri, 1, 0, "Theme", nemo_theme_provider);
} }
......
...@@ -85,7 +85,8 @@ HEADERS += \ ...@@ -85,7 +85,8 @@ HEADERS += \
autogenerated/nemothemefont.h \ autogenerated/nemothemefont.h \
autogenerated/nemothemegroove.h \ autogenerated/nemothemegroove.h \
autogenerated/nemothemetextfield.h \ autogenerated/nemothemetextfield.h \
autogenerated/nemothemetoolbar.h autogenerated/nemothemetoolbar.h \
autogenerated/nemothemewindow.h
SOURCES += \ SOURCES += \
qquicknemostyleextensionplugin.cpp \ qquicknemostyleextensionplugin.cpp \
...@@ -96,7 +97,8 @@ SOURCES += \ ...@@ -96,7 +97,8 @@ SOURCES += \
autogenerated/nemothemefont.cpp \ autogenerated/nemothemefont.cpp \
autogenerated/nemothemegroove.cpp \ autogenerated/nemothemegroove.cpp \
autogenerated/nemothemetextfield.cpp \ autogenerated/nemothemetextfield.cpp \
autogenerated/nemothemetoolbar.cpp autogenerated/nemothemetoolbar.cpp \
autogenerated/nemothemewindow.cpp
INSTALLS += target images qmlfiles themes INSTALLS += target images qmlfiles themes
......
...@@ -40,6 +40,9 @@ ...@@ -40,6 +40,9 @@
}, },
"toolBar": { "toolBar": {
"background": "#000000" "background": "#000000"
},
"window": {
"background": "#000000"
} }
} }
} }
...@@ -37,6 +37,9 @@ ...@@ -37,6 +37,9 @@
"textField": { "textField": {
"selectedTextColor": "#ffffff", "selectedTextColor": "#ffffff",
"selectionColor": "#0091e5" "selectionColor": "#0091e5"
},
"window": {
"background": "#000000"
} }
} }
} }
...@@ -53,6 +53,15 @@ ...@@ -53,6 +53,15 @@
} }
] ]
}, },
{
"name": "Window",
"properties": [
{
"name": "background",
"type": "QColor"
}
]
},
...@@ -141,6 +150,10 @@ ...@@ -141,6 +150,10 @@
{ {
"name": "toolBar", "name": "toolBar",
"object": "ToolBar" "object": "ToolBar"
},
{
"name": "window",
"object": "Window"
} }
], ],
"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