Kirigami2

styles/Material/InlineMessage.qml
1 /*
2  * SPDX-FileCopyrightText: 2018 Eike Hein <[email protected]>
3  * SPDX-FileCopyrightText: 2018 Marco Martin <[email protected]>
4  * SPDX-FileCopyrightText: 2018 Kai Uwe Broulik <[email protected]>
5  *
6  * SPDX-License-Identifier: LGPL-2.0-or-later
7  */
8 
9 import QtQuick 2.7
10 import QtGraphicalEffects 1.0 as GE
11 import org.kde.kirigami 2.5 as Kirigami
12 import "../../templates" as T
13 
14 /**
15  * An inline message item with support for informational, positive,
16  * warning and error types, and with support for associated actions.
17  *
18  * InlineMessage can be used to give information to the user or
19  * interact with the user, without requiring the use of a dialog.
20  *
21  * The InlineMessage item is hidden by default. It also manages its
22  * height (and implicitHeight) during an animated reveal when shown.
23  * You should avoid setting height on an InlineMessage unless it is
24  * already visible.
25  *
26  * Optionally an icon can be set, defaulting to an icon appropriate
27  * to the message type otherwise.
28  *
29  * Optionally a close button can be shown.
30  *
31  * Actions are added from left to right. If more actions are set than
32  * can fit, an overflow menu is provided.
33  *
34  * Example:
35  * @code
36  * InlineMessage {
37  * type: Kirigami.MessageType.Error
38  *
39  * text: "My error message"
40  *
41  * actions: [
42  * Kirigami.Action {
43  * icon.name: "edit"
44  * text: "Action text"
45  * onTriggered: {
46  * // do stuff
47  * }
48  * },
49  * Kirigami.Action {
50  * icon.name: "edit"
51  * text: "Action text"
52  * onTriggered: {
53  * // do stuff
54  * }
55  * }
56  * ]
57  * }
58  * @endcode
59  *
60  * @since 5.45
61  */
62 
63 T.InlineMessage {
64  id: root
65 
66  background: Rectangle {
67  id: bgBorderRect
68 
69  color: {
70  if (root.type == Kirigami.MessageType.Positive) {
71  return Kirigami.Theme.positiveTextColor;
72  } else if (root.type == Kirigami.MessageType.Warning) {
73  return Kirigami.Theme.neutralTextColor;
74  } else if (root.type == Kirigami.MessageType.Error) {
75  return Kirigami.Theme.negativeTextColor;
76  }
77 
78  return Kirigami.Theme.activeTextColor;
79  }
80 
81  radius: Kirigami.Units.smallSpacing / 2
82 
83  Rectangle {
84  id: bgFillRect
85 
86  anchors.fill: parent
87  anchors.margins: 1
88 
89  color: Kirigami.Theme.backgroundColor
90 
91  radius: bgBorderRect.radius * 0.60
92  }
93 
94  Rectangle {
95  anchors.fill: bgFillRect
96 
97  color: bgBorderRect.color
98 
99  opacity: 0.20
100 
101  radius: bgFillRect.radius
102  }
103 
104  layer.enabled: true
105  layer.effect: GE.DropShadow {
106  horizontalOffset: 0
107  verticalOffset: 1
108  radius: 12
109  samples: 32
110  color: Qt.rgba(0, 0, 0, 0.5)
111  }
112  }
113 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sun Jan 29 2023 04:11:03 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.