aboutsummaryrefslogtreecommitdiff
path: root/src/qt/bitcoingui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qt/bitcoingui.cpp')
-rw-r--r--src/qt/bitcoingui.cpp148
1 files changed, 94 insertions, 54 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index ccc0a6828c..e5dde88bd1 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -43,6 +43,7 @@
#include <QAction>
#include <QApplication>
#include <QComboBox>
+#include <QCursor>
#include <QDateTime>
#include <QDragEnterEvent>
#include <QListWidget>
@@ -88,6 +89,8 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
move(QGuiApplication::primaryScreen()->availableGeometry().center() - frameGeometry().center());
}
+ setContextMenuPolicy(Qt::PreventContextMenu);
+
#ifdef ENABLE_WALLET
enableWallet = WalletModel::isWalletEnabled();
#endif // ENABLE_WALLET
@@ -148,11 +151,11 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
frameBlocksLayout->setContentsMargins(3,0,3,0);
frameBlocksLayout->setSpacing(3);
unitDisplayControl = new UnitDisplayStatusBarControl(platformStyle);
- labelWalletEncryptionIcon = new QLabel();
- labelWalletHDStatusIcon = new QLabel();
- labelProxyIcon = new GUIUtil::ClickableLabel();
- connectionsControl = new GUIUtil::ClickableLabel();
- labelBlocksIcon = new GUIUtil::ClickableLabel();
+ labelWalletEncryptionIcon = new GUIUtil::ThemedLabel(platformStyle);
+ labelWalletHDStatusIcon = new GUIUtil::ThemedLabel(platformStyle);
+ labelProxyIcon = new GUIUtil::ClickableLabel(platformStyle);
+ connectionsControl = new GUIUtil::ClickableLabel(platformStyle);
+ labelBlocksIcon = new GUIUtil::ClickableLabel(platformStyle);
if(enableWallet)
{
frameBlocksLayout->addStretch();
@@ -197,9 +200,6 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
// Subscribe to notifications from core
subscribeToCoreSignals();
- connect(connectionsControl, &GUIUtil::ClickableLabel::clicked, [this] {
- m_node.setNetworkActive(!m_node.getNetworkActive());
- });
connect(labelProxyIcon, &GUIUtil::ClickableLabel::clicked, [this] {
openOptionsDialogWithTab(OptionsDialog::TAB_NETWORK);
});
@@ -306,27 +306,27 @@ void BitcoinGUI::createActions()
aboutQtAction = new QAction(tr("About &Qt"), this);
aboutQtAction->setStatusTip(tr("Show information about Qt"));
aboutQtAction->setMenuRole(QAction::AboutQtRole);
- optionsAction = new QAction(tr("&Options..."), this);
+ optionsAction = new QAction(tr("&Options…"), this);
optionsAction->setStatusTip(tr("Modify configuration options for %1").arg(PACKAGE_NAME));
optionsAction->setMenuRole(QAction::PreferencesRole);
optionsAction->setEnabled(false);
toggleHideAction = new QAction(tr("&Show / Hide"), this);
toggleHideAction->setStatusTip(tr("Show or hide the main Window"));
- encryptWalletAction = new QAction(tr("&Encrypt Wallet..."), this);
+ encryptWalletAction = new QAction(tr("&Encrypt Wallet…"), this);
encryptWalletAction->setStatusTip(tr("Encrypt the private keys that belong to your wallet"));
encryptWalletAction->setCheckable(true);
- backupWalletAction = new QAction(tr("&Backup Wallet..."), this);
+ backupWalletAction = new QAction(tr("&Backup Wallet…"), this);
backupWalletAction->setStatusTip(tr("Backup wallet to another location"));
- changePassphraseAction = new QAction(tr("&Change Passphrase..."), this);
+ changePassphraseAction = new QAction(tr("&Change Passphrase…"), this);
changePassphraseAction->setStatusTip(tr("Change the passphrase used for wallet encryption"));
- signMessageAction = new QAction(tr("Sign &message..."), this);
+ signMessageAction = new QAction(tr("Sign &message…"), this);
signMessageAction->setStatusTip(tr("Sign messages with your Bitcoin addresses to prove you own them"));
- verifyMessageAction = new QAction(tr("&Verify message..."), this);
+ verifyMessageAction = new QAction(tr("&Verify message…"), this);
verifyMessageAction->setStatusTip(tr("Verify messages to ensure they were signed with specified Bitcoin addresses"));
- m_load_psbt_action = new QAction(tr("&Load PSBT from file..."), this);
+ m_load_psbt_action = new QAction(tr("&Load PSBT from file…"), this);
m_load_psbt_action->setStatusTip(tr("Load Partially Signed Bitcoin Transaction"));
- m_load_psbt_clipboard_action = new QAction(tr("Load PSBT from clipboard..."), this);
+ m_load_psbt_clipboard_action = new QAction(tr("Load PSBT from clipboard…"), this);
m_load_psbt_clipboard_action->setStatusTip(tr("Load Partially Signed Bitcoin Transaction from clipboard"));
openRPCConsoleAction = new QAction(tr("Node window"), this);
@@ -340,7 +340,7 @@ void BitcoinGUI::createActions()
usedReceivingAddressesAction = new QAction(tr("&Receiving addresses"), this);
usedReceivingAddressesAction->setStatusTip(tr("Show the list of used receiving addresses and labels"));
- openAction = new QAction(tr("Open &URI..."), this);
+ openAction = new QAction(tr("Open &URI…"), this);
openAction->setStatusTip(tr("Open a bitcoin: URI"));
m_open_wallet_action = new QAction(tr("Open Wallet"), this);
@@ -348,14 +348,14 @@ void BitcoinGUI::createActions()
m_open_wallet_action->setStatusTip(tr("Open a wallet"));
m_open_wallet_menu = new QMenu(this);
- m_close_wallet_action = new QAction(tr("Close Wallet..."), this);
+ m_close_wallet_action = new QAction(tr("Close Wallet…"), this);
m_close_wallet_action->setStatusTip(tr("Close wallet"));
- m_create_wallet_action = new QAction(tr("Create Wallet..."), this);
+ m_create_wallet_action = new QAction(tr("Create Wallet…"), this);
m_create_wallet_action->setEnabled(false);
m_create_wallet_action->setStatusTip(tr("Create a new wallet"));
- m_close_all_wallets_action = new QAction(tr("Close All Wallets..."), this);
+ m_close_all_wallets_action = new QAction(tr("Close All Wallets…"), this);
m_close_all_wallets_action->setStatusTip(tr("Close all wallets"));
showHelpMessageAction = new QAction(tr("&Command-line options"), this);
@@ -544,7 +544,6 @@ void BitcoinGUI::createToolBars()
{
QToolBar *toolbar = addToolBar(tr("Tabs toolbar"));
appToolBar = toolbar;
- toolbar->setContextMenuPolicy(Qt::PreventContextMenu);
toolbar->setMovable(false);
toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
toolbar->addAction(overviewAction);
@@ -560,7 +559,7 @@ void BitcoinGUI::createToolBars()
m_wallet_selector = new QComboBox();
m_wallet_selector->setSizeAdjustPolicy(QComboBox::AdjustToContents);
- connect(m_wallet_selector, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &BitcoinGUI::setCurrentWalletBySelectorIndex);
+ connect(m_wallet_selector, qOverload<int>(&QComboBox::currentIndexChanged), this, &BitcoinGUI::setCurrentWalletBySelectorIndex);
m_wallet_selector_label = new QLabel();
m_wallet_selector_label->setText(tr("Wallet:") + " ");
@@ -585,7 +584,10 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH
createTrayIconMenu();
// Keep up to date with client
- updateNetworkState();
+ setNetworkActive(m_node.getNetworkActive());
+ connect(connectionsControl, &GUIUtil::ClickableLabel::clicked, [this] {
+ GUIUtil::PopupMenu(m_network_context_menu, QCursor::pos());
+ });
connect(_clientModel, &ClientModel::numConnectionsChanged, this, &BitcoinGUI::setNumConnections);
connect(_clientModel, &ClientModel::networkActiveChanged, this, &BitcoinGUI::setNetworkActive);
@@ -653,7 +655,7 @@ void BitcoinGUI::setWalletController(WalletController* wallet_controller)
m_open_wallet_action->setEnabled(true);
m_open_wallet_action->setMenu(m_open_wallet_menu);
- connect(wallet_controller, &WalletController::walletAdded, this, &BitcoinGUI::addWallet);
+ GUIUtil::ExceptionSafeConnect(wallet_controller, &WalletController::walletAdded, this, &BitcoinGUI::addWallet);
connect(wallet_controller, &WalletController::walletRemoved, this, &BitcoinGUI::removeWallet);
for (WalletModel* wallet_model : m_wallet_controller->getOpenWallets()) {
@@ -914,17 +916,21 @@ void BitcoinGUI::updateNetworkState()
QString tooltip;
if (m_node.getNetworkActive()) {
- tooltip = tr("%n active connection(s) to Bitcoin network", "", count) + QString(".<br>") + tr("Click to disable network activity.");
+ //: A substring of the tooltip.
+ tooltip = tr("%n active connection(s) to Bitcoin network.", "", count);
} else {
- tooltip = tr("Network activity disabled.") + QString("<br>") + tr("Click to enable network activity again.");
+ //: A substring of the tooltip.
+ tooltip = tr("Network activity disabled.");
icon = ":/icons/network_disabled";
}
// Don't word-wrap this (fixed-width) tooltip
- tooltip = QString("<nobr>") + tooltip + QString("</nobr>");
+ tooltip = QLatin1String("<nobr>") + tooltip + QLatin1String("<br>") +
+ //: A substring of the tooltip. "More actions" are available via the context menu.
+ tr("Click for more actions.") + QLatin1String("</nobr>");
connectionsControl->setToolTip(tooltip);
- connectionsControl->setPixmap(platformStyle->SingleColorIcon(icon).pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
+ connectionsControl->setThemedPixmap(icon, STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);
}
void BitcoinGUI::setNumConnections(int count)
@@ -932,9 +938,24 @@ void BitcoinGUI::setNumConnections(int count)
updateNetworkState();
}
-void BitcoinGUI::setNetworkActive(bool networkActive)
+void BitcoinGUI::setNetworkActive(bool network_active)
{
updateNetworkState();
+ m_network_context_menu->clear();
+ m_network_context_menu->addAction(
+ //: A context menu item. The "Peers tab" is an element of the "Node window".
+ tr("Show Peers tab"),
+ [this] {
+ rpcConsole->setTabFocus(RPCConsole::TabTypes::PEERS);
+ showDebugWindow();
+ });
+ m_network_context_menu->addAction(
+ network_active ?
+ //: A context menu item.
+ tr("Disable network activity") :
+ //: A context menu item. The network activity was disabled previously.
+ tr("Enable network activity"),
+ [this, new_state = !network_active] { m_node.setNetworkActive(new_state); });
}
void BitcoinGUI::updateHeadersSyncProgressLabel()
@@ -943,7 +964,7 @@ void BitcoinGUI::updateHeadersSyncProgressLabel()
int headersTipHeight = clientModel->getHeaderTipHeight();
int estHeadersLeft = (GetTime() - headersTipTime) / Params().GetConsensus().nPowTargetSpacing;
if (estHeadersLeft > HEADER_HEIGHT_DELTA_SYNC)
- progressBarLabel->setText(tr("Syncing Headers (%1%)...").arg(QString::number(100.0 / (headersTipHeight+estHeadersLeft)*headersTipHeight, 'f', 1)));
+ progressBarLabel->setText(tr("Syncing Headers (%1%)…").arg(QString::number(100.0 / (headersTipHeight+estHeadersLeft)*headersTipHeight, 'f', 1)));
}
void BitcoinGUI::openOptionsDialogWithTab(OptionsDialog::Tab tab)
@@ -989,24 +1010,24 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
updateHeadersSyncProgressLabel();
return;
}
- progressBarLabel->setText(tr("Synchronizing with network..."));
+ progressBarLabel->setText(tr("Synchronizing with network…"));
updateHeadersSyncProgressLabel();
break;
case BlockSource::DISK:
if (header) {
- progressBarLabel->setText(tr("Indexing blocks on disk..."));
+ progressBarLabel->setText(tr("Indexing blocks on disk…"));
} else {
- progressBarLabel->setText(tr("Processing blocks on disk..."));
+ progressBarLabel->setText(tr("Processing blocks on disk…"));
}
break;
case BlockSource::REINDEX:
- progressBarLabel->setText(tr("Reindexing blocks on disk..."));
+ progressBarLabel->setText(tr("Reindexing blocks on disk…"));
break;
case BlockSource::NONE:
if (header) {
return;
}
- progressBarLabel->setText(tr("Connecting to peers..."));
+ progressBarLabel->setText(tr("Connecting to peers…"));
break;
}
@@ -1020,7 +1041,7 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
// Set icon state: spinning if catching up, tick otherwise
if (secs < MAX_BLOCK_TIME_GAP) {
tooltip = tr("Up to date") + QString(".<br>") + tooltip;
- labelBlocksIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
+ labelBlocksIcon->setThemedPixmap(QStringLiteral(":/icons/synced"), STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);
#ifdef ENABLE_WALLET
if(walletFrame)
@@ -1043,12 +1064,12 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
progressBar->setValue(nVerificationProgress * 1000000000.0 + 0.5);
progressBar->setVisible(true);
- tooltip = tr("Catching up...") + QString("<br>") + tooltip;
+ tooltip = tr("Catching up…") + QString("<br>") + tooltip;
if(count != prevBlocks)
{
- labelBlocksIcon->setPixmap(platformStyle->SingleColorIcon(QString(
- ":/animation/spinner-%1").arg(spinnerFrame, 3, 10, QChar('0')))
- .pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
+ labelBlocksIcon->setThemedPixmap(
+ QString(":/animation/spinner-%1").arg(spinnerFrame, 3, 10, QChar('0')),
+ STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);
spinnerFrame = (spinnerFrame + 1) % SPINNER_FRAMES;
}
prevBlocks = count;
@@ -1137,7 +1158,17 @@ void BitcoinGUI::message(const QString& title, QString message, unsigned int sty
void BitcoinGUI::changeEvent(QEvent *e)
{
+#ifdef Q_OS_MACOS
+ if (e->type() == QEvent::PaletteChange) {
+ overviewAction->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/overview")));
+ sendCoinsAction->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/send")));
+ receiveCoinsAction->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/receiving_addresses")));
+ historyAction->setIcon(platformStyle->SingleColorIcon(QStringLiteral(":/icons/history")));
+ }
+#endif
+
QMainWindow::changeEvent(e);
+
#ifndef Q_OS_MAC // Ignored on Mac
if(e->type() == QEvent::WindowStateChange)
{
@@ -1255,7 +1286,7 @@ bool BitcoinGUI::handlePaymentRequest(const SendCoinsRecipient& recipient)
void BitcoinGUI::setHDStatus(bool privkeyDisabled, int hdEnabled)
{
- labelWalletHDStatusIcon->setPixmap(platformStyle->SingleColorIcon(privkeyDisabled ? ":/icons/eye" : hdEnabled ? ":/icons/hd_enabled" : ":/icons/hd_disabled").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
+ labelWalletHDStatusIcon->setThemedPixmap(privkeyDisabled ? QStringLiteral(":/icons/eye") : hdEnabled ? QStringLiteral(":/icons/hd_enabled") : QStringLiteral(":/icons/hd_disabled"), STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);
labelWalletHDStatusIcon->setToolTip(privkeyDisabled ? tr("Private key <b>disabled</b>") : hdEnabled ? tr("HD key generation is <b>enabled</b>") : tr("HD key generation is <b>disabled</b>"));
labelWalletHDStatusIcon->show();
// eventually disable the QLabel to set its opacity to 50%
@@ -1274,7 +1305,7 @@ void BitcoinGUI::setEncryptionStatus(int status)
break;
case WalletModel::Unlocked:
labelWalletEncryptionIcon->show();
- labelWalletEncryptionIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/lock_open").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
+ labelWalletEncryptionIcon->setThemedPixmap(QStringLiteral(":/icons/lock_open"), STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);
labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b>"));
encryptWalletAction->setChecked(true);
changePassphraseAction->setEnabled(true);
@@ -1282,7 +1313,7 @@ void BitcoinGUI::setEncryptionStatus(int status)
break;
case WalletModel::Locked:
labelWalletEncryptionIcon->show();
- labelWalletEncryptionIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/lock_closed").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
+ labelWalletEncryptionIcon->setThemedPixmap(QStringLiteral(":/icons/lock_closed"), STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);
labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>locked</b>"));
encryptWalletAction->setChecked(true);
changePassphraseAction->setEnabled(true);
@@ -1314,7 +1345,7 @@ void BitcoinGUI::updateProxyIcon()
if (proxy_enabled) {
if (!GUIUtil::HasPixmap(labelProxyIcon)) {
QString ip_port_q = QString::fromStdString(ip_port);
- labelProxyIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/proxy").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
+ labelProxyIcon->setThemedPixmap((":/icons/proxy"), STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);
labelProxyIcon->setToolTip(tr("Proxy is <b>enabled</b>: %1").arg(ip_port_q));
} else {
labelProxyIcon->show();
@@ -1374,7 +1405,6 @@ void BitcoinGUI::showProgress(const QString &title, int nProgress)
progressDialog = new QProgressDialog(title, QString(), 0, 100);
GUIUtil::PolishProgressDialog(progressDialog);
progressDialog->setWindowModality(Qt::ApplicationModal);
- progressDialog->setMinimumDuration(0);
progressDialog->setAutoClose(false);
progressDialog->setValue(0);
} else if (nProgress == 100) {
@@ -1439,9 +1469,10 @@ bool BitcoinGUI::isPrivacyModeActivated() const
return m_mask_values_action->isChecked();
}
-UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *platformStyle) :
- optionsModel(nullptr),
- menu(nullptr)
+UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *platformStyle)
+ : optionsModel(nullptr),
+ menu(nullptr),
+ m_platform_style{platformStyle}
{
createContextMenu();
setToolTip(tr("Unit to show amounts in. Click to select another unit."));
@@ -1454,7 +1485,7 @@ UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *pl
}
setMinimumSize(max_width, 0);
setAlignment(Qt::AlignRight | Qt::AlignVCenter);
- setStyleSheet(QString("QLabel { color : %1 }").arg(platformStyle->SingleColor().name()));
+ setStyleSheet(QString("QLabel { color : %1 }").arg(m_platform_style->SingleColor().name()));
}
/** So that it responds to button clicks */
@@ -1463,15 +1494,24 @@ void UnitDisplayStatusBarControl::mousePressEvent(QMouseEvent *event)
onDisplayUnitsClicked(event->pos());
}
+void UnitDisplayStatusBarControl::changeEvent(QEvent* e)
+{
+#ifdef Q_OS_MACOS
+ if (e->type() == QEvent::PaletteChange) {
+ QString style = QString("QLabel { color : %1 }").arg(m_platform_style->SingleColor().name());
+ if (style != styleSheet()) {
+ setStyleSheet(style);
+ }
+ }
+#endif
+}
+
/** Creates context menu, its actions, and wires up all the relevant signals for mouse events. */
void UnitDisplayStatusBarControl::createContextMenu()
{
menu = new QMenu(this);
- for (const BitcoinUnits::Unit u : BitcoinUnits::availableUnits())
- {
- QAction *menuAction = new QAction(QString(BitcoinUnits::longName(u)), this);
- menuAction->setData(QVariant(u));
- menu->addAction(menuAction);
+ for (const BitcoinUnits::Unit u : BitcoinUnits::availableUnits()) {
+ menu->addAction(BitcoinUnits::longName(u))->setData(QVariant(u));
}
connect(menu, &QMenu::triggered, this, &UnitDisplayStatusBarControl::onMenuSelection);
}