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 Behavior on implicitHeight {
156 enabled: !root.visible
158 SequentialAnimation {
159 PropertyAction { targets: root; property:
"_animating"; value:
true }
160 NumberAnimation { duration: Kirigami.Units.longDuration }
166 contentLayout.opacity = 0;
170 opacity: visible ? 1 : 0
172 Behavior on opacity {
173 enabled: !root.visible
175 NumberAnimation { duration: Kirigami.Units.shortDuration }
180 contentLayout.opacity = 0;
181 }
else if (opacity === 1) {
182 contentLayout.opacity = 1;
186 onImplicitHeightChanged: {
187 height = implicitHeight;
195 property bool complete:
false
197 Behavior on opacity {
198 enabled: root.visible && contentLayout.complete
200 SequentialAnimation {
201 NumberAnimation { duration: Kirigami.Units.shortDuration * 2 }
202 PropertyAction { targets: root; property:
"_animating"; value:
false }
208 return label.implicitHeight + actionsLayout.implicitHeight + actionsLayout.anchors.topMargin
210 return Math.max(icon.implicitHeight,
label.implicitHeight, closeButton.implicitHeight, actionsLayout.implicitHeight)
214 readonly
property real remainingWidth: width - (
216 +
label.anchors.leftMargin +
label.implicitWidth +
label.anchors.rightMargin
217 + (root.showCloseButton ? closeButton.width : 0)
219 readonly property
bool multiline: remainingWidth <= 0 || atBottom
221 readonly property bool atBottom: (root.actions.length > 0) && (
label.lineCount > 1 || actionsLayout.implicitWidth > remainingWidth)
226 width: Kirigami.
Units.iconSizes.smallMedium
227 height: Kirigami.
Units.iconSizes.smallMedium
231 leftMargin: Kirigami.
Units.smallSpacing
232 topMargin: Kirigami.
Units.smallSpacing
238 when: contentLayout.atBottom ||
label.height > icon.height * 1.7
241 anchors.top: icon.parent.top
242 anchors.verticalCenter: undefined
252 anchors.top: undefined
253 anchors.verticalCenter: parent.verticalCenter
259 if (root.icon.name) {
260 return root.icon.name;
261 }
else if (root.icon.source) {
262 return root.icon.source;
266 case Kirigami.MessageType.Positive:
267 return
"emblem-success";
268 case Kirigami.MessageType.Warning:
269 return
"emblem-warning";
270 case Kirigami.MessageType.Error:
271 return
"emblem-error";
273 return
"emblem-information";
277 color: root.icon.color
280 Kirigami.SelectableLabel {
285 leftMargin: Kirigami.Units.largeSpacing
286 right: root.showCloseButton ? closeButton.left : parent.right
287 rightMargin: root.showCloseButton ? Kirigami.Units.smallSpacing : 0
291 color: Kirigami.Theme.textColor
292 wrapMode: Text.WordWrap
296 verticalAlignment: Text.AlignVCenter
304 when: contentLayout.multiline
307 anchors.bottom: undefined
311 height:
label.implicitHeight
321 anchors.bottom:
label.parent.bottom
326 onLinkHovered:
link => root.linkHovered(link)
327 onLinkActivated:
link => root.linkActivated(link)
330 Kirigami.ActionToolBar {
334 actions: root.actions
335 visible: root.actions.length > 0
336 alignment:
Qt.AlignRight
340 top: contentLayout.atBottom ?
label.bottom : parent.top
341 topMargin: contentLayout.atBottom ? Kirigami.Units.largeSpacing : 0
342 right: (!contentLayout.atBottom && root.showCloseButton) ? closeButton.left : parent.
right
343 rightMargin: !contentLayout.atBottom && root.showCloseButton ? Kirigami.
Units.smallSpacing : 0
350 visible: root.showCloseButton
359 when: contentLayout.atBottom
362 anchors.top: parent.top
363 anchors.verticalCenter: undefined
370 anchors.top: undefined
371 anchors.verticalCenter: parent.verticalCenter
376 height: contentLayout.atBottom ? implicitHeight : implicitHeight
378 icon.
name:
"dialog-close"
380 onClicked: root.visible = false
383 Component.onCompleted: complete = true
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)