Changeset View
Changeset View
Standalone View
Standalone View
src/qtquick/qml/private/GridTileDelegate.qml
Show All 17 Lines | |||||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | import QtQuick 2.11 | 20 | import QtQuick 2.11 | ||
21 | import QtQuick.Controls 2.11 as Controls | 21 | import QtQuick.Controls 2.11 as Controls | ||
22 | import QtQuick.Templates 2.11 as T2 | 22 | import QtQuick.Templates 2.11 as T2 | ||
23 | import QtQuick.Layouts 1.11 | 23 | import QtQuick.Layouts 1.11 | ||
24 | import QtGraphicalEffects 1.11 | 24 | import QtGraphicalEffects 1.11 | ||
25 | 25 | | |||
26 | import org.kde.kirigami 2.2 as Kirigami | 26 | import org.kde.kirigami 2.12 as Kirigami | ||
27 | 27 | | |||
28 | /** | 28 | /** | ||
29 | * Base delegate for KControlmodules based on Grid views of thumbnails | 29 | * Base delegate for KControlmodules based on Grid views of thumbnails | ||
30 | * Use the onClicked signal handler for managing the main action when | 30 | * Use the onClicked signal handler for managing the main action when | ||
31 | * the user clicks on the tile, modified from the original GridDelegate | 31 | * the user clicks on the tile, modified from the original GridDelegate | ||
32 | * from the KCM module | 32 | * from the KCM module | ||
33 | * @inherits QtQuick.Templates.ItemDelegate | 33 | * @inherits QtQuick.Templates.ItemDelegate | ||
34 | */ | 34 | */ | ||
Show All 31 Lines | 35 | T2.ItemDelegate { | |||
66 | * The anchors of the actions listing | 66 | * The anchors of the actions listing | ||
67 | */ | 67 | */ | ||
68 | property alias actionsAnchors: actionsScope.anchors | 68 | property alias actionsAnchors: actionsScope.anchors | ||
69 | 69 | | |||
70 | width: GridView.view.cellWidth | 70 | width: GridView.view.cellWidth | ||
71 | height: GridView.view.cellHeight | 71 | height: GridView.view.cellHeight | ||
72 | hoverEnabled: true | 72 | hoverEnabled: true | ||
73 | 73 | | |||
74 | Rectangle { | 74 | Kirigami.ShadowedRectangle { | ||
75 | id: tile | 75 | id: tile | ||
76 | anchors.centerIn: parent | 76 | anchors.centerIn: parent | ||
77 | width: Kirigami.Settings.isMobile ? delegate.width - Kirigami.Units.gridUnit : Math.min(delegate.GridView.view.implicitCellWidth, delegate.width - Kirigami.Units.gridUnit) | 77 | width: Kirigami.Settings.isMobile ? delegate.width - Kirigami.Units.gridUnit : Math.min(delegate.GridView.view.implicitCellWidth, delegate.width - Kirigami.Units.gridUnit) | ||
78 | height: Math.min(delegate.GridView.view.implicitCellHeight, delegate.height - Kirigami.Units.gridUnit) | 78 | height: Math.min(delegate.GridView.view.implicitCellHeight, delegate.height - Kirigami.Units.gridUnit) | ||
79 | radius: Kirigami.Units.smallSpacing | 79 | radius: Kirigami.Units.smallSpacing | ||
80 | Kirigami.Theme.inherit: false | 80 | Kirigami.Theme.inherit: false | ||
81 | Kirigami.Theme.colorSet: Kirigami.Theme.View | 81 | Kirigami.Theme.colorSet: Kirigami.Theme.View | ||
82 | 82 | | |||
83 | shadow.xOffset: 0 | ||||
84 | shadow.yOffset: 2 | ||||
85 | shadow.size: 10 | ||||
86 | shadow.color: Qt.rgba(0, 0, 0, 0.3) | ||||
87 | | ||||
83 | color: { | 88 | color: { | ||
84 | if (delegate.GridView.isCurrentItem) { | 89 | if (delegate.GridView.isCurrentItem) { | ||
85 | return Kirigami.Theme.highlightColor; | 90 | return Kirigami.Theme.highlightColor; | ||
86 | } else if (parent.hovered) { | 91 | } else if (parent.hovered) { | ||
87 | return Kirigami.Theme.highlightColor; | 92 | return Kirigami.Theme.highlightColor; | ||
88 | } else { | 93 | } else { | ||
89 | return Kirigami.Theme.backgroundColor; | 94 | return Kirigami.Theme.backgroundColor; | ||
90 | } | 95 | } | ||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | 148 | ColumnLayout { | |||
144 | id: actionsColumn | 149 | id: actionsColumn | ||
145 | 150 | | |||
146 | Repeater { | 151 | Repeater { | ||
147 | model: delegate.actions | 152 | model: delegate.actions | ||
148 | delegate: Controls.Button { | 153 | delegate: Controls.Button { | ||
149 | icon.name: modelData.iconName | 154 | icon.name: modelData.iconName | ||
150 | text: modelData.text | 155 | text: modelData.text | ||
151 | activeFocusOnTab: focus || delegate.focus | 156 | activeFocusOnTab: focus || delegate.focus | ||
152 | onClicked: { | 157 | onClicked: modelData.trigger() | ||
153 | delegate.clicked() | | |||
154 | modelData.trigger() | | |||
155 | } | | |||
156 | enabled: modelData.enabled | 158 | enabled: modelData.enabled | ||
157 | visible: modelData.visible | 159 | visible: modelData.visible | ||
158 | //NOTE: there aren't any global settings where to take "official" tooltip timeouts | 160 | //NOTE: there aren't any global settings where to take "official" tooltip timeouts | ||
159 | Controls.ToolTip.delay: 1000 | 161 | Controls.ToolTip.delay: 1000 | ||
160 | Controls.ToolTip.timeout: 5000 | 162 | Controls.ToolTip.timeout: 5000 | ||
161 | Controls.ToolTip.visible: (Kirigami.Settings.isMobile ? pressed : hovered) && modelData.tooltip.length > 0 | 163 | Controls.ToolTip.visible: (Kirigami.Settings.isMobile ? pressed : hovered) && modelData.tooltip.length > 0 | ||
162 | Controls.ToolTip.text: modelData.tooltip | 164 | Controls.ToolTip.text: modelData.tooltip | ||
163 | } | 165 | } | ||
164 | } | 166 | } | ||
165 | } | 167 | } | ||
166 | } | 168 | } | ||
167 | } | 169 | } | ||
168 | // Bug 397367: explicitly using "delegate" as otherwise it crashes when switching between KCMs | | |||
169 | layer.enabled: delegate.GraphicsInfo.api === GraphicsInfo.OpenGL | | |||
170 | layer.effect: DropShadow { | | |||
171 | horizontalOffset: 0 | | |||
172 | verticalOffset: 2 | | |||
173 | radius: 10 | | |||
174 | samples: 32 | | |||
175 | color: Qt.rgba(0, 0, 0, 0.3) | | |||
176 | } | | |||
177 | } | 170 | } | ||
178 | 171 | | |||
179 | Controls.ToolTip.delay: 1000 | 172 | Controls.ToolTip.delay: 1000 | ||
180 | Controls.ToolTip.timeout: 5000 | 173 | Controls.ToolTip.timeout: 5000 | ||
181 | Controls.ToolTip.visible: hovered && delegate.toolTip.length > 0 | 174 | Controls.ToolTip.visible: hovered && delegate.toolTip.length > 0 | ||
182 | Controls.ToolTip.text: toolTip | 175 | Controls.ToolTip.text: toolTip | ||
183 | } | 176 | } |