diff --git a/src/declarativeimports/plasmacomponents/qml/Label.qml b/src/declarativeimports/plasmacomponents/qml/Label.qml --- a/src/declarativeimports/plasmacomponents/qml/Label.qml +++ b/src/declarativeimports/plasmacomponents/qml/Label.qml @@ -17,7 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. */ -import QtQuick 2.1 +import QtQuick 2.12 import QtQuick.Window 2.2 import QtQuick.Controls 1.0 import QtQuick.Controls.Private 1.0 as QtQuickControlsPrivate @@ -62,4 +62,41 @@ Accessible.role: Accessible.StaticText Accessible.name: text + + states: [ + State { + name: "right" + PropertyChanges { + target: root + x: root.width - metrics.width + } + }, + State { + name: "left" + PropertyChanges { + target: root + x: 0 + } + } + ] + + transitions: Transition { + id: transition + NumberAnimation { + properties: "x" + easing.type: Easing.Linear + duration: (metrics.width - root.width) * 50 + } + } + + TextMetrics { + id: metrics + text: root.text + font: root.font + } + + Timer { + running: root.width < metrics.width && !transition.running + onTriggered: root.state = root.state === "right" ? "left" : "right" + } }