Changeset View
Changeset View
Standalone View
Standalone View
applets/taskmanager/package/contents/ui/ScrollableTextWrapper.qml
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright 2020 by Tranter Madi <trmdi@yandex.com> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or modify | ||||
5 | * it under the terms of the GNU Library General Public License as | ||||
6 | * published by the Free Software Foundation; either version 2, or | ||||
7 | * (at your option) any later version. | ||||
8 | * | ||||
9 | * This program is distributed in the hope that it will be useful, | ||||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
12 | * GNU Library General Public License for more details | ||||
13 | * | ||||
14 | * You should have received a copy of the GNU Library General Public | ||||
15 | * License along with this program; if not, write to the | ||||
16 | * Free Software Foundation, Inc., | ||||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. | ||||
18 | */ | ||||
19 | | ||||
20 | import QtQuick 2.6 | ||||
21 | | ||||
22 | MouseArea { | ||||
23 | id: textWrapper | ||||
24 | | ||||
25 | default property Text textItem | ||||
26 | | ||||
27 | clip: textItem.elide === Text.ElideNone | ||||
28 | hoverEnabled: true | ||||
29 | | ||||
30 | onContainsMouseChanged: { | ||||
31 | if (!containsMouse) { | ||||
32 | state = "" | ||||
33 | } | ||||
34 | } | ||||
35 | | ||||
36 | Timer { | ||||
37 | id: timer | ||||
38 | interval: 500 | ||||
39 | running: textWrapper.containsMouse | ||||
40 | onTriggered: { | ||||
41 | if (textWrapper.width < textItem.implicitWidth) { | ||||
42 | textWrapper.state = "ShowRight" | ||||
43 | } | ||||
44 | } | ||||
45 | } | ||||
46 | | ||||
47 | states: [ | ||||
48 | State { | ||||
49 | name: "" | ||||
50 | PropertyChanges { target: textItem; x: 0 } | ||||
51 | }, | ||||
52 | State { | ||||
53 | name: "ShowRight" | ||||
54 | PropertyChanges { target: textItem; x: textWrapper.width - textItem.implicitWidth } | ||||
55 | } | ||||
56 | ] | ||||
57 | | ||||
58 | transitions: Transition { | ||||
59 | to: "ShowRight" | ||||
60 | NumberAnimation { | ||||
61 | target: textItem; properties: "x"; | ||||
62 | easing.type: Easing.Linear; | ||||
63 | duration: Math.abs(textItem.implicitWidth - textWrapper.width)*25 | ||||
64 | } | ||||
65 | } | ||||
66 | } |