9import QtQuick.Controls as QQC2
10import QtQuick.Templates as T
11import org.kde.kirigami as Kirigami
12import org.kde.kirigami.templates.private as TP
88 property int position: InlineMessage.Position.Inline
94 signal linkHovered(string link)
100 signal linkActivated(string link)
105 readonly property alias hoveredLink: label.hoveredLink
112 property int type: Kirigami.MessageType.Information
123 property TP.IconPropertiesGroup icon: TP.IconPropertiesGroup {}
135 property bool showCloseButton: false
142 property list<T.Action>
actions
147 readonly
property bool animating: _animating
149 property bool _animating:
false
151 implicitHeight: visible ? (contentLayout.implicitHeight + topPadding + bottomPadding) : 0
153 padding: Kirigami.
Units.smallSpacing
155 Accessible.role: Accessible.AlertMessage
156 Accessible.ignored: !visible
158 Behavior on implicitHeight {
159 enabled: !root.visible
161 SequentialAnimation {
162 PropertyAction { targets: root; property:
"_animating"; value:
true }
163 NumberAnimation { duration: Kirigami.Units.longDuration }
169 contentLayout.opacity = 0;
173 opacity: visible ? 1 : 0
175 Behavior on opacity {
176 enabled: !root.visible
178 NumberAnimation { duration: Kirigami.Units.shortDuration }
183 contentLayout.opacity = 0;
184 }
else if (opacity === 1) {
185 contentLayout.opacity = 1;
189 onImplicitHeightChanged: {
190 height = implicitHeight;
198 property bool complete:
false
200 Behavior on opacity {
201 enabled: root.visible && contentLayout.complete
203 SequentialAnimation {
204 NumberAnimation { duration: Kirigami.Units.shortDuration * 2 }
205 PropertyAction { targets: root; property:
"_animating"; value:
false }
211 return label.implicitHeight + actionsLayout.implicitHeight + actionsLayout.anchors.topMargin
213 return Math.max(icon.implicitHeight,
label.implicitHeight, closeButton.implicitHeight, actionsLayout.implicitHeight)
217 Accessible.ignored:
true
219 readonly
property real remainingWidth: width - (
221 +
label.anchors.leftMargin +
label.implicitWidth +
label.anchors.rightMargin
222 + (root.showCloseButton ? closeButton.width : 0)
224 readonly property
bool multiline: remainingWidth <= 0 || atBottom
226 readonly property bool atBottom: (root.actions.length > 0) && (
label.lineCount > 1 || actionsLayout.implicitWidth > remainingWidth)
231 width: Kirigami.
Units.iconSizes.smallMedium
232 height: Kirigami.
Units.iconSizes.smallMedium
236 leftMargin: Kirigami.
Units.smallSpacing
237 topMargin: Kirigami.
Units.smallSpacing
243 when: contentLayout.atBottom ||
label.height > icon.height * 1.7
246 anchors.top: icon.parent.top
247 anchors.verticalCenter: undefined
257 anchors.top: undefined
258 anchors.verticalCenter: parent.verticalCenter
264 if (root.icon.name) {
265 return root.icon.name;
266 }
else if (root.icon.source) {
267 return root.icon.source;
271 case Kirigami.MessageType.Positive:
272 return
"emblem-success";
273 case Kirigami.MessageType.Warning:
274 return
"emblem-warning";
275 case Kirigami.MessageType.Error:
276 return
"emblem-error";
278 return
"emblem-information";
282 color: root.icon.color
284 Accessible.ignored: !root.
visible
287 case Kirigami.MessageType.Positive:
288 return qsTr(
"Success");
289 case Kirigami.MessageType.Warning:
290 return qsTr(
"Warning");
291 case Kirigami.MessageType.Error:
292 return qsTr(
"Error");
299 Kirigami.SelectableLabel {
304 leftMargin: Kirigami.Units.largeSpacing
305 right: root.showCloseButton ? closeButton.left : parent.right
306 rightMargin: root.showCloseButton ? Kirigami.Units.smallSpacing : 0
310 color: Kirigami.Theme.textColor
311 wrapMode: Text.WordWrap
315 verticalAlignment: Text.AlignVCenter
323 when: contentLayout.multiline
326 anchors.bottom: undefined
330 height:
label.implicitHeight
340 anchors.bottom:
label.parent.bottom
345 onLinkHovered:
link => root.linkHovered(link)
346 onLinkActivated:
link => root.linkActivated(link)
348 Accessible.ignored: !root.visible
351 Kirigami.ActionToolBar {
355 actions: root.actions
356 visible: root.actions.length > 0
357 Accessible.ignored: !visible || !root.visible
358 alignment:
Qt.AlignRight
362 top: contentLayout.atBottom ?
label.bottom : parent.top
363 topMargin: contentLayout.atBottom ? Kirigami.Units.largeSpacing : 0
364 right: (!contentLayout.atBottom && root.showCloseButton) ? closeButton.left : parent.
right
365 rightMargin: !contentLayout.atBottom && root.showCloseButton ? Kirigami.
Units.smallSpacing : 0
372 visible: root.showCloseButton
381 when: contentLayout.atBottom
384 anchors.top: parent.top
385 anchors.verticalCenter: undefined
392 anchors.top: undefined
393 anchors.verticalCenter: parent.verticalCenter
398 height: contentLayout.atBottom ? implicitHeight : implicitHeight
401 display: QQC2.ToolButton.IconOnly
402 icon.
name:
"dialog-close"
404 onClicked: root.visible = false
406 Accessible.ignored: !root.visible
409 Component.onCompleted: complete = true
Class for rendering an icon in UI.
listTAction actions
This property holds the list of actions to show.
bool animating
This property holds whether the current message item is animating.
KIOCORE_EXPORT CopyJob * link(const QList< QUrl > &src, const QUrl &destDir, JobFlags flags=DefaultFlags)
QString name(StandardAction id)
QString label(StandardShortcut id)
QTextStream & left(QTextStream &stream)
QTextStream & right(QTextStream &stream)