From eb59f49530f5494ca810619e56727b12e71bc2b6 Mon Sep 17 00:00:00 2001 From: larteyoh Date: Sun, 27 Aug 2023 07:44:31 -0400 Subject: [PATCH] fix tests/ build --- qml/components/ProductDialog.qml | 3 +- qml/components/SettingsDialog.qml | 25 ++++++++++- qml/main.qml | 4 ++ qml/pages/ProfilePage.qml | 74 +++++++++++++++++++++++++++++++ src/core/seller.cpp | 1 - src/core/seller.hpp | 1 - src/core/settings.cpp | 2 + src/gui/user_controller.cpp | 5 +-- src/gui/user_controller.hpp | 1 - tests/CMakeLists.txt | 50 +++++++++++++-------- tests/auth_test.cpp | 8 ++-- tests/gui_qt_test.cpp | 2 +- 12 files changed, 143 insertions(+), 33 deletions(-) diff --git a/qml/components/ProductDialog.qml b/qml/components/ProductDialog.qml index 78c14ac..f8d1208 100644 --- a/qml/components/ProductDialog.qml +++ b/qml/components/ProductDialog.qml @@ -797,8 +797,7 @@ Popup { // List product let listing_key = User.listProduct( productNameField.text, - productDescriptionEdit.text, - productWeightField.text, + productDescriptionEdit.text, attributes, productCodeField.text, Backend.getCategoryIdByName(productCategoryBox.currentText), diff --git a/qml/components/SettingsDialog.qml b/qml/components/SettingsDialog.qml index 5ec0cb0..c79e701 100644 --- a/qml/components/SettingsDialog.qml +++ b/qml/components/SettingsDialog.qml @@ -26,6 +26,7 @@ Popup { property alias language: languageBox property alias hideHomepageButton: hideHomepageButtonSwitch.checked property alias hidePriceDisplay: priceDisplaySwitch.checked + property alias hideWalletSyncBarOnFull: walletSyncBarSwitch.checked // Wallet settings property alias balanceDisplay: balanceDisplayBox.currentIndex//property alias balanceDisplay: balanceDisplayBox.currentText property alias balanceAmountPrecision: balancePrecisionBox.currentText @@ -75,6 +76,7 @@ Popup { language: languageBox.currentText,//currentIndex, hide_homepage_button: hideHomepageButtonSwitch.checked, hide_price_display: priceDisplaySwitch.checked, + hide_wallet_sync_bar: walletSyncBarSwitch.checked, /*window_width: Script.getJsonRootObject()["window_width"], window_height: Script.getJsonRootObject()["window_height"], window_mode: Script.getJsonRootObject()["window_mode"],*/ @@ -457,6 +459,7 @@ Popup { onToggled: settingsDialog.save() } } + // hide price display Item { Layout.fillWidth: true Layout.preferredHeight: childrenRect.height @@ -475,6 +478,26 @@ Popup { backgroundCheckedColor: "#605185" onToggled: settingsDialog.save() } + } + // hide wallet sync bar(s) + Item { + Layout.fillWidth: true + Layout.preferredHeight: childrenRect.height + Text { + anchors.verticalCenter: walletSyncBarSwitch.verticalCenter + text: qsTr("Hide wallet sync bar on full:") + color: NeroshopComponents.Style.darkTheme ? "#ffffff" : "#000000" + } + + NeroshopComponents.Switch { + id: walletSyncBarSwitch + anchors.right: parent.right; anchors.rightMargin: 5 + //width: settingsStack.comboBoxWidth + checked: Script.getJsonRootObject()["hide_wallet_sync_bar"]//false + radius: 13 + backgroundCheckedColor: "#605185" + onToggled: settingsDialog.save() + } } } // RowLayout2 } // GroupBox2 @@ -648,7 +671,7 @@ Popup { id: requirePasswordOnWithdrawalSwitch anchors.right: parent.right; anchors.rightMargin: 5 //width: settingsStack.comboBoxWidth - checked: Script.getJsonRootObject()["monero"]["wallet"]["require_password_on_withdrawal"]//true + checked: true // can NEVER be modified!! radius: 13 backgroundCheckedColor: "#605185" onToggled: settingsDialog.save() diff --git a/qml/main.qml b/qml/main.qml index 616f6bb..20690d0 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -297,6 +297,10 @@ ApplicationWindow { repeat: true // If repeat is true the timer is triggered repeatedly at the specified interval onTriggered: { moneroDaemonSyncBar.value = Wallet.getSyncPercentage() + + if(settingsDialog.hideWalletSyncBarOnFull && (moneroDaemonSyncBar.value >= 1.0)) { + moneroDaemonSyncBar.parent.visible = false + } } } diff --git a/qml/pages/ProfilePage.qml b/qml/pages/ProfilePage.qml index 32efb3a..e6913ff 100644 --- a/qml/pages/ProfilePage.qml +++ b/qml/pages/ProfilePage.qml @@ -109,7 +109,23 @@ Page { width: rateDialogContent.width - spacing Button { Layout.fillWidth: true + implicitHeight: 40 text: "Cancel" + background: Rectangle { + color: "#f5c5c5" + radius: 18 + } + contentItem: Text { + text: parent.text + color: "#000000" + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + MouseArea { + anchors.fill: parent + onPressed: mouse.accepted = false + cursorShape: Qt.PointingHandCursor + } onClicked: { rateDialog.reject() } @@ -117,7 +133,23 @@ Page { Button { Layout.fillWidth: true + implicitHeight: 40 text: "Rate" + background: Rectangle { + color: "#e0e0c0"//"#e0e0e0" + radius: 18 + } + contentItem: Text { + text: parent.text + color: "#000000" + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + MouseArea { + anchors.fill: parent + onPressed: mouse.accepted = false + cursorShape: Qt.PointingHandCursor + } onClicked: { rateDialog.accept() } @@ -169,6 +201,11 @@ Page { color: parent.checked ? "red" : "#808080" radius: 5 } + MouseArea { + anchors.fill: parent + onPressed: mouse.accepted = false + cursorShape: Qt.PointingHandCursor + } } Button { width: (commentTextArea.width / 2) - parent.spacing @@ -187,6 +224,11 @@ Page { color: parent.checked ? "green" : "#808080" radius: 5 } + MouseArea { + anchors.fill: parent + onPressed: mouse.accepted = false + cursorShape: Qt.PointingHandCursor + } } } @@ -298,7 +340,23 @@ Page { width: messageDialogContent.width - spacing Button { Layout.fillWidth: true + implicitHeight: 40 text: "Cancel" + background: Rectangle { + color: "#f5c5c5" + radius: 18 + } + contentItem: Text { + text: parent.text + color: "#000000" + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + MouseArea { + anchors.fill: parent + onPressed: mouse.accepted = false + cursorShape: Qt.PointingHandCursor + } onClicked: { messageDialog.reject() } @@ -306,7 +364,23 @@ Page { Button { Layout.fillWidth: true + implicitHeight: 40 text: "Send" + background: Rectangle { + color: "#e0c0e0"//"#e0e0e0" + radius: 18 + } + contentItem: Text { + text: parent.text + color: "#000000" + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + MouseArea { + anchors.fill: parent + onPressed: mouse.accepted = false + cursorShape: Qt.PointingHandCursor + } onClicked: { messageDialog.accept() } diff --git a/src/core/seller.cpp b/src/core/seller.cpp index 3fa11e5..749120f 100644 --- a/src/core/seller.cpp +++ b/src/core/seller.cpp @@ -44,7 +44,6 @@ neroshop::Seller::~Seller() { std::string neroshop::Seller::list_item( const std::string& name, const std::string& description, - double weight, const std::vector& attributes, const std::string& product_code, int category_id, diff --git a/src/core/seller.hpp b/src/core/seller.hpp index c0e652f..ab3e0d1 100644 --- a/src/core/seller.hpp +++ b/src/core/seller.hpp @@ -25,7 +25,6 @@ public: std::string list_item( const std::string& name, const std::string& description, - double weight, const std::vector& attributes, const std::string& product_code, int category_id, diff --git a/src/core/settings.cpp b/src/core/settings.cpp index 22b481d..f425b37 100644 --- a/src/core/settings.cpp +++ b/src/core/settings.cpp @@ -180,6 +180,7 @@ bool neroshop::create_json() { root_obj.insert(QString("language"), QJsonValue("English")); root_obj.insert(QString("hide_homepage_button"), QJsonValue(false)); root_obj.insert(QString("hide_price_display"), QJsonValue(false)); + root_obj.insert(QString("hide_wallet_sync_bar"), QJsonValue(false)); root_obj.insert(QString("wallet_directory"), QJsonValue("")); /*root_obj.insert(QString("window_width"), QJsonValue(1280)); root_obj.insert(QString("window_height"), QJsonValue(900));//720)); @@ -251,6 +252,7 @@ bool neroshop::create_json() { settings_json["language"] = "English"; settings_json["hide_homepage_button"] = false; settings_json["hide_price_display"] = false; + settings_json["hide_wallet_sync_bar"] = false; settings_json["wallet_directory"] = ""; // leave blank to use default /*settings_json["window_width"] = 1280; settings_json["window_height"] = 900;//720; diff --git a/src/gui/user_controller.cpp b/src/gui/user_controller.cpp index bef202c..a3ed6a0 100644 --- a/src/gui/user_controller.cpp +++ b/src/gui/user_controller.cpp @@ -20,7 +20,7 @@ neroshop::UserController::~UserController() { } //---------------------------------------------------------------- QString neroshop::UserController::listProduct(const QString& name, const QString& description, - double weight, const QList& attributes, + const QList& attributes, const QString& product_code, int category_id, const QList& subcategory_ids, const QStringList& tags, const QList& images, int quantity, double price, const QString& currency, const QString& condition, const QString& location) { if (!_user) @@ -73,7 +73,6 @@ int quantity, double price, const QString& currency, const QString& condition, c // Add the attribute to the vector attributesVector.push_back(attribute); } - //return attributesVector; std::vector subcategoryIdVector; for(const int& subcategory_id : subcategory_ids) { @@ -93,7 +92,6 @@ int quantity, double price, const QString& currency, const QString& condition, c if(imageMap.contains("size")) image.size = imageMap.value("size").toInt(); if(imageMap.contains("id")) image.id = imageMap.value("id").toInt(); if(imageMap.contains("source")) image.source = imageMap.value("source").toString().toStdString(); - //if(imageMap.contains("")) imagesVector.push_back(image); } @@ -101,7 +99,6 @@ int quantity, double price, const QString& currency, const QString& condition, c auto listing_key = seller->list_item( name.toStdString(), description.toStdString(), - weight, attributesVector, product_code.toStdString(), category_id, diff --git a/src/gui/user_controller.hpp b/src/gui/user_controller.hpp index 07ad2e4..8ac3a3c 100644 --- a/src/gui/user_controller.hpp +++ b/src/gui/user_controller.hpp @@ -33,7 +33,6 @@ public: Q_INVOKABLE QString listProduct( const QString& name, const QString& description, - double weight, const QList& attributes, const QString& product_code, int category_id, diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2da292e..d3c1b08 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -7,9 +7,13 @@ set(neroshop_src_dir ${neroshop_root}/src) set(neroshop_crypto_src ${NEROSHOP_CORE_SRC_DIR}/crypto/rsa.cpp ${NEROSHOP_CORE_SRC_DIR}/crypto/sha256.cpp + ${NEROSHOP_CORE_SRC_DIR}/crypto/sha3.cpp ) -set(neroshop_database_src ${NEROSHOP_CORE_SRC_DIR}/database/sqlite.cpp) +set(neroshop_database_src + ${NEROSHOP_CORE_SRC_DIR}/database/database.cpp + ${NEROSHOP_CORE_SRC_DIR}/database/sqlite.cpp +) set(neroshop_network_src ${NEROSHOP_CORE_SRC_DIR}/network/i2p.cpp @@ -23,35 +27,45 @@ set(neroshop_price_src ${NEROSHOP_CORE_SRC_DIR}/price/cointelegraph.cpp ${NEROSHOP_CORE_SRC_DIR}/price/cryptorank.cpp ${NEROSHOP_CORE_SRC_DIR}/price/cryptowatch.cpp + ${NEROSHOP_CORE_SRC_DIR}/price/currency_converter.cpp ${NEROSHOP_CORE_SRC_DIR}/price/fawazahmed0.cpp ${NEROSHOP_CORE_SRC_DIR}/price/kraken.cpp ) set(neroshop_protocol_src + ${NEROSHOP_CORE_SRC_DIR}/protocol/messages/msgpack.cpp + ${NEROSHOP_CORE_SRC_DIR}/protocol/p2p/kademlia.cpp + ${NEROSHOP_CORE_SRC_DIR}/protocol/p2p/mapper.cpp + ${NEROSHOP_CORE_SRC_DIR}/protocol/p2p/node.cpp + ${NEROSHOP_CORE_SRC_DIR}/protocol/p2p/routing_table.cpp + ${NEROSHOP_CORE_SRC_DIR}/protocol/p2p/serializer.cpp ${NEROSHOP_CORE_SRC_DIR}/protocol/rpc/json_rpc.cpp + ${NEROSHOP_CORE_SRC_DIR}/protocol/transport/client.cpp + ${NEROSHOP_CORE_SRC_DIR}/protocol/transport/ip_address.cpp + ${NEROSHOP_CORE_SRC_DIR}/protocol/transport/server.cpp + ${NEROSHOP_CORE_SRC_DIR}/protocol/transport/zmq_client.cpp + ${NEROSHOP_CORE_SRC_DIR}/protocol/transport/zmq_server.cpp ) -set(neroshop_util_src - ${NEROSHOP_CORE_SRC_DIR}/util/downloader.cpp - ${NEROSHOP_CORE_SRC_DIR}/util/extractor.cpp - ${NEROSHOP_CORE_SRC_DIR}/util/regex.cpp - ${NEROSHOP_CORE_SRC_DIR}/util/updater.cpp +set(neroshop_tools_src + ${NEROSHOP_CORE_SRC_DIR}/tools/base64.cpp + ${NEROSHOP_CORE_SRC_DIR}/tools/downloader.cpp + ${NEROSHOP_CORE_SRC_DIR}/tools/extractor.cpp + ${NEROSHOP_CORE_SRC_DIR}/tools/logger.cpp + ${NEROSHOP_CORE_SRC_DIR}/tools/process.cpp + ${NEROSHOP_CORE_SRC_DIR}/tools/regex.cpp + ${NEROSHOP_CORE_SRC_DIR}/tools/script.cpp + ${NEROSHOP_CORE_SRC_DIR}/tools/timestamp.cpp + ${NEROSHOP_CORE_SRC_DIR}/tools/updater.cpp ) set(neroshop_core_src - ${NEROSHOP_CORE_SRC_DIR}/buyer.cpp ${NEROSHOP_CORE_SRC_DIR}/cart.cpp - ${NEROSHOP_CORE_SRC_DIR}/catalog.cpp - ${NEROSHOP_CORE_SRC_DIR}/client.cpp - ${NEROSHOP_CORE_SRC_DIR}/config.cpp - ${NEROSHOP_CORE_SRC_DIR}/currency_converter.cpp - ${NEROSHOP_CORE_SRC_DIR}/database.cpp - ${NEROSHOP_CORE_SRC_DIR}/item.cpp + ${NEROSHOP_CORE_SRC_DIR}/listing.cpp ${NEROSHOP_CORE_SRC_DIR}/order.cpp - ${NEROSHOP_CORE_SRC_DIR}/process.cpp - ${NEROSHOP_CORE_SRC_DIR}/script.cpp + ${NEROSHOP_CORE_SRC_DIR}/product.cpp ${NEROSHOP_CORE_SRC_DIR}/seller.cpp - ${NEROSHOP_CORE_SRC_DIR}/server.cpp + ${NEROSHOP_CORE_SRC_DIR}/settings.cpp # TODO: move to tools or not? ${NEROSHOP_CORE_SRC_DIR}/user.cpp ${NEROSHOP_CORE_SRC_DIR}/wallet.cpp ${neroshop_crypto_src} @@ -59,8 +73,8 @@ set(neroshop_core_src ${neroshop_network_src} ${neroshop_price_src} ${neroshop_protocol_src} - ${neroshop_util_src} - #[[${neroshop__src}]] + ${neroshop_tools_src} + #[[${neroshop_wallet_src}]] ) set(neroshop_srcs ${neroshop_core_src}) #set(neroshop_headers ) # not needed diff --git a/tests/auth_test.cpp b/tests/auth_test.cpp index 63a6d3c..5773114 100644 --- a/tests/auth_test.cpp +++ b/tests/auth_test.cpp @@ -40,7 +40,7 @@ static void register_user() { wallet->create_random(wallet_pwd, wallet_confirm_pwd, NEROSHOP_DEFAULT_WALLET_PATH + "/" + wallet_name); // Provide user with their mnemonic std::cout << "Store these words safely. These 25 words are the key to your account. If you lose them, your account goes bye-bye:\n\033[1;36m"; - std::cout << wallet->get_mnemonic() << "\033[0m" << std::endl; + std::cout << wallet->get_seed() << "\033[0m" << std::endl; // And their secret view and spend key pairs too ... std::cout << "Secret view key: " << wallet->get_monero_wallet()->get_private_view_key() << std::endl; std::cout << "Secret spend key: " << wallet->get_monero_wallet()->get_private_spend_key() << std::endl; @@ -102,11 +102,11 @@ static bool auth_with_seed() { //---------------------------- Wallet * wallet = new Wallet(); // Initialize monero wallet with existing wallet mnemonic - std::string wallet_mnemonic;// = "hefty value later extra artistic firm radar yodel talent future fungal nutshell because sanity awesome nail unjustly rage unafraid cedar delayed thumbs comb custom sanity"; + std::string wallet_seed;// = "hefty value later extra artistic firm radar yodel talent future fungal nutshell because sanity awesome nail unjustly rage unafraid cedar delayed thumbs comb custom sanity"; std::cout << "Please enter your wallet mnemonic:\n"; - std::getline(std::cin, wallet_mnemonic); + std::getline(std::cin, wallet_seed); // todo: allow user to specify a custom location for the wallet keyfile or use a default location - wallet->restore_from_mnemonic(wallet_mnemonic); + wallet->restore_from_seed(wallet_seed); // Get the hash of the primary address std::string primary_address = wallet->get_monero_wallet()->get_primary_address(); std::string user_auth_key = neroshop_crypto::sha256(primary_address); // temp diff --git a/tests/gui_qt_test.cpp b/tests/gui_qt_test.cpp index 30f072c..741d11e 100644 --- a/tests/gui_qt_test.cpp +++ b/tests/gui_qt_test.cpp @@ -2,7 +2,7 @@ // neroshop /*#include "../src/neroshop.hpp" using namespace neroshop;*/ -#include "../src/core/config.hpp" +#include "../src/core/settings.hpp" // Qt #include "main_window.hpp" #include