Skip to content

Commit

Permalink
feat(@desktop/general): copy button identified, will be mostly used a…
Browse files Browse the repository at this point in the history
…s a built in component
  • Loading branch information
saledjenic committed Apr 3, 2023
1 parent d8b1e47 commit 0ef3096
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
38 changes: 38 additions & 0 deletions ui/imports/shared/controls/CopyButton.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import QtQuick 2.15
import QtQuick.Controls 2.15

import StatusQ.Core 0.1
import StatusQ.Core.Theme 0.1

import utils 1.0
import shared.stores 1.0

StatusIcon {
id: root

required property string textToCopy

icon: "copy"
color: mouseArea.containsMouse? Theme.palette.primaryColor1 : Theme.palette.baseColor1

function reset() {
root.icon = "copy"
root.color = Qt.binding(function(){ return mouseArea.containsMouse? Theme.palette.primaryColor1 : Theme.palette.baseColor1 })
}

MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
cursorShape: containsMouse ? Qt.PointingHandCursor : Qt.ArrowCursor
onClicked: {
RootStore.copyToClipboard(root.textToCopy)
root.icon = "tiny/checkmark"
root.color = Theme.palette.successColor1

Backpressure.debounce(root, 1500, function () {
root.reset()
})()
}
}
}
1 change: 1 addition & 0 deletions ui/imports/shared/controls/qmldir
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,4 @@ StatusSyncCodeInput 1.0 StatusSyncCodeInput.qml
GetSyncCodeMobileInstructions 1.0 GetSyncCodeMobileInstructions.qml
GetSyncCodeDesktopInstructions 1.0 GetSyncCodeDesktopInstructions.qml
ErrorDetails 1.0 ErrorDetails.qml
CopyButton 1.0 CopyButton.qml

0 comments on commit 0ef3096

Please sign in to comment.