-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathStatusIndicator.qml
187 lines (156 loc) · 5.17 KB
/
StatusIndicator.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
177
178
179
180
181
182
183
184
185
186
187
/* Copyright 2021 Esri
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
//------------------------------------------------------------------------------
import ArcGIS.AppFramework 1.0
import "singletons" as Singletons
//------------------------------------------------------------------------------
Rectangle {
id: esriStatusIndicator
property bool hideAutomatically: false
property bool showDismissButton: false
property bool narrowLineHeight: false
property int hideAfter: 30000
property int containerHeight: 50
property int statusTextFontSize: 14
property int indicatorBorderWidth: 1
property string statusTextFontColor: "#111"
property alias message: statusText.text
property alias statusTextObject: statusText
readonly property var success: {
"backgroundColor": "#DDEEDB",
"borderColor": "#9BC19C"
}
readonly property var info: {
"backgroundColor": "#D2E9F9",
"borderColor": "#3B8FC4"
}
readonly property var warning: {
"backgroundColor": "#F3EDC7",
"borderColor": "#D9BF2B"
}
readonly property var error: {
"backgroundColor": "#F3DED7",
"borderColor": "#E4A793"
}
property var messageType: success
signal show()
signal hide()
signal hideImmediately()
signal linkClicked(string link)
color: messageType.backgroundColor
height: containerHeight
Layout.preferredHeight: containerHeight
border.width: indicatorBorderWidth
border.color: messageType.borderColor
visible: false
//--------------------------------------------------------------------------
RowLayout {
anchors.fill: parent
spacing: 0
Text {
id: statusText
Layout.fillHeight: true
Layout.fillWidth: true
color: statusTextFontColor
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
textFormat: Text.RichText
text: ""
font.pointSize: statusTextFontSize
font.family: defaultFontFamily
wrapMode: Text.WordWrap
lineHeight: narrowLineHeight ? .7 : 1
onLinkActivated: {
linkClicked(link.toString());
Qt.openUrlExternally(link);
}
}
Button {
visible: showDismissButton
enabled: showDismissButton
Layout.fillHeight: true
Layout.preferredWidth: parent.height
background: Rectangle {
anchors.fill: parent
color: messageType.backgroundColor
border.width: 1
border.color: messageType.borderColor
}
Rectangle {
anchors.fill: parent
color: "transparent"
anchors.margins: sf(8)
IconFont {
anchors.centerIn: parent
iconFont.font.pointSize: Singletons.Config.mediumFontSizePoint
color: messageType.borderColor
icon: _icons.x_cross
}
}
onClicked: {
hide();
}
}
}
// SIGNALS /////////////////////////////////////////////////////////////////
onShow: {
esriStatusIndicator.opacity = 1;
esriStatusIndicator.visible = true;
if (hideAutomatically) {
hideStatusMessage.start();
}
}
//--------------------------------------------------------------------------
onHide: {
fader.start()
}
//--------------------------------------------------------------------------
onHideImmediately: {
esriStatusIndicator.visible = false;
if (hideStatusMessage.running) {
hideStatusMessage.stop();
}
}
// COMPONENTS //////////////////////////////////////////////////////////////
Timer {
id: hideStatusMessage
interval: hideAfter
running: false
repeat: false
onTriggered: hide()
}
//--------------------------------------------------------------------------
PropertyAnimation {
id: fader
from: 1
to: 0
duration: 1000
property: "opacity"
running: false
easing.type: Easing.Linear
target: esriStatusIndicator
onStopped: {
esriStatusIndicator.visible = false;
if (hideStatusMessage.running) {
hideStatusMessage.stop();
}
}
}
// END /////////////////////////////////////////////////////////////////////
}