From 2dc38df779b62b58fc16426f8e86c522d314fe61 Mon Sep 17 00:00:00 2001 From: Roxanne Skelly Date: Wed, 13 Mar 2019 10:17:39 -0700 Subject: [PATCH] Case 20393 - Display item counts in categories dropdown in Marketplace --- .../hifi/commerce/marketplace/Marketplace.qml | 68 ++++++++++++------- .../src/avatar/MarketplaceItemUploader.cpp | 2 +- 2 files changed, 44 insertions(+), 26 deletions(-) diff --git a/interface/resources/qml/hifi/commerce/marketplace/Marketplace.qml b/interface/resources/qml/hifi/commerce/marketplace/Marketplace.qml index 07ded49956..601a04080a 100644 --- a/interface/resources/qml/hifi/commerce/marketplace/Marketplace.qml +++ b/interface/resources/qml/hifi/commerce/marketplace/Marketplace.qml @@ -87,22 +87,11 @@ Rectangle { console.log("Failed to get Marketplace Categories", result.data.message); } else { categoriesModel.clear(); - categoriesModel.append({ - id: -1, - name: "Everything" - }); - categoriesModel.append({ - id: -1, - name: "Stand-alone Optimized" - }); - categoriesModel.append({ - id: -1, - name: "Stand-alone Compatible" - }); - result.data.items.forEach(function(category) { + result.data.categories.forEach(function(category) { categoriesModel.append({ id: category.id, - name: category.name + name: category.name, + count: category.count }); }); } @@ -396,12 +385,12 @@ Rectangle { Rectangle { anchors { - left: parent.left; - bottom: parent.bottom; - top: parent.top; - topMargin: 100; + left: parent.left + bottom: parent.bottom + top: parent.top + topMargin: 100 } - width: parent.width/3 + width: parent.width/2 color: hifi.colors.white @@ -432,20 +421,49 @@ Rectangle { color: hifi.colors.white visible: true - RalewayRegular { + RalewaySemiBold { id: categoriesItemText anchors.leftMargin: 15 - anchors.fill:parent + anchors.top:parent.top + anchors.bottom: parent.bottom + anchors.left: parent.left + elide: Text.ElideRight text: model.name color: ListView.isCurrentItem ? hifi.colors.lightBlueHighlight : hifi.colors.baseGray horizontalAlignment: Text.AlignLeft verticalAlignment: Text.AlignVCenter size: 14 } + Rectangle { + id: categoryItemCount + anchors { + top: parent.top + bottom: parent.bottom + topMargin: 5 + bottomMargin: 5 + leftMargin: 10 + rightMargin: 10 + left: categoriesItemText.right + } + width: childrenRect.width + color: hifi.colors.blueHighlight + radius: height/2 + + RalewaySemiBold { + anchors.top: parent.top + anchors.bottom: parent.bottom + width: paintedWidth+30 + + text: model.count + color: hifi.colors.white + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + size: 16 + } + } } - MouseArea { anchors.fill: parent z: 10 @@ -476,9 +494,9 @@ Rectangle { parent: categoriesListView.parent anchors { - top: categoriesListView.top; - bottom: categoriesListView.bottom; - left: categoriesListView.right; + top: categoriesListView.top + bottom: categoriesListView.bottom + left: categoriesListView.right } contentItem.opacity: 1 diff --git a/interface/src/avatar/MarketplaceItemUploader.cpp b/interface/src/avatar/MarketplaceItemUploader.cpp index 53b37eba4f..28b07780b0 100644 --- a/interface/src/avatar/MarketplaceItemUploader.cpp +++ b/interface/src/avatar/MarketplaceItemUploader.cpp @@ -87,7 +87,7 @@ void MarketplaceItemUploader::doGetCategories() { if (error == QNetworkReply::NoError) { auto doc = QJsonDocument::fromJson(reply->readAll()); auto extractCategoryID = [&doc]() -> std::pair { - auto items = doc.object()["data"].toObject()["items"]; + auto items = doc.object()["data"].toObject()["categories"]; if (!items.isArray()) { qWarning() << "Categories parse error: data.items is not an array"; return { false, 0 };