Files
status-app/ui/shared/NotificationWindow.qml
T

113 lines
3.5 KiB
QML
Raw Normal View History

2020-07-10 17:47:31 -04:00
import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Window 2.12
import QtQml 2.13
2020-08-05 14:18:07 -04:00
import QtGraphicalEffects 1.13
2020-07-10 17:47:31 -04:00
import "../imports"
import "./status"
2020-08-05 14:18:07 -04:00
import "../app/AppLayouts/Chat/ContactsColumn"
2020-07-10 17:47:31 -04:00
Item {
id: root
2020-08-05 14:18:07 -04:00
property string chatId: ""
property string name: "channel name"
2020-08-05 14:18:07 -04:00
property string message: "Everything is connected"
property int chatType: 1
property var onClick
2020-08-05 14:18:07 -04:00
property string identicon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQAQMAAAC6caSPAAAABlBMVEXMzMz////TjRV2AAAAAWJLR0QB/wIt3gAAACpJREFUGBntwYEAAAAAw6D7Uw/gCtUAAAAAAAAAAAAAAAAAAAAAAAAAgBNPsAABAjKCqQAAAABJRU5ErkJggg=="
property var processClick: Backpressure.oneInTime(root, 1000, function () {
2020-07-22 11:35:14 -04:00
notificationSound.play()
var w1 = winInit.createObject(null)
w1.destroy()
2020-08-05 14:18:07 -04:00
})
2020-07-10 17:47:31 -04:00
Component {
id: winInit
Window {
flags: Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Popup
| Qt.WA_ShowWithoutActivating | Qt.BypassWindowManagerHint
2020-07-10 17:47:31 -04:00
width: 1
height: 1
Component.onCompleted: {
requestActivate()
mainWin.createObject(root)
}
}
}
Component {
id: mainWin
Window {
id: notificationWindowSub
flags: Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.WA_ShowWithoutActivating | Qt.BypassWindowManagerHint
height: channelNotif.height
width: channelNotif.width
2020-08-05 14:18:07 -04:00
x: Screen.width - (width + 50)
2020-07-10 17:47:31 -04:00
y: 50
visible: true
2020-08-05 14:18:07 -04:00
color: Style.current.transparent
2020-07-10 17:47:31 -04:00
StatusNotification {
2020-08-05 14:18:07 -04:00
id: channelNotif
chatId: root.chatId
name: root.name
message: root.message
2020-08-05 14:18:07 -04:00
chatType: root.chatType
identicon: root.identicon
MouseArea {
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
onClicked: {
timer.stop()
notificationWindowSub.close()
root.onClick(root.chatId)
notificationWindowSub.destroy()
}
2020-07-10 17:47:31 -04:00
}
Timer {
id: timer
interval: Constants.notificationPopupTTL
running: true
repeat: false
onTriggered: {
notificationWindowSub.close()
notificationWindowSub.destroy()
}
2020-07-15 18:00:18 -04:00
}
onVisibleChanged: {
if (visible) {
timer.running = true
if (applicationWindow.active) {
this.flags |= Qt.Popup
} else {
this.flags = Qt.FramelessWindowHint | Qt.WA_ShowWithoutActivating
| Qt.WindowStaysOnTopHint | Qt.BypassWindowManagerHint
}
2020-07-10 17:47:31 -04:00
}
}
}
}
}
function notifyUser(chatId, name, msg, chatType, identicon, onClick) {
this.chatId = chatId
this.name = name
this.message = msg
2020-08-05 14:18:07 -04:00
this.chatType = chatType
this.identicon = identicon
this.onClick = onClick
processClick()
2020-08-05 14:18:07 -04:00
}
2020-07-10 17:47:31 -04:00
}
/*##^##
Designer {
D{i:0;autoSize:true;height:480;width:640}
}
##^##*/