From 0f027caba2a4acb3da5c7bcdff77d13f0282651d Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Sun, 11 Jul 2021 12:28:50 +0300 Subject: [PATCH] Use one global string for "CoinJoin" in gui related stuff (#4117) --- src/coinjoin/coinjoin-client.cpp | 6 +++--- src/qt/bitcoingui.cpp | 9 +++++---- src/qt/coincontroldialog.cpp | 4 ++-- src/qt/optionsdialog.cpp | 3 ++- src/qt/overviewpage.cpp | 30 +++++++++++++++++------------- src/qt/sendcoinsdialog.cpp | 9 +++++---- src/qt/transactiontablemodel.cpp | 12 ++++++------ src/qt/transactionview.cpp | 11 ++++++----- src/qt/utilitydialog.cpp | 5 +++-- src/util/system.cpp | 2 ++ src/util/system.h | 1 + src/wallet/wallet.cpp | 2 +- 12 files changed, 53 insertions(+), 41 deletions(-) diff --git a/src/coinjoin/coinjoin-client.cpp b/src/coinjoin/coinjoin-client.cpp index 657cd6c211..8e259da45f 100644 --- a/src/coinjoin/coinjoin-client.cpp +++ b/src/coinjoin/coinjoin-client.cpp @@ -316,7 +316,7 @@ std::string CCoinJoinClientSession::GetStatus(bool fWaitForBlock) switch (nState) { case POOL_STATE_IDLE: - return strprintf(_("%s is idle."), "CoinJoin"); + return strprintf(_("%s is idle."), gCoinJoinName); case POOL_STATE_QUEUE: if (nStatusMessageProgress % 70 <= 30) strSuffix = "."; @@ -338,7 +338,7 @@ std::string CCoinJoinClientSession::GetStatus(bool fWaitForBlock) strSuffix = "..."; return strprintf(_("Found enough users, signing ( waiting %s )"), strSuffix); case POOL_STATE_ERROR: - return strprintf(_("%s request incomplete: %s"), "CoinJoin", strLastMessage) + " " + _("Will retry..."); + return strprintf(_("%s request incomplete: %s"), gCoinJoinName, strLastMessage) + " " + _("Will retry..."); default: return strprintf(_("Unknown state: id = %u"), nState); } @@ -1522,7 +1522,7 @@ bool CCoinJoinClientSession::CreateCollateralTransaction(CMutableTransaction& tx mixingWallet.AvailableCoins(vCoins, true, &coin_control); if (vCoins.empty()) { - strReason = "CoinJoin requires a collateral transaction and could not locate an acceptable input!"; + strReason = strprintf("%s requires a collateral transaction and could not locate an acceptable input!", gCoinJoinName); return false; } diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 389803ffde..5ffeeec5a1 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -340,8 +340,9 @@ void BitcoinGUI::createActions() sendCoinsMenuAction->setStatusTip(tr("Send coins to a Dash address")); sendCoinsMenuAction->setToolTip(sendCoinsMenuAction->statusTip()); - coinJoinCoinsMenuAction = new QAction("&CoinJoin", this); - coinJoinCoinsMenuAction->setStatusTip(tr("Send %1 funds to a Dash address").arg("CoinJoin")); + QString strCoinJoinName = QString::fromStdString(gCoinJoinName); + coinJoinCoinsMenuAction = new QAction(QString("&%1").arg(strCoinJoinName), this); + coinJoinCoinsMenuAction->setStatusTip(tr("Send %1 funds to a Dash address").arg(strCoinJoinName)); coinJoinCoinsMenuAction->setToolTip(coinJoinCoinsMenuAction->statusTip()); receiveCoinsMenuAction = new QAction(tr("&Receive"), this); @@ -424,9 +425,9 @@ void BitcoinGUI::createActions() showHelpMessageAction->setMenuRole(QAction::NoRole); showHelpMessageAction->setStatusTip(tr("Show the %1 help message to get a list with possible Dash command-line options").arg(tr(PACKAGE_NAME))); - showCoinJoinHelpAction = new QAction(tr("%1 &information").arg("CoinJoin"), this); + showCoinJoinHelpAction = new QAction(tr("%1 &information").arg(strCoinJoinName), this); showCoinJoinHelpAction->setMenuRole(QAction::NoRole); - showCoinJoinHelpAction->setStatusTip(tr("Show the %1 basic information").arg("CoinJoin")); + showCoinJoinHelpAction->setStatusTip(tr("Show the %1 basic information").arg(strCoinJoinName)); connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked())); diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index 7f444703c7..3bbc26033a 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -668,11 +668,11 @@ void CoinControlDialog::updateView() if (fHideAdditional) { strHideButton = tr("Show all coins"); } else { - strHideButton = tr("Hide %1 coins").arg("CoinJoin"); + strHideButton = tr("Hide %1 coins").arg(QString::fromStdString(gCoinJoinName)); } } else { if (fHideAdditional) { - strHideButton = tr("Show all %1 coins").arg("CoinJoin"); + strHideButton = tr("Show all %1 coins").arg(QString::fromStdString(gCoinJoinName)); } else { strHideButton = tr("Show spendable coins only"); } diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index a264f6cacb..2bbdfb20bd 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -68,7 +68,7 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) : connect(ui->prune, SIGNAL(toggled(bool)), ui->pruneSize, SLOT(setEnabled(bool))); /* Wallet */ - ui->coinJoinEnabled->setText(tr("Enable %1 features").arg("CoinJoin")); + ui->coinJoinEnabled->setText(tr("Enable %1 features").arg(QString::fromStdString(gCoinJoinName))); /* Network elements init */ #ifndef USE_UPNP @@ -100,6 +100,7 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) : ui->stackedWidgetOptions->removeWidget(ui->pageCoinJoin); ui->btnCoinJoin->hide(); } else { + ui->btnCoinJoin->setText(QString::fromStdString(gCoinJoinName)); pageButtons->addButton(ui->btnWallet, pageButtons->buttons().size()); pageButtons->addButton(ui->btnCoinJoin, pageButtons->buttons().size()); } diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 8d04121e82..73b1bb2452 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -152,7 +152,9 @@ OverviewPage::OverviewPage(QWidget* parent) : ui->labelCoinJoinSyncStatus->setText("(" + tr("out of sync") + ")"); ui->labelTransactionsStatus->setText("(" + tr("out of sync") + ")"); - ui->labelAnonymizedText->setText(tr("%1 Balance").arg("CoinJoin")); + QString strCoinJoinName = QString::fromStdString(gCoinJoinName); + ui->labelCoinJoinHeader->setText(strCoinJoinName); + ui->labelAnonymizedText->setText(tr("%1 Balance").arg(strCoinJoinName)); // hide PS frame (helps to preserve saved size) // we'll setup and make it visible in coinJoinStatus() later @@ -505,6 +507,7 @@ void OverviewPage::coinJoinStatus(bool fForce) } ui->labelCoinJoinEnabled->setToolTip(strKeysLeftText); + QString strCoinJoinName = QString::fromStdString(gCoinJoinName); if (!walletModel->coinJoin().isMixing()) { if (nBestHeight != walletModel->coinJoin().getCachedBlocks()) { walletModel->coinJoin().setCachedBlocks(nBestHeight); @@ -512,7 +515,7 @@ void OverviewPage::coinJoinStatus(bool fForce) } setWidgetsVisible(false); - ui->toggleCoinJoin->setText(tr("Start %1").arg("CoinJoin")); + ui->toggleCoinJoin->setText(tr("Start %1").arg(strCoinJoinName)); QString strEnabled = tr("Disabled"); // Show how many keys left in advanced PS UI mode only @@ -540,7 +543,7 @@ void OverviewPage::coinJoinStatus(bool fForce) tr("Note: You can turn this message off in options."); ui->labelCoinJoinEnabled->setToolTip(strWarn); LogPrint(BCLog::COINJOIN, "OverviewPage::coinJoinStatus -- Very low number of keys left since last automatic backup, warning user and trying to create new backup...\n"); - QMessageBox::warning(this, "CoinJoin", strWarn, QMessageBox::Ok, QMessageBox::Ok); + QMessageBox::warning(this, strCoinJoinName, strWarn, QMessageBox::Ok, QMessageBox::Ok); } else { LogPrint(BCLog::COINJOIN, "OverviewPage::coinJoinStatus -- Very low number of keys left since last automatic backup, skipping warning and trying to create new backup...\n"); } @@ -552,7 +555,7 @@ void OverviewPage::coinJoinStatus(bool fForce) // It's still more or less safe to continue but warn user anyway LogPrint(BCLog::COINJOIN, "OverviewPage::coinJoinStatus -- WARNING! Something went wrong on automatic backup: %s\n", strBackupWarning.toStdString()); - QMessageBox::warning(this, "CoinJoin", + QMessageBox::warning(this, strCoinJoinName, tr("WARNING! Something went wrong on automatic backup") + ":

" + strBackupWarning, QMessageBox::Ok, QMessageBox::Ok); } @@ -560,7 +563,7 @@ void OverviewPage::coinJoinStatus(bool fForce) // Things are really broken, warn user and stop mixing immediately LogPrint(BCLog::COINJOIN, "OverviewPage::coinJoinStatus -- ERROR! Failed to create automatic backup: %s\n", strBackupError.toStdString()); - QMessageBox::warning(this, "CoinJoin", + QMessageBox::warning(this, strCoinJoinName, tr("ERROR! Failed to create automatic backup") + ":

" + strBackupError + "
" + tr("Mixing is disabled, please close your wallet and fix the issue!"), QMessageBox::Ok, QMessageBox::Ok); @@ -605,9 +608,10 @@ void OverviewPage::toggleCoinJoin(){ QSettings settings; // Popup some information on first mixing QString hasMixed = settings.value("hasMixed").toString(); + QString strCoinJoinName = QString::fromStdString(gCoinJoinName); if(hasMixed.isEmpty()){ - QMessageBox::information(this, "CoinJoin", - tr("If you don't want to see internal %1 fees/transactions select \"Most Common\" as Type on the \"Transactions\" tab.").arg("CoinJoin"), + QMessageBox::information(this, strCoinJoinName, + tr("If you don't want to see internal %1 fees/transactions select \"Most Common\" as Type on the \"Transactions\" tab.").arg(strCoinJoinName), QMessageBox::Ok, QMessageBox::Ok); settings.setValue("hasMixed", "hasMixed"); } @@ -617,8 +621,8 @@ void OverviewPage::toggleCoinJoin(){ const CAmount nMinAmount = options.getSmallestDenomination() + options.getMaxCollateralAmount(); if(m_balances.balance < nMinAmount) { QString strMinAmount(BitcoinUnits::formatWithUnit(nDisplayUnit, nMinAmount)); - QMessageBox::warning(this, "CoinJoin", - tr("%1 requires at least %2 to use.").arg("CoinJoin").arg(strMinAmount), + QMessageBox::warning(this, strCoinJoinName, + tr("%1 requires at least %2 to use.").arg(strCoinJoinName).arg(strMinAmount), QMessageBox::Ok, QMessageBox::Ok); return; } @@ -631,8 +635,8 @@ void OverviewPage::toggleCoinJoin(){ { //unlock was cancelled walletModel->coinJoin().resetCachedBlocks(); - QMessageBox::warning(this, "CoinJoin", - tr("Wallet is locked and user declined to unlock. Disabling %1.").arg("CoinJoin"), + QMessageBox::warning(this, strCoinJoinName, + tr("Wallet is locked and user declined to unlock. Disabling %1.").arg(strCoinJoinName), QMessageBox::Ok, QMessageBox::Ok); LogPrint(BCLog::COINJOIN, "OverviewPage::toggleCoinJoin -- Wallet is locked and user declined to unlock. Disabling CoinJoin.\n"); return; @@ -644,11 +648,11 @@ void OverviewPage::toggleCoinJoin(){ walletModel->coinJoin().resetCachedBlocks(); if (walletModel->coinJoin().isMixing()) { - ui->toggleCoinJoin->setText(tr("Start %1").arg("CoinJoin")); + ui->toggleCoinJoin->setText(tr("Start %1").arg(strCoinJoinName)); walletModel->coinJoin().resetPool(); walletModel->coinJoin().stopMixing(); } else { - ui->toggleCoinJoin->setText(tr("Stop %1").arg("CoinJoin")); + ui->toggleCoinJoin->setText(tr("Stop %1").arg(strCoinJoinName)); walletModel->coinJoin().startMixing(); } } diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index d5ee6cd523..2d6f674e85 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -141,7 +141,7 @@ SendCoinsDialog::SendCoinsDialog(bool _fCoinJoin, QWidget* parent) : if (_fCoinJoin) { ui->sendButton->setText(tr("S&end mixed funds")); - ui->sendButton->setToolTip(tr("Confirm the %1 send action").arg("CoinJoin")); + ui->sendButton->setToolTip(tr("Confirm the %1 send action").arg(QString::fromStdString(gCoinJoinName))); } else { ui->sendButton->setText(tr("S&end")); ui->sendButton->setToolTip(tr("Confirm the send action")); @@ -360,9 +360,10 @@ void SendCoinsDialog::send(QList recipients) questionString.append(formatted.join("
")); questionString.append("
"); + QString strCoinJoinName = QString::fromStdString(gCoinJoinName); if(m_coin_control->IsUsingCoinJoin()) { - questionString.append(tr("using") + " " + tr("%1 funds only").arg("CoinJoin") + ""); + questionString.append(tr("using") + " " + tr("%1 funds only").arg(strCoinJoinName) + ""); } else { questionString.append(tr("using") + " " + tr("any available funds") + ""); } @@ -386,7 +387,7 @@ void SendCoinsDialog::send(QList recipients) if (m_coin_control->IsUsingCoinJoin()) { questionString.append(QString("
%1") - .arg(tr("(%1 transactions have higher fees usually due to no change output being allowed)").arg("CoinJoin"))); + .arg(tr("(%1 transactions have higher fees usually due to no change output being allowed)").arg(strCoinJoinName))); } } @@ -408,7 +409,7 @@ void SendCoinsDialog::send(QList recipients) if (nInputs >= 10 && m_coin_control->IsUsingCoinJoin()) { questionString.append("
"); questionString.append(""); - questionString.append(tr("Warning: Using %1 with %2 or more inputs can harm your privacy and is not recommended").arg("CoinJoin").arg(10)); + questionString.append(tr("Warning: Using %1 with %2 or more inputs can harm your privacy and is not recommended").arg(strCoinJoinName).arg(10)); questionString.append(""); questionString.append(tr("Click to learn more")); questionString.append(""); diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp index 505e1e0a60..dfbba950ac 100644 --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -382,7 +382,7 @@ QString TransactionTableModel::formatTxType(const TransactionRecord *wtx) const case TransactionRecord::RecvFromOther: return tr("Received from"); case TransactionRecord::RecvWithCoinJoin: - return tr("Received via %1").arg("CoinJoin"); + return tr("Received via %1").arg(QString::fromStdString(gCoinJoinName)); case TransactionRecord::SendToAddress: case TransactionRecord::SendToOther: return tr("Sent to"); @@ -392,15 +392,15 @@ QString TransactionTableModel::formatTxType(const TransactionRecord *wtx) const return tr("Mined"); case TransactionRecord::CoinJoinMixing: - return tr("%1 Mixing").arg("CoinJoin"); + return tr("%1 Mixing").arg(QString::fromStdString(gCoinJoinName)); case TransactionRecord::CoinJoinCollateralPayment: - return tr("%1 Collateral Payment").arg("CoinJoin"); + return tr("%1 Collateral Payment").arg(QString::fromStdString(gCoinJoinName)); case TransactionRecord::CoinJoinMakeCollaterals: - return tr("%1 Make Collateral Inputs").arg("CoinJoin"); + return tr("%1 Make Collateral Inputs").arg(QString::fromStdString(gCoinJoinName)); case TransactionRecord::CoinJoinCreateDenominations: - return tr("%1 Create Denominations").arg("CoinJoin"); + return tr("%1 Create Denominations").arg(QString::fromStdString(gCoinJoinName)); case TransactionRecord::CoinJoinSend: - return tr("%1 Send").arg("CoinJoin"); + return tr("%1 Send").arg(QString::fromStdString(gCoinJoinName)); default: return QString(); diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index c8199cbab8..90a023009d 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -75,6 +75,7 @@ TransactionView::TransactionView(QWidget* parent) : dateWidget->setCurrentIndex(settings.value("transactionDate").toInt()); hlayout->addWidget(dateWidget); + QString strCoinJoinName = QString::fromStdString(gCoinJoinName); typeWidget = new QComboBox(this); typeWidget->setFixedWidth(TYPE_COLUMN_WIDTH - 1); typeWidget->addItem(tr("All"), TransactionFilterProxy::ALL_TYPES); @@ -83,11 +84,11 @@ TransactionView::TransactionView(QWidget* parent) : TransactionFilterProxy::TYPE(TransactionRecord::RecvFromOther)); typeWidget->addItem(tr("Sent to"), TransactionFilterProxy::TYPE(TransactionRecord::SendToAddress) | TransactionFilterProxy::TYPE(TransactionRecord::SendToOther)); - typeWidget->addItem(tr("%1 Send").arg("CoinJoin"), TransactionFilterProxy::TYPE(TransactionRecord::CoinJoinSend)); - typeWidget->addItem(tr("%1 Make Collateral Inputs").arg("CoinJoin"), TransactionFilterProxy::TYPE(TransactionRecord::CoinJoinMakeCollaterals)); - typeWidget->addItem(tr("%1 Create Denominations").arg("CoinJoin"), TransactionFilterProxy::TYPE(TransactionRecord::CoinJoinCreateDenominations)); - typeWidget->addItem(tr("%1 Mixing").arg("CoinJoin"), TransactionFilterProxy::TYPE(TransactionRecord::CoinJoinMixing)); - typeWidget->addItem(tr("%1 Collateral Payment").arg("CoinJoin"), TransactionFilterProxy::TYPE(TransactionRecord::CoinJoinCollateralPayment)); + typeWidget->addItem(tr("%1 Send").arg(strCoinJoinName), TransactionFilterProxy::TYPE(TransactionRecord::CoinJoinSend)); + typeWidget->addItem(tr("%1 Make Collateral Inputs").arg(strCoinJoinName), TransactionFilterProxy::TYPE(TransactionRecord::CoinJoinMakeCollaterals)); + typeWidget->addItem(tr("%1 Create Denominations").arg(strCoinJoinName), TransactionFilterProxy::TYPE(TransactionRecord::CoinJoinCreateDenominations)); + typeWidget->addItem(tr("%1 Mixing").arg(strCoinJoinName), TransactionFilterProxy::TYPE(TransactionRecord::CoinJoinMixing)); + typeWidget->addItem(tr("%1 Collateral Payment").arg(strCoinJoinName), TransactionFilterProxy::TYPE(TransactionRecord::CoinJoinCollateralPayment)); typeWidget->addItem(tr("To yourself"), TransactionFilterProxy::TYPE(TransactionRecord::SendToSelf)); typeWidget->addItem(tr("Mined"), TransactionFilterProxy::TYPE(TransactionRecord::Generated)); typeWidget->addItem(tr("Other"), TransactionFilterProxy::TYPE(TransactionRecord::Other)); diff --git a/src/qt/utilitydialog.cpp b/src/qt/utilitydialog.cpp index ae1ffb328b..3b3dbbf409 100644 --- a/src/qt/utilitydialog.cpp +++ b/src/qt/utilitydialog.cpp @@ -119,7 +119,8 @@ HelpMessageDialog::HelpMessageDialog(interfaces::Node& node, QWidget *parent, He ui->helpMessage->moveCursor(QTextCursor::Start); ui->scrollArea->setVisible(false); } else if (helpMode == pshelp) { - setWindowTitle(tr("%1 information").arg("CoinJoin")); + QString strCoinJoinName = QString::fromStdString(gCoinJoinName); + setWindowTitle(tr("%1 information").arg(strCoinJoinName)); ui->aboutMessage->setTextFormat(Qt::RichText); ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); @@ -150,7 +151,7 @@ It can only do this, however, if you have automatic backups enabled.
\ Consequently, users who have backups disabled will also have %1 disabled.
\ For more information, see the %1 documentation." ) - .arg("CoinJoin") + .arg(strCoinJoinName) .arg(GUIUtil::getThemedStyleQString(GUIUtil::ThemedStyle::TS_COMMAND)) .arg("https://docs.dash.org/en/stable/wallets/dashcore/coinjoin-instantsend.html") ); diff --git a/src/util/system.cpp b/src/util/system.cpp index 5d0f4aeba4..1a5c008a2f 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -84,6 +84,8 @@ const int64_t nStartupTime = GetTime(); //Dash only features bool fMasternodeMode = false; bool fDisableGovernance = false; +const std::string gCoinJoinName = "CoinJoin"; + /** nWalletBackups: 1..10 - number of automatic backups to keep diff --git a/src/util/system.h b/src/util/system.h index fc820e2772..a326a11b16 100644 --- a/src/util/system.h +++ b/src/util/system.h @@ -55,6 +55,7 @@ extern bool fMasternodeMode; extern bool fDisableGovernance; extern int nWalletBackups; +extern const std::string gCoinJoinName; // Application startup time (used for uptime calculation) int64_t GetStartupTime(); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 31b3151490..7a8766adef 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3700,7 +3700,7 @@ bool CWallet::CreateTransaction(const std::vector& vecSend, CTransac strFailReason = _("Unable to locate enough non-denominated funds for this transaction."); } else if (coin_control.nCoinType == CoinType::ONLY_FULLY_MIXED) { strFailReason = _("Unable to locate enough mixed funds for this transaction."); - strFailReason += " " + strprintf(_("%s uses exact denominated amounts to send funds, you might simply need to mix some more coins."), "CoinJoin"); + strFailReason += " " + strprintf(_("%s uses exact denominated amounts to send funds, you might simply need to mix some more coins."), gCoinJoinName); } else if (nValueIn < nValueToSelect) { strFailReason = _("Insufficient funds."); }