9 import QtQuick.Layouts 1.0
10 import QtQuick.Controls 2.0 as QQC2
11 import QtQuick.Templates 2.0 as T2
12 import org.kde.kirigami 2.20 as Kirigami
73 signal linkHovered(
string link)
79 signal linkActivated(
string link)
84 readonly property
string hoveredLink: label.hoveredLink
91 property
int type: Kirigami.MessageType.Information
114 property bool showCloseButton:
false
121 property list<QtObject> actions
126 readonly
property bool animating: _animating
128 property bool _animating:
false
130 implicitHeight: visible ? (contentLayout.implicitHeight + topPadding + bottomPadding) : 0
132 padding: Kirigami.Units.smallSpacing
134 topPadding: undefined
135 leftPadding: undefined
136 rightPadding: undefined
137 bottomPadding: undefined
139 Behavior on implicitHeight {
140 enabled: !root.visible
142 SequentialAnimation {
143 PropertyAction { targets: root; property:
"_animating"; value:
true }
144 NumberAnimation { duration: Kirigami.Units.longDuration }
150 contentLayout.opacity = 0;
154 opacity: visible ? 1 : 0
156 Behavior on opacity {
157 enabled: !root.visible
159 NumberAnimation { duration: Kirigami.Units.shortDuration }
164 contentLayout.opacity = 0;
165 }
else if (opacity === 1) {
166 contentLayout.opacity = 1;
170 onImplicitHeightChanged: {
171 height = implicitHeight;
179 property bool complete:
false
181 Behavior on opacity {
182 enabled: root.visible && contentLayout.complete
184 SequentialAnimation {
185 NumberAnimation { duration: Kirigami.Units.shortDuration * 2 }
186 PropertyAction { targets: root; property:
"_animating"; value:
false }
191 if (actionsLayout.atBottom) {
192 return label.implicitHeight + actionsLayout.height + Kirigami.Units.gridUnit
194 return Math.max(icon.implicitHeight,
label.implicitHeight, closeButton.implicitHeight, actionsLayout.height)
198 readonly
property real remainingWidth: width - (
200 + labelArea.anchors.leftMargin +
label.implicitWidth + labelArea.anchors.rightMargin
201 + (root.showCloseButton ? closeButton.width : 0)
203 readonly property
bool multiline: remainingWidth <= 0 || actionsLayout.atBottom
208 width: Kirigami.Units.iconSizes.smallMedium
209 height: Kirigami.Units.iconSizes.smallMedium
213 top: actionsLayout.atBottom ? parent.top : undefined
214 verticalCenter: actionsLayout.atBottom ? undefined : parent.verticalCenter
218 if (root.icon.name) {
219 return root.icon.name;
220 }
else if (root.icon.source) {
221 return root.icon.source;
224 if (root.type === Kirigami.MessageType.Positive) {
225 return "dialog-positive";
226 }
else if (root.type === Kirigami.MessageType.Warning) {
227 return "dialog-warning";
228 }
else if (root.type === Kirigami.MessageType.Error) {
229 return "dialog-error";
232 return "dialog-information";
235 color: root.icon.color
243 leftMargin: Kirigami.Units.smallSpacing
245 rightMargin: root.showCloseButton ? Kirigami.Units.smallSpacing : 0
247 bottom: contentLayout.multiline ? undefined : parent.bottom
250 acceptedButtons:
Qt.NoButton
251 cursorShape:
label.hoveredLink.
length > 0 ?
Qt.PointingHandCursor : undefined
252 propagateComposedEvents:
true
254 implicitWidth:
label.implicitWidth
255 height: contentLayout.multiline ?
label.implicitHeight : implicitHeight
257 Kirigami.SelectableLabel {
261 height: parent.height
263 color: Kirigami.Theme.textColor
264 wrapMode: Text.WordWrap
268 verticalAlignment: Text.AlignVCenter
270 onLinkHovered:
link => root.linkHovered(link)
271 onLinkActivated:
link => root.linkActivated(link)
275 Kirigami.ActionToolBar {
279 actions: root.actions
280 visible: root.actions.length > 0
281 alignment:
Qt.AlignRight
283 readonly
property bool atBottom: (root.actions.length > 0) && (
label.lineCount > 1 || implicitWidth > contentLayout.remainingWidth)
287 top: atBottom ? labelArea.bottom : parent.top
288 topMargin: atBottom ? Kirigami.Units.gridUnit : 0
289 right: (!atBottom && root.showCloseButton) ? closeButton.
left : parent.
right
290 rightMargin: !atBottom && root.showCloseButton ? Kirigami.Units.smallSpacing : 0
297 visible: root.showCloseButton
301 top: actionsLayout.atBottom ? parent.top : undefined
302 verticalCenter: actionsLayout.atBottom ? undefined : parent.verticalCenter
305 height: actionsLayout.atBottom ? implicitHeight : implicitHeight
307 icon.name:
"dialog-close"
309 onClicked: root.visible =
false