Changeset View
Changeset View
Standalone View
Standalone View
src/GridBrowserDelegate.qml
- This file was moved from src/MediaArtistDelegate.qml.
Show All 11 Lines | |||||
12 | * Library General Public License for more details. | 12 | * Library General Public License for more details. | ||
13 | * | 13 | * | ||
14 | * You should have received a copy of the GNU Library General Public License | 14 | * You should have received a copy of the GNU Library General Public License | ||
15 | * along with this library; see the file COPYING.LIB. If not, write to | 15 | * along with this library; see the file COPYING.LIB. If not, write to | ||
16 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | * Boston, MA 02110-1301, USA. | 17 | * Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | import QtQuick 2.4 | 20 | import QtQuick 2.7 | ||
21 | import QtQuick.Controls 1.2 | 21 | import QtQuick.Controls 1.4 | ||
22 | import QtQuick.Controls.Styles 1.2 | 22 | import QtQuick.Controls.Styles 1.4 | ||
23 | import QtQuick.Window 2.2 | 23 | import QtQuick.Window 2.2 | ||
24 | import QtQml.Models 2.1 | 24 | import QtQml.Models 2.1 | ||
25 | import QtQuick.Layouts 1.2 | 25 | import QtQuick.Layouts 1.2 | ||
26 | import QtGraphicalEffects 1.0 | 26 | import QtGraphicalEffects 1.0 | ||
27 | 27 | | |||
28 | import org.kde.elisa 1.0 | 28 | import org.kde.elisa 1.0 | ||
29 | 29 | | |||
30 | FocusScope { | 30 | Item { | ||
31 | id: mediaServerEntry | 31 | id: gridEntry | ||
32 | | ||||
33 | property StackView stackView | | |||
34 | property MediaPlayList playListModel | | |||
35 | property var musicListener | | |||
36 | property var playerControl | | |||
37 | property var contentDirectoryModel | | |||
38 | property var image | | |||
39 | property alias name: nameLabel.text | | |||
40 | | ||||
41 | signal artistClicked() | | |||
42 | signal openArtist(var name) | | |||
43 | | ||||
44 | SystemPalette { | | |||
45 | id: myPalette | | |||
46 | colorGroup: SystemPalette.Active | | |||
47 | } | | |||
48 | 32 | | |||
49 | Theme { | 33 | property var imageUrl | ||
50 | id: elisaTheme | 34 | property bool shadowForImage | ||
51 | } | 35 | property alias mainText: mainLabel.text | ||
36 | property alias secondaryText: secondaryLabel.text | ||||
37 | property var containerData | ||||
38 | property bool delegateDisplaySecondaryText: true | ||||
39 | | ||||
40 | signal enqueue(var data); | ||||
41 | signal enqueueAndPlay(var data); | ||||
42 | signal open(); | ||||
43 | signal selected(); | ||||
52 | 44 | | |||
53 | Action { | 45 | Action { | ||
54 | id: enqueueAction | 46 | id: enqueueAction | ||
55 | 47 | | |||
56 | text: i18nc("Add all tracks from artist to play list", "Enqueue") | 48 | text: i18nc("Add whole container to play list", "Enqueue") | ||
57 | iconName: "media-track-add-amarok" | 49 | iconName: 'media-track-add-amarok' | ||
58 | onTriggered: mediaServerEntry.playListModel.enqueue(mediaServerEntry.name) | 50 | onTriggered: enqueue(containerData) | ||
59 | } | 51 | } | ||
60 | 52 | | |||
61 | Action { | 53 | Action { | ||
62 | id: openAction | 54 | id: openAction | ||
63 | 55 | | |||
64 | text: i18nc("Open artist view", "Open Artist") | 56 | text: i18nc("Open view of the container", "Open") | ||
65 | iconName: 'document-open-folder' | 57 | iconName: 'document-open-folder' | ||
66 | onTriggered: openArtist(name) | 58 | onTriggered: open() | ||
67 | } | 59 | } | ||
68 | 60 | | |||
69 | Action { | 61 | Action { | ||
70 | id: enqueueAndPlayAction | 62 | id: enqueueAndPlayAction | ||
71 | 63 | | |||
72 | text: i18nc("Clear play list and add all tracks from artist to play list", "Play Now and Replace Play List") | 64 | text: i18nc("Clear play list and add whole container to play list", "Play Now and Replace Play List") | ||
73 | iconName: "media-playback-start" | 65 | iconName: 'media-playback-start' | ||
74 | onTriggered: { | 66 | onTriggered: enqueueAndPlay(containerData) | ||
75 | mediaServerEntry.playListModel.clearAndEnqueue(mediaServerEntry.name) | | |||
76 | mediaServerEntry.playerControl.ensurePlay() | | |||
77 | } | | |||
78 | } | 67 | } | ||
79 | 68 | | |||
80 | Keys.onReturnPressed: openArtist(name) | 69 | Keys.onReturnPressed: open() | ||
81 | Keys.onEnterPressed: openArtist(name) | 70 | Keys.onEnterPressed: open() | ||
82 | 71 | | |||
83 | ColumnLayout { | 72 | ColumnLayout { | ||
84 | anchors.fill: parent | 73 | anchors.fill: parent | ||
85 | 74 | | |||
86 | spacing: 0 | 75 | spacing: 0 | ||
87 | 76 | | |||
88 | MouseArea { | 77 | MouseArea { | ||
89 | id: hoverHandle | 78 | id: hoverHandle | ||
90 | 79 | | |||
91 | hoverEnabled: true | 80 | hoverEnabled: true | ||
92 | acceptedButtons: Qt.LeftButton | 81 | acceptedButtons: Qt.LeftButton | ||
93 | focus: true | 82 | focus: true | ||
94 | 83 | | |||
95 | Layout.preferredHeight: mediaServerEntry.width * 0.85 + elisaTheme.layoutVerticalMargin * 0.5 + nameSize.height | 84 | Layout.preferredHeight: gridEntry.width * 0.85 + elisaTheme.layoutVerticalMargin * 0.5 + mainLabelSize.height + secondaryLabelSize.height | ||
96 | Layout.fillWidth: true | 85 | Layout.fillWidth: true | ||
97 | 86 | | |||
98 | onClicked: { | 87 | onClicked: { | ||
99 | hoverHandle.forceActiveFocus() | 88 | hoverHandle.forceActiveFocus() | ||
100 | artistClicked() | 89 | gridEntry.selected() | ||
101 | } | 90 | } | ||
102 | 91 | | |||
103 | onDoubleClicked: openArtist(name) | 92 | onDoubleClicked: open() | ||
93 | | ||||
94 | TextMetrics { | ||||
95 | id: mainLabelSize | ||||
96 | font: mainLabel.font | ||||
97 | text: mainLabel.text | ||||
98 | } | ||||
104 | 99 | | |||
105 | TextMetrics { | 100 | TextMetrics { | ||
106 | id: nameSize | 101 | id: secondaryLabelSize | ||
107 | font: nameLabel.font | 102 | font: secondaryLabel.font | ||
108 | text: nameLabel.text | 103 | text: secondaryLabel.text | ||
109 | } | 104 | } | ||
110 | 105 | | |||
111 | ColumnLayout { | 106 | ColumnLayout { | ||
112 | id: mainData | 107 | id: mainData | ||
113 | 108 | | |||
114 | spacing: 0 | 109 | spacing: 0 | ||
115 | anchors.fill: parent | 110 | anchors.fill: parent | ||
116 | 111 | | |||
117 | Item { | 112 | Item { | ||
118 | Layout.preferredWidth: mediaServerEntry.width * 0.85 | 113 | Layout.preferredHeight: gridEntry.width * 0.85 | ||
119 | Layout.preferredHeight: mediaServerEntry.width * 0.85 | 114 | Layout.preferredWidth: gridEntry.width * 0.85 | ||
120 | 115 | | |||
121 | Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter | 116 | Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter | ||
122 | 117 | | |||
118 | focus: true | ||||
119 | | ||||
123 | Loader { | 120 | Loader { | ||
124 | id: hoverLoader | 121 | id: hoverLoader | ||
125 | active: false | 122 | active: false | ||
126 | 123 | | |||
127 | anchors.centerIn: parent | 124 | anchors.centerIn: parent | ||
128 | z: 1 | 125 | z: 1 | ||
129 | 126 | | |||
130 | opacity: 0 | 127 | opacity: 0 | ||
Show All 25 Lines | 149 | ToolButton { | |||
156 | 153 | | |||
157 | width: elisaTheme.delegateToolButtonSize | 154 | width: elisaTheme.delegateToolButtonSize | ||
158 | height: elisaTheme.delegateToolButtonSize | 155 | height: elisaTheme.delegateToolButtonSize | ||
159 | } | 156 | } | ||
160 | } | 157 | } | ||
161 | } | 158 | } | ||
162 | 159 | | |||
163 | Image { | 160 | Image { | ||
164 | id: artistDecoration | 161 | id: coverImage | ||
165 | | ||||
166 | source: Qt.resolvedUrl(elisaTheme.defaultArtistImage) | | |||
167 | 162 | | |||
168 | anchors.fill: parent | 163 | anchors.fill: parent | ||
169 | 164 | | |||
170 | sourceSize.width: parent.width | 165 | sourceSize.width: parent.width | ||
171 | sourceSize.height: parent.height | 166 | sourceSize.height: parent.height | ||
172 | | ||||
173 | fillMode: Image.PreserveAspectFit | 167 | fillMode: Image.PreserveAspectFit | ||
174 | | ||||
175 | smooth: true | 168 | smooth: true | ||
176 | 169 | | |||
170 | source: gridEntry.imageUrl | ||||
171 | | ||||
177 | asynchronous: true | 172 | asynchronous: true | ||
178 | 173 | | |||
179 | layer.enabled: image === '' ? false : true | 174 | layer.enabled: shadowForImage | ||
180 | layer.effect: DropShadow { | 175 | layer.effect: DropShadow { | ||
176 | source: coverImage | ||||
177 | | ||||
181 | radius: 10 | 178 | radius: 10 | ||
182 | spread: 0.1 | 179 | spread: 0.1 | ||
183 | samples: 21 | 180 | samples: 21 | ||
184 | 181 | | |||
185 | color: myPalette.shadow | 182 | color: myPalette.shadow | ||
186 | } | 183 | } | ||
187 | } | 184 | } | ||
188 | } | 185 | } | ||
189 | 186 | | |||
190 | LabelWithToolTip { | 187 | LabelWithToolTip { | ||
191 | id: nameLabel | 188 | id: mainLabel | ||
192 | 189 | | |||
193 | font.weight: Font.Bold | 190 | font.weight: Font.Bold | ||
194 | color: myPalette.text | 191 | color: myPalette.text | ||
195 | 192 | | |||
196 | horizontalAlignment: Text.AlignLeft | 193 | horizontalAlignment: Text.AlignLeft | ||
197 | 194 | | |||
198 | Layout.preferredWidth: mediaServerEntry.width * 0.85 | | |||
199 | Layout.topMargin: elisaTheme.layoutVerticalMargin * 0.5 | 195 | Layout.topMargin: elisaTheme.layoutVerticalMargin * 0.5 | ||
196 | Layout.preferredWidth: gridEntry.width * 0.85 | ||||
200 | Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom | 197 | Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom | ||
201 | 198 | | |||
202 | elide: Text.ElideRight | 199 | elide: Text.ElideRight | ||
203 | } | 200 | } | ||
201 | | ||||
202 | LabelWithToolTip { | ||||
203 | id: secondaryLabel | ||||
204 | | ||||
205 | font.weight: Font.Light | ||||
206 | color: myPalette.text | ||||
207 | | ||||
208 | horizontalAlignment: Text.AlignLeft | ||||
209 | | ||||
210 | Layout.preferredWidth: gridEntry.width * 0.85 | ||||
211 | Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom | ||||
212 | | ||||
213 | visible: delegateDisplaySecondaryText | ||||
214 | | ||||
215 | elide: Text.ElideRight | ||||
216 | } | ||||
204 | } | 217 | } | ||
205 | } | 218 | } | ||
206 | 219 | | |||
207 | Item { | 220 | Item { | ||
208 | Layout.fillHeight: true | 221 | Layout.fillHeight: true | ||
209 | } | 222 | } | ||
210 | } | 223 | } | ||
211 | 224 | | |||
212 | states: [ | 225 | states: [ | ||
213 | State { | 226 | State { | ||
214 | name: 'notSelected' | 227 | name: 'notSelected' | ||
215 | when: !mediaServerEntry.activeFocus && !hoverHandle.containsMouse | 228 | when: !gridEntry.activeFocus && !hoverHandle.containsMouse | ||
216 | PropertyChanges { | 229 | PropertyChanges { | ||
217 | target: hoverLoader | 230 | target: hoverLoader | ||
218 | active: false | 231 | active: false | ||
219 | } | 232 | } | ||
220 | PropertyChanges { | 233 | PropertyChanges { | ||
221 | target: hoverLoader | 234 | target: hoverLoader | ||
222 | opacity: 0.0 | 235 | opacity: 0.0 | ||
223 | } | 236 | } | ||
224 | PropertyChanges { | 237 | PropertyChanges { | ||
225 | target: artistDecoration | 238 | target: coverImage | ||
226 | opacity: 1 | 239 | opacity: 1 | ||
227 | } | 240 | } | ||
228 | }, | 241 | }, | ||
229 | State { | 242 | State { | ||
230 | name: 'hoveredOrSelected' | 243 | name: 'hoveredOrSelected' | ||
231 | when: mediaServerEntry.activeFocus || hoverHandle.containsMouse | 244 | when: gridEntry.activeFocus || hoverHandle.containsMouse | ||
232 | PropertyChanges { | 245 | PropertyChanges { | ||
233 | target: hoverLoader | 246 | target: hoverLoader | ||
234 | active: true | 247 | active: true | ||
235 | } | 248 | } | ||
236 | PropertyChanges { | 249 | PropertyChanges { | ||
237 | target: hoverLoader | 250 | target: hoverLoader | ||
238 | opacity: 1.0 | 251 | opacity: 1.0 | ||
239 | } | 252 | } | ||
240 | PropertyChanges { | 253 | PropertyChanges { | ||
241 | target: artistDecoration | 254 | target: coverImage | ||
242 | opacity: 0.2 | 255 | opacity: 0.2 | ||
243 | } | 256 | } | ||
244 | } | 257 | } | ||
245 | ] | 258 | ] | ||
246 | 259 | | |||
247 | transitions: [ | 260 | transitions: [ | ||
248 | Transition { | 261 | Transition { | ||
249 | to: 'hoveredOrSelected' | 262 | to: 'hoveredOrSelected' | ||
Show All 28 Lines |