Skip to content

Commit 750475f

Browse files
Merge #6285: backport: bitcoin-core/gui#29, gui#123, #164, gui#256, gui#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
2 parents 9b21aef + 6431f71 commit 750475f

24 files changed

+273
-222
lines changed

src/Makefile.qt.include

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ RES_ANIMATION = $(wildcard $(srcdir)/qt/res/animation/spinner-*.png)
364364

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

367-
BITCOIN_QT_INCLUDES = -DQT_NO_KEYWORDS
367+
BITCOIN_QT_INCLUDES = -DQT_NO_KEYWORDS -DQT_USE_QSTRINGBUILDER
368368

369369
qt_libbitcoinqt_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BITCOIN_QT_INCLUDES) \
370370
$(QT_INCLUDES) $(QT_DBUS_INCLUDES) $(QR_CFLAGS)

src/qt/bitcoin.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
#include <QMessageBox>
5555
#include <QProcess>
5656
#include <QSettings>
57-
#include <QStringBuilder>
5857
#include <QThread>
5958
#include <QTimer>
6059
#include <QTranslator>
@@ -492,8 +491,8 @@ void BitcoinApplication::handleRunawayException(const QString &message)
492491
{
493492
QMessageBox::critical(
494493
nullptr, tr("Runaway exception"),
495-
tr("A fatal error occurred. %1 can no longer continue safely and will quit.").arg(PACKAGE_NAME) %
496-
QLatin1String("<br><br>") % GUIUtil::MakeHtmlLink(message, PACKAGE_BUGREPORT));
494+
tr("A fatal error occurred. %1 can no longer continue safely and will quit.").arg(PACKAGE_NAME) +
495+
QLatin1String("<br><br>") + GUIUtil::MakeHtmlLink(message, PACKAGE_BUGREPORT));
497496
::exit(EXIT_FAILURE);
498497
}
499498

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

510509
WId BitcoinApplication::getMainWinId() const

src/qt/bitcoingui.cpp

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
#include <QApplication>
4848
#include <QButtonGroup>
4949
#include <QComboBox>
50+
#include <QCursor>
5051
#include <QDateTime>
5152
#include <QDragEnterEvent>
5253
#include <QKeySequence>
@@ -114,6 +115,11 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const NetworkStyle* networkStyle,
114115
connect(walletFrame, &WalletFrame::message, [this](const QString& title, const QString& message, unsigned int style) {
115116
this->message(title, message, style);
116117
});
118+
connect(walletFrame, &WalletFrame::createWalletButtonClicked, [this] {
119+
auto activity = new CreateWalletActivity(getWalletController(), this);
120+
connect(activity, &CreateWalletActivity::finished, activity, &QObject::deleteLater);
121+
activity->create();
122+
});
117123
} else
118124
#endif // ENABLE_WALLET
119125
{
@@ -211,20 +217,13 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const NetworkStyle* networkStyle,
211217
// Subscribe to notifications from core
212218
subscribeToCoreSignals();
213219

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

220224
modalOverlay = new ModalOverlay(enableWallet, this->centralWidget());
221225
connect(labelBlocksIcon, &GUIUtil::ClickableLabel::clicked, this, &BitcoinGUI::showModalOverlay);
222226
connect(progressBar, &GUIUtil::ClickableProgressBar::clicked, this, &BitcoinGUI::showModalOverlay);
223-
#ifdef ENABLE_WALLET
224-
if(enableWallet) {
225-
connect(walletFrame, &WalletFrame::requestedSyncWarningInfo, this, &BitcoinGUI::showModalOverlay);
226-
}
227-
#endif
228227

229228
#ifdef Q_OS_MAC
230229
m_app_nap_inhibitor = new CAppNapInhibitor;
@@ -812,8 +811,11 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel, interfaces::BlockAndH
812811
}
813812

814813
// Keep up to date with client
815-
updateNetworkState();
814+
setNetworkActive(m_node.getNetworkActive());
816815
setNumConnections(_clientModel->getNumConnections());
816+
connect(labelConnectionsIcon, &GUIUtil::ClickableLabel::clicked, [this] {
817+
GUIUtil::PopupMenu(m_network_context_menu, QCursor::pos());
818+
});
817819
connect(_clientModel, &ClientModel::numConnectionsChanged, this, &BitcoinGUI::setNumConnections);
818820
connect(_clientModel, &ClientModel::networkActiveChanged, this, &BitcoinGUI::setNetworkActive);
819821

@@ -911,13 +913,28 @@ WalletController* BitcoinGUI::getWalletController()
911913
void BitcoinGUI::addWallet(WalletModel* walletModel)
912914
{
913915
if (!walletFrame) return;
914-
if (!walletFrame->addWallet(walletModel)) return;
916+
917+
WalletView* wallet_view = new WalletView(walletFrame);
918+
if (!walletFrame->addWallet(walletModel, wallet_view)) return;
919+
915920
rpcConsole->addWallet(walletModel);
916921
if (m_wallet_selector->count() == 0) {
917922
setWalletActionsEnabled(true);
918923
} else if (m_wallet_selector->count() == 1) {
919924
m_wallet_selector_action->setVisible(true);
920925
}
926+
927+
connect(wallet_view, &WalletView::outOfSyncWarningClicked, this, &BitcoinGUI::showModalOverlay);
928+
connect(wallet_view, &WalletView::transactionClicked, this, &BitcoinGUI::gotoHistoryPage);
929+
connect(wallet_view, &WalletView::coinsSent, this, &BitcoinGUI::gotoHistoryPage);
930+
connect(wallet_view, &WalletView::message, [this](const QString& title, const QString& message, unsigned int style) {
931+
this->message(title, message, style);
932+
});
933+
connect(wallet_view, &WalletView::encryptionStatusChanged, this, &BitcoinGUI::updateWalletStatus);
934+
connect(wallet_view, &WalletView::incomingTransaction, this, &BitcoinGUI::incomingTransaction);
935+
connect(wallet_view, &WalletView::hdEnabledStatusChanged, this, &BitcoinGUI::updateWalletStatus);
936+
connect(this, &BitcoinGUI::setPrivacy, wallet_view, &WalletView::setPrivacy);
937+
wallet_view->setPrivacy(isPrivacyModeActivated());
921938
const QString display_name = walletModel->getDisplayName();
922939
m_wallet_selector->addItem(display_name, QVariant::fromValue(walletModel));
923940
}
@@ -1270,31 +1287,54 @@ void BitcoinGUI::updateNetworkState()
12701287
nCountPrev = count;
12711288
fNetworkActivePrev = fNetworkActive;
12721289

1290+
QString tooltip;
12731291
if (fNetworkActive) {
1274-
labelConnectionsIcon->setToolTip(tr("%n active connection(s) to Dash network", "", count));
1292+
//: A substring of the tooltip.
1293+
tooltip = tr("%n active connection(s) to Dash network", "", count);
12751294
} else {
1276-
labelConnectionsIcon->setToolTip(tr("Network activity disabled"));
1295+
tooltip = tr("Network activity disabled");
12771296
icon = "connect_4";
12781297
color = GUIUtil::ThemedColor::RED;
12791298
}
12801299

1300+
// Don't word-wrap this (fixed-width) tooltip
1301+
tooltip = QLatin1String("<nobr>") + tooltip + QLatin1String("<br>") +
1302+
//: A substring of the tooltip. "More actions" are available via the context menu.
1303+
tr("Click for more actions.") + QLatin1String("</nobr>");
1304+
12811305
if (fNetworkActive && count == 0) {
12821306
startConnectingAnimation();
12831307
}
12841308
if (!fNetworkActive || count > 0) {
12851309
stopConnectingAnimation();
12861310
labelConnectionsIcon->setPixmap(GUIUtil::getIcon(icon, color).pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
12871311
}
1312+
labelConnectionsIcon->setToolTip(tooltip);
12881313
}
12891314

12901315
void BitcoinGUI::setNumConnections(int count)
12911316
{
12921317
updateNetworkState();
12931318
}
12941319

1295-
void BitcoinGUI::setNetworkActive(bool networkActive)
1320+
void BitcoinGUI::setNetworkActive(bool network_active)
12961321
{
12971322
updateNetworkState();
1323+
m_network_context_menu->clear();
1324+
m_network_context_menu->addAction(
1325+
//: A context menu item. The "Peers tab" is an element of the "Node window".
1326+
tr("Show Peers tab"),
1327+
[this] {
1328+
rpcConsole->setTabFocus(RPCConsole::TabTypes::PEERS);
1329+
showDebugWindow();
1330+
});
1331+
m_network_context_menu->addAction(
1332+
network_active ?
1333+
//: A context menu item.
1334+
tr("Disable network activity") :
1335+
//: A context menu item. The network activity was disabled previously.
1336+
tr("Enable network activity"),
1337+
[this, new_state = !network_active] { m_node.setNetworkActive(new_state); });
12981338
}
12991339

13001340
void BitcoinGUI::updateHeadersSyncProgressLabel()

src/qt/bitcoingui.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <QLabel>
1717
#include <QMainWindow>
1818
#include <QMap>
19+
#include <QMenu>
1920
#include <QPoint>
2021
#include <QPushButton>
2122
#include <QSystemTrayIcon>
@@ -51,7 +52,6 @@ class QAction;
5152
class QButtonGroup;
5253
class QComboBox;
5354
class QDateTime;
54-
class QMenu;
5555
class QProgressBar;
5656
class QProgressDialog;
5757
class QToolButton;
@@ -190,6 +190,8 @@ class BitcoinGUI : public QMainWindow
190190
ModalOverlay* modalOverlay = nullptr;
191191
QButtonGroup* tabGroup = nullptr;
192192

193+
QMenu* m_network_context_menu = new QMenu(this);
194+
193195
#ifdef Q_OS_MAC
194196
CAppNapInhibitor* m_app_nap_inhibitor = nullptr;
195197
#endif
@@ -264,7 +266,7 @@ public Q_SLOTS:
264266
/** Set number of connections shown in the UI */
265267
void setNumConnections(int count);
266268
/** Set network state shown in the UI */
267-
void setNetworkActive(bool networkActive);
269+
void setNetworkActive(bool network_active);
268270
/** Get restart command-line parameters and request restart */
269271
void handleRestart(QStringList args);
270272
/** Set number of blocks and last block date shown in the UI */

src/qt/guiutil.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@
6969
#include <QShortcut>
7070
#include <QSize>
7171
#include <QString>
72-
#include <QStringBuilder>
7372
#include <QTextDocument> // for Qt::mightBeRichText
7473
#include <QThread>
7574
#include <QTimer>
@@ -1931,7 +1930,7 @@ QString MakeHtmlLink(const QString& source, const QString& link)
19311930
{
19321931
return QString(source).replace(
19331932
link,
1934-
QLatin1String("<a href=\"") % link % QLatin1String("\">") % link % QLatin1String("</a>"));
1933+
QLatin1String("<a href=\"") + link + QLatin1String("\">") + link + QLatin1String("</a>"));
19351934
}
19361935

19371936
void PrintSlotException(

src/qt/optionsmodel.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#endif
2727

2828
#include <QDebug>
29+
#include <QLatin1Char>
2930
#include <QSettings>
3031
#include <QStringList>
3132

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

377378
static void SetProxySetting(QSettings &settings, const QString &name, const ProxySetting &ip_port)
378379
{
379-
settings.setValue(name, ip_port.ip + ":" + ip_port.port);
380+
settings.setValue(name, QString{ip_port.ip + QLatin1Char(':') + ip_port.port});
380381
}
381382

382383
static const QString GetDefaultProxyAddress()

src/qt/overviewpage.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,6 @@ void OverviewPage::handleTransactionClicked(const QModelIndex &index)
199199
Q_EMIT transactionClicked(filter->mapToSource(index));
200200
}
201201

202-
void OverviewPage::handleOutOfSyncWarningClicks()
203-
{
204-
Q_EMIT outOfSyncWarningClicked();
205-
}
206-
207202
void OverviewPage::setPrivacy(bool privacy)
208203
{
209204
m_privacy = privacy;
@@ -469,7 +464,7 @@ void OverviewPage::updateCoinJoinProgress()
469464

470465
ui->coinJoinProgress->setValue(progress);
471466

472-
QString strToolPip = ("<b>" + tr("Overall progress") + ": %1%</b><br/>" +
467+
QString strToolPip = QString("<b>" + tr("Overall progress") + ": %1%</b><br/>" +
473468
tr("Denominated") + ": %2%<br/>" +
474469
tr("Partially mixed") + ": %3%<br/>" +
475470
tr("Mixed") + ": %4%<br/>" +

src/qt/overviewpage.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ private Q_SLOTS:
7070
void handleTransactionClicked(const QModelIndex &index);
7171
void updateAlerts(const QString &warnings);
7272
void updateWatchOnlyLabels(bool showWatchOnly);
73-
void handleOutOfSyncWarningClicks();
7473
};
7574

7675
#endif // BITCOIN_QT_OVERVIEWPAGE_H

0 commit comments

Comments
 (0)