7pragma ComponentBehavior: Bound
11import QtQuick.Controls as QQC2
12import QtQuick.Templates as T
13import org.kde.kirigami as Kirigami
14import "private" as Private
29 property string toolTip
35 property string subtitle
41 property alias thumbnail: thumbnailArea.data
49 property bool thumbnailAvailable:
false
56 property list<
Kirigami.Action> actions
60 hoverEnabled: !
Kirigami.Settings.isMobile
62 Accessible.description: {
63 if (toolTip.length === 0) {
65 }
else if (subtitle.length === 0) {
68 return `${subtitle}; ${toolTip}`
71 Keys.onEnterPressed:
event => thumbnail.trigger()
72 Keys.onMenuPressed:
event => thumbnail.trigger()
73 Keys.onSpacePressed:
event => thumbnail.trigger()
79 verticalCenterOffset: Math.ceil(-labelLayout.height / 2)
81 width:
Kirigami.Settings.isMobile ? delegate.width -
Kirigami.Units.gridUnit : Math.min(delegate.GridView.view.implicitCellWidth, delegate.width -
Kirigami.Units.gridUnit)
82 height:
Kirigami.Settings.isMobile ? Math.round((delegate.width -
Kirigami.Units.gridUnit) / 1.6)
83 : Math.min(delegate.GridView.view.implicitCellHeight -
Kirigami.Units.gridUnit * 3,
84 delegate.height -
Kirigami.Units.gridUnit)
92 shadow.color:
Qt.rgba(0, 0, 0, 0.3)
95 if (delegate.GridView.isCurrentItem) {
96 if (delegate.enabled && delegate.GridView.view.neutralHighlight) {
97 return Kirigami.Theme.neutralTextColor;
99 return Kirigami.Theme.highlightColor;
101 if (delegate.enabled && delegate.hovered) {
103 return Qt.alpha(
Kirigami.Theme.highlightColor, 0.5);
105 return Kirigami.Theme.backgroundColor;
110 property Private.GridDelegateMenu menu
114 const component =
Qt.createComponent(
"private/GridDelegateMenu.qml");
115 menu = component.createObject(delegate);
125 radius: Math.round(
Kirigami.Units.cornerRadius / 2)
128 margins:
Kirigami.Units.smallSpacing
131 color:
Kirigami.Theme.backgroundColor
135 visible: !delegate.thumbnailAvailable
136 anchors.centerIn: parent
137 width:
Kirigami.Units.iconSizes.large
138 height:
Kirigami.Units.iconSizes.large
139 source: typeof pluginName ===
"string" && pluginName ===
"None" ?
"edit-none" :
"view-preview"
145 rightMargin:
Kirigami.Units.smallSpacing
146 bottom: parent.bottom
147 bottomMargin:
Kirigami.Units.smallSpacing
149 spacing:
Kirigami.Units.smallSpacing
154 visible: delegate.actions.length > 0 && (
Kirigami.Settings.isMobile || delegate.hovered || delegate.GridView.isCurrentItem)
157 model: delegate.actions
158 delegate: QQC2.Button {
159 required
property Kirigami.Action modelData
161 icon.name: modelData.icon.name
162 text: modelData.text || modelData.tooltip
163 display: QQC2.AbstractButton.IconOnly
165 enabled: modelData.enabled
166 visible: modelData.visible
168 activeFocusOnTab:
false
170 onClicked: modelData.trigger()
172 QQC2.ToolTip.visible: (
Kirigami.Settings.tabletMode ? pressed : hovered) && (QQC2.ToolTip.text !==
"")
173 QQC2.ToolTip.delay:
Kirigami.Settings.tabletMode ?
Qt.styleHints.mousePressAndHoldInterval :
Kirigami.Units.toolTipDelay
174 QQC2.ToolTip.text: text
188 right: thumbnail.right
189 top: thumbnail.bottom
190 topMargin:
Kirigami.Units.largeSpacing
196 Layout.fillWidth:
true
197 horizontalAlignment:
Text.AlignHCenter
198 verticalAlignment:
Text.AlignTop
200 color: enabled ?
Kirigami.Theme.textColor :
Kirigami.Theme.disabledTextColor
202 elide:
Text.ElideRight
203 font.bold: delegate.GridView.isCurrentItem
204 textFormat:
Text.PlainText
209 Layout.fillWidth:
true
210 horizontalAlignment:
Text.AlignHCenter
211 visible: delegate.subtitle.length > 0
213 text: delegate.subtitle
214 font.pointSize:
Kirigami.Theme.smallFont.pointSize
215 font.bold: delegate.GridView.isCurrentItem
217 elide:
Text.ElideRight
218 textFormat:
Text.PlainText
222 Layout.preferredHeight: 1
223 Layout.preferredWidth: Math.max(title.paintedWidth, caption.paintedWidth)
224 Layout.maximumWidth: labelLayout.width
225 Layout.alignment:
Qt.AlignHCenter
227 color:
Kirigami.Theme.highlightColor
229 opacity: delegate.visualFocus ? 1 : 0
232 Item { Layout.fillWidth:
true; Layout.fillHeight:
true; }
235 QQC2.ToolTip.visible: (
Kirigami.Settings.tabletMode ? pressed : hovered) && (QQC2.ToolTip.text !==
"")
236 QQC2.ToolTip.delay:
Kirigami.Settings.tabletMode ?
Qt.styleHints.mousePressAndHoldInterval :
Kirigami.Units.toolTipDelay
239 if (delegate.toolTip.length > 0) {
240 parts.push(delegate.toolTip);
242 if (title.truncated) {
243 parts.push(title.text);
245 if (caption.truncated) {
246 parts.push(caption.text);
248 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)