mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-26 02:35:16 +02:00
QmlMarketplace - Add 'logged out' behavior, fix issue with search scope
display
This commit is contained in:
parent
49e6120e73
commit
dfac0d88a2
5 changed files with 184 additions and 27 deletions
|
@ -37,18 +37,42 @@ Rectangle {
|
||||||
property string searchString: ""
|
property string searchString: ""
|
||||||
property bool keyboardEnabled: HMD.active
|
property bool keyboardEnabled: HMD.active
|
||||||
property bool keyboardRaised: false
|
property bool keyboardRaised: false
|
||||||
|
property string searchScopeString: "Featured"
|
||||||
|
property bool isLoggedIn: false;
|
||||||
|
|
||||||
anchors.fill: (typeof parent === undefined) ? undefined : parent
|
anchors.fill: (typeof parent === undefined) ? undefined : parent
|
||||||
|
|
||||||
function getMarketplaceItems() {
|
function getMarketplaceItems() {
|
||||||
marketplaceItemView.visible = false;
|
marketplaceItemView.visible = false;
|
||||||
itemsList.visible = true;
|
itemsList.visible = true;
|
||||||
marketBrowseModel.getFirstPage();
|
marketBrowseModel.getFirstPage();
|
||||||
|
{
|
||||||
|
if(root.searchString !== undefined && root.searchString !== "") {
|
||||||
|
root.searchScopeString = "Search Results: \"" + root.searchString + "\"";
|
||||||
|
} else if (root.categoryString !== "") {
|
||||||
|
root.searchScopeString = root.categoryString;
|
||||||
|
} else {
|
||||||
|
root.searchScopeString = "Featured";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
Commerce.getLoginStatus();
|
||||||
|
}
|
||||||
|
|
||||||
Component.onDestruction: {
|
Component.onDestruction: {
|
||||||
keyboard.raised = false;
|
keyboard.raised = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: GlobalServices
|
||||||
|
|
||||||
|
onMyUsernameChanged: {
|
||||||
|
console.log("LOGIN STATUS CHANGING");
|
||||||
|
Commerce.getLoginStatus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
target: MarketplaceScriptingInterface
|
target: MarketplaceScriptingInterface
|
||||||
|
@ -61,7 +85,7 @@ Rectangle {
|
||||||
categoriesModel.append({
|
categoriesModel.append({
|
||||||
id: -1,
|
id: -1,
|
||||||
name: "Everything"
|
name: "Everything"
|
||||||
});
|
});
|
||||||
result.data.items.forEach(function(category) {
|
result.data.items.forEach(function(category) {
|
||||||
categoriesModel.append({
|
categoriesModel.append({
|
||||||
id: category.id,
|
id: category.id,
|
||||||
|
@ -84,14 +108,16 @@ Rectangle {
|
||||||
marketplaceItem.image_url = result.data.thumbnail_url;
|
marketplaceItem.image_url = result.data.thumbnail_url;
|
||||||
marketplaceItem.name = result.data.title;
|
marketplaceItem.name = result.data.title;
|
||||||
marketplaceItem.likes = result.data.likes;
|
marketplaceItem.likes = result.data.likes;
|
||||||
marketplaceItem.liked = result.data.has_liked;
|
if(result.data.has_liked !== undefined) {
|
||||||
|
marketplaceItem.liked = result.data.has_liked;
|
||||||
|
}
|
||||||
marketplaceItem.creator = result.data.creator;
|
marketplaceItem.creator = result.data.creator;
|
||||||
marketplaceItem.categories = result.data.categories;
|
marketplaceItem.categories = result.data.categories;
|
||||||
marketplaceItem.price = result.data.cost;
|
marketplaceItem.price = result.data.cost;
|
||||||
marketplaceItem.description = result.data.description;
|
marketplaceItem.description = result.data.description;
|
||||||
marketplaceItem.attributions = result.data.attributions;
|
marketplaceItem.attributions = result.data.attributions;
|
||||||
marketplaceItem.license = result.data.license;
|
marketplaceItem.license = result.data.license;
|
||||||
marketplaceItem.available = result.data.availability == "available";
|
marketplaceItem.available = result.data.availability === "available";
|
||||||
marketplaceItem.created_at = result.data.created_at;
|
marketplaceItem.created_at = result.data.created_at;
|
||||||
marketplaceItemScrollView.contentHeight = marketplaceItemContent.height;
|
marketplaceItemScrollView.contentHeight = marketplaceItemContent.height;
|
||||||
itemsList.visible = false;
|
itemsList.visible = false;
|
||||||
|
@ -100,6 +126,15 @@ Rectangle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: Commerce
|
||||||
|
|
||||||
|
onLoginStatusResult: {
|
||||||
|
root.isLoggedIn = isLoggedIn;
|
||||||
|
itemsLoginStatus.visible = !isLoggedIn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
HifiCommerceCommon.CommerceLightbox {
|
HifiCommerceCommon.CommerceLightbox {
|
||||||
id: lightboxPopup
|
id: lightboxPopup
|
||||||
visible: false
|
visible: false
|
||||||
|
@ -423,7 +458,6 @@ Rectangle {
|
||||||
getMarketplaceItems();
|
getMarketplaceItems();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ScrollBar.vertical: ScrollBar {
|
ScrollBar.vertical: ScrollBar {
|
||||||
|
@ -452,12 +486,12 @@ Rectangle {
|
||||||
|
|
||||||
anchors {
|
anchors {
|
||||||
fill: parent
|
fill: parent
|
||||||
topMargin: 100
|
topMargin: 120
|
||||||
bottomMargin: 50
|
bottomMargin: 50
|
||||||
}
|
}
|
||||||
|
|
||||||
visible: true;
|
visible: true;
|
||||||
|
|
||||||
HifiModels.PSFListModel {
|
HifiModels.PSFListModel {
|
||||||
id: marketBrowseModel
|
id: marketBrowseModel
|
||||||
|
|
||||||
|
@ -467,7 +501,7 @@ Rectangle {
|
||||||
|
|
||||||
getPage: function () {
|
getPage: function () {
|
||||||
MarketplaceScriptingInterface.getMarketplaceItems(
|
MarketplaceScriptingInterface.getMarketplaceItems(
|
||||||
root.searchString == "" ? undefined : root.searchString,
|
root.searchString === "" ? undefined : root.searchString,
|
||||||
"",
|
"",
|
||||||
root.categoryString.toLowerCase(),
|
root.categoryString.toLowerCase(),
|
||||||
"",
|
"",
|
||||||
|
@ -503,11 +537,12 @@ Rectangle {
|
||||||
image_url:model.thumbnail_url
|
image_url:model.thumbnail_url
|
||||||
name: model.title
|
name: model.title
|
||||||
likes: model.likes
|
likes: model.likes
|
||||||
liked: model.has_liked
|
liked: model.has_liked ? model.has_liked : false
|
||||||
creator: model.creator
|
creator: model.creator
|
||||||
category: model.primary_category
|
category: model.primary_category
|
||||||
price: model.cost
|
price: model.cost
|
||||||
available: model.availability == "available"
|
available: model.availability === "available"
|
||||||
|
isLoggedIn: root.isLoggedIn;
|
||||||
|
|
||||||
onShowItem: {
|
onShowItem: {
|
||||||
MarketplaceScriptingInterface.getMarketplaceItem(item_id);
|
MarketplaceScriptingInterface.getMarketplaceItem(item_id);
|
||||||
|
@ -546,9 +581,65 @@ Rectangle {
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: itemsLoginStatus;
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
leftMargin: 15
|
||||||
|
rightMargin: 15
|
||||||
|
}
|
||||||
|
height: root.isLoggedIn ? 0 : 80
|
||||||
|
|
||||||
|
visible: !root.isLoggedIn
|
||||||
|
color: hifi.colors.greenHighlight
|
||||||
|
border.color: hifi.colors.greenShadow
|
||||||
|
border.width: 1
|
||||||
|
radius: 4
|
||||||
|
z: 10000
|
||||||
|
|
||||||
|
HifiControlsUit.Button {
|
||||||
|
id: loginButton;
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
top: parent.top
|
||||||
|
bottom: parent.bottom
|
||||||
|
leftMargin: 15
|
||||||
|
topMargin:10
|
||||||
|
bottomMargin: 10
|
||||||
|
}
|
||||||
|
width: 80;
|
||||||
|
|
||||||
|
text: root.price ? root.price : "LOG IN"
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
sendToScript({method: 'needsLogIn_loginClicked'});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RalewayRegular {
|
||||||
|
id: itemsLoginText
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
leftMargin: 15
|
||||||
|
top: parent.top;
|
||||||
|
bottom: parent.bottom;
|
||||||
|
right: parent.right;
|
||||||
|
left: loginButton.right
|
||||||
|
}
|
||||||
|
|
||||||
|
text: "to get items from the Marketplace."
|
||||||
|
color: hifi.colors.baseGray
|
||||||
|
horizontalAlignment: Text.AlignLeft
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
size: 18
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: breadcrumbs
|
id: breadcrumbs
|
||||||
|
|
||||||
|
anchors.top: itemsLoginStatus.bottom;
|
||||||
anchors.left: parent.left
|
anchors.left: parent.left
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
height: 34
|
height: 34
|
||||||
|
@ -598,7 +689,7 @@ Rectangle {
|
||||||
topMargin: 10
|
topMargin: 10
|
||||||
}
|
}
|
||||||
|
|
||||||
text: "Featured";
|
text: searchScopeString
|
||||||
color: hifi.colors.baseGray
|
color: hifi.colors.baseGray
|
||||||
horizontalAlignment: Text.AlignLeft
|
horizontalAlignment: Text.AlignLeft
|
||||||
verticalAlignment: Text.AlignVCenter
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
@ -751,8 +842,64 @@ Rectangle {
|
||||||
contentWidth: parent.width
|
contentWidth: parent.width
|
||||||
|
|
||||||
Rectangle {
|
Rectangle {
|
||||||
id: marketplaceItemContent
|
id: itemLoginStatus;
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
right: parent.right
|
||||||
|
leftMargin: 15
|
||||||
|
rightMargin: 15
|
||||||
|
}
|
||||||
|
height: root.isLoggedIn ? 0 : 80
|
||||||
|
|
||||||
|
visible: !root.isLoggedIn
|
||||||
|
color: hifi.colors.greenHighlight
|
||||||
|
border.color: hifi.colors.greenShadow
|
||||||
|
border.width: 1
|
||||||
|
radius: 4
|
||||||
|
z: 10000
|
||||||
|
|
||||||
|
HifiControlsUit.Button {
|
||||||
|
id: loginButton;
|
||||||
|
anchors {
|
||||||
|
left: parent.left
|
||||||
|
top: parent.top
|
||||||
|
bottom: parent.bottom
|
||||||
|
leftMargin: 15
|
||||||
|
topMargin:10
|
||||||
|
bottomMargin: 10
|
||||||
|
}
|
||||||
|
width: 80;
|
||||||
|
|
||||||
|
text: root.price ? root.price : "LOG IN"
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
sendToScript({method: 'needsLogIn_loginClicked'});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RalewayRegular {
|
||||||
|
id: itemsLoginText
|
||||||
|
|
||||||
|
anchors {
|
||||||
|
leftMargin: 15
|
||||||
|
top: parent.top;
|
||||||
|
bottom: parent.bottom;
|
||||||
|
right: parent.right;
|
||||||
|
left: loginButton.right
|
||||||
|
}
|
||||||
|
|
||||||
|
text: "to get items from the Marketplace."
|
||||||
|
color: hifi.colors.baseGray
|
||||||
|
horizontalAlignment: Text.AlignLeft
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
size: 18
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Rectangle {
|
||||||
|
id: marketplaceItemContent
|
||||||
|
anchors.top: itemLoginStatus.bottom;
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: childrenRect.height + 100
|
height: childrenRect.height + 100
|
||||||
|
|
||||||
|
@ -785,11 +932,14 @@ Rectangle {
|
||||||
MarketplaceItem {
|
MarketplaceItem {
|
||||||
id: marketplaceItem
|
id: marketplaceItem
|
||||||
|
|
||||||
|
|
||||||
anchors.topMargin: 15
|
anchors.topMargin: 15
|
||||||
anchors.top: backText.bottom
|
anchors.top: backText.bottom
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: childrenRect.height
|
height: childrenRect.height
|
||||||
|
|
||||||
|
isLoggedIn: root.isLoggedIn;
|
||||||
|
|
||||||
onBuy: {
|
onBuy: {
|
||||||
sendToScript({method: 'marketplace_checkout', itemId: item_id});
|
sendToScript({method: 'marketplace_checkout', itemId: item_id});
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ Rectangle {
|
||||||
property string posted: ""
|
property string posted: ""
|
||||||
property bool available: false
|
property bool available: false
|
||||||
property string created_at: ""
|
property string created_at: ""
|
||||||
|
property bool isLoggedIn: false;
|
||||||
|
|
||||||
onCategoriesChanged: {
|
onCategoriesChanged: {
|
||||||
categoriesListModel.clear();
|
categoriesListModel.clear();
|
||||||
|
@ -184,7 +185,9 @@ Rectangle {
|
||||||
}
|
}
|
||||||
|
|
||||||
onClicked: {
|
onClicked: {
|
||||||
MarketplaceScriptingInterface.marketplaceItemLike(root.item_id, !root.liked);
|
if (isLoggedIn) {
|
||||||
|
MarketplaceScriptingInterface.marketplaceItemLike(root.item_id, !root.liked);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -382,21 +385,21 @@ Rectangle {
|
||||||
onClicked: {
|
onClicked: {
|
||||||
licenseInfo.visible = true;
|
licenseInfo.visible = true;
|
||||||
var url;
|
var url;
|
||||||
if (root.license == "No Rights Reserved (CC0)") {
|
if (root.license === "No Rights Reserved (CC0)") {
|
||||||
url = "https://creativecommons.org/publicdomain/zero/1.0/"
|
url = "https://creativecommons.org/publicdomain/zero/1.0/"
|
||||||
} else if (root.license == "Attribution (CC BY)") {
|
} else if (root.license === "Attribution (CC BY)") {
|
||||||
url = "https://creativecommons.org/licenses/by/4.0/"
|
url = "https://creativecommons.org/licenses/by/4.0/"
|
||||||
} else if (root.license == "Attribution-ShareAlike (CC BY-SA)") {
|
} else if (root.license === "Attribution-ShareAlike (CC BY-SA)") {
|
||||||
url = "https://creativecommons.org/licenses/by-sa/4.0/"
|
url = "https://creativecommons.org/licenses/by-sa/4.0/"
|
||||||
} else if (root.license == "Attribution-NoDerivs (CC BY-ND)") {
|
} else if (root.license === "Attribution-NoDerivs (CC BY-ND)") {
|
||||||
url = "https://creativecommons.org/licenses/by-nd/4.0/"
|
url = "https://creativecommons.org/licenses/by-nd/4.0/"
|
||||||
} else if (root.license == "Attribution-NonCommercial (CC BY-NC)") {
|
} else if (root.license === "Attribution-NonCommercial (CC BY-NC)") {
|
||||||
url = "https://creativecommons.org/licenses/by-nc/4.0/"
|
url = "https://creativecommons.org/licenses/by-nc/4.0/"
|
||||||
} else if (root.license == "Attribution-NonCommercial-ShareAlike (CC BY-NC-SA)") {
|
} else if (root.license === "Attribution-NonCommercial-ShareAlike (CC BY-NC-SA)") {
|
||||||
url = "https://creativecommons.org/licenses/by-nc-sa/4.0/"
|
url = "https://creativecommons.org/licenses/by-nc-sa/4.0/"
|
||||||
} else if (root.license == "Attribution-NonCommercial-NoDerivs (CC BY-NC-ND)") {
|
} else if (root.license === "Attribution-NonCommercial-NoDerivs (CC BY-NC-ND)") {
|
||||||
url = "https://creativecommons.org/licenses/by-nc-nd/4.0/"
|
url = "https://creativecommons.org/licenses/by-nc-nd/4.0/"
|
||||||
} else if (root.license == "Proof of Provenance License (PoP License)") {
|
} else if (root.license === "Proof of Provenance License (PoP License)") {
|
||||||
url = "https://digitalassetregistry.com/PoP-License/v1/"
|
url = "https://digitalassetregistry.com/PoP-License/v1/"
|
||||||
}
|
}
|
||||||
if(url) {
|
if(url) {
|
||||||
|
|
|
@ -35,6 +35,7 @@ Rectangle {
|
||||||
property string category: ""
|
property string category: ""
|
||||||
property int price: 0
|
property int price: 0
|
||||||
property bool available: false
|
property bool available: false
|
||||||
|
property bool isLoggedIn: false;
|
||||||
|
|
||||||
signal buy()
|
signal buy()
|
||||||
signal showItem()
|
signal showItem()
|
||||||
|
@ -184,9 +185,11 @@ Rectangle {
|
||||||
bottom: parent.bottom
|
bottom: parent.bottom
|
||||||
}
|
}
|
||||||
onClicked: {
|
onClicked: {
|
||||||
root.liked = !root.liked;
|
if(isLoggedIn) {
|
||||||
root.likes = root.liked ? root.likes + 1 : root.likes - 1;
|
root.liked = !root.liked;
|
||||||
MarketplaceScriptingInterface.marketplaceItemLike(root.item_id, root.liked);
|
root.likes = root.liked ? root.likes + 1 : root.likes - 1;
|
||||||
|
MarketplaceScriptingInterface.marketplaceItemLike(root.item_id, root.liked);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2990,6 +2990,7 @@ void Application::initializeUi() {
|
||||||
QUrl{ "hifi/dialogs/security/SecurityImageModel.qml" },
|
QUrl{ "hifi/dialogs/security/SecurityImageModel.qml" },
|
||||||
QUrl{ "hifi/dialogs/security/SecurityImageSelection.qml" },
|
QUrl{ "hifi/dialogs/security/SecurityImageSelection.qml" },
|
||||||
QUrl{ "hifi/tablet/TabletMenu.qml" },
|
QUrl{ "hifi/tablet/TabletMenu.qml" },
|
||||||
|
QUrl{ "hifi/commerce/marketplace/Marketplace.qml" },
|
||||||
}, commerceCallback);
|
}, commerceCallback);
|
||||||
|
|
||||||
QmlContextCallback marketplaceCallback = [](QQmlContext* context) {
|
QmlContextCallback marketplaceCallback = [](QQmlContext* context) {
|
||||||
|
|
|
@ -613,7 +613,7 @@ var onQmlMessageReceived = function onQmlMessageReceived(message) {
|
||||||
case 'passphrasePopup_cancelClicked':
|
case 'passphrasePopup_cancelClicked':
|
||||||
case 'needsLogIn_cancelClicked':
|
case 'needsLogIn_cancelClicked':
|
||||||
// Should/must NOT check for wallet setup.
|
// Should/must NOT check for wallet setup.
|
||||||
ui.open(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL);
|
openMarketplace();
|
||||||
break;
|
break;
|
||||||
case 'needsLogIn_loginClicked':
|
case 'needsLogIn_loginClicked':
|
||||||
openLoginWindow();
|
openLoginWindow();
|
||||||
|
|
Loading…
Reference in a new issue