Browse Source

qml: remove ugly notification popup, add wallet name to notifications

master
Sander van Grieken 3 years ago
parent
commit
5eb7bcebef
  1. 8
      electrum/gui/qml/components/Constants.qml
  2. 96
      electrum/gui/qml/components/NotificationPopup.qml
  3. 9
      electrum/gui/qml/components/main.qml
  4. 7
      electrum/gui/qml/qeapp.py

8
electrum/gui/qml/components/Constants.qml

@ -27,11 +27,14 @@ Item {
readonly property int fingerWidth: 64 // TODO: determine finger width from screen dimensions and resolution readonly property int fingerWidth: 64 // TODO: determine finger width from screen dimensions and resolution
property color colorCredit: "#ff80ff80"
property color colorDebit: "#ffff8080"
property color mutedForeground: 'gray' //Qt.lighter(Material.background, 2) property color mutedForeground: 'gray' //Qt.lighter(Material.background, 2)
property color darkerBackground: Qt.darker(Material.background, 1.20) property color darkerBackground: Qt.darker(Material.background, 1.20)
property color lighterBackground: Qt.lighter(Material.background, 1.10) property color lighterBackground: Qt.lighter(Material.background, 1.10)
property color notificationBackground: Qt.lighter(Material.background, 1.5)
property color colorCredit: "#ff80ff80"
property color colorDebit: "#ffff8080"
property color colorMine: "yellow" property color colorMine: "yellow"
property color colorError: '#ffff8080' property color colorError: '#ffff8080'
property color colorLightningLocal: "blue" property color colorLightningLocal: "blue"
@ -41,7 +44,6 @@ Item {
property color colorPiechartOnchain: Qt.darker(Material.accentColor, 1.50) property color colorPiechartOnchain: Qt.darker(Material.accentColor, 1.50)
property color colorPiechartFrozen: 'gray' property color colorPiechartFrozen: 'gray'
property color colorPiechartLightning: 'orange' //Qt.darker(Material.accentColor, 1.20) property color colorPiechartLightning: 'orange' //Qt.darker(Material.accentColor, 1.20)
property color colorPiechartParticipant: 'gray' property color colorPiechartParticipant: 'gray'
property color colorPiechartSignature: 'yellow' property color colorPiechartSignature: 'yellow'

96
electrum/gui/qml/components/NotificationPopup.qml

@ -2,60 +2,114 @@ import QtQuick 2.6
import QtQuick.Layouts 1.0 import QtQuick.Layouts 1.0
import QtQuick.Controls 2.3 import QtQuick.Controls 2.3
import QtQuick.Controls.Material 2.0 import QtQuick.Controls.Material 2.0
import QtQuick.Controls.Material.impl 2.12
Rectangle { Item {
id: root id: root
property alias text: textItem.text property string message
property string wallet_name
property bool hide: true property bool _hide: true
color: Qt.lighter(Material.background, 1.5) clip:true
radius: constants.paddingXLarge
width: root.parent.width * 2/3 layer.enabled: height > 0
height: layout.height layer.effect: ElevationEffect {
x: (root.parent.width - width) / 2 elevation: constants.paddingXLarge
y: -height fullWidth: true
}
states: [ states: [
State { State {
name: 'expanded'; when: !hide name: 'expanded'; when: !_hide
PropertyChanges { target: root; y: 100 } PropertyChanges { target: root; height: layout.implicitHeight }
} }
] ]
transitions: [ transitions: [
Transition { Transition {
from: ''; to: 'expanded'; reversible: true from: ''; to: 'expanded'; reversible: true
NumberAnimation { properties: 'y'; duration: 300; easing.type: Easing.InOutQuad } NumberAnimation { target: root; properties: 'height'; duration: 300; easing.type: Easing.OutQuad }
} }
] ]
function show(message) { function show(wallet_name, message) {
root.text = message root.wallet_name = wallet_name
root.hide = false root.message = message
root._hide = false
closetimer.start() closetimer.start()
} }
RowLayout { Rectangle {
id: rect
width: root.width
height: layout.height
color: constants.colorAlpha(Material.dialogColor, 0.8)
anchors.bottom: root.bottom
ColumnLayout {
id: layout id: layout
width: parent.width width: parent.width
Text { spacing: 0
id: textItem
Layout.alignment: Qt.AlignHCenter RowLayout {
Layout.margins: constants.paddingLarge
spacing: constants.paddingSizeSmall
Image {
source: '../../icons/info.png'
Layout.preferredWidth: constants.iconSizeLarge
Layout.preferredHeight: constants.iconSizeLarge
}
Label {
id: messageLabel
Layout.fillWidth: true Layout.fillWidth: true
font.pixelSize: constants.fontSizeLarge font.pixelSize: constants.fontSizeLarge
color: Material.foreground color: Material.foreground
wrapMode: Text.Wrap wrapMode: Text.Wrap
text: root.message
}
} }
Rectangle {
Layout.preferredHeight: 2
Layout.fillWidth: true
color: Material.accentColor
}
}
RowLayout {
visible: root.wallet_name && root.wallet_name != Daemon.currentWallet.name
anchors.right: rect.right
anchors.bottom: rect.bottom
RowLayout {
Layout.margins: constants.paddingSmall
Image {
source: '../../icons/wallet.png'
Layout.preferredWidth: constants.iconSizeXSmall
Layout.preferredHeight: constants.iconSizeXSmall
}
Label {
font.pixelSize: constants.fontSizeSmall
color: Material.accentColor
text: root.wallet_name
}
}
}
}
MouseArea {
// capture all clicks
anchors.fill: parent
} }
Timer { Timer {
id: closetimer id: closetimer
interval: 5000 interval: 5000
repeat: false repeat: false
onTriggered: hide = true onTriggered: _hide = true
} }
} }

9
electrum/gui/qml/components/main.qml

@ -262,6 +262,7 @@ ApplicationWindow
NotificationPopup { NotificationPopup {
id: notificationPopup id: notificationPopup
width: parent.width
} }
Component { Component {
@ -360,8 +361,8 @@ ApplicationWindow
Connections { Connections {
target: AppController target: AppController
function onUserNotify(message) { function onUserNotify(wallet_name, message) {
notificationPopup.show(message) notificationPopup.show(wallet_name, message)
} }
function onShowException() { function onShowException() {
var dialog = crashDialog.createObject(app, { var dialog = crashDialog.createObject(app, {
@ -378,10 +379,10 @@ ApplicationWindow
} }
// TODO: add to notification queue instead of barging through // TODO: add to notification queue instead of barging through
function onPaymentSucceeded(key) { function onPaymentSucceeded(key) {
notificationPopup.show(qsTr('Payment Succeeded')) notificationPopup.show(Daemon.currentWallet.name, qsTr('Payment Succeeded'))
} }
function onPaymentFailed(key, reason) { function onPaymentFailed(key, reason) {
notificationPopup.show(qsTr('Payment Failed') + ': ' + reason) notificationPopup.show(Daemon.currentWallet.name, qsTr('Payment Failed') + ': ' + reason)
} }
} }

7
electrum/gui/qml/qeapp.py

@ -49,7 +49,7 @@ notification = None
class QEAppController(BaseCrashReporter, QObject): class QEAppController(BaseCrashReporter, QObject):
_dummy = pyqtSignal() _dummy = pyqtSignal()
userNotify = pyqtSignal(str) userNotify = pyqtSignal(str, str)
uriReceived = pyqtSignal(str) uriReceived = pyqtSignal(str)
showException = pyqtSignal() showException = pyqtSignal()
sendingBugreport = pyqtSignal() sendingBugreport = pyqtSignal()
@ -94,7 +94,7 @@ class QEAppController(BaseCrashReporter, QObject):
def on_wallet_usernotify(self, wallet, message): def on_wallet_usernotify(self, wallet, message):
self.logger.debug(message) self.logger.debug(message)
self.user_notification_queue.put(message) self.user_notification_queue.put((wallet,message))
if not self.notification_timer.isActive(): if not self.notification_timer.isActive():
self.logger.debug('starting app notification timer') self.logger.debug('starting app notification timer')
self.notification_timer.start() self.notification_timer.start()
@ -111,7 +111,8 @@ class QEAppController(BaseCrashReporter, QObject):
self.user_notification_last_time = now self.user_notification_last_time = now
self.logger.info("Notifying GUI about new user notifications") self.logger.info("Notifying GUI about new user notifications")
try: try:
self.userNotify.emit(self.user_notification_queue.get_nowait()) wallet, message = self.user_notification_queue.get_nowait()
self.userNotify.emit(str(wallet), message)
except queue.Empty: except queue.Empty:
pass pass

Loading…
Cancel
Save