Warning, /plasma/discover/discover/qml/CarouselInlineView.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2012 Aleix Pol Gonzalez <aleixpol@blue-systems.com> 0003 * SPDX-FileCopyrightText: 2020 Carl Schwan <carl@carlschwan.eu> 0004 * SPDX-FileCopyrightText: 2023 ivan tkachenko <me@ratijas.tk> 0005 * 0006 * SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 import QtQuick 0010 import QtQuick.Layouts 0011 import QtQuick.Controls as QQC2 0012 import QtQuick.Templates as T 0013 import org.kde.discover as Discover 0014 import org.kde.kirigami as Kirigami 0015 0016 T.Control { 0017 id: root 0018 0019 required property Discover.ScreenshotsModel carouselModel 0020 0021 property real edgeMargin: 0 0022 property alias view: view 0023 0024 property int currentIndex: 0 0025 0026 // TODO: Re-add tracking of failed images, store per-screenshot data in model 0027 property int failedCount: 0 0028 readonly property bool hasFailed: failedCount !== 0 && failedCount === view.count 0029 0030 implicitWidth: 0 0031 implicitHeight: implicitContentHeight 0032 0033 padding: 0 0034 topPadding: undefined 0035 leftPadding: undefined 0036 rightPadding: undefined 0037 bottomPadding: undefined 0038 verticalPadding: undefined 0039 horizontalPadding: undefined 0040 0041 focusPolicy: Qt.StrongFocus 0042 Keys.forwardTo: view 0043 0044 contentItem: ColumnLayout { 0045 spacing: 0 0046 0047 LayoutMirroring.enabled: root.mirrored 0048 LayoutMirroring.childrenInherit: true 0049 0050 ListView { 0051 id: view 0052 0053 Layout.fillWidth: true 0054 Layout.fillHeight: true 0055 0056 keyNavigationEnabled: true 0057 interactive: true 0058 0059 clip: true 0060 pixelAligned: true 0061 orientation: ListView.Horizontal 0062 snapMode: ListView.SnapToItem 0063 highlightRangeMode: ListView.StrictlyEnforceRange 0064 0065 displayMarginBeginning: root.edgeMargin 0066 displayMarginEnd: root.edgeMargin 0067 0068 preferredHighlightBegin: currentItem ? Math.round((width - currentItem.width) / 2) : 0 0069 preferredHighlightEnd: currentItem ? preferredHighlightBegin + currentItem.width : 0 0070 0071 highlightMoveDuration: Kirigami.Units.longDuration 0072 highlightResizeDuration: Kirigami.Units.longDuration 0073 0074 spacing: Kirigami.Units.gridUnit 0075 cacheBuffer: 10000 0076 0077 currentIndex: root.currentIndex 0078 0079 onCurrentIndexChanged: { 0080 root.currentIndex = currentIndex; 0081 } 0082 0083 Component.onCompleted: { 0084 // HACK: Layout polish loop detected for QQuickColumnLayout. Aborting after two iterations. 0085 // 0086 // That error leads to ListView content being initially mis-positioned. 0087 // So, let's fire a callback exactly after two event loop iterations. 0088 Qt.callLater(() => { 0089 Qt.callLater(() => { 0090 model = Qt.binding(() => root.carouselModel); 0091 }); 0092 }); 0093 } 0094 0095 delegate: CarouselDelegate { 0096 onActivated: { 0097 if (root.currentIndex === index) { 0098 controller.open(root.Window.window, root.carouselModel, index); 0099 } else { 0100 root.currentIndex = index; 0101 } 0102 } 0103 } 0104 0105 CarouselNavigationButtonsListViewAdapter { 0106 LayoutMirroring.enabled: root.LayoutMirroring.enabled 0107 0108 Kirigami.Theme.colorSet: Kirigami.Theme.Button 0109 0110 view: view 0111 edgeMargin: root.edgeMargin 0112 } 0113 } 0114 0115 CarouselPageIndicator { 0116 id: pageIndicator 0117 0118 Layout.fillWidth: true 0119 topPadding: Kirigami.Units.largeSpacing * 3 0120 0121 focusPolicy: Qt.NoFocus 0122 interactive: true 0123 count: carouselModel.count 0124 visible: count > 1 0125 0126 function bindCurrentIndex() { 0127 currentIndex = Qt.binding(() => root.currentIndex); 0128 } 0129 0130 onCurrentIndexChanged: { 0131 root.currentIndex = currentIndex; 0132 } 0133 } 0134 } 0135 0136 CarouselMaximizedViewController { 0137 id: controller 0138 0139 onCurrentIndexChanged: currentIndex => { 0140 // Set current index without animations 0141 const backup = view.highlightMoveDuration; 0142 view.highlightMoveDuration = 0; 0143 0144 root.currentIndex = currentIndex; 0145 0146 view.highlightMoveDuration = backup; 0147 } 0148 } 0149 }