From dc65665ee683f0d3ae246f4fe7e1f08f41ac5b27 Mon Sep 17 00:00:00 2001 From: cutefishd Date: Tue, 6 Apr 2021 18:08:36 +0800 Subject: [PATCH] Window: add notification --- src/controls/Toast.qml | 12 +++++++----- src/controls/Window.qml | 30 ++++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 13 deletions(-) diff --git a/src/controls/Toast.qml b/src/controls/Toast.qml index 3abb50d..9604392 100644 --- a/src/controls/Toast.qml +++ b/src/controls/Toast.qml @@ -7,7 +7,7 @@ import MeuiKit 1.0 as Meui Popup { id: control x: Math.round(parent.width / 2 - width / 2) - y: parent.height - height - Meui.Units.smallSpacing + y: parent.height - height - Meui.Units.largeSpacing implicitWidth: Math.max(background ? background.implicitWidth : 0, contentWidth + leftPadding + rightPadding) + leftInset + rightInset implicitHeight: Math.max(background ? background.implicitHeight : 0 , @@ -18,7 +18,7 @@ Popup { topPadding: Meui.Units.smallSpacing leftPadding: Meui.Units.smallSpacing rightPadding: Meui.Units.smallSpacing - bottomPadding: Meui.Units.smallSpacing + bottomPadding: Meui.Units.largeSpacing modal: false closePolicy: Popup.NoAutoClose @@ -172,8 +172,10 @@ Popup { } } - background: Meui.RoundedRect { - backgroundOpacity: 0.6 + background: Rectangle { + color: Meui.Theme.backgroundColor + radius: Meui.Theme.mediumRadius + opacity: 0.9 layer.enabled: true layer.effect: DropShadow { transparentBorder: true @@ -181,7 +183,7 @@ Popup { samples: 32 horizontalOffset: 0 verticalOffset: 0 - color: Qt.rgba(0, 0, 0, 0.11) + color: Qt.rgba(0, 0, 0, 0.14) } } } diff --git a/src/controls/Window.qml b/src/controls/Window.qml index c14a9e0..0965451 100644 --- a/src/controls/Window.qml +++ b/src/controls/Window.qml @@ -33,14 +33,6 @@ Window { headerBar.anchors.fill = _header } - function toggleMaximized() { - if (isMaximized) { - root.showNormal(); - } else { - root.showMaximized(); - } - } - Meui.WindowHelper { id: windowHelper } @@ -313,4 +305,26 @@ Window { } } } + + QtObject { + id: internal + property QtObject passiveNotification + } + + function showPassiveNotification(message, timeout, actionText, callBack) { + if (!internal.passiveNotification) { + var component = Qt.createComponent("qrc:/meui/kit/Toast.qml") + internal.passiveNotification = component.createObject(root) + } + + internal.passiveNotification.showNotification(message, timeout, actionText, callBack) + } + + function toggleMaximized() { + if (isMaximized) { + root.showNormal(); + } else { + root.showMaximized(); + } + } }