/
HelpTipNotification.qml
57 lines (51 loc) · 2.09 KB
/
HelpTipNotification.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/****************************************************************************
**
** Copyright (C) TERIFLIX Entertainment Spaces Pvt. Ltd. Bengaluru
** Author: Prashanth N Udupa (prashanth.udupa@teriflix.com)
**
** This code is distributed under GPL v3. Complete text of the license
** can be found here: https://www.gnu.org/licenses/gpl-3.0.txt
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
****************************************************************************/
import QtQuick 2.15
import io.scrite.components 1.0
QtObject {
property string tipName
property var helpTip: Scrite.user.helpTips[tipName]
property bool tipShown: helpNotificationSettings.isTipShown(tipName)
property bool enabled: true
Notification.title: helpTip ? helpTip.title : ""
Notification.image: helpTip ? helpTip.image.url : ""
Notification.active: enabled && helpTip && !tipShown
Notification.text: helpTip ? helpTip.text : ""
Notification.autoClose: false
Notification.buttons: {
var ret = []
if(helpTip)
helpTip.buttons.forEach( (item) => {
ret.push(item.text)
})
return ret
}
Notification.onImageClicked: {
if(helpTip) {
if(helpTip.image.action !== "$dismiss")
Qt.openUrlExternally(helpTip.image.action)
markTipAsShown()
}
}
Notification.onButtonClicked: (buttonIndex) => {
if(helpTip) {
const button = helpTip.buttons[buttonIndex]
if(button.action !== "$dismiss")
Qt.openUrlExternally(button.action)
}
markTipAsShown()
}
function markTipAsShown() {
helpNotificationSettings.markTipAsShown(tipName)
}
}