Commit 9b8a0218 authored by Nate Graham's avatar Nate Graham
Browse files

[applet] When only showing friendly name, add full name on hover

The applet has a special mode where it only shows a user-friendly name
(e.g. "Speakers" and "Microphone") when there is only one device, on the
logic that the full name is not needed when there is only one device
because the user knows what it is, and also depending on the audio
drivers in use, it can be a rather unsightly text string.

However there may be times when the user actually wants to know the full
name; perhaps they have forgotten which device of many they regularly
use is currently connected, for example. For this case, we now display
the full name on hover, so it's not getting in the way and possibly
looking ugly until it's actually needed.

BUG: 433476
FIXED-IN: 5.22
parent f720efe7
......@@ -31,6 +31,8 @@ ListItemBase {
readonly property var activePortIndex: ActivePortIndex
property bool onlyone: false
fullNameToShowOnHover: onlyone ? Description : ""
draggable: false
label: {
if (currentPort && currentPort.description) {
......
......@@ -41,6 +41,7 @@ PlasmaComponents.ListItem {
property alias icon: clientIcon.source
property alias iconUsesPlasmaTheme: clientIcon.usesPlasmaTheme
property string type
property string fullNameToShowOnHover: ""
checked: dropArea.containsDrag
opacity: (draggedStream && draggedStream.deviceIndex == Index) ? 0.3 : 1.0
......@@ -124,12 +125,48 @@ PlasmaComponents.ListItem {
onClicked: model.PulseObject.default = true;
}
PlasmaComponents3.Label {
id: soloLabel
RowLayout {
Layout.fillWidth: true
text: defaultButton.text
visible: !defaultButton.visible
elide: Text.ElideRight
// User-friendly name
PlasmaComponents3.Label {
Layout.fillWidth: !longDescription.visible
text: defaultButton.text
elide: Text.ElideRight
MouseArea {
id: labelHoverHandler
// Only want to handle hover for the width of
// the actual text item itself
anchors.left: parent.left
anchors.top: parent.top
width: parent.contentWidth
height: parent.contentHeight
hoverEnabled: true
acceptedButtons: Qt.NoButton
}
}
// Possibly not user-friendly description; only show on hover
PlasmaComponents3.Label {
id: longDescription
Layout.fillWidth: true
visible: opacity > 0
opacity: labelHoverHandler.containsMouse ? 1 : 0
Behavior on opacity {
NumberAnimation {
duration: PlasmaCore.Units.shortDuration
easing.type: Easing.InOutQuad
}
}
// Not a word puzzle because this is not a translated string
text: "(" + item.fullNameToShowOnHover + ")"
elide: Text.ElideRight
}
}
Item {
......
Supports Markdown
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