diff --git a/electrum/gui/qml/components/ExportTxDialog.qml b/electrum/gui/qml/components/ExportTxDialog.qml index 997276ef6..3170c3448 100644 --- a/electrum/gui/qml/components/ExportTxDialog.qml +++ b/electrum/gui/qml/components/ExportTxDialog.qml @@ -71,7 +71,10 @@ ElDialog { FlatButton { text: qsTr('Copy') icon.source: '../../icons/copy_bw.png' - onClicked: AppController.textToClipboard(dialog.text) + onClicked: { + AppController.textToClipboard(dialog.text) + toaster.show(this, qsTr('Copied!')) + } } FlatButton { text: qsTr('Share') @@ -84,6 +87,10 @@ ElDialog { } } + Toaster { + id: toaster + } + Connections { target: dialog.enter function onRunningChanged() { diff --git a/electrum/gui/qml/components/GenericShareDialog.qml b/electrum/gui/qml/components/GenericShareDialog.qml index 0c3ee2ebb..be8c8553a 100644 --- a/electrum/gui/qml/components/GenericShareDialog.qml +++ b/electrum/gui/qml/components/GenericShareDialog.qml @@ -79,7 +79,10 @@ ElDialog { FlatButton { text: qsTr('Copy') icon.source: '../../icons/copy_bw.png' - onClicked: AppController.textToClipboard(dialog.text) + onClicked: { + AppController.textToClipboard(dialog.text) + toaster.show(this, qsTr('Copied!')) + } } FlatButton { text: qsTr('Share') @@ -100,4 +103,8 @@ ElDialog { } } } + + Toaster { + id: toaster + } } diff --git a/electrum/gui/qml/components/ReceiveDialog.qml b/electrum/gui/qml/components/ReceiveDialog.qml index 34d15ae1d..c37b1f018 100644 --- a/electrum/gui/qml/components/ReceiveDialog.qml +++ b/electrum/gui/qml/components/ReceiveDialog.qml @@ -255,6 +255,7 @@ ElDialog { AppController.textToClipboard(_bip21uri) else AppController.textToClipboard(_address) + toaster.show(this, qsTr('Copied!')) } } FlatButton { @@ -415,6 +416,10 @@ ElDialog { } } + Toaster { + id: toaster + } + Component.onCompleted: { // callLater to make sure any popups are on top of the dialog stacking order Qt.callLater(createDefaultRequest) diff --git a/electrum/gui/qml/components/controls/Toaster.qml b/electrum/gui/qml/components/controls/Toaster.qml new file mode 100644 index 000000000..8255187c5 --- /dev/null +++ b/electrum/gui/qml/components/controls/Toaster.qml @@ -0,0 +1,57 @@ +import QtQuick 2.6 +import QtQuick.Layouts 1.0 +import QtQuick.Controls 2.14 +import QtQuick.Controls.Material 2.0 + +import ".." + +Item { + id: toaster + width: rect.width + height: rect.height + visible: false + + property int _y + property string _text + + function show(item, text) { + _text = text + var r = item.mapToItem(parent, item.x, item.y) + x = r.x + y = r.y - toaster.height - constants.paddingLarge + toaster._y = y - 35 + ani.restart() + } + + SequentialAnimation { + id: ani + running: false + PropertyAction { target: toaster; property: 'visible'; value: true } + PropertyAction { target: toaster; property: 'opacity'; value: 1 } + PauseAnimation { duration: 1000} + ParallelAnimation { + NumberAnimation { target: toaster; property: 'y'; to: toaster._y; duration: 1000; easing.type: Easing.InQuad } + NumberAnimation { target: toaster; property: 'opacity'; to: 0; duration: 1000 } + } + PropertyAction { target: toaster; property: 'visible'; value: false } + } + + Rectangle { + id: rect + width: contentItem.width + height: contentItem.height + color: constants.colorAlpha(Material.dialogColor, 0.90) + border { + color: Material.accentColor + width: 1 + } + + RowLayout { + id: contentItem + Label { + Layout.margins: 10 + text: toaster._text + } + } + } +}