diff --git a/applets/taskmanager/package/contents/ui/TextWrapper.qml b/applets/taskmanager/package/contents/ui/TextWrapper.qml new file mode 100644 --- /dev/null +++ b/applets/taskmanager/package/contents/ui/TextWrapper.qml @@ -0,0 +1,65 @@ +import QtQuick 2.6 + +Item { + id: textWrapper + + property var textItem + readonly property alias containsMouse: mouseItem.containsMouse + property int hoveringTime: 0 + readonly property bool longHovering: hoveringTime >= 500 + + clip: textItem.elide === Text.ElideNone + + onContainsMouseChanged: { + hoveringTime = 0 + if (containsMouse && width <= textItem.implicitWidth) { + timer.start() + } else { + timer.stop() + } + } + + onLongHoveringChanged: { + if (longHovering) { + state = "longHovering" + timer.stop() + } else { + state = "" + } + } + + MouseArea { + id: mouseItem + anchors.fill: parent + hoverEnabled: true + } + + Timer { + id: timer + running: false; interval: 100; repeat: true; + onTriggered: { + parent.hoveringTime += 100 + } + } + + states: [ + State { + name: "" + PropertyChanges { target: textItem; x: 0 } + }, + State { + name: "longHovering" + PropertyChanges { target: textItem; x: textWrapper.width - textItem.implicitWidth } + } + ] + + transitions: Transition { + to: "longHovering" + NumberAnimation { + target: textItem; properties: "x"; + easing.type: Easing.Linear; + duration: (textItem.implicitWidth - textWrapper.width)*25 + } + } + +} diff --git a/applets/taskmanager/package/contents/ui/ToolTipInstance.qml b/applets/taskmanager/package/contents/ui/ToolTipInstance.qml --- a/applets/taskmanager/package/contents/ui/ToolTipInstance.qml +++ b/applets/taskmanager/package/contents/ui/ToolTipInstance.qml @@ -321,24 +321,45 @@ Layout.fillWidth: true spacing: 0 - PlasmaComponents.Label { + TextWrapper { + id: songTextWrapper + Layout.fillWidth: true - lineHeight: 1 - maximumLineCount: artistText.visible? 1 : 2 - wrapMode: artistText.visible? Text.NoWrap : Text.Wrap - elide: Text.ElideRight - text: track || "" + Layout.preferredHeight: songText.contentHeight + + textItem: songText + + PlasmaComponents.Label { + id: songText + width: parent.width + height: contentHeight + lineHeight: 1 + maximumLineCount: artistText.visible? 1 : 2 + wrapMode: Text.NoWrap + elide: songTextWrapper.longHovering? Text.ElideNone : Text.ElideRight + text: track || "" + } } - PlasmaExtras.DescriptiveLabel { - id: artistText + TextWrapper { + id: artistTextWrapper + Layout.fillWidth: true - wrapMode: Text.NoWrap - lineHeight: 1 - elide: Text.ElideRight - text: artist || "" - visible: text != "" - font.pointSize: theme.smallestFont.pointSize + Layout.preferredHeight: artistText.visible? artistText.contentHeight : 0 + + textItem: artistText + + PlasmaExtras.DescriptiveLabel { + id: artistText + width: parent.width + height: contentHeight + wrapMode: Text.NoWrap + lineHeight: 1 + elide: artistTextWrapper.longHovering? Text.ElideNone : Text.ElideRight + text: artist || "" + visible: text != "" + font.pointSize: theme.smallestFont.pointSize + } } }