Also customise appearance of copy button in sharedelegate when clicked
authorClaudio Cambra <claudio.cambra@nextcloud.com>
Thu, 11 May 2023 06:10:30 +0000 (14:10 +0800)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Tue, 16 May 2023 13:16:11 +0000 (21:16 +0800)
Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
src/gui/filedetails/ShareDelegate.qml

index e48deaf4d6ebe98b5163773cd6723c0541646506..9c7d5a730528d10f793bcaad646d93eb370943f4 100644 (file)
@@ -175,30 +175,50 @@ GridLayout {
         CustomButton {
             id: copyLinkButton
 
+            function copyShareLink() {
+                clipboardHelper.text = root.link;
+                clipboardHelper.selectAll();
+                clipboardHelper.copy();
+                clipboardHelper.clear();
+
+                shareLinkCopied = true;
+                shareLinkCopyTimer.start();
+            }
+
+            property bool shareLinkCopied: false
+
             Layout.alignment: Qt.AlignCenter
-            Layout.preferredWidth: Style.iconButtonWidth
-            Layout.preferredHeight: width
+            Layout.preferredWidth: shareLinkCopied ? implicitWidth : Style.iconButtonWidth
+            Layout.preferredHeight: Style.iconButtonWidth
 
             toolTipText: qsTr("Copy share link location")
 
-            bgColor: Style.lightHover
-            bgNormalOpacity: 0
+            text: shareLinkCopied ? qsTr("Copied!") : ""
+            textColor: Style.ncHeaderTextColor
+            contentsFont.bold: true
+            bgColor: shareLinkCopied ? Style.positiveColor : Style.lightHover
+            bgNormalOpacity: shareLinkCopied ? 1 : 0
 
-            imageSource: "image://svgimage-custom-color/copy.svg/" + Style.ncTextColor
+            imageSource: shareLinkCopied ? "image://svgimage-custom-color/copy.svg/" + Style.ncHeaderTextColor :
+                                           "image://svgimage-custom-color/copy.svg/" + Style.ncTextColor
             icon.width: 16
             icon.height: 16
 
             visible: root.isLinkShare || root.isInternalLinkShare
             enabled: visible
 
-            onClicked: {
-                clipboardHelper.text = root.link;
-                clipboardHelper.selectAll();
-                clipboardHelper.copy();
-                clipboardHelper.clear();
+            onClicked: copyShareLink()
+
+            TextEdit {
+                id: clipboardHelper
+                visible: false
             }
 
-            TextEdit { id: clipboardHelper; visible: false}
+            Timer {
+                id: shareLinkCopyTimer
+                interval: Style.veryLongAnimationDuration
+                onTriggered: copyLinkButton.shareLinkCopied = false
+            }
         }
 
         CustomButton {