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
201 elide:
Text.ElideRight
202 font.bold: delegate.GridView.isCurrentItem
203 textFormat:
Text.PlainText
208 Layout.fillWidth:
true
209 horizontalAlignment:
Text.AlignHCenter
210 visible: delegate.subtitle.length > 0
212 text: delegate.subtitle
213 font.pointSize:
Kirigami.Theme.smallFont.pointSize
214 font.bold: delegate.GridView.isCurrentItem
215 elide:
Text.ElideRight
216 textFormat:
Text.PlainText
220 Layout.preferredHeight: 1
221 Layout.preferredWidth: Math.max(title.paintedWidth, caption.paintedWidth)
222 Layout.maximumWidth: labelLayout.width
223 Layout.alignment:
Qt.AlignHCenter
225 color:
Kirigami.Theme.highlightColor
227 opacity: delegate.visualFocus ? 1 : 0
230 Item { Layout.fillWidth:
true; Layout.fillHeight:
true; }
233 QQC2.ToolTip.visible: (
Kirigami.Settings.tabletMode ? pressed : hovered) && (QQC2.ToolTip.text !==
"")
234 QQC2.ToolTip.delay:
Kirigami.Settings.tabletMode ?
Qt.styleHints.mousePressAndHoldInterval :
Kirigami.Units.toolTipDelay
237 if (delegate.toolTip.length > 0) {
238 parts.push(delegate.toolTip);
240 if (title.truncated) {
241 parts.push(title.text);
243 if (caption.truncated) {
244 parts.push(caption.text);
246 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)