on xenial help sign in
Simplify and streamline Tiles and FilterGrids.
commitbeafe3a321082998e3e82b3828b22d473fad0568 authorMichał Sawicz <michal.sawicz@canonical.com> dateMon 7 Oct 2013, 13:29 (13 years ago) parent616b1ef
3 files changed+25−135
Dash/Apps/ApplicationsFilterGrid.qml+14−5 Dash/Music/AlbumTile.qml−116 Dash/Music/MusicFilterGrid.qml+11−14
Dash/Apps/ApplicationsFilterGrid.qml+14−5
@@ -19,7 +19,7 @@ import "../../Components"
1919import "../../Applications"
2020
2121FilterGrid {
22− id: filterGrid
22+ id: filtergrid
2323
2424 filter: false
2525 minimumHorizontalSpacing: units.gu(0.5)
@@ -28,9 +28,11 @@ FilterGrid {
2828 delegateHeight: units.gu(9.5)
2929 verticalSpacing: units.gu(2)
3030
31− signal clicked(int index, variant data)
31+ signal clicked(int index, var model, real itemY)
32+ signal pressAndHold(int index, var model, real itemY)
3233
3334 delegate: Tile {
35+ id: tile
3436 objectName: "delegate" + index
3537 Application {
3638 id: application
@@ -44,12 +46,19 @@ FilterGrid {
4446
4547 property string icon: model.icon ? model.icon : "../../graphics/applicationIcons/" + application.icon + ".png" // FIXME: this is temporary
4648
47− width: filterGrid.cellWidth
48− height: filterGrid.cellHeight
49+ width: filtergrid.cellWidth
50+ height: filtergrid.cellHeight
4951 text: model.title ? model.title : application.name // FIXME: this is temporary
5052 imageWidth: units.gu(8)
5153 imageHeight: units.gu(7.5)
5254 source: icon
53− onClicked: filterGrid.clicked(index, application.desktopFile);
55+
56+ onClicked: {
57+ filtergrid.clicked(index, filtergrid.model, tile.y)
58+ }
59+
60+ onPressAndHold: {
61+ filtergrid.pressAndHold(index, filtergrid.model, tile.y)
62+ }
5463 }
5564}
Dash/Music/AlbumTile.qmldeleted−116
@@ -1,116 +0,0 @@
1−/*
2− * Copyright (C) 2013 Canonical, Ltd.
3− *
4− * This program is free software; you can redistribute it and/or modify
5− * it under the terms of the GNU General Public License as published by
6− * the Free Software Foundation; version 3.
7− *
8− * This program is distributed in the hope that it will be useful,
9− * but WITHOUT ANY WARRANTY; without even the implied warranty of
10− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11− * GNU General Public License for more details.
12− *
13− * You should have received a copy of the GNU General Public License
14− * along with this program. If not, see <http://www.gnu.org/licenses/>.
15− */
16−
17−import QtQuick 2.0
18−import Ubuntu.Components 0.1
19−
20−AbstractButton {
21− id: root
22− property url source
23− property alias album: albumLabel.text
24− property alias artist: artistLabel.text
25− property alias iconWidth: icon.width
26− property alias iconHeight: icon.height
27−
28− UbuntuShape {
29− id: icon
30− anchors {
31− top: parent.top
32− horizontalCenter: parent.horizontalCenter
33− }
34− radius: "medium"
35− image: Image {
36− source: root.source
37− sourceSize { width: icon.width; height: icon.height }
38− asynchronous: true
39− cache: false
40− }
41− }
42−
43− UbuntuShape {
44− id: borderPressed
45−
46− anchors.fill: icon
47− radius: "medium"
48− borderSource: "radius_pressed.sci"
49− opacity: root.pressed ? 1.0 : 0.0
50− Behavior on opacity { NumberAnimation { duration: 200; easing.type: Easing.OutQuint } }
51− }
52−
53− Item {
54− id: artistContainer
55− anchors {
56− left: parent.left
57− right: parent.right
58− top: icon.bottom
59− }
60− height: units.gu(2)
61−
62− Label {
63− id: artistLabel
64− anchors {
65− baseline: parent.bottom
66− left: parent.left
67− right: parent.right
68− leftMargin: units.gu(1)
69− rightMargin: units.gu(1)
70− }
71−
72− color: Theme.palette.selected.backgroundText
73− opacity: 0.9
74− style: Text.Raised
75− styleColor: "black"
76− fontSize: "small"
77− elide: Text.ElideMiddle
78− horizontalAlignment: Text.AlignHCenter
79− }
80− }
81−
82− Item {
83− anchors {
84− left: parent.left
85− right: parent.right
86− top: artistContainer.bottom
87− }
88− height: units.gu(1.5)
89−
90− Label {
91− id: albumLabel
92− anchors {
93− baseline: parent.bottom
94− left: parent.left
95− right: parent.right
96− leftMargin: units.gu(1)
97− rightMargin: units.gu(1)
98− }
99−
100− color: Theme.palette.selected.backgroundText
101− opacity: 0.9
102− style: Text.Raised
103− styleColor: "black"
104− fontSize: "small"
105− font.weight: Font.Light
106− elide: Text.ElideMiddle
107− horizontalAlignment: Text.AlignHCenter
108− }
109− }
110−
111− GridView.onRemove: SequentialAnimation {
112− PropertyAction { target: root; property: "GridView.delayRemove"; value: true }
113− NumberAnimation { target: root; property: "opacity"; from: 1; to: 0; duration: 200; easing.type: Easing.InOutQuad }
114− PropertyAction { target: root; property: "GridView.delayRemove"; value: false }
115− }
116−}
Dash/Music/MusicFilterGrid.qml+11−14
@@ -18,7 +18,7 @@ import QtQuick 2.0
1818import "../../Components"
1919
2020FilterGrid {
21− id: filterGrid
21+ id: filtergrid
2222
2323 minimumHorizontalSpacing: units.gu(2)
2424 maximumNumberOfColumns: 5
@@ -29,29 +29,26 @@ FilterGrid {
2929 readonly property int iconWidth: (width / columns) * 0.8
3030 readonly property int iconHeight: iconWidth
3131
32− signal clicked(int index, var delegateItem, real itemY)
33− signal pressAndHold(int index, var delegateItem, real itemY)
32+ signal clicked(int index, var model, real itemY)
33+ signal pressAndHold(int index, var model, real itemY)
3434
35− delegate: AlbumTile {
35+ delegate: Tile {
3636 id: tile
3737 objectName: "delegate" + index
38− width: filterGrid.cellWidth
39− height: filterGrid.cellHeight
40− iconWidth: filterGrid.iconWidth
41− iconHeight: filterGrid.iconHeight
38+ width: filtergrid.cellWidth
39+ height: filtergrid.cellHeight
40+ imageWidth: filtergrid.iconWidth
41+ imageHeight: filtergrid.iconHeight
4242
43− artist: model.title
44− album: model.comment
43+ text: "%1<br />%2".arg(model.title).arg(model.comment)
4544 source: model.icon
4645
4746 onClicked: {
48− var data = { model: model }
49− filterGrid.clicked(index, data, tile.y)
47+ filtergrid.clicked(index, filtergrid.model, tile.y)
5048 }
5149
5250 onPressAndHold: {
53− var data = { model: model }
54− filterGrid.pressAndHold(index, data, tile.y)
51+ filtergrid.pressAndHold(index, filtergrid.model, tile.y)
5552 }
5653 }
5754}