mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 21:03:27 +02:00
Lots of fixes
This commit is contained in:
parent
528d2072f9
commit
b7282cc776
8 changed files with 129 additions and 44 deletions
|
@ -78,6 +78,25 @@ Rectangle {
|
||||||
verticalAlignment: Text.AlignVCenter;
|
verticalAlignment: Text.AlignVCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// "Change Security Image" button
|
||||||
|
HifiControlsUit.Button {
|
||||||
|
id: changeSecurityImageButton;
|
||||||
|
color: hifi.buttons.black;
|
||||||
|
colorScheme: hifi.colorSchemes.dark;
|
||||||
|
anchors.top: parent.top;
|
||||||
|
anchors.topMargin: 3;
|
||||||
|
anchors.bottom: parent.bottom;
|
||||||
|
anchors.bottomMargin: 3;
|
||||||
|
anchors.right: parent.right;
|
||||||
|
anchors.rightMargin: 20;
|
||||||
|
width: 200;
|
||||||
|
text: "Change Security Image"
|
||||||
|
onClicked: {
|
||||||
|
securityImageSelection.isManuallyChangingSecurityImage = true;
|
||||||
|
securityImageSelection.visible = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Separator
|
// Separator
|
||||||
HifiControlsUit.Separator {
|
HifiControlsUit.Separator {
|
||||||
anchors.left: parent.left;
|
anchors.left: parent.left;
|
||||||
|
|
42
interface/resources/qml/hifi/commerce/SecurityImageModel.qml
Normal file
42
interface/resources/qml/hifi/commerce/SecurityImageModel.qml
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
//
|
||||||
|
// SecurityImageModel.qml
|
||||||
|
// qml/hifi/commerce
|
||||||
|
//
|
||||||
|
// SecurityImageModel
|
||||||
|
//
|
||||||
|
// Created by Zach Fox on 2017-08-15
|
||||||
|
// Copyright 2017 High Fidelity, Inc.
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
//
|
||||||
|
|
||||||
|
import QtQuick 2.5
|
||||||
|
|
||||||
|
ListModel {
|
||||||
|
id: root;
|
||||||
|
ListElement{
|
||||||
|
sourcePath: "images/01cat.jpg"
|
||||||
|
securityImageEnumIndex: 1;
|
||||||
|
}
|
||||||
|
ListElement{
|
||||||
|
sourcePath: "images/02car.jpg"
|
||||||
|
securityImageEnumIndex: 2;
|
||||||
|
}
|
||||||
|
ListElement{
|
||||||
|
sourcePath: "images/03dog.jpg"
|
||||||
|
securityImageEnumIndex: 3;
|
||||||
|
}
|
||||||
|
ListElement{
|
||||||
|
sourcePath: "images/04stars.jpg"
|
||||||
|
securityImageEnumIndex: 4;
|
||||||
|
}
|
||||||
|
ListElement{
|
||||||
|
sourcePath: "images/05plane.jpg"
|
||||||
|
securityImageEnumIndex: 5;
|
||||||
|
}
|
||||||
|
ListElement{
|
||||||
|
sourcePath: "images/06gingerbread.jpg"
|
||||||
|
securityImageEnumIndex: 6;
|
||||||
|
}
|
||||||
|
}
|
|
@ -25,19 +25,32 @@ Rectangle {
|
||||||
|
|
||||||
id: securityImageSelectionRoot;
|
id: securityImageSelectionRoot;
|
||||||
property string referrerURL: "";
|
property string referrerURL: "";
|
||||||
|
property bool isManuallyChangingSecurityImage: false;
|
||||||
anchors.fill: parent;
|
anchors.fill: parent;
|
||||||
// Style
|
// Style
|
||||||
color: hifi.colors.baseGray;
|
color: hifi.colors.baseGray;
|
||||||
z:999; // On top of everything else
|
z:999; // On top of everything else
|
||||||
|
visible: false;
|
||||||
|
|
||||||
Hifi.QmlCommerce {
|
Hifi.QmlCommerce {
|
||||||
id: commerce;
|
id: commerce;
|
||||||
onSecurityImageChosen: {
|
onSecurityImageResult: {
|
||||||
securityImageSelectionRoot.visible = (imageID == 0);
|
if (!isManuallyChangingSecurityImage) {
|
||||||
|
securityImageSelectionRoot.visible = (imageID == 0);
|
||||||
|
}
|
||||||
|
if (imageID !== 0) {
|
||||||
|
for (var itr = 0; itr < gridModel.count; itr++) {
|
||||||
|
if (gridModel.get(itr).securityImageEnumIndex === imageID) {
|
||||||
|
securityImageGrid.currentIndex = itr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
visible: commerce.getSecurityImage() == 0;
|
Component.onCompleted: {
|
||||||
|
commerce.getSecurityImage();
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// TITLE BAR START
|
// TITLE BAR START
|
||||||
|
@ -137,26 +150,8 @@ Rectangle {
|
||||||
anchors.bottom: actionButtonsContainer.top;
|
anchors.bottom: actionButtonsContainer.top;
|
||||||
anchors.bottomMargin: 8;
|
anchors.bottomMargin: 8;
|
||||||
|
|
||||||
ListModel {
|
SecurityImageModel {
|
||||||
id: gridModel;
|
id: gridModel;
|
||||||
ListElement{
|
|
||||||
sourcePath: "images/01cat.jpg"
|
|
||||||
}
|
|
||||||
ListElement{
|
|
||||||
sourcePath: "images/02car.jpg"
|
|
||||||
}
|
|
||||||
ListElement{
|
|
||||||
sourcePath: "images/03dog.jpg"
|
|
||||||
}
|
|
||||||
ListElement{
|
|
||||||
sourcePath: "images/04stars.jpg"
|
|
||||||
}
|
|
||||||
ListElement{
|
|
||||||
sourcePath: "images/05plane.jpg"
|
|
||||||
}
|
|
||||||
ListElement{
|
|
||||||
sourcePath: "images/06gingerbread.jpg"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GridView {
|
GridView {
|
||||||
|
@ -199,7 +194,6 @@ Rectangle {
|
||||||
width: securityImageGrid.cellWidth;
|
width: securityImageGrid.cellWidth;
|
||||||
height: securityImageGrid.cellHeight;
|
height: securityImageGrid.cellHeight;
|
||||||
color: hifi.colors.blueHighlight;
|
color: hifi.colors.blueHighlight;
|
||||||
y: securityImageGrid.currentItem.y;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -235,7 +229,11 @@ Rectangle {
|
||||||
width: parent.width/2 - anchors.leftMargin*2;
|
width: parent.width/2 - anchors.leftMargin*2;
|
||||||
text: "Cancel"
|
text: "Cancel"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
sendToScript({method: 'securityImageSelection_cancelClicked', referrerURL: referrerURL});
|
if (!securityImageSelectionRoot.isManuallyChangingSecurityImage) {
|
||||||
|
sendToScript({method: 'securityImageSelection_cancelClicked', referrerURL: securityImageSelectionRoot.referrerURL});
|
||||||
|
} else {
|
||||||
|
securityImageSelectionRoot.visible = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +251,8 @@ Rectangle {
|
||||||
width: parent.width/2 - anchors.rightMargin*2;
|
width: parent.width/2 - anchors.rightMargin*2;
|
||||||
text: "Confirm";
|
text: "Confirm";
|
||||||
onClicked: {
|
onClicked: {
|
||||||
commerce.chooseSecurityImage(securityImageGrid.currentIndex + 1);
|
securityImageSelectionRoot.isManuallyChangingSecurityImage = false;
|
||||||
|
commerce.chooseSecurityImage(gridModel.get(securityImageGrid.currentIndex).securityImageEnumIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,11 @@ HIFI_QML_DEF(QmlCommerce)
|
||||||
|
|
||||||
QmlCommerce::QmlCommerce(QQuickItem* parent) : OffscreenQmlDialog(parent) {
|
QmlCommerce::QmlCommerce(QQuickItem* parent) : OffscreenQmlDialog(parent) {
|
||||||
auto ledger = DependencyManager::get<Ledger>();
|
auto ledger = DependencyManager::get<Ledger>();
|
||||||
|
auto wallet = DependencyManager::get<Wallet>();
|
||||||
connect(ledger.data(), &Ledger::buyResult, this, &QmlCommerce::buyResult);
|
connect(ledger.data(), &Ledger::buyResult, this, &QmlCommerce::buyResult);
|
||||||
connect(ledger.data(), &Ledger::balanceResult, this, &QmlCommerce::balanceResult);
|
connect(ledger.data(), &Ledger::balanceResult, this, &QmlCommerce::balanceResult);
|
||||||
connect(ledger.data(), &Ledger::inventoryResult, this, &QmlCommerce::inventoryResult);
|
connect(ledger.data(), &Ledger::inventoryResult, this, &QmlCommerce::inventoryResult);
|
||||||
|
connect(wallet.data(), &Wallet::securityImageResult, this, &QmlCommerce::securityImageResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlCommerce::buy(const QString& assetId, int cost, const QString& buyerUsername) {
|
void QmlCommerce::buy(const QString& assetId, int cost, const QString& buyerUsername) {
|
||||||
|
@ -49,3 +51,12 @@ void QmlCommerce::inventory() {
|
||||||
auto wallet = DependencyManager::get<Wallet>();
|
auto wallet = DependencyManager::get<Wallet>();
|
||||||
ledger->inventory(wallet->listPublicKeys());
|
ledger->inventory(wallet->listPublicKeys());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QmlCommerce::chooseSecurityImage(uint imageID) {
|
||||||
|
auto wallet = DependencyManager::get<Wallet>();
|
||||||
|
wallet->chooseSecurityImage(imageID);
|
||||||
|
}
|
||||||
|
void QmlCommerce::getSecurityImage() {
|
||||||
|
auto wallet = DependencyManager::get<Wallet>();
|
||||||
|
wallet->getSecurityImage();
|
||||||
|
}
|
|
@ -30,27 +30,14 @@ signals:
|
||||||
// because we can't scalably know of out-of-band changes (e.g., another machine interacting with the block chain).
|
// because we can't scalably know of out-of-band changes (e.g., another machine interacting with the block chain).
|
||||||
void balanceResult(int balance, const QString& failureMessage);
|
void balanceResult(int balance, const QString& failureMessage);
|
||||||
void inventoryResult(QJsonObject inventory, const QString& failureMessage);
|
void inventoryResult(QJsonObject inventory, const QString& failureMessage);
|
||||||
void securityImageChosen(uint imageID);
|
void securityImageResult(uint imageID);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Q_INVOKABLE void buy(const QString& assetId, int cost, const QString& buyerUsername = "");
|
Q_INVOKABLE void buy(const QString& assetId, int cost, const QString& buyerUsername = "");
|
||||||
Q_INVOKABLE void balance();
|
Q_INVOKABLE void balance();
|
||||||
Q_INVOKABLE void inventory();
|
Q_INVOKABLE void inventory();
|
||||||
|
Q_INVOKABLE void chooseSecurityImage(uint imageID);
|
||||||
enum SecurityImage {
|
Q_INVOKABLE void getSecurityImage();
|
||||||
NONE = 0,
|
|
||||||
Cat,
|
|
||||||
Car,
|
|
||||||
Dog,
|
|
||||||
Stars,
|
|
||||||
Plane,
|
|
||||||
Gingerbread
|
|
||||||
};
|
|
||||||
Q_INVOKABLE void chooseSecurityImage(uint imageID) { QmlCommerce::_chosenSecurityImage = (SecurityImage)imageID; emit securityImageChosen(imageID); }
|
|
||||||
Q_INVOKABLE uint getSecurityImage() { return (uint)QmlCommerce::_chosenSecurityImage; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
SecurityImage _chosenSecurityImage = SecurityImage::NONE;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_QmlCommerce_h
|
#endif // hifi_QmlCommerce_h
|
||||||
|
|
|
@ -43,4 +43,12 @@ QStringList Wallet::listPublicKeys() {
|
||||||
QString Wallet::signWithKey(const QString& text, const QString& key) {
|
QString Wallet::signWithKey(const QString& text, const QString& key) {
|
||||||
qCInfo(commerce) << "Signing text.";
|
qCInfo(commerce) << "Signing text.";
|
||||||
return "fixme signed";
|
return "fixme signed";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Wallet::chooseSecurityImage(uint imageID) {
|
||||||
|
_chosenSecurityImage = (SecurityImage)imageID;
|
||||||
|
emit securityImageResult(imageID);
|
||||||
|
}
|
||||||
|
void Wallet::getSecurityImage() {
|
||||||
|
emit securityImageResult(_chosenSecurityImage);
|
||||||
|
}
|
||||||
|
|
|
@ -26,9 +26,29 @@ public:
|
||||||
bool generateKeyPair();
|
bool generateKeyPair();
|
||||||
QStringList listPublicKeys();
|
QStringList listPublicKeys();
|
||||||
QString signWithKey(const QString& text, const QString& key);
|
QString signWithKey(const QString& text, const QString& key);
|
||||||
|
void chooseSecurityImage(uint imageID);
|
||||||
|
void getSecurityImage();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void securityImageResult(uint imageID);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// ALWAYS add SecurityImage enum values to the END of the enum.
|
||||||
|
// They must be in the same order as the images are listed in
|
||||||
|
// SecurityImageSelection.qml
|
||||||
|
enum SecurityImage {
|
||||||
|
NONE = 0,
|
||||||
|
Cat,
|
||||||
|
Car,
|
||||||
|
Dog,
|
||||||
|
Stars,
|
||||||
|
Plane,
|
||||||
|
Gingerbread
|
||||||
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QStringList _publicKeys{};
|
QStringList _publicKeys{};
|
||||||
|
SecurityImage _chosenSecurityImage = SecurityImage::NONE;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_Wallet_h
|
#endif // hifi_Wallet_h
|
||||||
|
|
|
@ -88,7 +88,7 @@
|
||||||
|
|
||||||
function onScreenChanged(type, url) {
|
function onScreenChanged(type, url) {
|
||||||
onMarketplaceScreen = type === "Web" && url === MARKETPLACE_URL_INITIAL;
|
onMarketplaceScreen = type === "Web" && url === MARKETPLACE_URL_INITIAL;
|
||||||
wireEventBridge(type === "QML" && (url === MARKETPLACE_CHECKOUT_QML_PATH || url === MARKETPLACE_INVENTORY_QML_PATH));
|
wireEventBridge(type === "QML" && (url === MARKETPLACE_CHECKOUT_QML_PATH || url === MARKETPLACE_INVENTORY_QML_PATH || url === MARKETPLACE_SECURITY_QML_PATH));
|
||||||
// for toolbar mode: change button to active when window is first openend, false otherwise.
|
// for toolbar mode: change button to active when window is first openend, false otherwise.
|
||||||
marketplaceButton.editProperties({ isActive: onMarketplaceScreen });
|
marketplaceButton.editProperties({ isActive: onMarketplaceScreen });
|
||||||
if (type === "Web" && url.indexOf(MARKETPLACE_URL) !== -1) {
|
if (type === "Web" && url.indexOf(MARKETPLACE_URL) !== -1) {
|
||||||
|
@ -219,7 +219,6 @@
|
||||||
tablet.gotoWebScreen(message.referrerURL, MARKETPLACES_INJECT_SCRIPT_URL);
|
tablet.gotoWebScreen(message.referrerURL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
break;
|
break;
|
||||||
case 'securityImageSelection_cancelClicked':
|
case 'securityImageSelection_cancelClicked':
|
||||||
console.log("ZRF HERE " + message.referrerURL);
|
|
||||||
tablet.gotoWebScreen(message.referrerURL, MARKETPLACES_INJECT_SCRIPT_URL);
|
tablet.gotoWebScreen(message.referrerURL, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue