Merge pull request #5672 from nextcloud/bugfix/provide-feedback-on-share-link-copy

Provide feedback on share link copy
This commit is contained in:
Claudio Cambra 2023-05-16 21:18:52 +08:00 committed by GitHub
commit 4dfab45d5f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 87 additions and 26 deletions

View file

@ -175,30 +175,62 @@ 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()
Behavior on bgColor {
ColorAnimation { duration: Style.shortAnimationDuration }
}
TextEdit { id: clipboardHelper; visible: false}
Behavior on bgNormalOpacity {
NumberAnimation { duration: Style.shortAnimationDuration }
}
Behavior on Layout.preferredWidth {
SmoothedAnimation { duration: Style.shortAnimationDuration }
}
TextEdit {
id: clipboardHelper
visible: false
}
Timer {
id: shareLinkCopyTimer
interval: Style.veryLongAnimationDuration
onTriggered: copyLinkButton.shareLinkCopied = false
}
}
CustomButton {

View file

@ -853,27 +853,51 @@ Page {
CustomButton {
id: copyShareLinkButton
height: Style.standardPrimaryButtonHeight
imageSource: "image://svgimage-custom-color/copy.svg/" + Style.ncHeaderTextColor
text: qsTr("Copy share link")
textColor: Style.ncHeaderTextColor
contentsFont.bold: true
bgColor: Style.ncBlue
bgNormalOpacity: 1.0
bgHoverOpacity: Style.hoverOpacity
visible: root.isLinkShare
enabled: visible
onClicked: {
function copyShareLink() {
clipboardHelper.text = root.link;
clipboardHelper.selectAll();
clipboardHelper.copy();
clipboardHelper.clear();
shareLinkCopied = true;
shareLinkCopyTimer.start();
}
TextEdit { id: clipboardHelper; visible: false }
property bool shareLinkCopied: false
height: Style.standardPrimaryButtonHeight
imageSource: "image://svgimage-custom-color/copy.svg/" + Style.ncHeaderTextColor
text: shareLinkCopied ? qsTr("Share link copied!") : qsTr("Copy share link")
textColor: Style.ncHeaderTextColor
contentsFont.bold: true
bgColor: shareLinkCopied ? Style.positiveColor : Style.ncBlue
bgNormalOpacity: 1.0
bgHoverOpacity: shareLinkCopied ? 1.0 : Style.hoverOpacity
visible: root.isLinkShare
enabled: visible
onClicked: copyShareLink()
Behavior on bgColor {
ColorAnimation { duration: Style.shortAnimationDuration }
}
Behavior on bgHoverOpacity {
NumberAnimation { duration: Style.shortAnimationDuration }
}
TextEdit {
id: clipboardHelper
visible: false
}
Timer {
id: shareLinkCopyTimer
interval: Style.veryLongAnimationDuration
onTriggered: copyShareLinkButton.shareLinkCopied = false
}
}
}
}

View file

@ -17,6 +17,7 @@ QtObject {
readonly property color menuBorder: Theme.darkMode ? Qt.lighter(backgroundColor, 2.5) : Qt.darker(backgroundColor, 1.5)
readonly property color backgroundColor: Theme.systemPalette.base
readonly property color buttonBackgroundColor: Theme.systemPalette.button
readonly property color positiveColor: Qt.rgba(0.38, 0.74, 0.38, 1)
readonly property color currentUserHeaderColor: UserModel.currentUser ? UserModel.currentUser.headerColor : ncBlue
readonly property color currentUserHeaderTextColor: UserModel.currentUser ? UserModel.currentUser.headerTextColor : ncHeaderTextColor
@ -146,6 +147,10 @@ QtObject {
readonly property int trayWindowMenuEntriesMargin: 6
// animation durations
readonly property int shortAnimationDuration: 200
readonly property int veryLongAnimationDuration: 3000
function variableSize(size) {
return size * (1 + Math.min(pixelSize / 100, 1));
}