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
142 property int subtitleMaximumLineCount: -1
150 property alias subtitleColor: listItemSubtitle.color
159 property bool allowStyledText: false
167 property alias defaultActionButtonAction: defaultActionButton.action
176 property bool defaultActionButtonVisible: true
186 property bool showDefaultActionButtonWhenBusy: false
217 property list<T.Action> contextualActions
219 readonly
property list<T.Action> __enabledContextualActions: contextualActions.
filter(action => action?.enabled ??
false)
232 property Component customExpandedViewContent
238 property alias customExpandedViewContentItem: customContentLoader.item
247 property bool isBusy:
false
258 property bool isDefault:
false
266 readonly
property alias expanded: expandedView.expanded
274 readonly
property bool hasExpandableContent: customExpandedViewContent !== null || __enabledContextualActions.
length > 0
281 if (!listItem.hasExpandableContent) {
284 expandedView.expanded =
true
285 listItem.itemExpanded()
292 function collapse() {
293 if (!listItem.hasExpandableContent) {
296 expandedView.expanded =
false
297 listItem.itemCollapsed()
304 function toggleExpanded() {
305 if (!listItem.hasExpandableContent) {
308 expandedView.expanded ? listItem.collapse() : listItem.expand()
311 signal itemExpanded()
312 signal itemCollapsed()
314 width: parent ? parent.width : undefined
315 height: mainLayout.height
318 enabled: listItem.ListView.view.highlightResizeDuration > 0
321 duration: listItem.ListView.view.highlightResizeDuration || -1
322 velocity: listItem.ListView.view.highlightResizeVelocity
323 easing.type: Easing.InOutCubic
326 clip: heightAnimation.running || expandedItemOpacityFade.running
328 onEnabledChanged:
if (!listItem.enabled) { collapse() }
330 Keys.onPressed: event => {
331 if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
332 if (defaultActionButtonAction) {
333 defaultActionButtonAction.trigger()
337 event.accepted = true;
338 }
else if (
event.key ===
Qt.Key_Escape) {
339 if (expandedView.expanded) {
341 event.accepted = true;
344 }
else if (
event.key ===
Qt.Key_Space) {
346 event.accepted = true;
350 KeyNavigation.tab: defaultActionButtonVisible ? defaultActionButton : expandToggleButton
351 KeyNavigation.right: defaultActionButtonVisible ? defaultActionButton : expandToggleButton
352 KeyNavigation.down: expandToggleButton.KeyNavigation.down
353 Keys.onDownPressed:
event => {
354 if (!actionsListLoader.item || ListView.view.currentIndex < 0) {
355 ListView.view.incrementCurrentIndex();
356 const item = ListView.view.currentItem;
358 item.forceActiveFocus(
Qt.TabFocusReason);
360 event.accepted =
true;
363 event.accepted =
false;
365 Keys.onUpPressed:
event => {
366 if (ListView.view.currentIndex === 0) {
367 event.accepted =
false;
369 ListView.view.decrementCurrentIndex();
370 const item = ListView.view.currentItem;
372 item.forceActiveFocus(
Qt.BacktabFocusReason);
374 event.accepted =
true;
378 Accessible.role: Accessible.Button
379 Accessible.name: title
380 Accessible.description: subtitle
385 enabled: listItem.hasExpandableContent
387 acceptedPointerTypes: PointerDevice.Generic | PointerDevice.Finger
390 listItem.ListView.view.currentIndex = index
391 listItem.toggleExpanded()
400 acceptedButtons:
Qt.NoButton
409 if (parent.y - listItem.ListView.view.contentY >= 0 && parent.y - listItem.ListView.view.contentY + parent.height + 1 < listItem.ListView.view.height) {
410 listItem.ListView.view.currentIndex = (containsMouse ? index : -1)
413 onExited:
if (listItem.ListView.view.currentIndex === index) {
414 listItem.ListView.view.currentIndex = -1;
420 anchors.top: parent.top
421 anchors.left: parent.left
422 anchors.right: parent.right
429 Layout.fillWidth:
true
430 Layout.margins:
Kirigami.Units.smallSpacing
432 Layout.minimumHeight: defaultActionButton.height
438 implicitWidth:
Kirigami.Units.iconSizes.medium
439 implicitHeight:
Kirigami.Units.iconSizes.medium
446 anchors.right: parent.right
447 anchors.bottom: parent.bottom
449 implicitWidth:
Kirigami.Units.iconSizes.small
450 implicitHeight:
Kirigami.Units.iconSizes.small
456 Layout.fillWidth:
true
457 Layout.alignment:
Qt.AlignVCenter
464 visible: text.length > 0
466 Layout.fillWidth:
true
470 textFormat: listItem.allowStyledText ? Text.StyledText : Text.PlainText
471 elide: Text.ElideRight
477 font.weight: listItem.isDefault && listItem.ListView.view.
count > 1
482 PlasmaComponents3.Label {
485 visible: text.length > 0
489 opacity: color ===
Kirigami.Theme.textColor ? 0.7 : 1.0
491 Layout.fillWidth:
true
493 textFormat: listItem.allowStyledText ? Text.StyledText : Text.PlainText
494 elide: Text.ElideRight
495 maximumLineCount: subtitleCanWrap ? (subtitleMaximumLineCount === -1 ? undefined : subtitleMaximumLineCount) : 1
496 wrapMode: subtitleCanWrap ? Text.WordWrap : Text.NoWrap
504 visible: listItem.isBusy
507 Layout.maximumHeight: defaultActionButton.implicitHeight
508 Layout.maximumWidth: Layout.maximumHeight
513 id: defaultActionButton
515 visible: defaultActionButtonAction
516 && listItem.defaultActionButtonVisible
517 && (!busyIndicator.visible || listItem.showDefaultActionButtonWhenBusy)
519 KeyNavigation.tab: expandToggleButton
520 KeyNavigation.
right: expandToggleButton
521 KeyNavigation.down: expandToggleButton.KeyNavigation.down
522 Keys.onUpPressed:
event => listItem.Keys.upPressed(
event)
524 Accessible.
name: action !== null ? action.text :
""
529 id: expandToggleButton
530 visible: listItem.hasExpandableContent
533 text: expandedView.expanded ?
i18ndc(
"libplasma6",
"@action:button",
"Collapse") :
i18ndc(
"libplasma6",
"@action:button",
"Expand")
534 icon.
name: expandedView.expanded ?
"collapse" :
"expand"
536 Keys.onUpPressed:
event => listItem.Keys.upPressed(
event)
538 onClicked: listItem.toggleExpanded()
550 property bool expanded: false
552 Layout.preferredHeight: expanded ?
553 expandedViewLayout.implicitHeight + expandedViewLayout.anchors.topMargin + expandedViewLayout.anchors.bottomMargin : 0
554 Layout.fillWidth: true
556 opacity: expanded ? 1 : 0
557 Behavior on opacity {
558 enabled: listItem.ListView.view.highlightResizeDuration > 0
560 id: expandedItemOpacityFade
561 duration: listItem.ListView.view.highlightResizeDuration || -1
563 velocity: listItem.ListView.view.highlightResizeVelocity / 200
564 easing.
type: Easing.InOutCubic
570 id: expandedViewLayout
578 id: actionsListLoader
580 visible:
status === Loader.Ready
581 active: expandedView.visible && listItem.__enabledContextualActions.length > 0
583 Layout.fillWidth: true
585 sourceComponent:
Item {
586 height: childrenRect.height
587 width: actionsListLoader.width
590 anchors.top: parent.top
601 model: listItem.__enabledContextualActions
604 required property int index
605 required property T.
Action modelData
607 Layout.fillWidth: true
612 KeyNavigation.
up: index > 0 ? actionRepeater.itemAt(index - 1) : expandToggleButton
613 Keys.onDownPressed:
event => {
614 if (index === actionRepeater.count - 1) {
615 event.accepted = true;
616 listItem.ListView.view.incrementCurrentIndex();
617 listItem.ListView.view.currentItem.forceActiveFocus(Qt.TabFocusReason);
619 event.accepted = false;
635 Layout.fillWidth:
true
636 imagePath:
"widgets/line"
637 elementId:
"horizontal-line"
638 visible: actionsListLoader.visible && customContentLoader.visible
643 id: customContentLoader
644 visible:
status === Loader.Ready
646 Layout.fillWidth:
true
648 active: expandedView.visible
650 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)
QString name(StandardAction id)
const QList< QKeySequence > & up()
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)