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
|
|
|
|
|
|
|
import "../imports"
|
2020-11-17 19:02:56 +00:00
|
|
|
import "./status"
|
2020-08-05 18:18:07 +00:00
|
|
|
import "../app/AppLayouts/Chat/ContactsColumn"
|
2020-07-10 21:47:31 +00:00
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
2020-08-05 18:18:07 +00:00
|
|
|
property string chatId: ""
|
|
|
|
property string message: "Everything is connected"
|
|
|
|
property int messageType: 1
|
|
|
|
property int chatType: 1
|
|
|
|
property string timestamp: "20/2/2020"
|
|
|
|
property string identicon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQAQMAAAC6caSPAAAABlBMVEXMzMz////TjRV2AAAAAWJLR0QB/wIt3gAAACpJREFUGBntwYEAAAAAw6D7Uw/gCtUAAAAAAAAAAAAAAAAAAAAAAAAAgBNPsAABAjKCqQAAAABJRU5ErkJggg=="
|
|
|
|
property string username: "@jonas"
|
2020-11-16 19:25:46 +00:00
|
|
|
property string channelName: "sic-mundus"
|
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
|
|
|
|
2020-11-17 19:02:56 +00:00
|
|
|
StatusNotification {
|
2020-08-05 18:18:07 +00:00
|
|
|
id: channelNotif
|
2020-11-17 19:02:56 +00:00
|
|
|
chatId: root.chatId
|
|
|
|
name: {
|
|
|
|
if (appSettings.notificationMessagePreviewSetting === Constants.notificationPreviewAnonymous) {
|
|
|
|
return "Status"
|
|
|
|
}
|
2020-11-16 19:25:46 +00:00
|
|
|
if (root.chatType === Constants.chatTypePublic) {
|
|
|
|
return root.chatId
|
|
|
|
}
|
|
|
|
return root.chatType === Constants.chatTypePrivateGroupChat ? Utils.filterXSS(root.channelName) : Utils.removeStatusEns(root.username)
|
2020-11-17 19:02:56 +00:00
|
|
|
}
|
|
|
|
message: {
|
|
|
|
if (appSettings.notificationMessagePreviewSetting > Constants.notificationPreviewNameOnly) {
|
|
|
|
switch(root.messageType){
|
|
|
|
case Constants.imageType: return qsTr("Image");
|
|
|
|
case Constants.stickerType: return qsTr("Sticker");
|
|
|
|
default: return Emoji.parse(root.message, "26x26").replace(/\n|\r/g, ' ')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return qsTr("You have a new message")
|
|
|
|
}
|
2020-08-05 18:18:07 +00:00
|
|
|
chatType: root.chatType
|
|
|
|
identicon: root.identicon
|
|
|
|
|
2020-11-17 19:02:56 +00:00
|
|
|
MouseArea {
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
anchors.fill: parent
|
|
|
|
onClicked: {
|
|
|
|
timer.stop()
|
|
|
|
notificationWindowSub.close()
|
|
|
|
applicationWindow.raise()
|
|
|
|
chatsModel.setActiveChannel(root.chatId)
|
|
|
|
}
|
2020-07-10 21:47:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Timer {
|
|
|
|
id: timer
|
2020-08-05 18:18:07 +00:00
|
|
|
interval: 4000
|
|
|
|
running: false
|
2020-07-10 21:47:31 +00:00
|
|
|
repeat: false
|
2020-07-15 22:00:18 +00:00
|
|
|
onTriggered: {
|
2020-08-05 18:18:07 +00:00
|
|
|
notificationWindowSub.close()
|
2020-07-15 22:00:18 +00:00
|
|
|
}
|
2020-07-10 21:47:31 +00:00
|
|
|
}
|
|
|
|
onVisibleChanged: {
|
2020-08-05 18:18:07 +00:00
|
|
|
if (visible) {
|
|
|
|
timer.running = true
|
2020-07-10 21:47:31 +00:00
|
|
|
if (applicationWindow.active) {
|
|
|
|
this.flags |= Qt.Popup
|
|
|
|
} else {
|
2020-11-17 19:02:56 +00:00
|
|
|
this.flags = Qt.FramelessWindowHint | Qt.WA_ShowWithoutActivating
|
|
|
|
| Qt.WindowStaysOnTopHint | Qt.BypassWindowManagerHint
|
2020-07-10 21:47:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-11-17 19:02:56 +00:00
|
|
|
|
2020-07-10 21:47:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-16 19:25:46 +00:00
|
|
|
function notifyUser(chatId, msg, messageType, chatType, timestamp, identicon, username, channelName) {
|
2020-07-22 18:27:11 +00:00
|
|
|
this.chatId = chatId
|
|
|
|
this.message = msg
|
2020-08-05 18:18:07 +00:00
|
|
|
this.messageType = parseInt(messageType, 10)
|
|
|
|
this.chatType = chatType
|
|
|
|
this.timestamp = timestamp
|
|
|
|
this.identicon = identicon
|
|
|
|
this.username = username
|
2020-11-16 19:25:46 +00:00
|
|
|
this.channelName = channelName
|
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}
|
|
|
|
}
|
|
|
|
##^##*/
|
2020-08-05 18:18:07 +00:00
|
|
|
|