7pragma ComponentBehavior: Bound
11import QtQuick.Templates as T
12import org.kde.plasma.core as PlasmaCore
13import org.kde.ksvg as KSvg
14import org.kde.plasma.components as PlasmaComponents3
15import org.kde.plasma.extras as PlasmaExtras
16import org.kde.kirigami as Kirigami
97 property alias icon: listItemIcon.source
106 property alias iconEmblem: iconEmblem.source
115 property alias title: listItemTitle.text
124 property alias subtitle: listItemSubtitle.text
133 property bool subtitleCanWrap: false
141 property alias subtitleColor: listItemSubtitle.color
150 property bool allowStyledText: false
158 property alias defaultActionButtonAction: defaultActionButton.action
167 property bool defaultActionButtonVisible: true
177 property bool showDefaultActionButtonWhenBusy: false
208 property list<T.Action> contextualActions
210 readonly
property list<T.Action> __enabledContextualActions: contextualActions.
filter(action => action?.enabled ??
false)
223 property Component customExpandedViewContent
229 property alias customExpandedViewContentItem: customContentLoader.item
238 property bool isBusy:
false
249 property bool isDefault:
false
257 readonly
property alias expanded: expandedView.expanded
265 readonly
property bool hasExpandableContent: customExpandedViewContent !== null || __enabledContextualActions.
length > 0
272 if (!listItem.hasExpandableContent) {
275 expandedView.expanded =
true
276 listItem.itemExpanded()
283 function collapse() {
284 if (!listItem.hasExpandableContent) {
287 expandedView.expanded =
false
288 listItem.itemCollapsed()
295 function toggleExpanded() {
296 if (!listItem.hasExpandableContent) {
299 expandedView.expanded ? listItem.collapse() : listItem.expand()
302 signal itemExpanded()
303 signal itemCollapsed()
305 width: parent ? parent.width : undefined
306 height: mainLayout.height
309 enabled: listItem.ListView.view.highlightResizeDuration > 0
312 duration: listItem.ListView.view.highlightResizeDuration || -1
313 velocity: listItem.ListView.view.highlightResizeVelocity
314 easing.type: Easing.InOutCubic
317 clip: heightAnimation.running || expandedItemOpacityFade.running
319 onEnabledChanged:
if (!listItem.enabled) { collapse() }
321 Keys.onPressed:
event => {
323 if (defaultActionButtonAction) {
324 defaultActionButtonAction.trigger()
328 event.accepted =
true;
329 }
else if (
event.key ===
Qt.Key_Escape) {
330 if (expandedView.expanded) {
332 event.accepted =
true;
335 }
else if (
event.key ===
Qt.Key_Space) {
337 event.accepted =
true;
341 KeyNavigation.tab: defaultActionButtonVisible ? defaultActionButton : expandToggleButton
342 KeyNavigation.right: defaultActionButtonVisible ? defaultActionButton : expandToggleButton
343 KeyNavigation.down: expandToggleButton.KeyNavigation.down
344 Keys.onDownPressed:
event => {
345 if (!actionsListLoader.item || ListView.view.currentIndex < 0) {
346 ListView.view.incrementCurrentIndex();
347 ListView.view.currentItem.forceActiveFocus(
Qt.TabFocusReason);
348 event.accepted =
true;
351 event.accepted =
false;
353 Keys.onUpPressed:
event => {
354 if (ListView.view.currentIndex === 0) {
355 event.accepted =
false;
357 ListView.view.decrementCurrentIndex();
358 ListView.view.currentItem.forceActiveFocus(
Qt.BacktabFocusReason);
362 Accessible.role: Accessible.Button
363 Accessible.name: title
364 Accessible.description: subtitle
369 enabled: listItem.hasExpandableContent
371 acceptedPointerTypes: PointerDevice.Generic | PointerDevice.Finger
374 listItem.ListView.view.currentIndex = index
375 listItem.toggleExpanded()
384 acceptedButtons:
Qt.NoButton
393 if (parent.y - listItem.ListView.view.contentY >= 0 && parent.y - listItem.ListView.view.contentY + parent.height + 1 < listItem.ListView.view.height) {
394 listItem.ListView.view.currentIndex = (containsMouse ? index : -1)
397 onExited:
if (listItem.ListView.view.currentIndex === index) {
398 listItem.ListView.view.currentIndex = -1;
404 anchors.top: parent.top
405 anchors.left: parent.left
406 anchors.right: parent.right
413 Layout.fillWidth:
true
414 Layout.margins:
Kirigami.Units.smallSpacing
416 Layout.minimumHeight: defaultActionButton.height
422 implicitWidth:
Kirigami.Units.iconSizes.medium
423 implicitHeight:
Kirigami.Units.iconSizes.medium
430 anchors.right: parent.right
431 anchors.bottom: parent.bottom
433 implicitWidth:
Kirigami.Units.iconSizes.small
434 implicitHeight:
Kirigami.Units.iconSizes.small
440 Layout.fillWidth:
true
441 Layout.alignment:
Qt.AlignVCenter
448 visible: text.length > 0
450 Layout.fillWidth:
true
454 textFormat: listItem.allowStyledText ? Text.StyledText : Text.PlainText
455 elide: Text.ElideRight
461 font.weight: listItem.isDefault && listItem.ListView.view.
count > 1
466 PlasmaComponents3.Label {
469 visible: text.length > 0
473 opacity: color ===
Kirigami.Theme.textColor ? 0.7 : 1.0
475 Layout.fillWidth:
true
477 textFormat: listItem.allowStyledText ? Text.StyledText : Text.PlainText
478 elide: Text.ElideRight
479 maximumLineCount: subtitleCanWrap ? 9999 : 1
480 wrapMode: subtitleCanWrap ? Text.WordWrap : Text.NoWrap
485 PlasmaComponents3.BusyIndicator {
488 visible: listItem.isBusy
491 Layout.maximumHeight: defaultActionButton.implicitHeight
492 Layout.maximumWidth: Layout.maximumHeight
496 PlasmaComponents3.ToolButton {
497 id: defaultActionButton
499 visible: defaultActionButtonAction
500 && listItem.defaultActionButtonVisible
501 && (!busyIndicator.visible || listItem.showDefaultActionButtonWhenBusy)
503 KeyNavigation.tab: expandToggleButton
504 KeyNavigation.
right: expandToggleButton
505 KeyNavigation.down: expandToggleButton.KeyNavigation.down
506 Keys.onUpPressed:
event => listItem.Keys.upPressed(
event)
508 Accessible.
name: action !== null ? action.text :
""
513 id: expandToggleButton
514 visible: listItem.hasExpandableContent
517 text: expandedView.expanded ?
i18ndc(
"libplasma6",
"@action:button",
"Collapse") :
i18ndc(
"libplasma6",
"@action:button",
"Expand")
518 icon.
name: expandedView.expanded ?
"collapse" :
"expand"
520 Keys.onUpPressed:
event => listItem.Keys.upPressed(
event)
522 onClicked: listItem.toggleExpanded()
534 property bool expanded: false
536 Layout.preferredHeight: expanded ?
537 expandedViewLayout.implicitHeight + expandedViewLayout.anchors.topMargin + expandedViewLayout.anchors.bottomMargin : 0
538 Layout.fillWidth: true
540 opacity: expanded ? 1 : 0
541 Behavior on opacity {
542 enabled: listItem.ListView.view.highlightResizeDuration > 0
544 id: expandedItemOpacityFade
545 duration: listItem.ListView.view.highlightResizeDuration || -1
547 velocity: listItem.ListView.view.highlightResizeVelocity / 200
548 easing.
type: Easing.InOutCubic
554 id: expandedViewLayout
562 id: actionsListLoader
564 visible:
status === Loader.Ready
565 active: expandedView.visible && listItem.__enabledContextualActions.length > 0
567 Layout.fillWidth: true
569 sourceComponent:
Item {
570 height: childrenRect.height
571 width: actionsListLoader.width
574 anchors.top: parent.top
585 model: listItem.__enabledContextualActions
588 required property int index
589 required property T.
Action modelData
591 Layout.fillWidth: true
596 KeyNavigation.
up: index > 0 ? actionRepeater.itemAt(index - 1) : expandToggleButton
597 Keys.onDownPressed:
event => {
598 if (index === actionRepeater.count - 1) {
599 event.accepted =
true;
600 listItem.ListView.view.incrementCurrentIndex();
601 listItem.ListView.view.currentItem.forceActiveFocus(
Qt.TabFocusReason);
603 event.accepted =
false;
619 Layout.fillWidth:
true
620 imagePath:
"widgets/line"
621 elementId:
"horizontal-line"
622 visible: actionsListLoader.
visible && customContentLoader.visible
627 id: customContentLoader
628 visible:
status === Loader.Ready
630 Layout.fillWidth:
true
632 active: expandedView.visible
634 sourceComponent: listItem.customExpandedViewContent
Q_SCRIPTABLE CaptureState status()
QString i18ndc(const char *domain, const char *context, const char *text, const TYPE &arg...)
AKONADI_CALENDAR_EXPORT KCalendarCore::Event::Ptr event(const Akonadi::Item &item)
Type type(const QSqlDatabase &db)
QStringView level(QStringView ifopt)
QAction * up(const QObject *recvr, const char *slot, QObject *parent)
QString name(StandardAction id)
qsizetype length() const const
QStringList filter(QStringView str, Qt::CaseSensitivity cs) const const
qsizetype count(QChar ch, Qt::CaseSensitivity cs) const const
QTextStream & left(QTextStream &stream)
QTextStream & right(QTextStream &stream)