-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathIQNotificationContainer.qml
176 lines (158 loc) · 6.31 KB
/
IQNotificationContainer.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/*
* This file is part of IQ Notifier.
*
* IQ Notifier is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* IQ Notifier is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with IQ Notifier. If not, see <http://www.gnu.org/licenses/>.
*/
import QtQuick 2.5
import QtQuick.Layouts 1.1
import IQNotifier 1.0
IQFancyContainer {
id: root
showDuration: IQThemes.notificationsTheme.showAnimationDuration
dropDuration: IQThemes.notificationsTheme.dropAnimationDuration
color: IQThemes.notificationsTheme.bgColor
bgImageSource: IQThemes.notificationsTheme.bgImage
signal buttonClicked(string button)
property int referenceHeight: 0
property alias appName: bar.text
property alias title: titleText.text
property alias body: bodyText.text
property url iconUrl: ""
property variant buttons: ""
property alias expireTimeout: expirationBar.expireTimeout
property bool expiration: false
property int barHeight: IQThemes.notificationsTheme.barHeight ?
IQThemes.notificationsTheme.barHeight :
referenceHeight * barFactor
property int expirationBarHeight: IQThemes.notificationsTheme.expirationBarHeight
property int contentMargin: referenceHeight*spacingFactor*2
property int fontPointSize: IQThemes.notificationsTheme.fontSize ?
IQThemes.notificationsTheme.fontSize :
referenceHeight * fontPointSizeFactor
property int iconSize: IQThemes.notificationsTheme.iconSize ?
IQThemes.notificationsTheme.iconSize :
referenceHeight * iconFactor
property real barFactor: 0.148;
property real iconFactor: 0.3;
property real spacingFactor: 0.04;
property real buttonFactor: 0.13;
property real fontPointSizeFactor: 0.045;
IQNotificationBar {
id: bar
color: IQThemes.notificationsTheme.barBgColor
textColor: IQThemes.notificationsTheme.barTextColor
textFontSize: IQThemes.notificationsTheme.barFontSize ?
IQThemes.notificationsTheme.barFontSize :
height*0.4
closeButtonImageSource: IQThemes.notificationsTheme.closeButtonImage
elementsScale: IQThemes.notificationsTheme.closeButtonImageScale
height: barHeight;
visible: height
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
onCloseClicked: root.closeClicked()
}
IQExpirationBar {
id: expirationBar
anchors.top: bar.bottom
anchors.left: parent.left
color: IQThemes.notificationsTheme.expirationBarColor
height: expirationBarHeight
// Crutch to run animation after object created
runnig: expiration && root.height == root.referenceHeight && root.height > 0
}
Component {
id: iconComponent
Image {
id: icon
source: iconUrl
sourceSize.width: iconSize
sourceSize.height: iconSize
fillMode: Image.PreserveAspectFit
visible: source.toString().length
}
}
Loader {
id: iconAtLeftSideLoader
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.top: bar.bottom
anchors.leftMargin: contentMargin
visible: sourceComponent != undefined
sourceComponent: IQThemes.notificationsTheme.iconPosition ? iconComponent : undefined
}
ColumnLayout {
id: column
spacing: referenceHeight * spacingFactor
anchors.rightMargin: contentMargin
anchors.leftMargin: contentMargin
anchors.bottomMargin: contentMargin
anchors.topMargin: contentMargin
anchors.top: bar.bottom
anchors.right: parent.right
anchors.bottom: parent.bottom
anchors.left: iconAtLeftSideLoader.right
Loader {
visible: sourceComponent != undefined
sourceComponent: !IQThemes.notificationsTheme.iconPosition ? iconComponent : undefined
Layout.fillWidth: !buttonsLayout.visible
Layout.fillHeight: Layout.fillWidth
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
}
Text {
id: titleText
visible: text.length
color: IQThemes.notificationsTheme.titleTextColor
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.pointSize: root.fontPointSize
font.weight: Font.Medium
wrapMode: Text.WordWrap
Layout.fillWidth: true
Layout.fillHeight: false
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
}
Text {
id: bodyText
color: IQThemes.notificationsTheme.bodyTextColor
visible: text.length
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.WrapAtWordBoundaryOrAnywhere
font.pointSize: titleText.font.pointSize
Layout.fillWidth: true
Layout.fillHeight: false
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
}
RowLayout {
id: buttonsLayout
visible: buttons.length
Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
Layout.fillWidth: true
Layout.fillHeight: false
Repeater {
model: buttons
IQButton {
height: referenceHeight * buttonFactor
color: IQThemes.notificationsTheme.buttonBgColor
textColor: IQThemes.notificationsTheme.buttonTextColor
Layout.fillHeight: true
Layout.fillWidth: true
text: modelData.text
onClicked: buttonClicked(modelData.action)
}
}
}
}
}