Use same tooltip component everywhere
authorClaudio Cambra <claudio.cambra@gmail.com>
Tue, 9 Aug 2022 15:20:34 +0000 (17:20 +0200)
committerMatthieu Gallien <matthieu_gallien@yahoo.fr>
Tue, 6 Sep 2022 06:40:03 +0000 (08:40 +0200)
Signed-off-by: Claudio Cambra <claudio.cambra@gmail.com>
resources.qrc
src/gui/tray/ActivityItem.qml
src/gui/tray/ActivityItemActions.qml
src/gui/tray/ActivityItemContent.qml
src/gui/tray/CustomButton.qml
src/gui/tray/CustomTextButton.qml
src/gui/tray/NCToolTip.qml [new file with mode: 0644]
src/gui/tray/TalkReplyTextField.qml
src/gui/tray/UnifiedSearchResultListItem.qml

index d9db7bc05d87c64046d259aa256dca5fdd685b8e..e25f2fc4ab60c7009d1b48d799eeb9a39e82c1c0 100644 (file)
@@ -34,5 +34,6 @@
         <file>src/gui/tray/TalkReplyTextField.qml</file>
         <file>src/gui/tray/CallNotificationDialog.qml</file>
         <file>src/gui/tray/NCBusyIndicator.qml</file>
+        <file>src/gui/tray/NCToolTip.qml</file>
     </qresource>
 </RCC>
index b0ead37ed43272c5391646d291a593303167eca1..e952c194e408fdf200ce903ef2e7779cfc487fc1 100644 (file)
@@ -40,19 +40,9 @@ MouseArea {
         color: (parent.containsMouse ? Style.lightHover : "transparent")
     }
 
-    ToolTip {
-        id: activityMouseAreaTooltip
-        visible: containsMouse && !activityContent.childHovered && model.displayLocation !== ""
-        delay: Qt.styleHints.mousePressAndHoldInterval
+    NCToolTip {
+        visible: root.containsMouse && !activityContent.childHovered && model.displayLocation !== ""
         text: qsTr("In %1").arg(model.displayLocation)
-        contentItem: Label {
-            text: activityMouseAreaTooltip.text
-            color: Style.ncTextColor
-        }
-        background: Rectangle {
-            border.color: Style.menuBorder
-            color: Style.backgroundColor
-        }
     }
 
     ColumnLayout {
index 1b1b70e5c4fc7daad25142bf0dfa157793bf2eff..6d9da418224079b4d3de5cc54fe146dd3e6434ea 100644 (file)
@@ -77,19 +77,9 @@ RowLayout {
                 radius: width / 2
             }
 
-            ToolTip {
-                id: moreActionsButtonTooltip
+            NCToolTip {
                 visible: parent.hovered
-                delay: Qt.styleHints.mousePressAndHoldInterval
                 text: qsTr("Show more actions")
-                contentItem: Label {
-                    text: moreActionsButtonTooltip.text
-                    color: Style.ncTextColor
-                }
-                background: Rectangle {
-                    border.color: Style.menuBorder
-                    color: Style.backgroundColor
-                }
             }
 
             Accessible.name: qsTr("Show more actions")
index 5b4e14fadd529131995d4960098fee69dbf5f75a..da4b3f846661de11ff0e2ea502c102cd08369c98 100644 (file)
@@ -185,19 +185,9 @@ RowLayout {
 
         Layout.margins: Style.roundButtonBackgroundVerticalMargins
 
-        ToolTip {
-            id: dismissActionButtonTooltip
+        NCToolTip {
             visible: parent.hovered
-            delay: Qt.styleHints.mousePressAndHoldInterval
             text: qsTr("Dismiss")
-            contentItem: Label {
-                text: dismissActionButtonTooltip.text
-                color: Style.ncTextColor
-            }
-            background: Rectangle {
-                border.color: Style.menuBorder
-                color: Style.backgroundColor
-            }
         }
 
         Accessible.name: qsTr("Dismiss")
index 32d6ff575ee49c32e7756dca950b59e78c0438cd..9a6ff17af9de69ef4dbb52d9be4f45865458829b 100644 (file)
@@ -31,19 +31,9 @@ Button {
     leftPadding: root.text === "" ? 5 : 10
     rightPadding: root.text === "" ? 5 : 10
 
-    ToolTip {
-        id: customButtonTooltip
+    NCToolTip {
         text: root.toolTipText
-        delay: Qt.styleHints.mousePressAndHoldInterval
         visible: root.toolTipText !== "" && root.hovered
-        contentItem: Label {
-            text: customButtonTooltip.text
-            color: Style.ncTextColor
-        }
-        background: Rectangle {
-            border.color: Style.menuBorder
-            color: Style.backgroundColor
-        }
     }
 
     contentItem: RowLayout {
index 000a54d3ccbd33b1eaf799c009fd3d40d8fb863f..5c1199a92928d3ba9b9bee57964a5bb74911225c 100644 (file)
@@ -32,19 +32,9 @@ Label {
     signal pressed(QtObject mouse)
     signal clicked(QtObject mouse)
 
-    ToolTip {
-        id: customTextButtonTooltip
+    NCToolTip {
         text: root.toolTipText
-        delay: Qt.styleHints.mousePressAndHoldInterval
         visible: root.toolTipText !== "" && root.hovered
-        contentItem: Label {
-            text: customTextButtonTooltip.text
-            color: Style.ncTextColor
-        }
-        background: Rectangle {
-            border.color: Style.menuBorder
-            color: Style.backgroundColor
-        }
     }
 
     MouseArea {
diff --git a/src/gui/tray/NCToolTip.qml b/src/gui/tray/NCToolTip.qml
new file mode 100644 (file)
index 0000000..3d9dbb0
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2022 by Claudio Cambra <claudio.cambra@nextcloud.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * for more details.
+ */
+
+import QtQml 2.15
+import QtQuick 2.15
+import QtQuick.Controls 2.15
+
+import Style 1.0
+
+ToolTip {
+    id: toolTip
+    clip: true
+    delay: Qt.styleHints.mousePressAndHoldInterval
+    contentItem: Label {
+        text: toolTip.text
+        color: Style.ncTextColor
+        wrapMode: Text.Wrap
+    }
+    background: Rectangle {
+        border.color: Style.menuBorder
+        color: Style.backgroundColor
+    }
+}
index bec9e11df5ae3ca0be9c8dd3f0936beb24068f2f..79070590ed053b37fab6619add0a9e190971f643 100644 (file)
@@ -48,9 +48,8 @@ TextField {
             top: replyMessageTextField.top
         }
 
-        ToolTip {
+        NCToolTip {
             visible: sendReplyMessageButton.hovered
-            delay: Qt.styleHints.mousePressAndHoldInterval
             text:  qsTr("Send reply to chat message")
         }
     }
index c53ca4066f67debbd430945f0870a3f46d96e72b..4e4246ce624e4b85de1ddddca1d548c799312094 100644 (file)
@@ -24,19 +24,9 @@ MouseArea {
 
     height: Style.unifiedSearchItemHeight
 
-    ToolTip {
-        id: unifiedSearchResultMouseAreaTooltip
+    NCToolTip {
         visible: unifiedSearchResultMouseArea.containsMouse
         text: isFetchMoreTrigger ? qsTr("Load more results") : model.resultTitle + "\n\n" + model.subline
-        delay: Qt.styleHints.mousePressAndHoldInterval
-        contentItem: Label {
-            text: unifiedSearchResultMouseAreaTooltip.text
-            color: Style.ncTextColor
-        }
-        background: Rectangle {
-            border.color: Style.menuBorder
-            color: Style.backgroundColor
-        }
     }
 
     Rectangle {