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 @@
#include <QtQml>
#include <QtQuick/QQuickView>
#include <QtCore/QString>
#include <QScreen>
#ifndef QT_NO_WIDGETS
#include <QtWidgets/QApplication>
......@@ -64,6 +65,13 @@ QT_BEGIN_NAMESPACE
int main(int argc, char *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)); \
QObject *topLevel = engine.rootObjects().value(0); \
QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel); \
......
......@@ -39,13 +39,59 @@
****************************************************************************/
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
Item {
Rectangle {
id: root
width: parent.width
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 {
spacing: 40
anchors.centerIn: parent
......@@ -70,7 +116,6 @@ Item {
text: "Go back"
onClicked: if (stackView) stackView.pop()
}
}
}
}
......@@ -18,19 +18,64 @@
*/
import QtQuick 2.1
import QtQuick.Controls 1.0 //needed for the Stack attached property
import QtQuick.Controls.Nemo 1.0
import QtQuick.Layouts 1.0
Item {
Rectangle {
id: root
width: parent.width
height: parent.height
color: "black"
property var oldItem
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.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 :/
Item {
......@@ -160,7 +205,6 @@ Item {
}
}
}
}
Item {
......
......@@ -43,13 +43,16 @@
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
Item {
Rectangle {
id: root
width: parent.width
height: parent.height
color: "black"
property real progress: 0
SequentialAnimation on progress {
loops: Animation.Infinite
......@@ -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 {
spacing: 40
anchors.centerIn: parent
......@@ -88,7 +134,7 @@ Item {
value: 1
width: 400
}
}
}
Component {
......
......@@ -43,13 +43,59 @@
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
Item {
Rectangle {
id: root
width: parent.width
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 {
spacing: 12
anchors.centerIn: parent
......@@ -69,7 +115,7 @@ Item {
style: touchStyle
value: 1.0
}
}
}
Component {
......
......@@ -43,15 +43,58 @@
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
Item {
Rectangle {
id: root
width: parent.width
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.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
Tab {
title: "Buttons"
......
......@@ -43,13 +43,16 @@
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
Item {
Rectangle {
id: root
width: parent.width
height: parent.height
color: "black"
property real progress: 0
SequentialAnimation on progress {
loops: Animation.Infinite
......@@ -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 {
spacing: 40
anchors.centerIn: parent
......@@ -102,6 +148,8 @@ Item {
readOnly: true
}
}
}
Component {
id: touchStyle
......
......@@ -39,6 +39,7 @@
****************************************************************************/
import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Controls.Nemo 1.0
import QtQuick.Controls.Styles.Nemo 1.0
import QtQuick.Window 2.1
......@@ -46,34 +47,64 @@ import "content"
ApplicationWindow {
width: 854
height: 480
Rectangle {
color: "#212126"
anchors.fill: parent
}
contentOrientation: Qt.PortraitOrientation
id: appWindow
contentOrientation: Screen.orientation
// Implements back key navigation
Keys.onReleased: {
if (event.key === Qt.Key_Back) {
if (stackView.depth > 1) {
stackView.pop();
if (pageStack.depth > 1) {
pageStack.pop();
event.accepted = true;
} 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
height: 100
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: stackView.depth > 1 ? 1 : 0
opacity: pageItem.Stack.view.depth > 1 ? 1 : 0
anchors.verticalCenter: parent.verticalCenter
antialiasing: true
height: 60
......@@ -88,7 +119,7 @@ ApplicationWindow {
id: backmouse
anchors.fill: parent
anchors.margins: -10
onClicked: stackView.pop()
onClicked: pageItem.Stack.view.pop()
}
}
......@@ -101,51 +132,18 @@ ApplicationWindow {
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 {
model: pageModel
anchors.fill: parent
anchors { top: toolbar.bottom; left: parent.left; right: parent.right; bottom: parent.bottom }
clip: true
delegate: AndroidDelegate {
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
BuildRequires: qt5-qtcore-devel
BuildRequires: qt5-qtgui-devel
BuildRequires: qt5-qtdeclarative-devel
BuildRequires: qt5-qtopengl-devel
BuildRequires: qt5-qtdeclarative-qtquick-devel
BuildRequires: qt5-qtv8-devel
BuildRequires: qt5-qmake
BuildRequires: pkgconfig(Qt5Quick)
BuildRequires: fdupes
Requires: qt5-qtquickcontrols
Requires: qt5-qtgraphicaleffects
......
/*
* 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.
*/
import QtQuick.Window 2.0
import QtQuick 2.1
import QtQuick.Controls 1.0
import QtQuick.Layouts 1.0
import QtQuick.Controls.Private 1.0
import QtQuick.Controls.Nemo 1.0
import QtQuick.Controls.Styles.Nemo 1.0
NemoWindow {
id: root
width: 320
height: 240
/*! \internal */
default property alias data: contentArea.data
property alias pageStack: stackView
property alias initialPage: stackView.initialItem
property alias orientation: contentArea.uiOrientation
readonly property var _bgColor: Theme.window.background
color: _bgColor
readonly property int defaultAllowedOrientations: Qt.PortraitOrientation | Qt.LandscapeOrientation
//these are application-wise allowed orientations, i.e. what is used if the current Page doesn't set any
allowedOrientations: defaultAllowedOrientations
onAllowedOrientationsChanged: {
orientationConstraintsChanged()
}
function orientationConstraintsChanged() {
if (!isOrientationAllowed(contentArea.filteredOrientation)) {
var orientations = [Qt.PortraitOrientation, Qt.LandscapeOrientation,
Qt.InvertedPortraitOrientation, Qt.InvertedLandscapeOrientation]
//TODO: use a better algo to fall back to the *closest* UI orientation
//example: don't go from InvertedLandscape to Landscape, but to InvertedPortrait/Portrait, if allowed
for (var i=0; i<orientations.length; i++) {
if (isOrientationAllowed(orientations[i])) {
contentArea.filteredOrientation = orientations[i]
break
}
}
}
}
// TODO: We're assuming default fb orientation of the hw is portrait
// Soon a compositor fix will be published that will make that consistent on all hw
// i.e. Screen.width will be width of portrait orientation on all hardware!
// (at the moment, Screen.width is the width of the screen in landscape mode in N9/N950, while on
// other hardware it could be width of the screen in portrait mode)
property bool __transpose: (rotationToTrasposeToPortrait() % 180) != 0
// XXX: This is to account for HW screen rotation
// Sooner or later we will get rid of this as the compositor will
// do that for us
function rotationToTrasposeToPortrait() {
switch (Screen.primaryOrientation) {
case Qt.PortraitOrientation:
return 0
case Qt.LandscapeOrientation:
return -90
case Qt.InvertedPortraitOrientation:
return -180
case Qt.InvertedLandscapeOrientation:
return -270
}
}
function isOrientationAllowed(orientationToBeChecked) {
var allowedOrientations = root.allowedOrientations
//use Page's allowed orientations if available
if (stackView._isCurrentItemNemoPage() && stackView.currentItem.allowedOrientations) {
allowedOrientations = stackView.currentItem.allowedOrientations
}
//this shouldn't happen, as orientation 0 is not part of Qt ENUM
if (!orientationToBeChecked) {
console.log("Hi! I'm a bug, report me to faenil (trying to set invalid orientation)")
return false
}
//check if orientation is part of the allowed orientations mask
//bit-by-bit AND
return (orientationToBeChecked & allowedOrientations)
}
SystemPalette {id: syspal}
Item {
id: backgroundItem
anchors.centerIn: parent
width: __transpose ? Screen.height : Screen.width
height: __transpose ? Screen.width : Screen.height
rotation: rotationToTrasposeToPortrait()
//This is the rotating item
Item {
id: contentArea
width: parent.width
height: parent.height
anchors.centerIn: parent
property int _horizontalDimension: parent ? parent.width : 0
property int _verticalDimension: parent ? parent.height : 0
property alias defaultOrientationTransition: orientationState.defaultTransition
// This is used for states switching
property int filteredOrientation: Qt.PortraitOrientation
//this is the reliable value which changes during the orientation transition
//the default value is set to Qt.PortraitOrientation
property int uiOrientation: Qt.PortraitOrientation
property bool orientationTransitionRunning: false
Screen.onOrientationChanged: {
if (root.isOrientationAllowed(Screen.orientation)) filteredOrientation = Screen.orientation
}
StackView {
id: stackView
width: parent.width
height: parent.height
//this has to be a function, property won't work inside onCurrentItemChanged, as currentItem in that slot will be outdated
//(i.e. not yet updated to the new value)
function _isCurrentItemNemoPage() { return currentItem && currentItem.hasOwnProperty("__isNemoPage") }
//This properties are accessible for free by the Page via Stack.view.<property>
readonly property int orientation: contentArea.uiOrientation
property alias allowedOrientations: root.allowedOrientations
property alias orientationTransitionRunning: contentArea.orientationTransitionRunning
//TODO: CHECK IF THE TARGET IS ACTUALLY CHANGING (i.e. function works like a binding)
Connections {
id: pageConn
target: stackView._isCurrentItemNemoPage() ? stackView.currentItem : null
onAllowedOrientationsChanged: root.orientationConstraintsChanged()
}
}
Item {
id: orientationState
state: 'Unanimated'
states: [
State {
name: 'Unanimated'
when: !stackView
},
State {
name: 'Portrait'
when: contentArea.filteredOrientation === Qt.PortraitOrientation
PropertyChanges {
target: contentArea
restoreEntryValues: false
width: _horizontalDimension
height: _verticalDimension
rotation: 0
uiOrientation: Qt.PortraitOrientation
}
},
State {
name: 'Landscape'
when: contentArea.filteredOrientation === Qt.LandscapeOrientation
PropertyChanges {
target: contentArea
restoreEntryValues: false
width: _verticalDimension
height: _horizontalDimension
rotation: 90
uiOrientation: Qt.LandscapeOrientation
}
},
State {
name: 'PortraitInverted'
when: contentArea.filteredOrientation === Qt.InvertedPortraitOrientation
PropertyChanges {
target: contentArea
restoreEntryValues: false
width: _horizontalDimension
height: _verticalDimension
rotation: 180
uiOrientation: Qt.InvertedPortraitOrientation
}
},
State {
name: 'LandscapeInverted'
when: contentArea.filteredOrientation === Qt.InvertedLandscapeOrientation
PropertyChanges {
target: contentArea
restoreEntryValues: false
width: _verticalDimension
height: _horizontalDimension
rotation: 270
uiOrientation: Qt.InvertedLandscapeOrientation
}
}
]
property Transition defaultTransition: Transition {
to: 'Portrait,Landscape,PortraitInverted,LandscapeInverted'
from: 'Portrait,Landscape,PortraitInverted,LandscapeInverted'
SequentialAnimation {
PropertyAction {
target: contentArea
property: 'orientationTransitionRunning'
value: true
}
NumberAnimation {
target: contentArea
property: 'opacity'
to: 0
duration: 150
}
PropertyAction {
target: contentArea
properties: 'width,height,rotation,uiOrientation'
}
NumberAnimation {
target: contentArea
property: 'opacity'
to: 1
duration: 150
}
PropertyAction {
target: contentArea
property: 'orientationTransitionRunning'
value: false
}
}
}
Component.onCompleted: {
if (transitions.length === 0) {
transitions = [ defaultTransition ]
}
}
}
}
}
}
......@@ -7,18 +7,21 @@ THEME_IMPORT_PATH = QtQuick/Controls/Styles/Nemo/themes
# Added/Reimplemented Controls
QML_FILES += \
Button.qml
Button.qml \
ApplicationWindow.qml
OTHER_FILES += qmldir \
$$QML_FILES
HEADERS += \
qquicknemocontrolsextensionplugin.h \
hacks.h
hacks.h \
nemowindow.h
SOURCES += \
qquicknemocontrolsextensionplugin.cpp \
hacks.cpp
hacks.cpp \
nemowindow.cpp
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
# GlacierSlider 1.0 GlacierSlider.qml
Button 1.0 Button.qml
ApplicationWindow 1.0 ApplicationWindow.qml
# MIRRORED CONTROLS:
# These are the controls that we take directly from official QQC.
......@@ -19,7 +20,6 @@ Button 1.0 Button.qml
# case Nemo plugin doesn't provide an overridden component)
# NOTE: "../" here is assumed to be the relative path to the official QQC!!
ApplicationWindow 1.0 ../ApplicationWindow.qml
CheckBox 1.0 ../CheckBox.qml
ComboBox 1.0 ../ComboBox.qml
GroupBox 1.0 ../GroupBox.qml
......
......@@ -21,6 +21,7 @@
#include "qquicknemocontrolsextensionplugin.h"
#include <QtQml>
#include "hacks.h"
#include "nemowindow.h"
QQuickNemoControlsExtensionPlugin::QQuickNemoControlsExtensionPlugin(QObject *parent) :
QQmlExtensionPlugin(parent)
......@@ -37,7 +38,7 @@ void QQuickNemoControlsExtensionPlugin::registerTypes(const char *uri)
{
Q_ASSERT(uri == QLatin1String("QtQuick.Controls.Nemo"));
qmlRegisterSingletonType<QObject>(uri, 1, 0, "NemoHacks", nemo_hacks_singletontype_provider);
qmlRegisterType<NemoWindow>(uri, 1, 0, "NemoWindow");
}
void QQuickNemoControlsExtensionPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
......
......@@ -43,6 +43,7 @@ NemoTheme::NemoTheme(QObject *parent)
, m_groove(new NemoThemeGroove(this))
, m_textField(new NemoThemeTextField(this))
, m_toolBar(new NemoThemeToolBar(this))
, m_window(new NemoThemeWindow(this))
{
loadFromFile(GLACIER_THEME);
int id = QFontDatabase::addApplicationFont("/usr/share/fonts/google-opensans/OpenSans-Regular.ttf");
......@@ -105,6 +106,11 @@ NemoThemeToolBar * NemoTheme::toolBar() const
return m_toolBar;
}
NemoThemeWindow * NemoTheme::window() const
{
return m_window;
}
QString NemoTheme::fontFamily() const
{
return m_fontFamily;
......@@ -312,4 +318,7 @@ void NemoTheme::loadFromFile(const QString &fileName)
// Setting properties for toolBar
QJsonObject stylesToolBar = styles.value("toolBar").toObject();
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 @@
#include "nemothemegroove.h"
#include "nemothemetextfield.h"
#include "nemothemetoolbar.h"
#include "nemothemewindow.h"
class NemoTheme: public QObject
{
......@@ -40,6 +41,7 @@ class NemoTheme: public QObject
Q_PROPERTY(NemoThemeGroove * groove READ groove CONSTANT)
Q_PROPERTY(NemoThemeTextField * textField READ textField CONSTANT)
Q_PROPERTY(NemoThemeToolBar * toolBar READ toolBar CONSTANT)
Q_PROPERTY(NemoThemeWindow * window READ window CONSTANT)
Q_PROPERTY(QString fontFamily READ fontFamily CONSTANT)
public:
explicit NemoTheme(QObject *parent = 0);
......@@ -52,6 +54,7 @@ public:
NemoThemeGroove * groove() const;
NemoThemeTextField * textField() const;
NemoThemeToolBar * toolBar() const;
NemoThemeWindow * window() const;
QString fontFamily() const;
public Q_SLOTS:
void loadFromFile(const QString &fileName);
......@@ -66,6 +69,7 @@ private:
NemoThemeGroove * m_groove;
NemoThemeTextField * m_textField;
NemoThemeToolBar * m_toolBar;
NemoThemeWindow * m_window;
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)
qmlRegisterUncreatableType<NemoThemeGroove>(uri, 1, 0, "NemoThemeGroove", reason);
qmlRegisterUncreatableType<NemoThemeTextField>(uri, 1, 0, "NemoThemeTextField", reason);
qmlRegisterUncreatableType<NemoThemeToolBar>(uri, 1, 0, "NemoThemeToolBar", reason);
qmlRegisterUncreatableType<NemoThemeWindow>(uri, 1, 0, "NemoThemeWindow", reason);
qmlRegisterSingletonType<QObject>(uri, 1, 0, "Theme", nemo_theme_provider);
}
......
......@@ -85,7 +85,8 @@ HEADERS += \
autogenerated/nemothemefont.h \
autogenerated/nemothemegroove.h \
autogenerated/nemothemetextfield.h \
autogenerated/nemothemetoolbar.h
autogenerated/nemothemetoolbar.h \
autogenerated/nemothemewindow.h
SOURCES += \
qquicknemostyleextensionplugin.cpp \
......@@ -96,7 +97,8 @@ SOURCES += \
autogenerated/nemothemefont.cpp \
autogenerated/nemothemegroove.cpp \
autogenerated/nemothemetextfield.cpp \
autogenerated/nemothemetoolbar.cpp
autogenerated/nemothemetoolbar.cpp \
autogenerated/nemothemewindow.cpp
INSTALLS += target images qmlfiles themes
......
......@@ -40,6 +40,9 @@
},
"toolBar": {
"background": "#000000"
},
"window": {
"background": "#000000"
}
}
}
......@@ -37,6 +37,9 @@
"textField": {
"selectedTextColor": "#ffffff",
"selectionColor": "#0091e5"
},
"window": {
"background": "#000000"
}
}
}
......@@ -53,6 +53,15 @@
}
]
},
{
"name": "Window",
"properties": [
{
"name": "background",
"type": "QColor"
}
]
},
......@@ -141,6 +150,10 @@
{
"name": "toolBar",
"object": "ToolBar"
},
{
"name": "window",
"object": "Window"
}
],
"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