9import QtQuick.Controls as QQC2
10import QtQuick.Templates as T2
11import org.kde.kirigami 2 as Kirigami
26 property string toolTip
32 property string subtitle
38 property alias thumbnail: thumbnailArea.data
46 property bool thumbnailAvailable: false
53 property list<Kirigami.Action> actions
57 hoverEnabled: !
Kirigami.Settings.isMobile
59 Accessible.description: {
60 if (delegate.toolTip.length === 0) {
62 }
else if (delegate.subtitle.length === 0) {
65 return `${subtitle}; ${toolTip}`
68 Keys.onEnterPressed: thumbnail.trigger()
69 Keys.onMenuPressed: thumbnail.trigger()
70 Keys.onSpacePressed: thumbnail.trigger()
76 verticalCenterOffset: Math.ceil(-labelLayout.height / 2)
78 width:
Kirigami.Settings.isMobile ? delegate.width -
Kirigami.Units.gridUnit : Math.min(delegate.GridView.view.implicitCellWidth, delegate.width -
Kirigami.Units.gridUnit)
79 height:
Kirigami.Settings.isMobile ? Math.round((delegate.width -
Kirigami.Units.gridUnit) / 1.6)
80 : Math.min(delegate.GridView.view.implicitCellHeight -
Kirigami.Units.gridUnit * 3,
81 delegate.height -
Kirigami.Units.gridUnit)
89 shadow.color:
Qt.rgba(0, 0, 0, 0.3)
92 if (delegate.GridView.isCurrentItem) {
93 if (delegate.enabled && delegate.GridView.view.neutralHighlight) {
94 return Kirigami.Theme.neutralTextColor;
96 return Kirigami.Theme.highlightColor;
98 if (delegate.enabled && delegate.hovered) {
100 return Qt.alpha(
Kirigami.Theme.highlightColor, 0.5);
102 return Kirigami.Theme.backgroundColor;
107 property QQC2.Menu menu: null
114 const component =
Qt.createComponent(
"private/GridDelegateMenu.qml");
115 menu = component.createObject(delegate);
123 radius:
Kirigami.Units.smallSpacing / 2
126 margins:
Kirigami.Units.smallSpacing
129 color:
Kirigami.Theme.backgroundColor
133 visible: !delegate.thumbnailAvailable
134 anchors.centerIn: parent
135 width:
Kirigami.Units.iconSizes.large
136 height:
Kirigami.Units.iconSizes.large
137 source: typeof pluginName ===
"string" && pluginName ===
"None" ?
"edit-none" :
"view-preview"
143 rightMargin:
Kirigami.Units.smallSpacing
144 bottom: parent.bottom
145 bottomMargin:
Kirigami.Units.smallSpacing
147 spacing:
Kirigami.Units.smallSpacing
152 visible: delegate.actions.length > 0 && (
Kirigami.Settings.isMobile || delegate.hovered || delegate.GridView.isCurrentItem)
155 model: delegate.actions
156 delegate: QQC2.Button {
157 required
property Kirigami.Action modelData
159 icon.name: modelData.icon.name
160 text: modelData.text || modelData.tooltip
161 display: QQC2.AbstractButton.IconOnly
163 enabled: modelData.enabled
164 visible: modelData.visible
166 activeFocusOnTab:
false
168 onClicked: modelData.trigger()
170 QQC2.ToolTip.text: text
171 QQC2.ToolTip.visible: (
Kirigami.Settings.tabletMode ? pressed : hovered) && (text !==
"")
172 QQC2.ToolTip.delay:
Kirigami.Settings.tabletMode ?
Qt.styleHints.mousePressAndHoldInterval :
Kirigami.Units.toolTipDelay
186 right: thumbnail.right
187 top: thumbnail.bottom
188 topMargin:
Kirigami.Units.largeSpacing
194 Layout.fillWidth:
true
195 horizontalAlignment: Text.AlignHCenter
196 verticalAlignment: Text.AlignTop
198 color: enabled ?
Kirigami.Theme.textColor :
Kirigami.Theme.disabledTextColor
199 elide: Text.ElideRight
200 font.bold: delegate.GridView.isCurrentItem
201 textFormat: Text.PlainText
206 Layout.fillWidth:
true
207 horizontalAlignment: Text.AlignHCenter
208 visible: delegate.subtitle.length > 0
210 text: delegate.subtitle
211 font.pointSize:
Kirigami.Theme.smallFont.pointSize
212 font.bold: delegate.GridView.isCurrentItem
213 elide: Text.ElideRight
214 textFormat: Text.PlainText
218 Layout.preferredHeight: 1
219 Layout.preferredWidth: Math.max(title.paintedWidth, caption.paintedWidth)
220 Layout.maximumWidth: labelLayout.width
221 Layout.alignment:
Qt.AlignHCenter
223 color:
Kirigami.Theme.highlightColor
225 opacity: delegate.visualFocus ? 1 : 0
228 Item { Layout.fillWidth:
true; Layout.fillHeight:
true; }
231 QQC2.ToolTip.delay: 1000
232 QQC2.ToolTip.timeout: 5000
233 QQC2.ToolTip.
visible: hovered && (delegate.toolTip.length > 0 || title.truncated || caption.truncated)
235 if (delegate.toolTip.length > 0) {
236 return delegate.toolTip;
239 if (title.truncated) {
240 parts.push(title.text);
242 if (caption.truncated) {
243 parts.push(caption.text);
245 return parts.join(
"\n");
A ScrollView containing a GridView, with the default behavior about sizing and background as recommen...
alias view
view: GridView Exposes the internal GridView: in order to set a model or a delegate to it,...
QTextStream & left(QTextStream &stream)
QTextStream & right(QTextStream &stream)