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-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"
|
|
|
|
|
|
|
|
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-08-05 18:18:07 +00:00
|
|
|
flags: Qt.WindowStaysOnTopHint | Qt.WindowStaysOnTopHint | Qt.Popup
|
|
|
|
| Qt.WA_ShowWithoutActivating | Qt.WindowStaysOnTopHint
|
|
|
|
| Qt.BypassWindowManagerHint | Qt.WindowStaysOnTopHint
|
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-08-05 18:18:07 +00:00
|
|
|
flags: Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint
|
|
|
|
| Qt.WA_ShowWithoutActivating | Qt.BypassWindowManagerHint
|
|
|
|
| Qt.WindowStaysOnTopHint | Qt.BypassWindowManagerHint
|
|
|
|
width: 300 + 10
|
|
|
|
height: channelNotif.height + 10
|
|
|
|
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-08-05 18:18:07 +00:00
|
|
|
Channel {
|
|
|
|
id: channelNotif
|
|
|
|
name: root.chatType === Constants.chatTypeOneToOne ? root.username : root.chatId
|
|
|
|
lastMessage: root.message
|
|
|
|
timestamp: root.timestamp
|
|
|
|
chatType: root.chatType
|
|
|
|
unviewedMessagesCount: "0"
|
|
|
|
hasMentions: false
|
|
|
|
contentType: root.messageType
|
|
|
|
identicon: root.identicon
|
|
|
|
searchStr: ""
|
|
|
|
isCompact: false
|
|
|
|
color: Style.current.background
|
|
|
|
anchors.rightMargin: 10
|
|
|
|
}
|
|
|
|
DropShadow {
|
|
|
|
anchors.fill: channelNotif
|
|
|
|
horizontalOffset: 2
|
|
|
|
verticalOffset: 5
|
|
|
|
visible: channelNotif.visible
|
|
|
|
source: channelNotif
|
|
|
|
radius: 10
|
|
|
|
samples: 15
|
|
|
|
color: "#ad000000"
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
2020-07-10 21:47:31 +00:00
|
|
|
anchors.fill: parent
|
2020-08-05 18:18:07 +00:00
|
|
|
onClicked: {
|
|
|
|
timer.stop()
|
|
|
|
notificationWindowSub.close()
|
|
|
|
applicationWindow.raise()
|
|
|
|
chatsModel.setActiveChannel(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-08-05 18:18:07 +00:00
|
|
|
this.flags = Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint
|
|
|
|
| Qt.WA_ShowWithoutActivating | Qt.BypassWindowManagerHint
|
|
|
|
| Qt.WindowStaysOnTopHint | Qt.BypassWindowManagerHint
|
2020-07-10 21:47:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-05 18:18:07 +00:00
|
|
|
function notifyUser(chatId, msg, messageType, chatType, timestamp, identicon, username) {
|
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-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
|
|
|
|