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 => {
322 if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
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 const item = ListView.view.currentItem;
349 item.forceActiveFocus(
Qt.TabFocusReason);
351 event.accepted =
true;
354 event.accepted =
false;
356 Keys.onUpPressed:
event => {
357 if (ListView.view.currentIndex === 0) {
358 event.accepted =
false;
360 ListView.view.decrementCurrentIndex();
361 const item = ListView.view.currentItem;
363 item.forceActiveFocus(
Qt.BacktabFocusReason);
365 event.accepted =
true;
369 Accessible.role: Accessible.Button
370 Accessible.name: title
371 Accessible.description: subtitle
376 enabled: listItem.hasExpandableContent
378 acceptedPointerTypes: PointerDevice.Generic | PointerDevice.Finger
381 listItem.ListView.view.currentIndex = index
382 listItem.toggleExpanded()
391 acceptedButtons:
Qt.NoButton
400 if (parent.y - listItem.ListView.view.contentY >= 0 && parent.y - listItem.ListView.view.contentY + parent.height + 1 < listItem.ListView.view.height) {
401 listItem.ListView.view.currentIndex = (containsMouse ? index : -1)
404 onExited:
if (listItem.ListView.view.currentIndex === index) {
405 listItem.ListView.view.currentIndex = -1;
411 anchors.top: parent.top
412 anchors.left: parent.left
413 anchors.right: parent.right
420 Layout.fillWidth:
true
421 Layout.margins:
Kirigami.Units.smallSpacing
423 Layout.minimumHeight: defaultActionButton.height
429 implicitWidth:
Kirigami.Units.iconSizes.medium
430 implicitHeight:
Kirigami.Units.iconSizes.medium
437 anchors.right: parent.right
438 anchors.bottom: parent.bottom
440 implicitWidth:
Kirigami.Units.iconSizes.small
441 implicitHeight:
Kirigami.Units.iconSizes.small
447 Layout.fillWidth:
true
448 Layout.alignment:
Qt.AlignVCenter
455 visible: text.length > 0
457 Layout.fillWidth:
true
461 textFormat: listItem.allowStyledText ? Text.StyledText : Text.PlainText
462 elide: Text.ElideRight
468 font.weight: listItem.isDefault && listItem.ListView.view.
count > 1
473 PlasmaComponents3.Label {
476 visible: text.length > 0
480 opacity: color ===
Kirigami.Theme.textColor ? 0.7 : 1.0
482 Layout.fillWidth:
true
484 textFormat: listItem.allowStyledText ? Text.StyledText : Text.PlainText
485 elide: Text.ElideRight
486 maximumLineCount: subtitleCanWrap ? 9999 : 1
487 wrapMode: subtitleCanWrap ? Text.WordWrap : Text.NoWrap
492 PlasmaComponents3.BusyIndicator {
495 visible: listItem.isBusy
498 Layout.maximumHeight: defaultActionButton.implicitHeight
499 Layout.maximumWidth: Layout.maximumHeight
503 PlasmaComponents3.ToolButton {
504 id: defaultActionButton
506 visible: defaultActionButtonAction
507 && listItem.defaultActionButtonVisible
508 && (!busyIndicator.visible || listItem.showDefaultActionButtonWhenBusy)
510 KeyNavigation.tab: expandToggleButton
511 KeyNavigation.
right: expandToggleButton
512 KeyNavigation.down: expandToggleButton.KeyNavigation.down
513 Keys.onUpPressed:
event => listItem.Keys.upPressed(
event)
515 Accessible.
name: action !== null ? action.text :
""
520 id: expandToggleButton
521 visible: listItem.hasExpandableContent
524 text: expandedView.expanded ?
i18ndc(
"libplasma6",
"@action:button",
"Collapse") :
i18ndc(
"libplasma6",
"@action:button",
"Expand")
525 icon.
name: expandedView.expanded ?
"collapse" :
"expand"
527 Keys.onUpPressed:
event => listItem.Keys.upPressed(
event)
529 onClicked: listItem.toggleExpanded()
541 property bool expanded: false
543 Layout.preferredHeight: expanded ?
544 expandedViewLayout.implicitHeight + expandedViewLayout.anchors.topMargin + expandedViewLayout.anchors.bottomMargin : 0
545 Layout.fillWidth: true
547 opacity: expanded ? 1 : 0
548 Behavior on opacity {
549 enabled: listItem.ListView.view.highlightResizeDuration > 0
551 id: expandedItemOpacityFade
552 duration: listItem.ListView.view.highlightResizeDuration || -1
554 velocity: listItem.ListView.view.highlightResizeVelocity / 200
555 easing.
type: Easing.InOutCubic
561 id: expandedViewLayout
569 id: actionsListLoader
571 visible:
status === Loader.Ready
572 active: expandedView.visible && listItem.__enabledContextualActions.length > 0
574 Layout.fillWidth: true
576 sourceComponent:
Item {
577 height: childrenRect.height
578 width: actionsListLoader.width
581 anchors.top: parent.top
592 model: listItem.__enabledContextualActions
595 required property int index
596 required property T.
Action modelData
598 Layout.fillWidth: true
603 KeyNavigation.
up: index > 0 ? actionRepeater.itemAt(index - 1) : expandToggleButton
604 Keys.onDownPressed:
event => {
605 if (index === actionRepeater.count - 1) {
606 event.accepted = true;
607 listItem.ListView.view.incrementCurrentIndex();
608 listItem.ListView.view.currentItem.forceActiveFocus(Qt.TabFocusReason);
610 event.accepted = false;
626 Layout.fillWidth:
true
627 imagePath:
"widgets/line"
628 elementId:
"horizontal-line"
629 visible: actionsListLoader.visible && customContentLoader.visible
634 id: customContentLoader
635 visible:
status === Loader.Ready
637 Layout.fillWidth:
true
639 active: expandedView.visible
641 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)
QString name(GameStandardAction id)
QStringView level(QStringView ifopt)
VehicleSection::Type type(QStringView coachNumber, QStringView coachClassification)
QAction * up(const QObject *recvr, const char *slot, QObject *parent)
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)