status-desktop/ui/shared/NotificationWindow.qml
Alexandra Betouni 4ee21ada05 feat(desktop) Added image function in Style
Introduced Style.svg() Style.png() Style.emoji() and
Style.icon() in Style.qml. Those should be used to
set the source in Images instead of using relative
paths. Usage:
Image {
   source: Style.svg("check)
   ....

Also moved all Singletons inside a new "utils"
folder and made it a QML module, to use
import utils 1.0 instead of relative paths

Closes #3678
2021-09-28 15:28:00 -04:00

114 lines
3.5 KiB
QML

import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Window 2.12
import QtQml 2.13
import QtGraphicalEffects 1.13
import utils 1.0
import "./status"
import "../app/AppLayouts/Chat/ContactsColumn"
Item {
id: root
property string chatId: ""
property string name: "channel name"
property string message: "Everything is connected"
property int chatType: 1
property var onClick
property string identicon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAAGQAQMAAAC6caSPAAAABlBMVEXMzMz////TjRV2AAAAAWJLR0QB/wIt3gAAACpJREFUGBntwYEAAAAAw6D7Uw/gCtUAAAAAAAAAAAAAAAAAAAAAAAAAgBNPsAABAjKCqQAAAABJRU5ErkJggg=="
property var processClick: Backpressure.oneInTime(root, 1000, function () {
notificationSound.play()
var w1 = winInit.createObject(null)
w1.destroy()
})
Component {
id: winInit
Window {
flags: Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint | Qt.Popup
| Qt.WA_ShowWithoutActivating | Qt.BypassWindowManagerHint
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
x: Screen.width - (width + 50)
y: 50
visible: true
color: Style.current.transparent
StatusNotification {
id: channelNotif
chatId: root.chatId
name: root.name
message: root.message
chatType: root.chatType
identicon: root.identicon
MouseArea {
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
onClicked: {
timer.stop()
notificationWindowSub.close()
root.onClick(root.chatId)
notificationWindowSub.destroy()
}
}
Timer {
id: timer
interval: Constants.notificationPopupTTL
running: true
repeat: false
onTriggered: {
notificationWindowSub.close()
notificationWindowSub.destroy()
}
}
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
}
}
}
}
}
}
function notifyUser(chatId, name, msg, chatType, identicon, onClick) {
this.chatId = chatId
this.name = name
this.message = msg
this.chatType = chatType
this.identicon = identicon
this.onClick = onClick
processClick()
}
}
/*##^##
Designer {
D{i:0;autoSize:true;height:480;width:640}
}
##^##*/