Merge branch 'QmlMarketplace' of https://github.com/roxanneskelly/hifi into QmlMarketplace

This commit is contained in:
Roxanne Skelly 2019-02-15 11:35:06 -08:00
commit fb524f8900
6 changed files with 101 additions and 69 deletions

View file

@ -31,8 +31,9 @@ Rectangle {
id: root id: root
property string activeView: "initialize" property string activeView: "initialize"
property int currentSortIndex: 0 property int currentSortIndex: 1
property string sortString: "recent" property string sortString: "recent"
property bool isAscending: false
property string categoryString: "" property string categoryString: ""
property string searchString: "" property string searchString: ""
property bool keyboardEnabled: HMD.active property bool keyboardEnabled: HMD.active
@ -316,23 +317,28 @@ Rectangle {
font.pixelSize: hifi.fontSizes.textFieldInput font.pixelSize: hifi.fontSizes.textFieldInput
placeholderText: "Search Marketplace" placeholderText: "Search Marketplace"
Timer {
id: keypressTimer
running: false
repeat: false
interval: 300
onTriggered: searchField.accepted()
}
// workaround for https://bugreports.qt.io/browse/QTBUG-49297 // workaround for https://bugreports.qt.io/browse/QTBUG-49297
Keys.onPressed: { Keys.onPressed: {
switch (event.key) { switch (event.key) {
case Qt.Key_Return: case Qt.Key_Return:
case Qt.Key_Enter: case Qt.Key_Enter:
event.accepted = true; event.accepted = true;
searchField.text = "";
// emit accepted signal manually getMarketplaceItems();
if (acceptableInput) { searchField.forceActiveFocus();
searchField.accepted();
searchField.forceActiveFocus();
}
break; break;
case Qt.Key_Backspace: default:
if (searchField.text === "") { keypressTimer.restart();
primaryFilter_index = -1;
}
break; break;
} }
} }
@ -498,6 +504,7 @@ Rectangle {
"", "",
"", "",
root.sortString, root.sortString,
root.isAscending,
WalletScriptingInterface.limitedCommerce, WalletScriptingInterface.limitedCommerce,
marketBrowseModel.currentPageToRetrieve, marketBrowseModel.currentPageToRetrieve,
marketBrowseModel.itemsPerPage marketBrowseModel.itemsPerPage
@ -726,7 +733,7 @@ Rectangle {
top: parent.top top: parent.top
leftMargin: 20 leftMargin: 20
} }
width: root.isLoggedIn ? 322 : 242 width: root.isLoggedIn ? 342 : 262
height: 36 height: 36
radius: 4 radius: 4
@ -737,27 +744,27 @@ Rectangle {
id: sortModel id: sortModel
ListElement { ListElement {
name: "Name"; name: "Name"
glyph: ";"
sortString: "alpha" sortString: "alpha"
ascending: true
} }
ListElement { ListElement {
name: "Date"; name: "Date"
glyph: ";"; sortString: "recent"
sortString: "recent"; ascending: false
} }
ListElement { ListElement {
name: "Popular"; name: "Popular"
glyph: ";"; sortString: "likes"
sortString: "likes"; ascending: false
} }
ListElement { ListElement {
name: "My Likes"; name: "My Likes"
glyph: ";"; sortString: "my_likes"
sortString: "my_likes"; ascending: false
} }
} }
@ -783,10 +790,10 @@ Rectangle {
currentIndex: 1; currentIndex: 1;
delegate: SortButton { delegate: SortButton {
width: 80 width: 85
height: parent.height height: parent.height
glyph: model.glyph ascending: model.ascending
text: model.name text: model.name
visible: root.isLoggedIn || model.sortString != "my_likes" visible: root.isLoggedIn || model.sortString != "my_likes"
@ -794,6 +801,12 @@ Rectangle {
checked: ListView.isCurrentItem checked: ListView.isCurrentItem
onClicked: { onClicked: {
if(root.currentSortIndex == index) {
ascending = !ascending;
} else {
ascending = model.ascending;
}
root.isAscending = ascending;
root.currentSortIndex = index; root.currentSortIndex = index;
sortListView.positionViewAtIndex(index, ListView.Beginning); sortListView.positionViewAtIndex(index, ListView.Beginning);
sortListView.currentIndex = index; sortListView.currentIndex = index;
@ -802,7 +815,7 @@ Rectangle {
} }
} }
highlight: Rectangle { highlight: Rectangle {
width: 80 width: 85
height: parent.height height: parent.height
color: hifi.colors.faintGray color: hifi.colors.faintGray
@ -1125,6 +1138,8 @@ Rectangle {
fill: parent fill: parent
} }
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
RalewayRegular { RalewayRegular {
id: licenseText id: licenseText

View file

@ -520,7 +520,7 @@ Rectangle {
} 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/legalcode.txt" url = "https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode.txt"
} 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 = "licenses/Popv1.txt"
} }
if(url) { if(url) {
showLicense(url) showLicense(url)

View file

@ -28,58 +28,60 @@ Item {
id: root; id: root;
property string ascGlyph: "\u2191"
property string descGlyph: "\u2193"
property string text: ""
property bool ascending: false
property bool checked: false
signal clicked()
property string glyph: ""; width: childrenRect.width
property string text: ""; height: parent.height
property bool checked: false;
signal clicked();
width: childrenRect.width;
height: parent.height;
Rectangle { Rectangle {
anchors.top: parent.top; anchors.top: parent.top
anchors.left: parent.left; anchors.left: parent.left
height: parent.height; height: parent.height
width: 2; width: 2
color: hifi.colors.faintGray; color: hifi.colors.faintGray
visible: index > 0; visible: index > 0
} }
HiFiGlyphs { RalewayRegular {
id: buttonGlyph; id: buttonGlyph
text: root.glyph; text: root.ascending ? root.ascGlyph : root.descGlyph
// Size // Size
size: 14; size: 14
// Anchors // Anchors
anchors.left: parent.left; anchors.left: parent.left
anchors.leftMargin: 0; anchors.leftMargin: 10
anchors.top: parent.top; anchors.top: parent.top
anchors.verticalCenter: parent.verticalCenter; anchors.topMargin: 6
height: parent.height; anchors.bottom: parent.bottom
horizontalAlignment: Text.AlignHCenter; horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignTop
// Style // Style
color: hifi.colors.lightGray; color: hifi.colors.lightGray
} }
RalewayRegular { RalewayRegular {
id: buttonText; id: buttonText
text: root.text; text: root.text
// Text size // Text size
size: 14; size: 14
// Style // Style
color: hifi.colors.lightGray; color: hifi.colors.lightGray
elide: Text.ElideRight; elide: Text.ElideRight
horizontalAlignment: Text.AlignHCenter; horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter; verticalAlignment: Text.AlignVCenter
// Anchors // Anchors
anchors.left: parent.left; anchors.left: buttonGlyph.right
anchors.leftMargin: 20; anchors.leftMargin: 5
anchors.top: parent.top; anchors.top: parent.top
height: parent.height; height: parent.height
} }
MouseArea { MouseArea {
anchors.fill: parent; anchors.fill: parent
hoverEnabled: enabled; hoverEnabled: enabled
onClicked: { onClicked: {
root.clicked(); root.clicked();
} }

View file

@ -0,0 +1,12 @@
<h2>Proof of Provenance License (PoP License) v1.0</h2>
<br>
<p>
Subject to the terms and conditions of this license, the Copyright Holder grants a worldwide, non-exclusive, non-sublicensable, non-transferable (except by transfer of the Certificate or beneficial ownership thereof) license (i) to the Certificate Holder to display ONE COPY of the Item at a time across any and all virtual worlds WITHOUT MODIFICATION; (ii) to any party to view and interact with the Item as displayed by the Certificate Holder. Redistributions of source code must retain the all copyright notices. Notwithstanding the foregoing, modification of the Item may be permitted pursuant to terms provided in the Certificate.
</p>
<p>
THE ITEM IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR A CONTRIBUTOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS ITEM, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</p>
<p><i>
Reference to the “Certificate” means the Proof of Provenance Certificate containing a hash of the code used to generate the Item; Item means the visual representation produced by the execution of the code hashed in the Certificate (which term includes the code itself); and “Certificate Holder” means a single holder of the private key for the Certificate.
</i></p>

View file

@ -50,9 +50,10 @@ void QmlMarketplace::getMarketplaceItems(
const QString& adminFilter, const QString& adminFilter,
const QString& adminFilterCost, const QString& adminFilterCost,
const QString& sort, const QString& sort,
const bool isFree, bool isAscending,
const int& page, bool isFree,
const int& perPage) { int page,
int perPage) {
QString endpoint = "items"; QString endpoint = "items";
QUrlQuery request; QUrlQuery request;
@ -62,6 +63,7 @@ void QmlMarketplace::getMarketplaceItems(
request.addQueryItem("adminFilter", adminFilter); request.addQueryItem("adminFilter", adminFilter);
request.addQueryItem("adminFilterCost", adminFilterCost); request.addQueryItem("adminFilterCost", adminFilterCost);
request.addQueryItem("sort", sort); request.addQueryItem("sort", sort);
request.addQueryItem("sort_dir", isAscending ? "asc" : "desc");
if (isFree) { if (isFree) {
request.addQueryItem("isFree", "true"); request.addQueryItem("isFree", "true");
} }

View file

@ -46,9 +46,10 @@ protected:
const QString& adminFilter = QString("published"), const QString& adminFilter = QString("published"),
const QString& adminFilterCost = QString(), const QString& adminFilterCost = QString(),
const QString& sort = QString(), const QString& sort = QString(),
const bool isFree = false, bool isAscending = false,
const int& page = 1, bool isFree = false,
const int& perPage = 20); int page = 1,
int perPage = 20);
Q_INVOKABLE void getMarketplaceItem(const QString& marketplaceItemId); Q_INVOKABLE void getMarketplaceItem(const QString& marketplaceItemId);
Q_INVOKABLE void marketplaceItemLike(const QString& marketplaceItemId, const bool like = true); Q_INVOKABLE void marketplaceItemLike(const QString& marketplaceItemId, const bool like = true);
Q_INVOKABLE void getMarketplaceCategories(); Q_INVOKABLE void getMarketplaceCategories();