diff --git a/TODO.md b/TODO.md index fc92bc53..4ca3df19 100644 --- a/TODO.md +++ b/TODO.md @@ -90,9 +90,7 @@ - Multiaccount aliases: - Warn when conflict with another alias - - Add an explanation tooltip - Prevent sending messages with a user not in the current room - - Support \ escaping - Accept drag and drop to upload files or set a new avatar - Improve room tooltips, e.g. show last messages diff --git a/src/gui/Base/HLabeledTextField.qml b/src/gui/Base/HLabeledTextField.qml index 190c9d71..8d9f2caa 100644 --- a/src/gui/Base/HLabeledTextField.qml +++ b/src/gui/Base/HLabeledTextField.qml @@ -1,21 +1,54 @@ // SPDX-License-Identifier: LGPL-3.0-or-later import QtQuick 2.12 -import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 -Column { +HColumnLayout { spacing: theme.spacing / 2 - property alias label: fieldLabel - property alias field: textField - HLabel { - id: fieldLabel + property alias label: label + property alias field: field + property alias toolTip: toolTip + + + HRowLayout { + HLabel { + id: label + + Layout.fillWidth: true + } + + HIcon { + svgName: "field-tooltip-available" + visible: toolTip.text + + Binding on colorize { + value: theme.colors.accentElement + when: hoverHandler.hovered || toolTip.visible + } + } + + HoverHandler { + id: hoverHandler + enabled: toolTip.text + } + + TapHandler { + onTapped: toolTip.instantShow() + enabled: toolTip.text + } + + HToolTip { + id: toolTip + visible: toolTip.text && hoverHandler.hovered + } } HTextField { - id: textField + id: field radius: 2 - width: parent.width + + Layout.fillWidth: true } } diff --git a/src/gui/Base/HToolTip.qml b/src/gui/Base/HToolTip.qml index 582d5633..edc4947c 100644 --- a/src/gui/Base/HToolTip.qml +++ b/src/gui/Base/HToolTip.qml @@ -6,18 +6,9 @@ import QtQuick.Layouts 1.12 ToolTip { id: toolTip - delay: theme.controls.toolTip.delay + delay: instant ? 0 : theme.controls.toolTip.delay padding: background.border.width - - property alias label: label - property alias backgroundColor: background.color - - readonly property bool hideNow: ! window.hovered - - onHideNowChanged: if (visible && hideNow) toolTip.hide() - - background: Rectangle { id: background color: theme.controls.toolTip.background @@ -50,6 +41,25 @@ ToolTip { HNumberAnimation { property: "opacity"; to: 0.0 } } + onHideNowChanged: if (visible && hideNow) toolTip.hide() + + + property bool instant: false + + property alias label: label + property alias backgroundColor: background.color + + readonly property bool hideNow: ! window.hovered + + + function instantShow() { + if (visible) return + instant = true + open() + instant = false + } + + TapHandler { onTapped: toolTip.hide() } diff --git a/src/gui/Pages/AccountSettings/Profile.qml b/src/gui/Pages/AccountSettings/Profile.qml index 83b2e317..2fc8a532 100644 --- a/src/gui/Pages/AccountSettings/Profile.qml +++ b/src/gui/Pages/AccountSettings/Profile.qml @@ -172,9 +172,16 @@ HGridLayout { property bool changed: field.text !== currentAlias id: aliasField - label.text: qsTr("Write alias:") + label.text: qsTr("Multi-account composer alias:") field.onAccepted: applyChanges() + toolTip.text: qsTr( + "From any account, start a message with specified alias " + + "followed by a space to type and send as this account.\n" + + "This account must a member of the room too.\n" + + "To ignore the alias when typing, prepend it with a space." + ) + Component.onCompleted: field.text = currentAlias Layout.fillWidth: true diff --git a/src/icons/thin/field-tooltip-available.svg b/src/icons/thin/field-tooltip-available.svg new file mode 100644 index 00000000..c8654c91 --- /dev/null +++ b/src/icons/thin/field-tooltip-available.svg @@ -0,0 +1,5 @@ + + + + +