Skip to content

Commit

Permalink
Merge #6285: backport: bitcoin-core/gui#29, gui#123, #164, gui#256, g…
Browse files Browse the repository at this point in the history
…ui#309, gui#313, gui#329, gui#331, gui#333, gui#346, gui#393

6431f71 Merge bitcoin-core/gui#393: Fix regression in "Encrypt Wallet" menu item (Hennadii Stepanov)
fc900a8 Merge bitcoin-core/gui#333: refactor: Signal-slot connections cleanup (Hennadii Stepanov)
9ca2aad Merge bitcoin-core/gui#164: Handle peer addition/removal in a right way (Hennadii Stepanov)
7d9ce32 Merge bitcoin-core/gui#29: refactor: Optimize signal-slot connections logic (Hennadii Stepanov)
3be79a9 Merge bitcoin-core/gui#256: Save/restore column sizes of the tables in the Peers tab (Hennadii Stepanov)
f4fccd3 Merge bitcoin-core/gui#329: Make console buttons look clickable (Hennadii Stepanov)
5a0d524 Merge bitcoin-core/gui#123: rpc: Do not accept command while executing another one (Hennadii Stepanov)
1931064 Merge bitcoin-core/gui#331: Make RPC console welcome message translation-friendly (Hennadii Stepanov)
69a1305 Merge bitcoin-core/gui#309: Add access to the Peers tab from the network icon (Hennadii Stepanov)
c858325 Merge bitcoin-core/gui#346: English translations update (Hennadii Stepanov)
412445a Merge bitcoin-core/gui#313: qt: Optimize string concatenation by default (W. J. van der Laan)

Pull request description:

  ## Issue being fixed or feature implemented
  Gui related backports from bitcoin v22

  ## What was done?
  See commits

  ## How Has This Been Tested?
  Run unit/functional tests

  See also:

  <img alt="right menu" src="https://user-images.githubusercontent.com/32963518/116794314-d64b9b80-aad4-11eb-89ca-7f75c7442ba8.gif"/>

  ## Breaking Changes
  N/A

  ## Checklist:
  - [x] I have performed a self-review of my own code
  - [ ] I have commented my code, particularly in hard-to-understand areas
  - [ ] I have added or updated relevant unit/integration/functional/e2e tests
  - [ ] I have made corresponding changes to the documentation
  - [x] I have assigned this pull request to a milestone

ACKs for top commit:
  UdjinM6:
    light ACK 6431f71
  PastaPastaPasta:
    utACK 6431f71

Tree-SHA512: bb14de71c9375b10da695db6c521c26686815b8b5ca2748bfe3bd2eafa9d332acd60acd85a1f2eed3aa831d16e5741ecc7570130ce9cf5bff011c065b55d62b2
  • Loading branch information
PastaPastaPasta committed Sep 27, 2024
2 parents 9b21aef + 6431f71 commit 750475f
Show file tree
Hide file tree
Showing 24 changed files with 273 additions and 222 deletions.
2 changes: 1 addition & 1 deletion src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ RES_ANIMATION = $(wildcard $(srcdir)/qt/res/animation/spinner-*.png)

BITCOIN_RC = qt/res/dash-qt-res.rc

BITCOIN_QT_INCLUDES = -DQT_NO_KEYWORDS
BITCOIN_QT_INCLUDES = -DQT_NO_KEYWORDS -DQT_USE_QSTRINGBUILDER

qt_libbitcoinqt_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BITCOIN_QT_INCLUDES) \
$(QT_INCLUDES) $(QT_DBUS_INCLUDES) $(QR_CFLAGS)
Expand Down
9 changes: 4 additions & 5 deletions src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
#include <QMessageBox>
#include <QProcess>
#include <QSettings>
#include <QStringBuilder>
#include <QThread>
#include <QTimer>
#include <QTranslator>
Expand Down Expand Up @@ -492,8 +491,8 @@ void BitcoinApplication::handleRunawayException(const QString &message)
{
QMessageBox::critical(
nullptr, tr("Runaway exception"),
tr("A fatal error occurred. %1 can no longer continue safely and will quit.").arg(PACKAGE_NAME) %
QLatin1String("<br><br>") % GUIUtil::MakeHtmlLink(message, PACKAGE_BUGREPORT));
tr("A fatal error occurred. %1 can no longer continue safely and will quit.").arg(PACKAGE_NAME) +
QLatin1String("<br><br>") + GUIUtil::MakeHtmlLink(message, PACKAGE_BUGREPORT));
::exit(EXIT_FAILURE);
}

Expand All @@ -503,8 +502,8 @@ void BitcoinApplication::handleNonFatalException(const QString& message)
QMessageBox::warning(
nullptr, tr("Internal error"),
tr("An internal error occurred. %1 will attempt to continue safely. This is "
"an unexpected bug which can be reported as described below.").arg(PACKAGE_NAME) %
QLatin1String("<br><br>") % GUIUtil::MakeHtmlLink(message, PACKAGE_BUGREPORT));
"an unexpected bug which can be reported as described below.").arg(PACKAGE_NAME) +
QLatin1String("<br><br>") + GUIUtil::MakeHtmlLink(message, PACKAGE_BUGREPORT));
}

WId BitcoinApplication::getMainWinId() const
Expand Down
64 changes: 52 additions & 12 deletions src/qt/bitcoingui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include <QApplication>
#include <QButtonGroup>
#include <QComboBox>
#include <QCursor>
#include <QDateTime>
#include <QDragEnterEvent>
#include <QKeySequence>
Expand Down Expand Up @@ -114,6 +115,11 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const NetworkStyle* networkStyle,
connect(walletFrame, &WalletFrame::message, [this](const QString& title, const QString& message, unsigned int style) {
this->message(title, message, style);
});
connect(walletFrame, &WalletFrame::createWalletButtonClicked, [this] {
auto activity = new CreateWalletActivity(getWalletController(), this);
connect(activity, &CreateWalletActivity::finished, activity, &QObject::deleteLater);
activity->create();
});
} else
#endif // ENABLE_WALLET
{
Expand Down Expand Up @@ -211,20 +217,13 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const NetworkStyle* networkStyle,
// Subscribe to notifications from core
subscribeToCoreSignals();

// Jump to peers tab by clicking on connections icon
connect(labelConnectionsIcon, &GUIUtil::ClickableLabel::clicked, this, &BitcoinGUI::showPeers);
connect(labelProxyIcon, &GUIUtil::ClickableLabel::clicked, [this] {
openOptionsDialogWithTab(OptionsDialog::TAB_NETWORK);
});

modalOverlay = new ModalOverlay(enableWallet, this->centralWidget());
connect(labelBlocksIcon, &GUIUtil::ClickableLabel::clicked, this, &BitcoinGUI::showModalOverlay);
connect(progressBar, &GUIUtil::ClickableProgressBar::clicked, this, &BitcoinGUI::showModalOverlay);
#ifdef ENABLE_WALLET
if(enableWallet) {
connect(walletFrame, &WalletFrame::requestedSyncWarningInfo, this, &BitcoinGUI::showModalOverlay);
}
#endif

#ifdef Q_OS_MAC
m_app_nap_inhibitor = new CAppNapInhibitor;
Expand Down Expand Up @@ -812,8 +811,11 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH
}

// Keep up to date with client
updateNetworkState();
setNetworkActive(m_node.getNetworkActive());
setNumConnections(_clientModel->getNumConnections());
connect(labelConnectionsIcon, &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);

Expand Down Expand Up @@ -911,13 +913,28 @@ WalletController* BitcoinGUI::getWalletController()
void BitcoinGUI::addWallet(WalletModel* walletModel)
{
if (!walletFrame) return;
if (!walletFrame->addWallet(walletModel)) return;

WalletView* wallet_view = new WalletView(walletFrame);
if (!walletFrame->addWallet(walletModel, wallet_view)) return;

rpcConsole->addWallet(walletModel);
if (m_wallet_selector->count() == 0) {
setWalletActionsEnabled(true);
} else if (m_wallet_selector->count() == 1) {
m_wallet_selector_action->setVisible(true);
}

connect(wallet_view, &WalletView::outOfSyncWarningClicked, this, &BitcoinGUI::showModalOverlay);
connect(wallet_view, &WalletView::transactionClicked, this, &BitcoinGUI::gotoHistoryPage);
connect(wallet_view, &WalletView::coinsSent, this, &BitcoinGUI::gotoHistoryPage);
connect(wallet_view, &WalletView::message, [this](const QString& title, const QString& message, unsigned int style) {
this->message(title, message, style);
});
connect(wallet_view, &WalletView::encryptionStatusChanged, this, &BitcoinGUI::updateWalletStatus);
connect(wallet_view, &WalletView::incomingTransaction, this, &BitcoinGUI::incomingTransaction);
connect(wallet_view, &WalletView::hdEnabledStatusChanged, this, &BitcoinGUI::updateWalletStatus);
connect(this, &BitcoinGUI::setPrivacy, wallet_view, &WalletView::setPrivacy);
wallet_view->setPrivacy(isPrivacyModeActivated());
const QString display_name = walletModel->getDisplayName();
m_wallet_selector->addItem(display_name, QVariant::fromValue(walletModel));
}
Expand Down Expand Up @@ -1270,31 +1287,54 @@ void BitcoinGUI::updateNetworkState()
nCountPrev = count;
fNetworkActivePrev = fNetworkActive;

QString tooltip;
if (fNetworkActive) {
labelConnectionsIcon->setToolTip(tr("%n active connection(s) to Dash network", "", count));
//: A substring of the tooltip.
tooltip = tr("%n active connection(s) to Dash network", "", count);
} else {
labelConnectionsIcon->setToolTip(tr("Network activity disabled"));
tooltip = tr("Network activity disabled");
icon = "connect_4";
color = GUIUtil::ThemedColor::RED;
}

// Don't word-wrap this (fixed-width) tooltip
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>");

if (fNetworkActive && count == 0) {
startConnectingAnimation();
}
if (!fNetworkActive || count > 0) {
stopConnectingAnimation();
labelConnectionsIcon->setPixmap(GUIUtil::getIcon(icon, color).pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
}
labelConnectionsIcon->setToolTip(tooltip);
}

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()
Expand Down
6 changes: 4 additions & 2 deletions src/qt/bitcoingui.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <QLabel>
#include <QMainWindow>
#include <QMap>
#include <QMenu>
#include <QPoint>
#include <QPushButton>
#include <QSystemTrayIcon>
Expand Down Expand Up @@ -51,7 +52,6 @@ class QAction;
class QButtonGroup;
class QComboBox;
class QDateTime;
class QMenu;
class QProgressBar;
class QProgressDialog;
class QToolButton;
Expand Down Expand Up @@ -190,6 +190,8 @@ class BitcoinGUI : public QMainWindow
ModalOverlay* modalOverlay = nullptr;
QButtonGroup* tabGroup = nullptr;

QMenu* m_network_context_menu = new QMenu(this);

#ifdef Q_OS_MAC
CAppNapInhibitor* m_app_nap_inhibitor = nullptr;
#endif
Expand Down Expand Up @@ -264,7 +266,7 @@ public Q_SLOTS:
/** Set number of connections shown in the UI */
void setNumConnections(int count);
/** Set network state shown in the UI */
void setNetworkActive(bool networkActive);
void setNetworkActive(bool network_active);
/** Get restart command-line parameters and request restart */
void handleRestart(QStringList args);
/** Set number of blocks and last block date shown in the UI */
Expand Down
3 changes: 1 addition & 2 deletions src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@
#include <QShortcut>
#include <QSize>
#include <QString>
#include <QStringBuilder>
#include <QTextDocument> // for Qt::mightBeRichText
#include <QThread>
#include <QTimer>
Expand Down Expand Up @@ -1931,7 +1930,7 @@ QString MakeHtmlLink(const QString& source, const QString& link)
{
return QString(source).replace(
link,
QLatin1String("<a href=\"") % link % QLatin1String("\">") % link % QLatin1String("</a>"));
QLatin1String("<a href=\"") + link + QLatin1String("\">") + link + QLatin1String("</a>"));
}

void PrintSlotException(
Expand Down
3 changes: 2 additions & 1 deletion src/qt/optionsmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#endif

#include <QDebug>
#include <QLatin1Char>
#include <QSettings>
#include <QStringList>

Expand Down Expand Up @@ -376,7 +377,7 @@ static ProxySetting GetProxySetting(QSettings &settings, const QString &name)

static void SetProxySetting(QSettings &settings, const QString &name, const ProxySetting &ip_port)
{
settings.setValue(name, ip_port.ip + ":" + ip_port.port);
settings.setValue(name, QString{ip_port.ip + QLatin1Char(':') + ip_port.port});
}

static const QString GetDefaultProxyAddress()
Expand Down
7 changes: 1 addition & 6 deletions src/qt/overviewpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,6 @@ void OverviewPage::handleTransactionClicked(const QModelIndex &index)
Q_EMIT transactionClicked(filter->mapToSource(index));
}

void OverviewPage::handleOutOfSyncWarningClicks()
{
Q_EMIT outOfSyncWarningClicked();
}

void OverviewPage::setPrivacy(bool privacy)
{
m_privacy = privacy;
Expand Down Expand Up @@ -469,7 +464,7 @@ void OverviewPage::updateCoinJoinProgress()

ui->coinJoinProgress->setValue(progress);

QString strToolPip = ("<b>" + tr("Overall progress") + ": %1%</b><br/>" +
QString strToolPip = QString("<b>" + tr("Overall progress") + ": %1%</b><br/>" +
tr("Denominated") + ": %2%<br/>" +
tr("Partially mixed") + ": %3%<br/>" +
tr("Mixed") + ": %4%<br/>" +
Expand Down
1 change: 0 additions & 1 deletion src/qt/overviewpage.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ private Q_SLOTS:
void handleTransactionClicked(const QModelIndex &index);
void updateAlerts(const QString &warnings);
void updateWatchOnlyLabels(bool showWatchOnly);
void handleOutOfSyncWarningClicks();
};

#endif // BITCOIN_QT_OVERVIEWPAGE_H
Loading

0 comments on commit 750475f

Please sign in to comment.