From ed74592769bb086c195952c9108c84610c0b5bc2 Mon Sep 17 00:00:00 2001 From: miruka Date: Thu, 5 Nov 2020 22:03:59 -0400 Subject: [PATCH] Add HToolTip.instantToggle(), use for some buttons Used for buttons that trigger a tooltip instantly: if the tooltip is currently visible, hide it. --- src/gui/Base/Buttons/FieldHelpButton.qml | 2 +- src/gui/Base/HToolTip.qml | 4 ++++ src/gui/Pages/Chat/RoomHeader.qml | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/gui/Base/Buttons/FieldHelpButton.qml b/src/gui/Base/Buttons/FieldHelpButton.qml index f77ca6bd..0e860c76 100644 --- a/src/gui/Base/Buttons/FieldHelpButton.qml +++ b/src/gui/Base/Buttons/FieldHelpButton.qml @@ -12,7 +12,7 @@ HButton { iconItem.small: true toolTip.text: helpText - onClicked: toolTip.instantShow() + onClicked: toolTip.instantToggle() onActiveFocusChanged: if (! activeFocus && toolTip.visible) toolTip.hide() Layout.fillHeight: true diff --git a/src/gui/Base/HToolTip.qml b/src/gui/Base/HToolTip.qml index 83d5b2ff..801c3fbb 100644 --- a/src/gui/Base/HToolTip.qml +++ b/src/gui/Base/HToolTip.qml @@ -21,6 +21,10 @@ ToolTip { instant = false } + function instantToggle(timeout=-1) { + visible ? hide() : instantShow(timeout) + } + delay: instant ? 0 : theme.controls.toolTip.delay padding: background.border.width diff --git a/src/gui/Pages/Chat/RoomHeader.qml b/src/gui/Pages/Chat/RoomHeader.qml index 4e345f9a..a17fabe3 100644 --- a/src/gui/Pages/Chat/RoomHeader.qml +++ b/src/gui/Pages/Chat/RoomHeader.qml @@ -159,7 +159,7 @@ Rectangle { "unverified devices") : qsTr("All members in this encrypted room are verified") - onClicked: toolTip.instantShow() + onClicked: toolTip.instantToggle() Layout.preferredWidth: chat.roomInfo.encrypted ? avatar.width : 0 Layout.fillHeight: true