From b1160280fede0f1fd5775acb393e6aeebd15dc88 Mon Sep 17 00:00:00 2001 From: tobtoht Date: Wed, 21 Oct 2020 13:24:16 +0200 Subject: [PATCH] Mainwindow: fix tab order and stylization --- src/mainwindow.cpp | 27 +++++++++++++++------------ src/mainwindow.h | 11 +++++++++++ src/mainwindow.ui | 38 +++++++++++++++++++------------------- 3 files changed, 45 insertions(+), 31 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b6d9a35..faf6943 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -118,10 +118,9 @@ 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(5, false); + ui->tabWidget->setTabVisible(Tabs::XMR_TO, false); #endif - #if defined(Q_OS_LINUX) // system tray m_trayIcon = new QSystemTrayIcon(QIcon(":/assets/images/appicons/64x64.png")); @@ -183,6 +182,8 @@ MainWindow::MainWindow(AppContext *ctx, QWidget *parent) : connect(m_xmrig, &XMRigWidget::miningStarted, [=]{ m_ctx->setWindowTitle(true); }); connect(m_xmrig, &XMRigWidget::miningEnded, [=]{ m_ctx->setWindowTitle(false); }); +#else + ui->tabWidget->setTabVisible(Tabs::XMRIG, false); #endif // CCS/Reddit widget @@ -296,7 +297,7 @@ MainWindow::MainWindow(AppContext *ctx, QWidget *parent) : }); connect(ui->receiveWidget, &ReceiveWidget::showTransactions, [this](const QString &text) { ui->historyWidget->setSearchText(text); - ui->tabWidget->setCurrentIndex(1); //history + ui->tabWidget->setCurrentIndex(Tabs::HISTORY); }); // History @@ -344,7 +345,7 @@ MainWindow::MainWindow(AppContext *ctx, QWidget *parent) : connect(ui->coinsWidget, &CoinsWidget::sweepOutput, m_ctx, &AppContext::onSweepOutput); connect(m_ctx, &AppContext::walletClosing, [=]{ - ui->tabWidget->setCurrentIndex(0); + ui->tabWidget->setCurrentIndex(Tabs::HOME); }); // window title @@ -390,9 +391,14 @@ void MainWindow::initMenu() { connect(ui->actionShow_Coins, &QAction::triggered, m_tabShowHideSignalMapper, QOverload<>::of(&QSignalMapper::map)); m_tabShowHideMapper["Coins"] = new ToggleTab(ui->tabCoins, "Coins", "Coins", ui->actionShow_Coins, Config::showTabCoins); m_tabShowHideSignalMapper->setMapping(ui->actionShow_Coins, "Coins"); + + connect(ui->actionShow_calc, &QAction::triggered, m_tabShowHideSignalMapper, QOverload<>::of(&QSignalMapper::map)); + m_tabShowHideMapper["Calc"] = new ToggleTab(ui->tabCalc, "Calc", "Calc", ui->actionShow_calc, Config::showTabCalc); + m_tabShowHideSignalMapper->setMapping(ui->actionShow_calc, "Calc"); + #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_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); @@ -405,9 +411,6 @@ void MainWindow::initMenu() { #else ui->actionShow_XMRig->setVisible(false); #endif - connect(ui->actionShow_calc, &QAction::triggered, m_tabShowHideSignalMapper, QOverload<>::of(&QSignalMapper::map)); - m_tabShowHideMapper["Calc"] = new ToggleTab(ui->tabCalc, "Calc", "Calc", ui->actionShow_calc, Config::showTabCalc); - m_tabShowHideSignalMapper->setMapping(ui->actionShow_calc, "Calc"); for (const auto &key: m_tabShowHideMapper.keys()) { const auto toggleTab = m_tabShowHideMapper.value(key); @@ -1008,17 +1011,17 @@ void MainWindow::donateButtonClicked() { donation = 1.337; ui->sendWidget->fill(m_ctx->featherDonationAddress, "Donation to the Feather development team", donation); - ui->tabWidget->setCurrentIndex(2); + ui->tabWidget->setCurrentIndex(Tabs::SEND); } void MainWindow::showHistoryTab() { this->raise(); - ui->tabWidget->setCurrentIndex(1); + ui->tabWidget->setCurrentIndex(Tabs::HISTORY); } void MainWindow::showSendTab() { this->raise(); - ui->tabWidget->setCurrentIndex(2); + ui->tabWidget->setCurrentIndex(Tabs::SEND); } void MainWindow::showCalcWindow() { @@ -1027,7 +1030,7 @@ void MainWindow::showCalcWindow() { void MainWindow::showSendScreen(const CCSEntry &entry) { ui->sendWidget->fill(entry); - ui->tabWidget->setCurrentIndex(2); + ui->tabWidget->setCurrentIndex(Tabs::SEND); } void MainWindow::onViewOnBlockExplorer(const QString &txid) { diff --git a/src/mainwindow.h b/src/mainwindow.h index 6832dc7..e676a35 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -65,6 +65,17 @@ public: qreal screenDpiPhysical; qreal screenRatio; + enum Tabs { + HOME = 0, + HISTORY, + SEND, + RECEIVE, + COINS, + CALC, + XMR_TO, + XMRIG + }; + public slots: void initWidgets(); void initMenu(); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 0409137..bab9f11 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -224,13 +224,27 @@ + + + + :/assets/images/coldcard.png:/assets/images/coldcard.png + + + Calc + + + + + + + :/assets/images/xmrto.png:/assets/images/xmrto.png - xmr.to + XMR.to @@ -266,27 +280,13 @@ - - - - :/assets/images/coldcard.png:/assets/images/coldcard.png - - - Calc - - - - - - - :/assets/images/xmrig.ico:/assets/images/xmrig.ico - XmrRig + XMRig @@ -305,7 +305,7 @@ 0 0 894 - 22 + 30 @@ -415,8 +415,8 @@ View - + @@ -505,7 +505,7 @@ - Show Xmr.To + Show XMR.to