Browse Source

qml: add simple Toaster, mainly to indicate copy to clipboard

master
Sander van Grieken 3 years ago
parent
commit
d43f37d078
  1. 9
      electrum/gui/qml/components/ExportTxDialog.qml
  2. 9
      electrum/gui/qml/components/GenericShareDialog.qml
  3. 5
      electrum/gui/qml/components/ReceiveDialog.qml
  4. 57
      electrum/gui/qml/components/controls/Toaster.qml

9
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() {

9
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
}
}

5
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)

57
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
}
}
}
}
Loading…
Cancel
Save