Commit 1c6e7e91 authored by Andrea Bernabei's avatar Andrea Bernabei

[components] Add Page and fix ApplicationWindow accordingly

parent d570d470
...@@ -142,8 +142,6 @@ ApplicationWindow { ...@@ -142,8 +142,6 @@ ApplicationWindow {
} }
} }
} }
} }
...@@ -50,8 +50,24 @@ NemoWindow { ...@@ -50,8 +50,24 @@ NemoWindow {
orientationConstraintsChanged() orientationConstraintsChanged()
} }
function orientationConstraintsChanged() { Screen.onOrientationChanged: {
if (!isOrientationAllowed(contentArea.filteredOrientation)) { if (root.isOrientationAllowed(Screen.orientation)) {
contentArea.filteredOrientation = Screen.orientation
}
}
function orientationConstraintsChanged()
{
//if the current orientation is not allowed anymore, fallback to an allowed one
//stackInitialized check prevents setting an orientation before the stackview
//(but more importantly the initialItem of the stack) has been created
if(stackView.stackInitialized && !isOrientationAllowed(contentArea.filteredOrientation)) {
fallbackToAnAllowedOrientation()
}
}
function fallbackToAnAllowedOrientation()
{
var orientations = [Qt.PortraitOrientation, Qt.LandscapeOrientation, var orientations = [Qt.PortraitOrientation, Qt.LandscapeOrientation,
Qt.InvertedPortraitOrientation, Qt.InvertedLandscapeOrientation] Qt.InvertedPortraitOrientation, Qt.InvertedLandscapeOrientation]
...@@ -64,7 +80,6 @@ NemoWindow { ...@@ -64,7 +80,6 @@ NemoWindow {
} }
} }
} }
}
// TODO: We're assuming default fb orientation of the hw is portrait // 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 // Soon a compositor fix will be published that will make that consistent on all hw
...@@ -76,7 +91,8 @@ NemoWindow { ...@@ -76,7 +91,8 @@ NemoWindow {
// XXX: This is to account for HW screen rotation // XXX: This is to account for HW screen rotation
// Sooner or later we will get rid of this as the compositor will // Sooner or later we will get rid of this as the compositor will
// do that for us // do that for us
function rotationToTrasposeToPortrait() { function rotationToTrasposeToPortrait()
{
switch (Screen.primaryOrientation) { switch (Screen.primaryOrientation) {
case Qt.PortraitOrientation: case Qt.PortraitOrientation:
return 0 return 0
...@@ -89,8 +105,8 @@ NemoWindow { ...@@ -89,8 +105,8 @@ NemoWindow {
} }
} }
function isOrientationAllowed(orientationToBeChecked) { function isOrientationAllowed(orientationToBeChecked)
{
var allowedOrientations = root.allowedOrientations var allowedOrientations = root.allowedOrientations
//use Page's allowed orientations if available //use Page's allowed orientations if available
...@@ -98,13 +114,10 @@ NemoWindow { ...@@ -98,13 +114,10 @@ NemoWindow {
allowedOrientations = 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 //check if orientation is part of the allowed orientations mask
//bit-by-bit AND //bit-by-bit AND
//NOTE: this also returns false if orientationToBeChecked == 0,
//so we don't need additional checks for that
return (orientationToBeChecked & allowedOrientations) return (orientationToBeChecked & allowedOrientations)
} }
...@@ -131,7 +144,7 @@ NemoWindow { ...@@ -131,7 +144,7 @@ NemoWindow {
property alias defaultOrientationTransition: orientationState.defaultTransition property alias defaultOrientationTransition: orientationState.defaultTransition
// This is used for states switching // This is used for states switching
property int filteredOrientation: Qt.PortraitOrientation property int filteredOrientation
//this is the reliable value which changes during the orientation transition //this is the reliable value which changes during the orientation transition
//the default value is set to Qt.PortraitOrientation //the default value is set to Qt.PortraitOrientation
...@@ -139,25 +152,45 @@ NemoWindow { ...@@ -139,25 +152,45 @@ NemoWindow {
property bool orientationTransitionRunning: false property bool orientationTransitionRunning: false
Screen.onOrientationChanged: {
if (root.isOrientationAllowed(Screen.orientation)) filteredOrientation = Screen.orientation
}
StackView { StackView {
id: stackView id: stackView
width: parent.width width: parent.width
height: parent.height height: parent.height
//this has to be a function, property won't work inside onCurrentItemChanged, as currentItem in that slot will be outdated Component.onCompleted: stackInitialized = true
//(i.e. not yet updated to the new value) //IMPORTANT: this property makes it so that at app startup we wait for the initial page to be pushed
function _isCurrentItemNemoPage() { return currentItem && currentItem.hasOwnProperty("__isNemoPage") } //before determining the initial ui orientation (see the states logic below)
//If we don't use this, the orientation will change first time based on NemoWindow's allowedOrientation,
//and the second time based on the allowedOrientations of the initialItem of the stack.
//Using this property avoids that, and make the UI directly start in the correct orientation
//TODO: find a cleaner way to do it (if there's any)
property bool stackInitialized: false
onStackInitializedChanged: if (stackInitialized) {
//set Screen.orientation as default, if allowed
if (root.isOrientationAllowed(Screen.orientation)) {
contentArea.filteredOrientation = Screen.orientation
} else {
//let the window handle it, it will fall back to an allowed orientation
root.orientationConstraintsChanged()
}
}
//this has to be a function, property won't work inside onCurrentItemChanged, as the property binding hasn't been updated yet there
//(hence we'd be using the old currentItem)
function _isCurrentItemNemoPage()
{
return currentItem && currentItem.hasOwnProperty("__isNemoPage")
}
//update orientation constraints when a Page is pushed/popped
onCurrentItemChanged: if (_isCurrentItemNemoPage() && currentItem.allowedOrientations)
root.orientationConstraintsChanged()
//This properties are accessible for free by the Page via Stack.view.<property> //This properties are accessible for free by the Page via Stack.view.<property>
readonly property int orientation: contentArea.uiOrientation readonly property int orientation: contentArea.uiOrientation
property alias allowedOrientations: root.allowedOrientations property alias allowedOrientations: root.allowedOrientations
property alias orientationTransitionRunning: contentArea.orientationTransitionRunning property alias orientationTransitionRunning: contentArea.orientationTransitionRunning
//TODO: CHECK IF THE TARGET IS ACTUALLY CHANGING (i.e. function works like a binding)
Connections { Connections {
id: pageConn id: pageConn
target: stackView._isCurrentItemNemoPage() ? stackView.currentItem : null target: stackView._isCurrentItemNemoPage() ? stackView.currentItem : null
...@@ -173,11 +206,11 @@ NemoWindow { ...@@ -173,11 +206,11 @@ NemoWindow {
states: [ states: [
State { State {
name: 'Unanimated' name: 'Unanimated'
when: !stackView when: !stackView || !stackInitialized
}, },
State { State {
name: 'Portrait' name: 'Portrait'
when: contentArea.filteredOrientation === Qt.PortraitOrientation when: contentArea.filteredOrientation === Qt.PortraitOrientation// && stackInitialized
PropertyChanges { PropertyChanges {
target: contentArea target: contentArea
restoreEntryValues: false restoreEntryValues: false
...@@ -189,7 +222,7 @@ NemoWindow { ...@@ -189,7 +222,7 @@ NemoWindow {
}, },
State { State {
name: 'Landscape' name: 'Landscape'
when: contentArea.filteredOrientation === Qt.LandscapeOrientation when: contentArea.filteredOrientation === Qt.LandscapeOrientation //&& stackInitialized
PropertyChanges { PropertyChanges {
target: contentArea target: contentArea
restoreEntryValues: false restoreEntryValues: false
...@@ -201,7 +234,7 @@ NemoWindow { ...@@ -201,7 +234,7 @@ NemoWindow {
}, },
State { State {
name: 'PortraitInverted' name: 'PortraitInverted'
when: contentArea.filteredOrientation === Qt.InvertedPortraitOrientation when: contentArea.filteredOrientation === Qt.InvertedPortraitOrientation //&& stackInitialized
PropertyChanges { PropertyChanges {
target: contentArea target: contentArea
restoreEntryValues: false restoreEntryValues: false
...@@ -213,7 +246,7 @@ NemoWindow { ...@@ -213,7 +246,7 @@ NemoWindow {
}, },
State { State {
name: 'LandscapeInverted' name: 'LandscapeInverted'
when: contentArea.filteredOrientation === Qt.InvertedLandscapeOrientation when: contentArea.filteredOrientation === Qt.InvertedLandscapeOrientation //&& stackInitialized
PropertyChanges { PropertyChanges {
target: contentArea target: contentArea
restoreEntryValues: false restoreEntryValues: false
...@@ -265,9 +298,6 @@ NemoWindow { ...@@ -265,9 +298,6 @@ NemoWindow {
} }
} }
} }
} }
} }
/****************************************************************************************
**
** Copyright (C) 2013 Andrea Bernabei <and.bernabei@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 things like Stack attached properties
import QtQuick.Controls.Nemo 1.0
import QtQuick.Controls.Styles.Nemo 1.0
import QtQuick.Window 2.0
NemoPage {
id: page
width: parent.width
height: parent.height
property alias color: background.color
property int status: pageStack ? Stack.status : Stack.Inactive
property alias tools: toolBar.data
property alias __dimmer: dimmer
readonly property StackView pageStack: Stack.view
//Children of "page" will be automatically reparented to "content"
default property alias __content: content.data
//TODO: move to c++ to do type/value checking
//this is read by AppWindow and StackView to update orientation accordingly
property int allowedOrientations
//TODO: Page pageStack is null when page is pushed, so this will default to Portrait
// We may want to avoid this useless change of value on page creation (how?)
readonly property int orientation: pageStack ? pageStack.orientation : Qt.PortraitOrientation
//TODO: alias these properties with those of the applicationWindow
//property alias orientationTransitions
//property alias defaultOrientationTransition
readonly property bool orientationTransitionRunning: pageStack ? pageStack.orientationTransitionRunning : false
readonly property bool isPortrait: (orientation === Qt.PortraitOrientation || orientation === Qt.InvertedPortraitOrientation)
readonly property bool isLandscape: (orientation === Qt.LandscapeOrientation || orientation === Qt.InvertedLandscapeOrientation)
property bool __isNemoPage
Rectangle {
id: background
anchors.fill: parent
color: Theme.page.background
}
ToolBar {
id: toolBar
}
Item {
id: content
anchors.bottom: parent.bottom
anchors.top: toolBar.bottom
anchors.right: parent.right
anchors.left: parent.left
}
Rectangle {
id: dimmer
height: Theme.page.dimmer.height
anchors.top: toolBar.bottom
anchors.left: parent.left
anchors.right: parent.right
gradient: Gradient {
GradientStop { position: Theme.page.dimmer.startPosition; color: Theme.page.dimmer.startColor }
GradientStop { position: Theme.page.dimmer.endPosition; color: Theme.page.dimmer.endColor }
}
}
}
...@@ -8,7 +8,8 @@ THEME_IMPORT_PATH = QtQuick/Controls/Styles/Nemo/themes ...@@ -8,7 +8,8 @@ THEME_IMPORT_PATH = QtQuick/Controls/Styles/Nemo/themes
# Added/Reimplemented Controls # Added/Reimplemented Controls
QML_FILES += \ QML_FILES += \
Button.qml \ Button.qml \
ApplicationWindow.qml ApplicationWindow.qml \
Page.qml
OTHER_FILES += qmldir \ OTHER_FILES += qmldir \
$$QML_FILES $$QML_FILES
...@@ -16,12 +17,14 @@ OTHER_FILES += qmldir \ ...@@ -16,12 +17,14 @@ OTHER_FILES += qmldir \
HEADERS += \ HEADERS += \
qquicknemocontrolsextensionplugin.h \ qquicknemocontrolsextensionplugin.h \
hacks.h \ hacks.h \
nemowindow.h nemowindow.h \
nemopage.h
SOURCES += \ SOURCES += \
qquicknemocontrolsextensionplugin.cpp \ qquicknemocontrolsextensionplugin.cpp \
hacks.cpp \ hacks.cpp \
nemowindow.cpp nemowindow.cpp \
nemopage.cpp
target.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH target.path = $$[QT_INSTALL_QML]/$$PLUGIN_IMPORT_PATH
......
...@@ -24,3 +24,13 @@ Hacks::Hacks(QQmlEngine *engine, QObject *parent) : ...@@ -24,3 +24,13 @@ Hacks::Hacks(QQmlEngine *engine, QObject *parent) :
{ {
m_engine = engine; m_engine = engine;
} }
bool Hacks::isOrientationMaskValid(Qt::ScreenOrientations orientations) {
//README: This is needed because otherwise you could assign it
//things like (Qt.PortraitOrientation | 444) from QML,
//and it would still appear as a valid Qt::ScreenOrientations in c++
Qt::ScreenOrientations max = (Qt::PortraitOrientation | Qt::LandscapeOrientation
| Qt::InvertedPortraitOrientation | Qt::InvertedLandscapeOrientation);
return (orientations <= max && orientations != 0);
}
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <QObject> #include <QObject>
#include <QQmlEngine> #include <QQmlEngine>
#include <qnamespace.h>
// NEMOHACKS // NEMOHACKS
// A UTILITY CLASS WHICH EXPOSES HACKS TO QML via NemoHacks identifier // A UTILITY CLASS WHICH EXPOSES HACKS TO QML via NemoHacks identifier
...@@ -32,6 +33,7 @@ class Hacks : public QObject ...@@ -32,6 +33,7 @@ class Hacks : public QObject
Q_OBJECT Q_OBJECT
public: public:
explicit Hacks(QQmlEngine* engine, QObject *parent = 0); explicit Hacks(QQmlEngine* engine, QObject *parent = 0);
static bool isOrientationMaskValid(Qt::ScreenOrientations orientations);
signals: signals:
......
#include "nemopage.h"
#include "hacks.h"
NemoPage::NemoPage(QQuickItem *parent) :
QQuickItem(parent)
{
}
Qt::ScreenOrientations NemoPage::allowedOrientations() const
{
return m_allowedOrientations;
}
void NemoPage::setAllowedOrientations(Qt::ScreenOrientations allowed)
{
//This way no invalid values can get assigned to allowedOrientations
if (m_allowedOrientations != allowed && Hacks::isOrientationMaskValid(allowed)) {
m_allowedOrientations = allowed;
emit allowedOrientationsChanged();
}
}
#ifndef NEMOPAGE_H
#define NEMOPAGE_H
#include <QQuickItem>
class NemoPage : public QQuickItem
{
Q_OBJECT
Q_PROPERTY(Qt::ScreenOrientations allowedOrientations READ allowedOrientations WRITE setAllowedOrientations NOTIFY allowedOrientationsChanged)
public:
explicit NemoPage(QQuickItem *parent = 0);
Qt::ScreenOrientations allowedOrientations() const;
void setAllowedOrientations(Qt::ScreenOrientations allowed);
signals:
void allowedOrientationsChanged();
public slots:
private:
Qt::ScreenOrientations m_allowedOrientations;
};
#endif // NEMOPAGE_H
...@@ -19,24 +19,22 @@ ...@@ -19,24 +19,22 @@
#include "nemowindow.h" #include "nemowindow.h"
#include <QDebug> #include <QDebug>
#include "hacks.h"
NemoWindow::NemoWindow(QWindow *parent) : NemoWindow::NemoWindow(QWindow *parent) :
QQuickWindow(parent) QQuickWindow(parent)
{ {
} }
Qt::ScreenOrientations NemoWindow::allowedOrientations() const { Qt::ScreenOrientations NemoWindow::allowedOrientations() const
{
return m_allowedOrientations; return m_allowedOrientations;
} }
void NemoWindow::setAllowedOrientations(Qt::ScreenOrientations allowed) { void NemoWindow::setAllowedOrientations(Qt::ScreenOrientations allowed)
{
//This way no invalid values can get assigned to allowedOrientations //This way no invalid values can get assigned to allowedOrientations
//README: This is needed because otherwise you could assign it if (m_allowedOrientations != allowed && Hacks::isOrientationMaskValid(allowed)) {
//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; m_allowedOrientations = allowed;
emit allowedOrientationsChanged(); emit allowedOrientationsChanged();
} }
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
class NemoWindow : public QQuickWindow class NemoWindow : public QQuickWindow
{ {
Q_OBJECT Q_OBJECT
Q_ENUMS(Orientation)
Q_PROPERTY(Qt::ScreenOrientations allowedOrientations READ allowedOrientations WRITE setAllowedOrientations NOTIFY allowedOrientationsChanged) Q_PROPERTY(Qt::ScreenOrientations allowedOrientations READ allowedOrientations WRITE setAllowedOrientations NOTIFY allowedOrientationsChanged)
public: public:
explicit NemoWindow(QWindow *parent = 0); explicit NemoWindow(QWindow *parent = 0);
......
...@@ -10,6 +10,7 @@ plugin nemocontrolsplugin ...@@ -10,6 +10,7 @@ plugin nemocontrolsplugin
Button 1.0 Button.qml Button 1.0 Button.qml
ApplicationWindow 1.0 ApplicationWindow.qml ApplicationWindow 1.0 ApplicationWindow.qml
Page 1.0 Page.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.
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <QtQml> #include <QtQml>
#include "hacks.h" #include "hacks.h"
#include "nemowindow.h" #include "nemowindow.h"
#include "nemopage.h"
QQuickNemoControlsExtensionPlugin::QQuickNemoControlsExtensionPlugin(QObject *parent) : QQuickNemoControlsExtensionPlugin::QQuickNemoControlsExtensionPlugin(QObject *parent) :
QQmlExtensionPlugin(parent) QQmlExtensionPlugin(parent)
...@@ -39,6 +40,7 @@ void QQuickNemoControlsExtensionPlugin::registerTypes(const char *uri) ...@@ -39,6 +40,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"); qmlRegisterType<NemoWindow>(uri, 1, 0, "NemoWindow");
qmlRegisterType<NemoPage>(uri, 1, 0, "NemoPage");
} }
void QQuickNemoControlsExtensionPlugin::initializeEngine(QQmlEngine *engine, const char *uri) void QQuickNemoControlsExtensionPlugin::initializeEngine(QQmlEngine *engine, const char *uri)
......
...@@ -44,6 +44,7 @@ NemoTheme::NemoTheme(QObject *parent) ...@@ -44,6 +44,7 @@ NemoTheme::NemoTheme(QObject *parent)
, 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)) , m_window(new NemoThemeWindow(this))
, m_page(new NemoThemePage(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");
...@@ -111,6 +112,11 @@ NemoThemeWindow * NemoTheme::window() const ...@@ -111,6 +112,11 @@ NemoThemeWindow * NemoTheme::window() const
return m_window; return m_window;
} }
NemoThemePage * NemoTheme::page() const
{
return m_page;
}
QString NemoTheme::fontFamily() const QString NemoTheme::fontFamily() const
{ {
return m_fontFamily; return m_fontFamily;
...@@ -321,4 +327,20 @@ void NemoTheme::loadFromFile(const QString &fileName) ...@@ -321,4 +327,20 @@ void NemoTheme::loadFromFile(const QString &fileName)
// Setting properties for window // Setting properties for window
QJsonObject stylesWindow = styles.value("window").toObject(); QJsonObject stylesWindow = styles.value("window").toObject();
m_window->setBackground(jsonToColor(jsonValue(stylesWindow, "background", "window"), defines)); m_window->setBackground(jsonToColor(jsonValue(stylesWindow, "background", "window"), defines));
// Setting properties for page
QJsonObject stylesPage = styles.value("page").toObject();
m_page->setBackground(jsonToColor(jsonValue(stylesPage, "background", "page"), defines));
// Setting properties for dimmer
QJsonObject stylesPageDimmer = stylesPage.value("dimmer").toObject();
m_page->dimmer()->setStartColor(jsonToColor(jsonValue(stylesPageDimmer, "startColor", "dimmer"), defines));
m_page->dimmer()->setEndColor(jsonToColor(jsonValue(stylesPageDimmer, "endColor", "dimmer"), defines));
if (stylesPageDimmer.contains("height")) {
m_page->dimmer()->setHeight(jsonToInt(stylesPage.value("dimmer"), defines));
}
if (stylesPageDimmer.contains("startPosition")) {
m_page->dimmer()->setStartPosition(jsonToDouble(stylesPage.value("dimmer"), defines));
}
if (stylesPageDimmer.contains("endPosition")) {
m_page->dimmer()->setEndPosition(jsonToDouble(stylesPage.value("dimmer"), defines));
}
} }
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include "nemothemetextfield.h" #include "nemothemetextfield.h"
#include "nemothemetoolbar.h" #include "nemothemetoolbar.h"
#include "nemothemewindow.h" #include "nemothemewindow.h"
#include "nemothemepage.h"
class NemoTheme: public QObject class NemoTheme: public QObject
{ {
...@@ -42,6 +43,7 @@ class NemoTheme: public QObject ...@@ -42,6 +43,7 @@ class NemoTheme: public QObject
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(NemoThemeWindow * window READ window CONSTANT)
Q_PROPERTY(NemoThemePage * page READ page 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);
...@@ -55,6 +57,7 @@ public: ...@@ -55,6 +57,7 @@ public:
NemoThemeTextField * textField() const; NemoThemeTextField * textField() const;
NemoThemeToolBar * toolBar() const; NemoThemeToolBar * toolBar() const;
NemoThemeWindow * window() const; NemoThemeWindow * window() const;
NemoThemePage * page() const;
QString fontFamily() const; QString fontFamily() const;
public Q_SLOTS: public Q_SLOTS:
void loadFromFile(const QString &fileName); void loadFromFile(const QString &fileName);
...@@ -70,6 +73,7 @@ private: ...@@ -70,6 +73,7 @@ private:
NemoThemeTextField * m_textField; NemoThemeTextField * m_textField;
NemoThemeToolBar * m_toolBar; NemoThemeToolBar * m_toolBar;
NemoThemeWindow * m_window; NemoThemeWindow * m_window;
NemoThemePage * m_page;
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 "nemothemepage.h"
NemoThemePage::NemoThemePage(QObject *parent)
: QObject(parent)
, m_dimmer(new NemoThemePageDimmer(this))
{
}
QColor NemoThemePage::background() const
{
return m_background;
}
void NemoThemePage::setBackground(const QColor &background)
{
if (m_background != background) {
m_background = background;
emit backgroundChanged();
}
}
NemoThemePageDimmer * NemoThemePage::dimmer() const
{
return m_dimmer;
}
/*
* 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 NEMOTHEMEPAGE_H
#define NEMOTHEMEPAGE_H
#include <QtCore/QObject>
#include <QtGui/QColor>
#include "nemothemepagedimmer.h"
class NemoThemePage: public QObject
{
Q_OBJECT
Q_PROPERTY(QColor background READ background NOTIFY backgroundChanged)
Q_PROPERTY(NemoThemePageDimmer * dimmer READ dimmer CONSTANT)
public:
explicit NemoThemePage(QObject *parent = 0);
QColor background() const;
void setBackground(const QColor &background);
NemoThemePageDimmer * dimmer() const;
Q_SIGNALS:
void backgroundChanged();
private:
QColor m_background;
NemoThemePageDimmer * m_dimmer;
};
#endif //NEMOTHEMEPAGE_H
/*
* 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 "nemothemepagedimmer.h"
NemoThemePageDimmer::NemoThemePageDimmer(QObject *parent)
: QObject(parent)
, m_height(15)
, m_startPosition(0)
, m_endPosition(1.0)
{
}
QColor NemoThemePageDimmer::startColor() const
{
return m_startColor;
}
void NemoThemePageDimmer::setStartColor(const QColor &startColor)
{
if (m_startColor != startColor) {
m_startColor = startColor;
emit startColorChanged();
}
}
QColor NemoThemePageDimmer::endColor() const
{
return m_endColor;
}
void NemoThemePageDimmer::setEndColor(const QColor &endColor)
{
if (m_endColor != endColor) {
m_endColor = endColor;
emit endColorChanged();
}
}
int NemoThemePageDimmer::height() const
{
return m_height;
}
void NemoThemePageDimmer::setHeight(int height)
{
if (m_height != height) {
m_height = height;
emit heightChanged();
}
}
double NemoThemePageDimmer::startPosition() const
{
return m_startPosition;
}
void NemoThemePageDimmer::setStartPosition(double startPosition)
{
if (m_startPosition != startPosition) {
m_startPosition = startPosition;
emit startPositionChanged();
}
}
double NemoThemePageDimmer::endPosition() const
{
return m_endPosition;
}
void NemoThemePageDimmer::setEndPosition(double endPosition)
{
if (m_endPosition != endPosition) {
m_endPosition = endPosition;
emit endPositionChanged();
}
}
/*
* 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 NEMOTHEMEPAGEDIMMER_H
#define NEMOTHEMEPAGEDIMMER_H
#include <QtCore/QObject>
#include <QtGui/QColor>
class NemoThemePageDimmer: public QObject
{
Q_OBJECT
Q_PROPERTY(QColor startColor READ startColor NOTIFY startColorChanged)
Q_PROPERTY(QColor endColor READ endColor NOTIFY endColorChanged)
Q_PROPERTY(int height READ height NOTIFY heightChanged)
Q_PROPERTY(double startPosition READ startPosition NOTIFY startPositionChanged)
Q_PROPERTY(double endPosition READ endPosition NOTIFY endPositionChanged)
public:
explicit NemoThemePageDimmer(QObject *parent = 0);
QColor startColor() const;
void setStartColor(const QColor &startColor);
QColor endColor() const;
void setEndColor(const QColor &endColor);
int height() const;
void setHeight(int height);
double startPosition() const;
void setStartPosition(double startPosition);
double endPosition() const;
void setEndPosition(double endPosition);
Q_SIGNALS:
void startColorChanged();
void endColorChanged();
void heightChanged();
void startPositionChanged();
void endPositionChanged();
private:
QColor m_startColor;
QColor m_endColor;
int m_height;
double m_startPosition;
double m_endPosition;
};
#endif //NEMOTHEMEPAGEDIMMER_H
...@@ -47,6 +47,9 @@ void QQuickNemoStyleExtensionPlugin::registerTypes(const char *uri) ...@@ -47,6 +47,9 @@ void QQuickNemoStyleExtensionPlugin::registerTypes(const char *uri)
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); qmlRegisterUncreatableType<NemoThemeWindow>(uri, 1, 0, "NemoThemeWindow", reason);
qmlRegisterUncreatableType<NemoThemePage>(uri, 1, 0, "NemoThemePage", reason);
qmlRegisterUncreatableType<NemoThemePageDimmer>(uri, 1, 0, "NemoThemePageDimmer", reason);
qmlRegisterSingletonType<QObject>(uri, 1, 0, "Theme", nemo_theme_provider); qmlRegisterSingletonType<QObject>(uri, 1, 0, "Theme", nemo_theme_provider);
} }
......
...@@ -86,7 +86,9 @@ HEADERS += \ ...@@ -86,7 +86,9 @@ HEADERS += \
autogenerated/nemothemegroove.h \ autogenerated/nemothemegroove.h \
autogenerated/nemothemetextfield.h \ autogenerated/nemothemetextfield.h \
autogenerated/nemothemetoolbar.h \ autogenerated/nemothemetoolbar.h \
autogenerated/nemothemewindow.h autogenerated/nemothemewindow.h \
autogenerated/nemothemepage.h \
autogenerated/nemothemepagedimmer.h
SOURCES += \ SOURCES += \
qquicknemostyleextensionplugin.cpp \ qquicknemostyleextensionplugin.cpp \
...@@ -98,7 +100,9 @@ SOURCES += \ ...@@ -98,7 +100,9 @@ SOURCES += \
autogenerated/nemothemegroove.cpp \ autogenerated/nemothemegroove.cpp \
autogenerated/nemothemetextfield.cpp \ autogenerated/nemothemetextfield.cpp \
autogenerated/nemothemetoolbar.cpp \ autogenerated/nemothemetoolbar.cpp \
autogenerated/nemothemewindow.cpp autogenerated/nemothemewindow.cpp \
autogenerated/nemothemepage.cpp \
autogenerated/nemothemepagedimmer.cpp
INSTALLS += target images qmlfiles themes INSTALLS += target images qmlfiles themes
......
...@@ -43,6 +43,13 @@ ...@@ -43,6 +43,13 @@
}, },
"window": { "window": {
"background": "#000000" "background": "#000000"
},
"page": {
"background": "#000000",
"dimmer": {
"startColor": "black",
"endColor": "transparent"
}
} }
} }
} }
...@@ -40,6 +40,13 @@ ...@@ -40,6 +40,13 @@
}, },
"window": { "window": {
"background": "#000000" "background": "#000000"
},
"page": {
"background": "#000000",
"dimmer": {
"startColor": "black",
"endColor": "transparent"
}
} }
} }
} }
...@@ -62,6 +62,19 @@ ...@@ -62,6 +62,19 @@
} }
] ]
}, },
{
"name": "Page",
"properties": [
{
"name": "background",
"type": "QColor"
},
{
"name": "dimmer",
"object": "PageDimmer"
}
]
},
...@@ -128,6 +141,34 @@ ...@@ -128,6 +141,34 @@
"default": 25 "default": 25
} }
] ]
},
{
"name": "PageDimmer",
"properties": [
{
"name": "startColor",
"type": "QColor"
},
{
"name": "endColor",
"type": "QColor"
},
{
"name": "height",
"type": "int",
"default": 15
},
{
"name": "startPosition",
"type": "double",
"default": 0
},
{
"name": "endPosition",
"type": "double",
"default": 1.0
}
]
} }
], ],
"properties": [ "properties": [
...@@ -154,6 +195,10 @@ ...@@ -154,6 +195,10 @@
{ {
"name": "window", "name": "window",
"object": "Window" "object": "Window"
},
{
"name": "page",
"object": "Page"
} }
], ],
"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