From 184d8666140d34f45741888f949e8476ee6c044c Mon Sep 17 00:00:00 2001 From: tobtoht Date: Sun, 23 May 2021 15:58:28 +0200 Subject: [PATCH] MainWindow: add account id to title --- src/mainwindow.cpp | 18 +++++++++++------- src/mainwindow.h | 2 +- src/widgets/xmrigwidget.cpp | 7 +++++++ src/widgets/xmrigwidget.h | 3 +++ 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 5429cb7..1fe25b6 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -199,8 +199,8 @@ void MainWindow::initWidgets() { m_xmrig = new XMRigWidget(m_ctx, this); ui->xmrRigLayout->addWidget(m_xmrig); - connect(m_xmrig, &XMRigWidget::miningStarted, [this]{ this->setTitle(true); }); - connect(m_xmrig, &XMRigWidget::miningEnded, [this]{ this->setTitle(false); }); + connect(m_xmrig, &XMRigWidget::miningStarted, [this]{ this->updateTitle(); }); + connect(m_xmrig, &XMRigWidget::miningEnded, [this]{ this->updateTitle(); }); #else ui->tabWidget->setTabVisible(Tabs::XMRIG, false); #endif @@ -361,6 +361,7 @@ void MainWindow::initWalletContext() { // Wallet connect(m_ctx->wallet.get(), &Wallet::connectionStatusChanged, this, &MainWindow::onConnectionStatusChanged); + connect(m_ctx->wallet.get(), &Wallet::currentSubaddressAccountChanged, [this]{this->updateTitle();}); } void MainWindow::startupWarning() { @@ -461,7 +462,7 @@ void MainWindow::onWalletOpened() { m_coinsWidget->setModel(m_ctx->wallet->coinsModel(), m_ctx->wallet->coins()); this->updatePasswordIcon(); - this->setTitle(false); + this->updateTitle(); m_ctx->nodes->connectToNode(); m_updateBytes.start(250); @@ -1354,13 +1355,16 @@ QString MainWindow::getHardwareDevice() { return "Unknown"; } -void MainWindow::setTitle(bool mining) { - auto title = QString("Feather - [%1]").arg(this->walletName()); - if (m_ctx->wallet && m_ctx->wallet->viewOnly()) +void MainWindow::updateTitle() { + QString title = QString("%1 (#%2)").arg(this->walletName(), QString::number(m_ctx->wallet->currentSubaddressAccount())); + + if (m_ctx->wallet->viewOnly()) title += " [view-only]"; - if (mining) + if (m_xmrig->isMining()) title += " [mining]"; + title += " - Feather"; + this->setWindowTitle(title); } diff --git a/src/mainwindow.h b/src/mainwindow.h index 4d14251..22acbb2 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -200,7 +200,7 @@ private: QString getPlatformTag(); void displayWalletErrorMsg(const QString &err); QString getHardwareDevice(); - void setTitle(bool mining); + void updateTitle(); void donationNag(); void updateRecentlyOpened(const QString &filename); diff --git a/src/widgets/xmrigwidget.cpp b/src/widgets/xmrigwidget.cpp index 5a4a98d..aef8e7c 100644 --- a/src/widgets/xmrigwidget.cpp +++ b/src/widgets/xmrigwidget.cpp @@ -115,6 +115,10 @@ XMRigWidget::XMRigWidget(QSharedPointer ctx, QWidget *parent) } } +bool XMRigWidget::isMining() { + return m_isMining; +} + void XMRigWidget::onWalletClosed() { this->onStopClicked(); this->onClearClicked(); @@ -173,6 +177,7 @@ void XMRigWidget::onStartClicked() { m_XMRig->start(xmrigPath, m_threads, address, username, password, ui->relayTor->isChecked(), ui->check_tls->isChecked()); ui->btn_start->setEnabled(false); ui->btn_stop->setEnabled(true); + m_isMining = true; emit miningStarted(); } @@ -181,6 +186,7 @@ void XMRigWidget::onStopClicked() { ui->btn_start->setEnabled(true); ui->btn_stop->setEnabled(false); ui->label_status->hide(); + m_isMining = false; emit miningEnded(); } @@ -200,6 +206,7 @@ void XMRigWidget::onProcessError(const QString &msg) { ui->btn_start->setEnabled(true); ui->btn_stop->setEnabled(false); ui->label_status->hide(); + m_isMining = false; emit miningEnded(); } diff --git a/src/widgets/xmrigwidget.h b/src/widgets/xmrigwidget.h index cadd801..fd800a4 100644 --- a/src/widgets/xmrigwidget.h +++ b/src/widgets/xmrigwidget.h @@ -25,6 +25,8 @@ public: ~XMRigWidget() override; QStandardItemModel *model(); + bool isMining(); + public slots: void onWalletClosed(); void onStartClicked(); @@ -55,6 +57,7 @@ private: QStandardItemModel *m_model; QMenu *m_contextMenu; + bool m_isMining = false; int m_threads; QStringList m_urls; QStringList m_pools{"pool.xmr.pt:9000", "pool.supportxmr.com:9000", "mine.xmrpool.net:443", "xmrpool.eu:9999", "xmr-eu1.nanopool.org:14433", "pool.minexmr.com:6666", "us-west.minexmr.com:6666", "monerohash.com:9999", "cryptonote.social:5555", "cryptonote.social:5556"};