Use one global string for "CoinJoin" in gui related stuff (#4117)

This commit is contained in:
UdjinM6 2021-07-11 12:28:50 +03:00 committed by GitHub
parent 08558d67ee
commit 0f027caba2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 53 additions and 41 deletions

View File

@ -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;
}

View File

@ -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()));

View File

@ -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");
}

View File

@ -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());
}

View File

@ -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") + ":<br><br>" + 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") + ":<br><br>" + strBackupError + "<br>" +
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();
}
}

View File

@ -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<SendCoinsRecipient> recipients)
questionString.append(formatted.join("<br />"));
questionString.append("<br />");
QString strCoinJoinName = QString::fromStdString(gCoinJoinName);
if(m_coin_control->IsUsingCoinJoin()) {
questionString.append(tr("using") + " <b>" + tr("%1 funds only").arg("CoinJoin") + "</b>");
questionString.append(tr("using") + " <b>" + tr("%1 funds only").arg(strCoinJoinName) + "</b>");
} else {
questionString.append(tr("using") + " <b>" + tr("any available funds") + "</b>");
}
@ -386,7 +387,7 @@ void SendCoinsDialog::send(QList<SendCoinsRecipient> recipients)
if (m_coin_control->IsUsingCoinJoin()) {
questionString.append(QString("<br /><span style='font-size:10pt; font-weight:normal;'>%1</span>")
.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<SendCoinsRecipient> recipients)
if (nInputs >= 10 && m_coin_control->IsUsingCoinJoin()) {
questionString.append("<br />");
questionString.append("<span style='" + GUIUtil::getThemedStyleQString(GUIUtil::ThemedStyle::TS_ERROR) + "'>");
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("<a style='" + GUIUtil::getThemedStyleQString(GUIUtil::ThemedStyle::TS_COMMAND) + "' href=\"https://docs.dash.org/en/stable/wallets/dashcore/coinjoin-instantsend.html#inputs\">");
questionString.append(tr("Click to learn more"));
questionString.append("</a>");

View File

@ -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();

View File

@ -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));

View File

@ -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.<br> \
Consequently, users who have backups disabled will also have %1 disabled. <hr>\
For more information, see the <a style=\"%2\" href=\"%3\">%1 documentation</a>."
)
.arg("CoinJoin")
.arg(strCoinJoinName)
.arg(GUIUtil::getThemedStyleQString(GUIUtil::ThemedStyle::TS_COMMAND))
.arg("https://docs.dash.org/en/stable/wallets/dashcore/coinjoin-instantsend.html")
);

View File

@ -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

View File

@ -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();

View File

@ -3700,7 +3700,7 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& 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.");
}