Merge branch 'master' into sebas/themeswitch

This commit is contained in:
Sebastian Kügler 2014-02-04 02:13:15 +01:00
commit 5f5716791a
39 changed files with 111 additions and 107 deletions

View File

@ -84,30 +84,6 @@ Item {
}
}
Row {
PlasmaComponents.Label {
text: "units.dp: "
width: cwidth
}
PlasmaComponents.Label {
width: cheight
height: cheight / 2
text: units.dp(1)
}
}
Row {
PlasmaComponents.Label {
text: "units.gu: "
width: cwidth
}
PlasmaComponents.Label {
width: cheight
height: cheight / 2
text: units.gu(1)
}
}
Row {
PlasmaComponents.Label {
text: "units.largeSpacing: "

View File

@ -157,7 +157,7 @@ Item {
target: frame
properties: "scale"
to: 0
duration: 250
duration: units.longDuration
}
ScriptAction { script: frame.destroy()}
}
@ -177,8 +177,8 @@ Item {
property real startX: mouseArea.startX/mouseArea.width
property real startY: mouseArea.startY/mouseArea.height
NumberAnimation on dx { id: dxAnim; to: 0; duration: 350; easing.type: Easing.OutElastic }
NumberAnimation on dy { id: dyAnim; to: 0; duration: 350; easing.type: Easing.OutElastic }
NumberAnimation on dx { id: dxAnim; to: 0; duration: units.longDuration; easing.type: Easing.OutElastic }
NumberAnimation on dy { id: dyAnim; to: 0; duration: units.longDuration; easing.type: Easing.OutElastic }
//! [fragment]
fragmentShader: {
"uniform lowp float qt_Opacity;" +

View File

@ -33,7 +33,8 @@
Units::Units (QObject *parent)
: QObject(parent),
m_gridUnit(-1),
m_devicePixelRatio(-1)
m_devicePixelRatio(-1),
m_longDuration(250) // default base value for animations
{
m_iconSizes = new QQmlPropertyMap(this);
updateDevicePixelRatio();
@ -130,7 +131,6 @@ void Units::updateDevicePixelRatio()
int Units::gridUnit() const
{
const int gridUnit = QFontMetrics(QApplication::font()).boundingRect("M").width();
return m_gridUnit;
}
@ -163,6 +163,17 @@ void Units::updateSpacing()
}
}
int Units::longDuration() const
{
return m_longDuration;
}
int Units::shortDuration() const
{
return m_longDuration / 5;
}
bool Units::eventFilter(QObject *watched, QEvent *event)
{
if (watched == QCoreApplication::instance()) {
@ -173,5 +184,3 @@ bool Units::eventFilter(QObject *watched, QEvent *event)
return QObject::eventFilter(watched, event);
}
#include "units.moc"

View File

@ -36,7 +36,7 @@ class Units : public QObject
* The fundamental unit of space that should be used for sizes, expressed in pixels.
* Given the screen has an accurate DPI settings, it corresponds to a millimeter
*/
Q_PROPERTY(int gridUnit READ gridUnit NOTIFY gridUnitChanged())
Q_PROPERTY(int gridUnit READ gridUnit NOTIFY gridUnitChanged)
/**
* units.iconSizes provides access to platform-dependent icon sizing
@ -83,6 +83,18 @@ class Units : public QObject
*/
Q_PROPERTY(qreal devicePixelRatio READ devicePixelRatio NOTIFY devicePixelRatioChanged)
/**
* units.longDuration should be used for longer, screen-covering animations, for opening and
* closing of dialogs and other "not too small" animations
*/
Q_PROPERTY(int longDuration READ longDuration NOTIFY durationChanged)
/**
* units.longDuration should be used for short animations, such as accentuating a UI event,
* hover events, etc..
*/
Q_PROPERTY(int shortDuration READ shortDuration NOTIFY durationChanged)
public:
Units(QObject *parent = 0);
~Units();
@ -116,11 +128,24 @@ public:
*/
int largeSpacing() const;
/**
* @return Duration for long animations, in milliseconds.
* @since 5.0
*/
int longDuration() const;
/**
* @return Duration for short animations, in milliseconds.
* @since 5.0
*/
int shortDuration() const;
Q_SIGNALS:
void devicePixelRatioChanged();
void gridUnitChanged();
void iconSizesChanged();
void spacingChanged();
void durationChanged();
private Q_SLOTS:
void themeChanged();
@ -144,6 +169,8 @@ private:
int m_smallSpacing;
int m_largeSpacing;
int m_longDuration;
};
#endif //UNITS_H

View File

@ -55,10 +55,10 @@ PlasmaCore.FrameSvgItem {
onClicked: { textField.copy(); editBubble.state = "collapsed"; }
onPressed: PropertyAnimation { target: copyIcon; properties: "scale";
from: 1.0; to: 0.9;
duration: 175; easing.type: Easing.OutExpo; }
duration: units.shortDuration * 3; easing.type: Easing.OutExpo; }
onReleased: PropertyAnimation { target: copyIcon; properties: "scale";
from: 0.9; to: 1.0;
duration: 175; easing.type: Easing.OutExpo; }
duration: units.shortDuration * 3; easing.type: Easing.OutExpo; }
}
}
PlasmaCore.IconItem {
@ -74,10 +74,10 @@ PlasmaCore.FrameSvgItem {
onClicked: { textField.paste(); editBubble.state = "collapsed"; }
onPressed: PropertyAnimation { target: pasteIcon; properties: "scale";
from: 1.0; to: 0.9;
duration: 175; easing.type: Easing.OutExpo; }
duration: units.shortDuration * 3; easing.type: Easing.OutExpo; }
onReleased: PropertyAnimation { target: pasteIcon; properties: "scale";
from: 0.9; to: 1.0;
duration: 175; easing.type: Easing.OutExpo; }
duration: units.shortDuration * 3; easing.type: Easing.OutExpo; }
}
}
}
@ -98,15 +98,15 @@ PlasmaCore.FrameSvgItem {
Transition {
from: "collapsed"; to: "expanded"
ParallelAnimation {
PropertyAnimation { properties: "opacity"; duration: 175; easing.type: Easing.InExpo; }
PropertyAnimation { properties: "scale"; duration: 175; easing.type: Easing.InExpo; }
PropertyAnimation { properties: "opacity"; duration: units.shortDuration * 3; easing.type: Easing.InExpo; }
PropertyAnimation { properties: "scale"; duration: units.shortDuration * 3; easing.type: Easing.InExpo; }
}
},
Transition {
from: "expanded"; to: "collapsed"
ParallelAnimation {
PropertyAnimation { properties: "opacity"; duration: 175; easing.type: Easing.OutExpo; }
PropertyAnimation { properties: "scale"; duration: 100; easing.type: Easing.OutExpo; }
PropertyAnimation { properties: "opacity"; duration: units.shortDuration * 3; easing.type: Easing.OutExpo; }
PropertyAnimation { properties: "scale"; duration: units.shortDuration * 2; easing.type: Easing.OutExpo; }
}
}
]

View File

@ -85,7 +85,7 @@ Item {
opacity: 0
Behavior on opacity {
NumberAnimation {
duration: 250
duration: units.longDuration
}
}
@ -172,7 +172,7 @@ Item {
opacity: dragArea.pressed?1:0
Behavior on opacity {
NumberAnimation {
duration: 250
duration: units.longDuration
}
}
}

View File

@ -50,7 +50,7 @@ Private.DualStateButton {
opacity: checked ? 1 : 0
Behavior on opacity {
PropertyAnimation { duration: 100 }
PropertyAnimation { duration: units.shortDuration * 2 }
}
}
@ -77,7 +77,7 @@ Private.DualStateButton {
width: height
x: checked ? width : 0
Behavior on x {
PropertyAnimation { duration: 100 }
PropertyAnimation { duration: units.shortDuration * 2 }
}
}
}

View File

@ -178,7 +178,7 @@ Item {
opacity: (textInput.text != "" && clearButtonShown) ? 1 : 0
Behavior on opacity {
NumberAnimation {
duration: 250
duration: units.longDuration
easing.type: Easing.InOutQuad
}
}

View File

@ -63,7 +63,7 @@ Item {
Transition {
PropertyAnimation {
properties: "opacity"
duration: 250
duration: units.longDuration
easing.type: Easing.OutQuad
}
}

View File

@ -61,7 +61,7 @@ Item {
Transition {
PropertyAnimation {
properties: "opacity"
duration: 250
duration: units.longDuration
easing.type: Easing.OutQuad
}
}

View File

@ -96,7 +96,7 @@ Item {
Transition {
PropertyAnimation {
properties: "opacity"
duration: 250
duration: units.longDuration
easing.type: Easing.OutQuad
}
}

View File

@ -29,7 +29,6 @@
* theme.
*/
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import "private" as Private
@ -215,8 +214,8 @@ Item {
to: "normal"
// Cross fade from pressed to normal
ParallelAnimation {
NumberAnimation { target: surfaceNormal; property: "opacity"; to: 1; duration: 100 }
NumberAnimation { target: surfacePressed; property: "opacity"; to: 0; duration: 100 }
NumberAnimation { target: surfaceNormal; property: "opacity"; to: 1; duration: units.shortDuration * 2 }
NumberAnimation { target: surfacePressed; property: "opacity"; to: 0; duration: units.shortDuration * 2 }
}
}
]

View File

@ -55,7 +55,7 @@ Private.DualStateButton {
}
Behavior on opacity {
NumberAnimation {
duration: 250
duration: units.longDuration
easing.type: Easing.InOutQuad
}
}

View File

@ -26,7 +26,7 @@ import org.kde.plasma.core 2.0 as PlasmaCore
* derivates)
*
* Provides built-in animation of Behavior on opacity Easing.OutQuad for a
* duration of 250.
* duration of 250 (defined in units.longDuration).
*
* (TODO, make optional? e.g. animate: false)
*/
@ -55,7 +55,7 @@ Item {
Behavior on opacity {
NumberAnimation {
duration: 250
duration: units.longDuration
easing.type: Easing.OutQuad
}
}
@ -75,7 +75,7 @@ Item {
Behavior on opacity {
NumberAnimation {
duration: 250
duration: units.longDuration
easing.type: Easing.OutQuad
}
}

View File

@ -94,7 +94,7 @@ Item {
Component.onCompleted: {
prefix = (listItem.sectionDelegate ? "section" : (listItem.checked ? "pressed" : "normal"))
}
Behavior on opacity { NumberAnimation { duration: 200 } }
Behavior on opacity { NumberAnimation { duration: units.longDuration } }
}
PlasmaCore.SvgItem {
svg: PlasmaCore.Svg {imagePath: "widgets/listitem"}

View File

@ -44,6 +44,8 @@
// navigation model. Pages can be defined as QML items or components.
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import "." 2.0 as PlasmaComponents
import "private/PageStack.js" as Engine
@ -81,7 +83,7 @@ Item {
/**
* Should page transitions be animated? Default is true.
*/
property bool animate: true
property bool animate: units.longDuration > 0
/**
* The page to be automatically loaded when this PageStack component gets
@ -264,7 +266,7 @@ Item {
property int stackWidth: Math.max(root.width, root.height)
// Duration of transition animation (in ms)
property int transitionDuration: root.animate ? 150 : 0
property int transitionDuration: root.animate ? units.longAnimation / 2 : 0
// Flag that indicates the container should be cleaned up after the transition has ended.
property bool cleanupAfterTransition: false

View File

@ -54,7 +54,7 @@ Private.DualStateButton {
}
Behavior on opacity {
NumberAnimation {
duration: 250
duration: units.longDuration
easing.type: Easing.InOutQuad
}
}

View File

@ -80,7 +80,7 @@ Item {
implicitWidth: scrollBar.implicitWidth
Behavior on opacity {
NumberAnimation {
duration: 250
duration: units.longDuration
}
}
@ -129,7 +129,7 @@ Item {
opacity: sectionLabel.text && scrollBar.pressed ? 1 : 0
Behavior on opacity {
NumberAnimation {
duration: 250
duration: units.longDuration
}
}
}

View File

@ -157,7 +157,7 @@ Item {
id: contents
// Plasma API
property bool animated: true
property bool animated: units.longDuration > 0
property real handleWidth: contents.isVertical ? grooveSvg.elementSize("vertical-slider-handle").width : grooveSvg.elementSize("horizontal-slider-handle").width
property real handleHeight: contents.isVertical ? grooveSvg.elementSize("vertical-slider-handle").height : grooveSvg.elementSize("horizontal-slider-handle").height

View File

@ -55,7 +55,7 @@ Private.DualStateButton {
}
Behavior on opacity {
NumberAnimation {
duration: 250
duration: units.longDuration
easing.type: Easing.InOutQuad
}
}

View File

@ -100,7 +100,7 @@ FocusScope {
Behavior on x {
PropertyAnimation {
easing.type: Easing.InQuad
duration: 250
duration: units.longDuration
}
}
}
@ -168,7 +168,7 @@ FocusScope {
}
Behavior on x {
NumberAnimation {
duration: 250
duration: units.longDuration
easing.type: Easing.InOutQuad
}
}

View File

@ -207,14 +207,14 @@ Item {
to: "Incoming"
SequentialAnimation {
ScriptAction { script: root.clip = true }
PropertyAnimation { properties: "opacity,x"; easing.type: Easing.InQuad; duration: 250 }
PropertyAnimation { properties: "opacity,x"; easing.type: Easing.InQuad; duration: units.longDuration }
ScriptAction { script: {incomingDone(); root.clip = false} }
}
},
Transition {
to: "OutgoingLeft,OutgoingRight"
SequentialAnimation {
PropertyAnimation { properties: "opacity,x"; easing.type: Easing.InQuad; duration: 250 }
PropertyAnimation { properties: "opacity,x"; easing.type: Easing.InQuad; duration: units.longDuration }
ScriptAction { script: outgoingDone() }
}
}

View File

@ -363,7 +363,7 @@ FocusScope {
opacity: (textInput.text != "" && clearButtonShown && textField.enabled) ? 1 : 0
Behavior on opacity {
NumberAnimation {
duration: 250
duration: units.longDuration
easing.type: Easing.InOutQuad
}
}

View File

@ -39,7 +39,7 @@ Item{
Behavior on height {
PropertyAnimation {
id: heightAnimation
duration: 250
duration: units.longDuration
}
}
z: 1000
@ -201,19 +201,19 @@ Item{
Behavior on opacity {
PropertyAnimation {
id: containerAOpacityAnimation
duration: 250
duration: units.longDuration
}
}
Behavior on x {
enabled: containerA.animationsEnabled
PropertyAnimation {
duration: 250
duration: units.longDuration
}
}
Behavior on y {
enabled: containerA.animationsEnabled
PropertyAnimation {
duration: 250
duration: units.longDuration
}
}
}
@ -223,18 +223,18 @@ Item{
height: parent.height
opacity: 0
Behavior on opacity {
PropertyAnimation { duration: 250 }
PropertyAnimation { duration: units.longDuration }
}
Behavior on x {
enabled: containerA.animationsEnabled
PropertyAnimation {
duration: 250
duration: units.longDuration
}
}
Behavior on y {
enabled: containerA.animationsEnabled
PropertyAnimation {
duration: 250
duration: units.longDuration
}
}
}

View File

@ -227,7 +227,7 @@ Item {
//internal: if there is no hover status, don't paint on mouse over in touchscreens
opacity: (internal.userPressed || checked || !flat || (shadow.hasOverState && mouse.containsMouse && button.enabled)) ? 1 : 0
Behavior on opacity {
PropertyAnimation { duration: 250 }
PropertyAnimation { duration: units.longDuration }
}
PlasmaCore.Svg {
@ -333,7 +333,7 @@ Item {
//internal: if there is no hover status, don't paint on mouse over in touchscreens
opacity: (internal.userPressed || checked || !flat || (roundShadow.hasOverState && mouse.containsMouse)) ? 1 : 0
Behavior on opacity {
PropertyAnimation { duration: 250 }
PropertyAnimation { duration: units.longDuration }
}
}
}
@ -365,7 +365,7 @@ Item {
height: parent.height
color: mouse.containsMouse ? theme.buttonTextColor : theme.textColor
Behavior on color { ColorAnimation { duration: 100 } }
Behavior on color { ColorAnimation { duration: units.shortDuration * 2 } }
elide: Text.ElideRight
horizontalAlignment: icon.valid ? Text.AlignLeft : Text.AlignHCenter

View File

@ -126,7 +126,7 @@ Item {
Transition {
PropertyAnimation {
properties: "opacity"
duration: 250
duration: units.longDuration
easing.type: Easing.OutQuad
}
}

View File

@ -47,7 +47,7 @@ Item {
SequentialAnimation {
id: appearAnimation
NumberAnimation {
duration: 250
duration: units.longDuration
easing.type: Easing.InOutQuad
target: dismissArea
properties: "opacity"

View File

@ -126,7 +126,7 @@ Item {
Transition {
PropertyAnimation {
properties: "opacity"
duration: 250
duration: units.longDuration
easing.type: Easing.OutQuad
}
}

View File

@ -34,7 +34,7 @@ PlasmaCore.FrameSvgItem {
opacity: 0
Behavior on opacity {
NumberAnimation {
duration: 250
duration: units.longDuration
easing.type: Easing.OutQuad
}
}

View File

@ -90,7 +90,7 @@ Item {
Transition {
PropertyAnimation {
properties: "opacity"
duration: 250
duration: units.longDuration
easing.type: Easing.OutQuad
}
}

View File

@ -121,7 +121,7 @@ Item {
clip: true
width: navigationWidth + space
Behavior on width {
NumberAnimation { duration: 250; easing.type: Easing.InOutExpo; }
NumberAnimation { duration: units.longDuration; easing.type: Easing.InOutExpo; }
}
Item {

View File

@ -178,7 +178,7 @@ Item {
property bool completed: false
// Duration of transition animation (in ms)
property int transitionDuration: 250
property int transitionDuration: units.longDuration
// Sets the page status.
function setPageStatus(page, status)

View File

@ -187,7 +187,7 @@ Item {
opacity: flickableItem.atYBeginning ? 0 : 1
Behavior on opacity {
NumberAnimation {
duration: 250
duration: units.longDuration
easing.type: Easing.InOutQuad
}
}
@ -207,7 +207,7 @@ Item {
opacity: flickableItem.atYEnd ? 0 : 1
Behavior on opacity {
NumberAnimation {
duration: 250
duration: units.longDuration
easing.type: Easing.InOutQuad
}
}
@ -226,7 +226,7 @@ Item {
opacity: flickableItem.atXBeginning ? 0 : 1
Behavior on opacity {
NumberAnimation {
duration: 250
duration: units.longDuration
easing.type: Easing.InOutQuad
}
}
@ -245,7 +245,7 @@ Item {
opacity: flickableItem.atXEnd ? 0 : 1
Behavior on opacity {
NumberAnimation {
duration: 250
duration: units.longDuration
easing.type: Easing.InOutQuad
}
}

View File

@ -19,14 +19,14 @@
*/
import QtQuick 2.0
import "Animations.js" as Animations
import org.kde.plasma.core 2.0 as PlasmaCore
SequentialAnimation {
id: activateAnimation
objectName: "activateAnimation"
property Item targetItem
property int duration: Animations.normalDuration/5
property int duration: units.shortDuration
// Fast scaling while we're animation == more FPS
ScriptAction { script: targetItem.smooth = false }

View File

@ -1,8 +0,0 @@
.pragma library
// a normal animation
var normalDuration = 250;
// for direct feedback, such as tapping
var feedbackDuration = 50;

View File

@ -19,14 +19,13 @@
*/
import QtQuick 2.0
import "Animations.js" as Animations
SequentialAnimation {
id: appearAnimation
objectName: "appearAnimation"
property Item targetItem
property int duration: Animations.normalDuration
property int duration: units.longDuration
// Fast scaling while we're animation == more FPS
ScriptAction { script: { targetItem.smooth = false; targetItem.visible = true; } }

View File

@ -19,14 +19,14 @@
*/
import QtQuick 2.0
import "Animations.js" as Animations
import org.kde.plasma.core 2.0 as PlasmaCore
SequentialAnimation {
id: disappearAnimation
objectName: "disappearAnimation"
property Item targetItem
property int duration: Animations.normalDuration
property int duration: units.longDuration
ScriptAction { script: targetItem.smooth = false; }

View File

@ -19,14 +19,14 @@
*/
import QtQuick 2.0
import "Animations.js" as Animations
import org.kde.plasma.core 2.0 as PlasmaCore
SequentialAnimation {
id: pressedAnimation
objectName: "pressedAnimation"
property Item targetItem
property int duration: Animations.feedbackDuration
property int duration: units.shortDuration
// Fast scaling while we're animation == more FPS
ScriptAction { script: targetItem.smooth = false }

View File

@ -19,14 +19,14 @@
*/
import QtQuick 2.0
import "Animations.js" as Animations
import org.kde.plasma.core 2.0 as PlasmaCore
SequentialAnimation {
id: releasedAnimation
objectName: "releasedAnimation"
property Item targetItem
property int duration: Animations.feedbackDuration
property int duration: units.shortDuration
// Fast scaling while we're animation == more FPS
ScriptAction { script: targetItem.smooth = false }