Commit a5586200 authored by Lucien XU's avatar Lucien XU

[feature] Added a nicer transition effect

It is smoother, thanks to some easing curves,
and the duration is now customizable.
parent 835988af
...@@ -195,6 +195,50 @@ NemoWindow { ...@@ -195,6 +195,50 @@ NemoWindow {
target: stackView._isCurrentItemNemoPage() ? stackView.currentItem : null target: stackView._isCurrentItemNemoPage() ? stackView.currentItem : null
onAllowedOrientationsChanged: root.orientationConstraintsChanged() onAllowedOrientationsChanged: root.orientationConstraintsChanged()
} }
delegate: StackViewDelegate {
pushTransition: Component {
StackViewTransition {
PropertyAnimation {
target: enterItem
property: "x"
from: target.width
to: 0
duration: Theme.pageStack.transitionDuration
easing.type: Easing.OutQuad
}
PropertyAnimation {
target: exitItem
property: "x"
from: 0
to: -target.width
duration: Theme.pageStack.transitionDuration
easing.type: Easing.OutQuad
}
}
}
popTransition: Component {
StackViewTransition {
PropertyAnimation {
target: enterItem
property: "x"
from: -target.width
to: 0
duration: Theme.pageStack.transitionDuration
easing.type: Easing.OutQuad
}
PropertyAnimation {
target: exitItem
property: "x"
from: 0
to: target.width
duration: Theme.pageStack.transitionDuration
easing.type: Easing.OutQuad
}
}
}
}
} }
Item { Item {
......
...@@ -45,6 +45,7 @@ NemoTheme::NemoTheme(QObject *parent) ...@@ -45,6 +45,7 @@ NemoTheme::NemoTheme(QObject *parent)
, 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)) , m_page(new NemoThemePage(this))
, m_pageStack(new NemoThemePageStack(this))
, m_spinner(new NemoThemeSpinner(this)) , m_spinner(new NemoThemeSpinner(this))
, m_label(new NemoThemeLabel(this)) , m_label(new NemoThemeLabel(this))
, m_checkbox(new NemoThemeCheckbox(this)) , m_checkbox(new NemoThemeCheckbox(this))
...@@ -120,6 +121,11 @@ NemoThemePage * NemoTheme::page() const ...@@ -120,6 +121,11 @@ NemoThemePage * NemoTheme::page() const
return m_page; return m_page;
} }
NemoThemePageStack * NemoTheme::pageStack() const
{
return m_pageStack;
}
NemoThemeSpinner * NemoTheme::spinner() const NemoThemeSpinner * NemoTheme::spinner() const
{ {
return m_spinner; return m_spinner;
...@@ -396,6 +402,13 @@ void NemoTheme::loadFromFile(const QString &fileName) ...@@ -396,6 +402,13 @@ void NemoTheme::loadFromFile(const QString &fileName)
} else { } else {
m_page->dimmer()->setEndPositionDefault(); m_page->dimmer()->setEndPositionDefault();
} }
// Setting properties for pageStack
QJsonObject stylesPageStack = styles.value("pageStack").toObject();
if (stylesPageStack.contains("transitionDuration")) {
m_pageStack->setTransitionDuration(jsonToInt(stylesPageStack.value("transitionDuration"), defines));
} else {
m_pageStack->setTransitionDurationDefault();
}
// Setting properties for spinner // Setting properties for spinner
QJsonObject stylesSpinner = styles.value("spinner").toObject(); QJsonObject stylesSpinner = styles.value("spinner").toObject();
if (stylesSpinner.contains("radius")) { if (stylesSpinner.contains("radius")) {
......
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
#include "nemothemetoolbar.h" #include "nemothemetoolbar.h"
#include "nemothemewindow.h" #include "nemothemewindow.h"
#include "nemothemepage.h" #include "nemothemepage.h"
#include "nemothemepagestack.h"
#include "nemothemespinner.h" #include "nemothemespinner.h"
#include "nemothemelabel.h" #include "nemothemelabel.h"
#include "nemothemecheckbox.h" #include "nemothemecheckbox.h"
...@@ -47,6 +48,7 @@ class NemoTheme: public QObject ...@@ -47,6 +48,7 @@ class NemoTheme: public QObject
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(NemoThemePage * page READ page CONSTANT)
Q_PROPERTY(NemoThemePageStack * pageStack READ pageStack CONSTANT)
Q_PROPERTY(NemoThemeSpinner * spinner READ spinner CONSTANT) Q_PROPERTY(NemoThemeSpinner * spinner READ spinner CONSTANT)
Q_PROPERTY(NemoThemeLabel * label READ label CONSTANT) Q_PROPERTY(NemoThemeLabel * label READ label CONSTANT)
Q_PROPERTY(NemoThemeCheckbox * checkbox READ checkbox CONSTANT) Q_PROPERTY(NemoThemeCheckbox * checkbox READ checkbox CONSTANT)
...@@ -64,6 +66,7 @@ public: ...@@ -64,6 +66,7 @@ public:
NemoThemeToolBar * toolBar() const; NemoThemeToolBar * toolBar() const;
NemoThemeWindow * window() const; NemoThemeWindow * window() const;
NemoThemePage * page() const; NemoThemePage * page() const;
NemoThemePageStack * pageStack() const;
NemoThemeSpinner * spinner() const; NemoThemeSpinner * spinner() const;
NemoThemeLabel * label() const; NemoThemeLabel * label() const;
NemoThemeCheckbox * checkbox() const; NemoThemeCheckbox * checkbox() const;
...@@ -83,6 +86,7 @@ private: ...@@ -83,6 +86,7 @@ private:
NemoThemeToolBar * m_toolBar; NemoThemeToolBar * m_toolBar;
NemoThemeWindow * m_window; NemoThemeWindow * m_window;
NemoThemePage * m_page; NemoThemePage * m_page;
NemoThemePageStack * m_pageStack;
NemoThemeSpinner * m_spinner; NemoThemeSpinner * m_spinner;
NemoThemeLabel * m_label; NemoThemeLabel * m_label;
NemoThemeCheckbox * m_checkbox; NemoThemeCheckbox * m_checkbox;
......
/*
* 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 "nemothemepagestack.h"
NemoThemePageStack::NemoThemePageStack(QObject *parent)
: QObject(parent)
, m_transitionDuration(500)
{
}
int NemoThemePageStack::transitionDuration() const
{
return m_transitionDuration;
}
void NemoThemePageStack::setTransitionDuration(int transitionDuration)
{
if (m_transitionDuration != transitionDuration) {
m_transitionDuration = transitionDuration;
emit transitionDurationChanged();
}
}
void NemoThemePageStack::setTransitionDurationDefault()
{
if (m_transitionDuration != 500) {
m_transitionDuration = 500;
emit transitionDurationChanged();
}
}
/*
* 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 NEMOTHEMEPAGESTACK_H
#define NEMOTHEMEPAGESTACK_H
#include <QtCore/QObject>
class NemoThemePageStack: public QObject
{
Q_OBJECT
Q_PROPERTY(int transitionDuration READ transitionDuration NOTIFY transitionDurationChanged)
public:
explicit NemoThemePageStack(QObject *parent = 0);
int transitionDuration() const;
void setTransitionDuration(int transitionDuration);
void setTransitionDurationDefault();
Q_SIGNALS:
void transitionDurationChanged();
private:
int m_transitionDuration;
};
#endif //NEMOTHEMEPAGESTACK_H
...@@ -52,6 +52,7 @@ void QQuickNemoStyleExtensionPlugin::registerTypes(const char *uri) ...@@ -52,6 +52,7 @@ void QQuickNemoStyleExtensionPlugin::registerTypes(const char *uri)
qmlRegisterUncreatableType<NemoThemeSpinner>(uri, 1, 0, "NemoThemeSpinner", reason); qmlRegisterUncreatableType<NemoThemeSpinner>(uri, 1, 0, "NemoThemeSpinner", reason);
qmlRegisterUncreatableType<NemoThemeLabel>(uri, 1, 0, "NemoThemeLabel", reason); qmlRegisterUncreatableType<NemoThemeLabel>(uri, 1, 0, "NemoThemeLabel", reason);
qmlRegisterUncreatableType<NemoThemeCheckbox>(uri, 1, 0, "NemoThemeCheckbox", reason); qmlRegisterUncreatableType<NemoThemeCheckbox>(uri, 1, 0, "NemoThemeCheckbox", reason);
qmlRegisterUncreatableType<NemoThemePageStack>(uri, 1, 0, "NemoThemePageStack", reason);
qmlRegisterSingletonType<QObject>(uri, 1, 0, "Theme", nemo_theme_provider); qmlRegisterSingletonType<QObject>(uri, 1, 0, "Theme", nemo_theme_provider);
......
...@@ -86,7 +86,8 @@ HEADERS += \ ...@@ -86,7 +86,8 @@ HEADERS += \
autogenerated/nemothemepagedimmer.h \ autogenerated/nemothemepagedimmer.h \
autogenerated/nemothemespinner.h \ autogenerated/nemothemespinner.h \
autogenerated/nemothemelabel.h \ autogenerated/nemothemelabel.h \
autogenerated/nemothemecheckbox.h autogenerated/nemothemecheckbox.h \
autogenerated/nemothemepagestack.h
SOURCES += \ SOURCES += \
qquicknemostyleextensionplugin.cpp \ qquicknemostyleextensionplugin.cpp \
...@@ -103,7 +104,8 @@ SOURCES += \ ...@@ -103,7 +104,8 @@ SOURCES += \
autogenerated/nemothemepagedimmer.cpp \ autogenerated/nemothemepagedimmer.cpp \
autogenerated/nemothemespinner.cpp \ autogenerated/nemothemespinner.cpp \
autogenerated/nemothemelabel.cpp \ autogenerated/nemothemelabel.cpp \
autogenerated/nemothemecheckbox.cpp autogenerated/nemothemecheckbox.cpp \
autogenerated/nemothemepagestack.cpp
INSTALLS += target images qmlfiles themes INSTALLS += target images qmlfiles themes
......
...@@ -61,6 +61,9 @@ ...@@ -61,6 +61,9 @@
"checkbox": { "checkbox": {
"back1": "#0091e5", "back1": "#0091e5",
"back2": "#313131" "back2": "#313131"
},
"pageStack": {
"transitionDuration": 1500
} }
} }
} }
...@@ -233,6 +233,16 @@ ...@@ -233,6 +233,16 @@
"type": "QColor" "type": "QColor"
} }
] ]
},
{
"name": "PageStack",
"properties": [
{
"name": "transitionDuration",
"type": "int",
"default": 500
}
]
} }
], ],
"properties": [ "properties": [
...@@ -264,6 +274,10 @@ ...@@ -264,6 +274,10 @@
"name": "page", "name": "page",
"object": "Page" "object": "Page"
}, },
{
"name": "pageStack",
"object": "PageStack"
},
{ {
"name": "spinner", "name": "spinner",
"object": "Spinner" "object": "Spinner"
......
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