2020-07-10 21:47:31 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Window 2.12
|
|
|
|
import QtQml 2.13
|
2020-08-05 18:18:07 +00:00
|
|
|
import QtGraphicalEffects 1.13
|
2020-07-10 21:47:31 +00:00
|
|
|
|
2021-10-28 13:37:26 +00:00
|
|
|
import StatusQ.Platform 0.1
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2021-10-14 11:40:29 +00:00
|
|
|
import "../status"
|
2021-10-14 13:39:12 +00:00
|
|
|
import "../controls"
|
2020-07-10 21:47:31 +00:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
2020-08-05 18:18:07 +00:00
|
|
|
property string chatId: ""
|
2020-12-07 17:37:39 +00:00
|
|
|
property string name: "channel name"
|
2022-07-19 08:34:27 +00:00
|
|
|
property string message: qsTr("Everything is connected")
|
2020-08-05 18:18:07 +00:00
|
|
|
property int chatType: 1
|
2020-12-07 17:37:39 +00:00
|
|
|
property var onClick
|
2020-08-05 18:18:07 +00:00
|
|
|
|
|
|
|
property var processClick: Backpressure.oneInTime(root, 1000, function () {
|
2020-07-22 15:35:14 +00:00
|
|
|
notificationSound.play()
|
|
|
|
var w1 = winInit.createObject(null)
|
|
|
|
w1.destroy()
|
2020-08-05 18:18:07 +00:00
|
|
|
})
|
2020-07-10 21:47:31 +00:00
|
|
|
|
|
|
|
Component {
|
|
|
|
id: winInit
|
|
|
|
Window {
|
2020-11-17 19:02:56 +00:00
|
|
|
flags: Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Popup
|
|
|
|
| Qt.WA_ShowWithoutActivating | Qt.BypassWindowManagerHint
|
2020-07-10 21:47:31 +00:00
|
|
|
width: 1
|
|
|
|
height: 1
|
|
|
|
Component.onCompleted: {
|
|
|
|
requestActivate()
|
|
|
|
mainWin.createObject(root)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Component {
|
|
|
|
id: mainWin
|
|
|
|
|
|
|
|
Window {
|
|
|
|
id: notificationWindowSub
|
2020-11-17 19:02:56 +00:00
|
|
|
flags: Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.WA_ShowWithoutActivating | Qt.BypassWindowManagerHint
|
|
|
|
height: channelNotif.height
|
|
|
|
width: channelNotif.width
|
2020-08-05 18:18:07 +00:00
|
|
|
x: Screen.width - (width + 50)
|
2020-07-10 21:47:31 +00:00
|
|
|
y: 50
|
|
|
|
visible: true
|
2020-08-05 18:18:07 +00:00
|
|
|
color: Style.current.transparent
|
2020-07-10 21:47:31 +00:00
|
|
|
|
2021-10-28 13:37:26 +00:00
|
|
|
StatusMacNotification {
|
2020-08-05 18:18:07 +00:00
|
|
|
id: channelNotif
|
2020-11-17 19:02:56 +00:00
|
|
|
chatId: root.chatId
|
2020-12-07 17:37:39 +00:00
|
|
|
name: root.name
|
|
|
|
message: root.message
|
2020-08-05 18:18:07 +00:00
|
|
|
|
2020-12-01 21:22:15 +00:00
|
|
|
MouseArea {
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: {
|
|
|
|
timer.stop()
|
|
|
|
notificationWindowSub.close()
|
2020-12-07 17:37:39 +00:00
|
|
|
root.onClick(root.chatId)
|
|
|
|
notificationWindowSub.destroy()
|
2020-12-01 21:22:15 +00:00
|
|
|
}
|
2020-07-10 21:47:31 +00:00
|
|
|
}
|
|
|
|
|
2020-12-01 21:22:15 +00:00
|
|
|
Timer {
|
|
|
|
id: timer
|
2020-12-07 17:37:39 +00:00
|
|
|
interval: Constants.notificationPopupTTL
|
|
|
|
running: true
|
2020-12-01 21:22:15 +00:00
|
|
|
repeat: false
|
|
|
|
onTriggered: {
|
|
|
|
notificationWindowSub.close()
|
2020-12-07 17:37:39 +00:00
|
|
|
notificationWindowSub.destroy()
|
2020-12-01 21:22:15 +00:00
|
|
|
}
|
2020-07-15 22:00:18 +00:00
|
|
|
}
|
2020-12-01 21:22:15 +00:00
|
|
|
onVisibleChanged: {
|
|
|
|
if (visible) {
|
|
|
|
timer.running = true
|
2021-12-08 21:20:43 +00:00
|
|
|
if (Global.applicationWindow.active) {
|
2020-12-01 21:22:15 +00:00
|
|
|
this.flags |= Qt.Popup
|
|
|
|
} else {
|
|
|
|
this.flags = Qt.FramelessWindowHint | Qt.WA_ShowWithoutActivating
|
|
|
|
| Qt.WindowStaysOnTopHint | Qt.BypassWindowManagerHint
|
|
|
|
}
|
2020-07-10 21:47:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-30 15:30:28 +00:00
|
|
|
function notifyUser(chatId, name, msg, chatType, onClick) {
|
2020-07-22 18:27:11 +00:00
|
|
|
this.chatId = chatId
|
2020-12-07 17:37:39 +00:00
|
|
|
this.name = name
|
2020-07-22 18:27:11 +00:00
|
|
|
this.message = msg
|
2020-08-05 18:18:07 +00:00
|
|
|
this.chatType = chatType
|
2020-12-07 17:37:39 +00:00
|
|
|
this.onClick = onClick
|
2020-07-22 18:27:11 +00:00
|
|
|
processClick()
|
2020-08-05 18:18:07 +00:00
|
|
|
}
|
2020-07-10 21:47:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*##^##
|
|
|
|
Designer {
|
|
|
|
D{i:0;autoSize:true;height:480;width:640}
|
|
|
|
}
|
|
|
|
##^##*/
|