Changeset View
Changeset View
Standalone View
Standalone View
src/qtquick/qml/NewStuffItem.qml
Show All 13 Lines | |||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * Lesser General Public License for more details. | 15 | * Lesser General Public License for more details. | ||
16 | * | 16 | * | ||
17 | * You should have received a copy of the GNU Lesser General Public | 17 | * You should have received a copy of the GNU Lesser General Public | ||
18 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | 18 | * License along with this library. If not, see <http://www.gnu.org/licenses/>. | ||
19 | * | 19 | * | ||
20 | */ | 20 | */ | ||
21 | 21 | | |||
22 | import QtQuick 2.2 | 22 | import QtQuick 2.11 | ||
23 | import QtQuick.Controls 1.4 as QtControls | 23 | import QtQuick.Controls 2.11 as QtControls | ||
24 | import QtQuick.Layouts 1.11 as QtLayouts | ||||
24 | 25 | | |||
25 | import org.kde.kirigami 2.1 as Kirigami | 26 | import org.kde.kirigami 2.1 as Kirigami | ||
26 | import org.kde.newstuff 1.0 as NewStuff | 27 | | ||
28 | import org.kde.newstuff 1.62 as NewStuff | ||||
27 | 29 | | |||
28 | Kirigami.SwipeListItem { | 30 | Kirigami.SwipeListItem { | ||
29 | id: listItem; | 31 | id: listItem; | ||
30 | height: Kirigami.Units.iconSizes.huge + Kirigami.Units.smallSpacing * 2; | 32 | height: Math.max(Kirigami.Units.iconSizes.huge + Kirigami.Units.smallSpacing * 2, nameText.height + descriptionText.height + Kirigami.Units.smallSpacing * 5); | ||
31 | property QtObject listModel; | 33 | property QtObject listModel; | ||
32 | enabled: true; | 34 | enabled: true; | ||
33 | actions: [ | 35 | actions: [ | ||
34 | Kirigami.Action { | 36 | Kirigami.Action { | ||
35 | text: i18nc("Request installation of this item", "Install"); | 37 | text: i18nc("Request installation of this item", "Install"); | ||
36 | iconName: "list-add" | 38 | iconName: "list-add" | ||
37 | onTriggered: { listModel.installItem(model.index); } | 39 | onTriggered: { listModel.installItem(model.index, 1); } | ||
38 | enabled: model.status == NewStuff.ItemsModel.DownloadableStatus || model.status == NewStuff.ItemsModel.DeletedStatus; | 40 | enabled: model.status == NewStuff.ItemsModel.DownloadableStatus || model.status == NewStuff.ItemsModel.DeletedStatus; | ||
39 | visible: enabled; | 41 | visible: enabled; | ||
40 | }, | 42 | }, | ||
41 | Kirigami.Action { | 43 | Kirigami.Action { | ||
42 | text: i18nc("Request updating of this item", "Update"); | 44 | text: i18nc("Request updating of this item", "Update"); | ||
43 | iconName: "refresh" | 45 | iconName: "refresh" | ||
44 | onTriggered: { listModel.installItem(model.index); } | 46 | onTriggered: { listModel.installItem(model.index, 1); } | ||
45 | enabled: model.status == NewStuff.ItemsModel.UpdateableStatus; | 47 | enabled: model.status == NewStuff.ItemsModel.UpdateableStatus; | ||
46 | visible: enabled; | 48 | visible: enabled; | ||
47 | }, | 49 | }, | ||
48 | Kirigami.Action { | 50 | Kirigami.Action { | ||
49 | text: i18nc("Request uninstallation of this item", "Uninstall"); | 51 | text: i18nc("Request uninstallation of this item", "Uninstall"); | ||
50 | iconName: "list-remove" | 52 | iconName: "list-remove" | ||
51 | onTriggered: { listModel.uninstallItem(model.index); } | 53 | onTriggered: { listModel.uninstallItem(model.index); } | ||
52 | enabled: model.status == NewStuff.ItemsModel.InstalledStatus | 54 | enabled: model.status == NewStuff.ItemsModel.InstalledStatus | ||
53 | visible: enabled; | 55 | visible: enabled; | ||
54 | } | 56 | } | ||
55 | ] | 57 | ] | ||
56 | Item { | 58 | QtLayouts.RowLayout { | ||
57 | anchors.fill: parent; | | |||
58 | Item { | 59 | Item { | ||
59 | id: previewContainer; | 60 | id: previewContainer; | ||
60 | anchors { | 61 | QtLayouts.Layout.preferredHeight: listItem.height - Kirigami.Units.smallSpacing * 2; | ||
61 | top: parent.top; | 62 | QtLayouts.Layout.minimumWidth: Kirigami.Units.iconSizes.huge; | ||
62 | left: parent.left; | 63 | QtLayouts.Layout.maximumWidth: Kirigami.Units.iconSizes.huge; | ||
63 | bottom: parent.bottom; | | |||
64 | margins: Kirigami.Units.smallSpacing; | | |||
65 | } | | |||
66 | width: height; | | |||
67 | Image { | 64 | Image { | ||
68 | id: previewImage; | 65 | id: previewImage; | ||
69 | anchors { | 66 | anchors { | ||
70 | fill: parent; | 67 | fill: parent; | ||
71 | margins: Kirigami.Units.smallSpacing; | 68 | margins: Kirigami.Units.smallSpacing; | ||
69 | leftMargin: -Kirigami.Units.smallSpacing; | ||||
72 | } | 70 | } | ||
73 | asynchronous: true; | 71 | asynchronous: true; | ||
74 | fillMode: Image.PreserveAspectFit; | 72 | fillMode: Image.PreserveAspectFit; | ||
75 | source: model.previewsSmall.length > 0 ? model.previewsSmall[0] : ""; | 73 | source: model.previewsSmall.length > 0 ? model.previewsSmall[0] : ""; | ||
76 | Kirigami.Icon { | 74 | Kirigami.Icon { | ||
77 | id: updateAvailableBadge; | 75 | id: updateAvailableBadge; | ||
78 | opacity: (model.status == NewStuff.ItemsModel.UpdateableStatus) ? 1 : 0; | 76 | opacity: (model.status == NewStuff.ItemsModel.UpdateableStatus) ? 1 : 0; | ||
79 | Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration; } } | 77 | Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration; } } | ||
Show All 15 Lines | 91 | anchors { | |||
95 | right: parent.right; | 93 | right: parent.right; | ||
96 | margins: -Kirigami.Units.smallSpacing; | 94 | margins: -Kirigami.Units.smallSpacing; | ||
97 | } | 95 | } | ||
98 | height: Kirigami.Units.iconSizes.smallMedium; | 96 | height: Kirigami.Units.iconSizes.smallMedium; | ||
99 | width: height; | 97 | width: height; | ||
100 | source: "vcs-normal"; | 98 | source: "vcs-normal"; | ||
101 | } | 99 | } | ||
102 | } | 100 | } | ||
103 | } | 101 | Rectangle { | ||
104 | Kirigami.Label { | 102 | anchors.fill: parent | ||
105 | anchors { | 103 | opacity: installIndicator.opacity > 0 ? 0.7 : 0 | ||
106 | verticalCenter: parent.verticalCenter; | 104 | Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration; } } | ||
107 | left: previewContainer.right; | 105 | visible: opacity > 0 | ||
108 | leftMargin: Kirigami.Units.largeSpacing; | | |||
109 | } | | |||
110 | text: model.name; | | |||
111 | } | 106 | } | ||
112 | QtControls.BusyIndicator { | 107 | QtControls.BusyIndicator { | ||
113 | anchors { | 108 | id: installIndicator | ||
114 | verticalCenter: parent.verticalCenter; | 109 | anchors.centerIn: parent; | ||
115 | right: parent.right; | | |||
116 | rightMargin: Kirigami.Units.largeSpacing + Kirigami.Units.iconSizes.large; | | |||
117 | } | | |||
118 | opacity: (model.status == NewStuff.ItemsModel.InstallingStatus || model.status == NewStuff.ItemsModel.UpdatingStatus) ? 1 : 0; | 110 | opacity: (model.status == NewStuff.ItemsModel.InstallingStatus || model.status == NewStuff.ItemsModel.UpdatingStatus) ? 1 : 0; | ||
119 | Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration; } } | 111 | Behavior on opacity { NumberAnimation { duration: Kirigami.Units.shortDuration; } } | ||
120 | running: opacity > 0; | 112 | running: opacity > 0; | ||
121 | Kirigami.Label { | 113 | QtControls.Label { | ||
122 | anchors { | 114 | anchors { | ||
123 | verticalCenter: parent.verticalCenter; | 115 | horizontalCenter: parent.horizontalCenter; | ||
124 | right: parent.left; | 116 | bottom: parent.bottom; | ||
125 | rightMargin: Kirigami.Units.smallSpacing; | 117 | margins: Kirigami.Units.smallSpacing; | ||
126 | } | 118 | } | ||
127 | text: (model.status == NewStuff.ItemsModel.InstallingStatus) ? "Installing" : ((model.status == NewStuff.ItemsModel.UpdatingStatus) ? "Updating" : ""); | 119 | text: (model.status == NewStuff.ItemsModel.InstallingStatus) ? "Installing" : ((model.status == NewStuff.ItemsModel.UpdatingStatus) ? "Updating" : ""); | ||
128 | width: paintedWidth; | 120 | width: paintedWidth; | ||
129 | } | 121 | } | ||
130 | } | 122 | } | ||
131 | } | 123 | } | ||
124 | QtLayouts.ColumnLayout { | ||||
125 | QtLayouts.Layout.fillWidth: true | ||||
126 | QtLayouts.Layout.fillHeight: true | ||||
127 | Kirigami.Heading { | ||||
128 | id: nameText | ||||
129 | QtLayouts.Layout.fillWidth: true | ||||
130 | level: 3 | ||||
131 | text: model.name | ||||
132 | opacity: 1 - installIndicator.opacity | ||||
133 | } | ||||
134 | QtControls.Label { | ||||
135 | id: descriptionText | ||||
136 | QtLayouts.Layout.fillWidth: true | ||||
137 | text: model.summary.split("\n")[0]; | ||||
138 | elide: Text.ElideRight | ||||
139 | maximumLineCount: 2 | ||||
140 | wrapMode: Text.Wrap | ||||
141 | opacity: 1 - installIndicator.opacity | ||||
142 | } | ||||
143 | Item { | ||||
144 | QtLayouts.Layout.fillWidth: true | ||||
145 | QtLayouts.Layout.fillHeight: true | ||||
146 | } | ||||
147 | } | ||||
148 | } | ||||
132 | } | 149 | } |