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
229 anchors.left: parent.left
232 if (root.icon.name) {
233 return root.icon.name;
234 }
else if (root.icon.source) {
239 case Kirigami.MessageType.Positive:
240 return "emblem-positive";
241 case Kirigami.MessageType.Warning:
242 return "emblem-warning";
243 case Kirigami.MessageType.Error:
244 return "emblem-error";
246 return "emblem-information";
250 color: root.icon.color
254 when: contentLayout.atBottom
257 anchors.top: contentLayout.top
266 anchors.verticalCenter: contentLayout.verticalCenter
272 Kirigami.SelectableLabel {
277 leftMargin: Kirigami.Units.smallSpacing
278 right: root.showCloseButton ? closeButton.left : parent.right
279 rightMargin: root.showCloseButton ? Kirigami.Units.smallSpacing : 0
283 color: Kirigami.Theme.textColor
284 wrapMode: Text.WordWrap
288 verticalAlignment: Text.AlignVCenter
296 when: contentLayout.multiline
299 anchors.bottom: undefined
303 height:
label.implicitHeight
313 anchors.bottom:
label.parent.bottom
318 onLinkHovered:
link => root.linkHovered(link)
319 onLinkActivated:
link => root.linkActivated(link)
322 Kirigami.ActionToolBar {
326 actions: root.actions
327 visible: root.actions.length > 0
328 alignment:
Qt.AlignRight
332 top: contentLayout.atBottom ?
label.bottom : parent.top
333 topMargin: contentLayout.atBottom ? Kirigami.Units.largeSpacing : 0
334 right: (!contentLayout.atBottom && root.showCloseButton) ? closeButton.left : parent.
right
335 rightMargin: !contentLayout.atBottom && root.showCloseButton ? Kirigami.
Units.smallSpacing : 0
342 visible: root.showCloseButton
351 when: contentLayout.atBottom
354 anchors.top: parent.top
355 anchors.verticalCenter: undefined
362 anchors.top: undefined
363 anchors.verticalCenter: parent.verticalCenter
368 height: contentLayout.atBottom ? implicitHeight : implicitHeight
370 icon.
name:
"dialog-close"
372 onClicked: root.visible = false
375 Component.onCompleted: complete = true
Class for rendering an icon in UI.
QML_ELEMENTQVariant source
The source of this icon.
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)