8import QtQuick.Controls as QQC2
9import QtQuick.Templates as T
12import org.kde.kirigami as Kirigami
14import "private" as Private
55 property real maximumWidth:
Kirigami.Units.gridUnit * 30
62 property real padding: 0
63 property real verticalPadding: padding
64 property real horizontalPadding: padding
65 property real topPadding: verticalPadding
66 property real bottomPadding: verticalPadding
67 property real leftPadding: horizontalPadding
68 property real rightPadding: horizontalPadding
73 readonly
property bool cardWidthRestricted: root.width > root.maximumWidth
102 property list<QtObject> infoCards
104 component InfoCard: QtObject {
105 property bool visible:
true
106 property string title
107 property string subtitle
108 property string buttonIcon
109 property string tooltipText
110 property int subtitleTextFormat: Text.AutoText
117 Layout.fillWidth:
true
119 implicitHeight: topPadding + bottomPadding + grid.implicitHeight
124 function getDarkness(background: color): real {
127 var temp =
Qt.darker(background, 1);
128 var a = 1 - ( 0.299 * temp.r + 0.587 * temp.g + 0.114 * temp.b);
132 readonly
property bool isDarkColor: {
133 const temp =
Qt.darker(
Kirigami.Theme.backgroundColor, 1);
134 return temp.a > 0 && getDarkness(
Kirigami.Theme.backgroundColor) >= 0.4;
139 bottom: parent.bottom
143 leftMargin: root.cardWidthRestricted ? Math.round((root.width - root.maximumWidth) / 2) : 0
144 rightMargin: root.cardWidthRestricted ? Math.round((root.width - root.maximumWidth) / 2) : 0
150 readonly
property int cellWidth:
Kirigami.Units.gridUnit * 10
151 readonly
property int visibleChildrenCount: visibleChildren.length - 1
155 leftMargin: root.leftPadding
156 rightMargin: root.rightPadding
157 topMargin: root.topPadding
158 bottomMargin: root.bottomPadding
161 columns: root.cardWidthRestricted && grid.visibleChildrenCount % 3 === 0 ? 3 : 2
162 columnSpacing:
Kirigami.Units.smallSpacing
163 rowSpacing:
Kirigami.Units.smallSpacing
168 model: root.infoCards
170 QQC2.AbstractButton {
173 required
property int index
174 required
property QtObject modelData
176 readonly
property string title: modelData.title
177 readonly
property string subtitle: modelData.subtitle
178 readonly
property string buttonIcon: modelData.buttonIcon
179 readonly
property string tooltipText: modelData.tooltipText
180 readonly
property int subtitleTextFormat: modelData.subtitleTextFormat
182 visible: modelData.visible
184 action: modelData.action
186 leftPadding:
Kirigami.Units.largeSpacing
187 rightPadding:
Kirigami.Units.largeSpacing
188 topPadding:
Kirigami.Units.largeSpacing
189 bottomPadding:
Kirigami.Units.largeSpacing
191 leftInset: root.cardWidthRestricted ? 0 : -infoCardDelegate.background.border.width
192 rightInset: root.cardWidthRestricted ? 0 : -infoCardDelegate.background.border.width
196 Accessible.name: title +
" " + subtitle
197 Accessible.role: action ? Accessible.Button : Accessible.Note
199 Layout.preferredWidth: grid.cellWidth
200 Layout.columnSpan: grid.visibleChildrenCount % grid.columns !== 0 && index === grid.visibleChildrenCount - 1 ? 2 : 1
201 Layout.fillWidth:
true
202 Layout.fillHeight:
true
204 QQC2.ToolTip.text: tooltipText
205 QQC2.ToolTip.visible: tooltipText && hovered
206 QQC2.ToolTip.delay:
Kirigami.Units.toolTipDelay
208 background:
Kirigami.ShadowedRectangle {
209 radius: root.cardWidthRestricted ?
Kirigami.Units.cornerRadius : 0
210 color:
Kirigami.Theme.backgroundColor
213 color: _private.isDarkColor ?
Qt.darker(
Kirigami.Theme.backgroundColor, 1.2) :
Kirigami.ColorUtils.linearInterpolation(
Kirigami.Theme.backgroundColor,
Kirigami.Theme.textColor, 0.15)
218 size: _private.isDarkColor ?
Kirigami.Units.smallSpacing :
Kirigami.Units.largeSpacing
219 color:
Qt.alpha(
Kirigami.Theme.textColor, 0.10)
224 radius: root.cardWidthRestricted ?
Kirigami.Units.cornerRadius : 0
229 if (!infoCardDelegate.enabled || !infoCardDelegate.action) {
231 }
else if (infoCardDelegate.pressed) {
233 }
else if (infoCardDelegate.visualFocus) {
235 }
else if (!
Kirigami.Settings.tabletMode && infoCardDelegate.hovered) {
243 ColorAnimation { duration:
Kirigami.Units.shortDuration }
248 contentItem: RowLayout {
252 source: infoCardDelegate.buttonIcon
254 Layout.alignment:
Qt.AlignTop
262 Layout.fillWidth:
true
264 text: infoCardDelegate.title
265 verticalAlignment:
Text.AlignVCenter
266 horizontalAlignment: icon.visible ?
Text.AlignLeft :
Text.AlignHCenter
268 elide:
Text.ElideRight
274 Layout.fillWidth:
true
275 Layout.fillHeight:
true
276 visible: infoCardDelegate.subtitle
277 text: infoCardDelegate.subtitle
278 horizontalAlignment: icon.visible ?
Text.AlignLeft :
Text.AlignHCenter
279 elide:
Text.ElideRight
281 textFormat: infoCardDelegate.subtitleTextFormat
283 verticalAlignment:
Text.AlignTop
284 onLinkActivated: (
link) => modelData.linkActivated(link)
KIOCORE_EXPORT CopyJob * link(const QList< QUrl > &src, const QUrl &destDir, JobFlags flags=DefaultFlags)
QStringView level(QStringView ifopt)
QTextStream & left(QTextStream &stream)
QTextStream & right(QTextStream &stream)