From 8ffd2293f4fdfd6fcf739a5eb91fe730505d64fe Mon Sep 17 00:00:00 2001 From: tobtoht Date: Sat, 12 Dec 2020 02:49:33 +0100 Subject: [PATCH] Consolidate exchanges to exchange tab --- src/CMakeLists.txt | 2 +- src/MorphTokenWidget.ui | 2 +- src/appcontext.cpp | 4 +- src/mainwindow.cpp | 24 +++------ src/mainwindow.h | 3 +- src/mainwindow.ui | 105 +++++++++++++++++++++++++--------------- src/utils/config.cpp | 3 +- src/utils/config.h | 3 +- 8 files changed, 80 insertions(+), 66 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1e3ef97..1be194c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -121,7 +121,7 @@ if(DONATE_BEG) endif() if(XMRTO) - target_compile_definitions(feather PRIVATE XMRTO=1) + target_compile_definitions(feather PRIVATE HAS_XMRTO=1) endif() if(MORPHTOKEN) diff --git a/src/MorphTokenWidget.ui b/src/MorphTokenWidget.ui index fcdbff7..85414db 100644 --- a/src/MorphTokenWidget.ui +++ b/src/MorphTokenWidget.ui @@ -29,7 +29,7 @@ - 1 + 0 diff --git a/src/appcontext.cpp b/src/appcontext.cpp index 590c946..ddbad36 100644 --- a/src/appcontext.cpp +++ b/src/appcontext.cpp @@ -147,7 +147,7 @@ AppContext::AppContext(QCommandLineParser *cmdargs) { AppContext::prices = new Prices(); // xmr.to -#ifdef XMRTO +#ifdef HAS_XMRTO this->XMRTo = new XmrTo(this); #endif @@ -419,7 +419,7 @@ void AppContext::onWSMessage(const QJsonObject &msg) { QJsonObject fiat_rates = msg.value("data").toObject(); AppContext::prices->fiatPricesReceived(fiat_rates); } -#if defined(XMRTO) +#if defined(HAS_XMRTO) else if(cmd == "xmrto_rates") { auto xmr_rates = msg.value("data").toObject(); this->XMRTo->onRatesReceived(xmr_rates); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 4d65a0a..1f93c6b 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -106,7 +106,7 @@ MainWindow::MainWindow(AppContext *ctx, QWidget *parent) : connect(ui->actionShow_debug_info, &QAction::triggered, this, &MainWindow::showDebugInfo); connect(ui->actionOfficialWebsite, &QAction::triggered, [=] { Utils::externalLinkWarning("https://featherwallet.org"); }); -#if defined(XMRTO) +#if defined(HAS_XMRTO) // xmr.to connects/widget connect(ui->xmrToWidget, &XMRToWidget::viewOrder, m_ctx->XMRTo, &XmrTo::onViewOrder); connect(ui->xmrToWidget, &XMRToWidget::getRates, m_ctx->XMRTo, &XmrTo::onGetRates); @@ -118,11 +118,11 @@ MainWindow::MainWindow(AppContext *ctx, QWidget *parent) : connect(m_ctx->XMRTo, &XmrTo::openURL, this, [=](const QString &url){ Utils::externalLinkWarning(url); }); ui->xmrToWidget->setHistoryModel(m_ctx->XMRTo->tableModel); #else - ui->tabWidget->setTabVisible(Tabs::XMR_TO, false); + ui->tabExchanges->setTabVisible(0, false); #endif #ifndef HAS_MORPHTOKEN - ui->tabWidget->setTabVisible(Tabs::MORPHTOKEN, false); + ui->tabExchanges->setTabVisible(1, false); #endif #if defined(Q_OS_LINUX) @@ -403,20 +403,12 @@ void MainWindow::initMenu() { m_tabShowHideMapper["Calc"] = new ToggleTab(ui->tabCalc, "Calc", "Calc", ui->actionShow_calc, Config::showTabCalc); m_tabShowHideSignalMapper->setMapping(ui->actionShow_calc, "Calc"); -#if defined(HAS_MORPHTOKEN) - connect(ui->actionShow_MorphToken, &QAction::triggered, m_tabShowHideSignalMapper, QOverload<>::of(&QSignalMapper::map)); - m_tabShowHideMapper["MorphToken"] = new ToggleTab(ui->tabMorphToken, "MorphToken", "MorphToken", ui->actionShow_MorphToken, Config::showTabMorphToken); - m_tabShowHideSignalMapper->setMapping(ui->actionShow_MorphToken, "MorphToken"); +#if defined(HAS_XMRTO) || defined(HAS_MORPHTOKEN) + connect(ui->actionShow_Exchange, &QAction::triggered, m_tabShowHideSignalMapper, QOverload<>::of(&QSignalMapper::map)); + m_tabShowHideMapper["Exchange"] = new ToggleTab(ui->tabExchange, "Exchange", "Exchange", ui->actionShow_Exchange, Config::showTabExchange); + m_tabShowHideSignalMapper->setMapping(ui->actionShow_Exchange, "Exchange"); #else - ui->actionShow_MorphToken->setVisible(false); -#endif - -#if defined(XMRTO) - connect(ui->actionShow_xmr_to, &QAction::triggered, m_tabShowHideSignalMapper, QOverload<>::of(&QSignalMapper::map)); - m_tabShowHideMapper["XMRto"] = new ToggleTab(ui->tabXmrTo, "XMRto", "XMR.to", ui->actionShow_xmr_to, Config::showTabXMRto); - m_tabShowHideSignalMapper->setMapping(ui->actionShow_xmr_to, "XMRto"); -#else - ui->actionShow_xmr_to->setVisible(false); + ui->actionShow_Exchanges->setVisible(false); #endif #if defined(HAS_XMRIG) diff --git a/src/mainwindow.h b/src/mainwindow.h index 9ee6f38..b5e2496 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -76,8 +76,7 @@ public: RECEIVE, COINS, CALC, - MORPHTOKEN, - XMR_TO, + EXCHANGES, XMRIG }; diff --git a/src/mainwindow.ui b/src/mainwindow.ui index bf486f1..0b916a9 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -96,7 +96,7 @@ - 1 + 0 true @@ -272,29 +272,15 @@ - + - :/assets/images/morphtoken.png:/assets/images/morphtoken.png + :/assets/images/update.png:/assets/images/update.png - MorphToken + Exchange - - - - - - - - - - :/assets/images/xmrto.png:/assets/images/xmrto.png - - - XMR.to - - + 0 @@ -305,26 +291,66 @@ 0 - 1 + 0 - - - - - - Qt::Vertical + + + 0 - - QSizePolicy::Preferred - - - - 20 - 0 - - - + + + + :/assets/images/xmrto.png:/assets/images/xmrto.png + + + XMR.to + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + + :/assets/images/morphtoken.png:/assets/images/morphtoken.png + + + MorphToken + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + @@ -465,8 +491,7 @@ - - + @@ -713,9 +738,9 @@ Import transaction - + - Show MorphToken + Show Exchange diff --git a/src/utils/config.cpp b/src/utils/config.cpp index 33eb201..ef15354 100644 --- a/src/utils/config.cpp +++ b/src/utils/config.cpp @@ -41,8 +41,7 @@ static const QHash configStrings = { {Config::nodeSource,{QS("nodeSource"), 0}}, {Config::useOnionNodes,{QS("useOnionNodes"), false}}, {Config::showTabCoins,{QS("showTabCoins"), false}}, - {Config::showTabMorphToken, {QS("showTabMorphToken"), false}}, - {Config::showTabXMRto,{QS("showTabXMRto"), true}}, + {Config::showTabExchange, {QS("showTabExchange"), true}}, {Config::showTabXMRig,{QS("showTabXMRig"), false}}, {Config::showTabCalc,{QS("showTabCalc"), true}}, {Config::geometry, {QS("geometry"), {}}}, diff --git a/src/utils/config.h b/src/utils/config.h index 4e2a218..b043d8e 100644 --- a/src/utils/config.h +++ b/src/utils/config.h @@ -39,8 +39,7 @@ public: nodeSource, useOnionNodes, showTabCoins, - showTabMorphToken, - showTabXMRto, + showTabExchange, showTabCalc, showTabXMRig, geometry,