Skip to content

Commit 2a58340

Browse files
committed
Merge #13248: [gui] Make proxy icon from statusbar clickable
6d5fcad [gui] Make proxy icon from statusbar clickable (Cristian Mircea Messel) Pull request description: Clicking on the proxy icon will open settings showing the network tab bitcoin/bitcoin#11491 (comment) Tree-SHA512: c3549749296918818694a371326d1a3b1075478918aaee940b5c7119a7e2cb991dcfda78f20d44d6d001157b9b82951f0d5157b17f4f0d1a0a242795efade036
2 parents df660aa + 6d5fcad commit 2a58340

File tree

4 files changed

+46
-18
lines changed

4 files changed

+46
-18
lines changed

src/qt/bitcoingui.cpp

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
146146
unitDisplayControl = new UnitDisplayStatusBarControl(platformStyle);
147147
labelWalletEncryptionIcon = new QLabel();
148148
labelWalletHDStatusIcon = new QLabel();
149-
labelProxyIcon = new QLabel();
149+
labelProxyIcon = new GUIUtil::ClickableLabel();
150150
connectionsControl = new GUIUtil::ClickableLabel();
151151
labelBlocksIcon = new GUIUtil::ClickableLabel();
152152
if(enableWallet)
@@ -193,7 +193,12 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
193193
// Subscribe to notifications from core
194194
subscribeToCoreSignals();
195195

196-
connect(connectionsControl, SIGNAL(clicked(QPoint)), this, SLOT(toggleNetworkActive()));
196+
connect(connectionsControl, &GUIUtil::ClickableLabel::clicked, [this] {
197+
m_node.setNetworkActive(!m_node.getNetworkActive());
198+
});
199+
connect(labelProxyIcon, &GUIUtil::ClickableLabel::clicked, [this] {
200+
openOptionsDialogWithTab(OptionsDialog::TAB_NETWORK);
201+
});
197202

198203
modalOverlay = new ModalOverlay(this->centralWidget());
199204
#ifdef ENABLE_WALLET
@@ -635,12 +640,7 @@ void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
635640

636641
void BitcoinGUI::optionsClicked()
637642
{
638-
if(!clientModel || !clientModel->getOptionsModel())
639-
return;
640-
641-
OptionsDialog dlg(this, enableWallet);
642-
dlg.setModel(clientModel->getOptionsModel());
643-
dlg.exec();
643+
openOptionsDialogWithTab(OptionsDialog::TAB_MAIN);
644644
}
645645

646646
void BitcoinGUI::aboutClicked()
@@ -764,6 +764,17 @@ void BitcoinGUI::updateHeadersSyncProgressLabel()
764764
progressBarLabel->setText(tr("Syncing Headers (%1%)...").arg(QString::number(100.0 / (headersTipHeight+estHeadersLeft)*headersTipHeight, 'f', 1)));
765765
}
766766

767+
void BitcoinGUI::openOptionsDialogWithTab(OptionsDialog::Tab tab)
768+
{
769+
if (!clientModel || !clientModel->getOptionsModel())
770+
return;
771+
772+
OptionsDialog dlg(this, enableWallet);
773+
dlg.setCurrentTab(tab);
774+
dlg.setModel(clientModel->getOptionsModel());
775+
dlg.exec();
776+
}
777+
767778
void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool header)
768779
{
769780
if (modalOverlay)
@@ -1231,11 +1242,6 @@ void BitcoinGUI::unsubscribeFromCoreSignals()
12311242
m_handler_question->disconnect();
12321243
}
12331244

1234-
void BitcoinGUI::toggleNetworkActive()
1235-
{
1236-
m_node.setNetworkActive(!m_node.getNetworkActive());
1237-
}
1238-
12391245
UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *platformStyle) :
12401246
optionsModel(0),
12411247
menu(0)

src/qt/bitcoingui.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <config/bitcoin-config.h>
1010
#endif
1111

12+
#include <qt/optionsdialog.h>
13+
1214
#include <amount.h>
1315

1416
#include <QLabel>
@@ -45,6 +47,10 @@ class QProgressBar;
4547
class QProgressDialog;
4648
QT_END_NAMESPACE
4749

50+
namespace GUIUtil {
51+
class ClickableLabel;
52+
}
53+
4854
/**
4955
Bitcoin GUI main class. This class represents the main window of the Bitcoin UI. It communicates with both the client and
5056
wallet models to give the user an up-to-date view of the current core state.
@@ -93,8 +99,8 @@ class BitcoinGUI : public QMainWindow
9399
UnitDisplayStatusBarControl* unitDisplayControl = nullptr;
94100
QLabel* labelWalletEncryptionIcon = nullptr;
95101
QLabel* labelWalletHDStatusIcon = nullptr;
96-
QLabel* labelProxyIcon = nullptr;
97-
QLabel* connectionsControl = nullptr;
102+
GUIUtil::ClickableLabel* labelProxyIcon = nullptr;
103+
GUIUtil::ClickableLabel* connectionsControl = nullptr;
98104
QLabel* labelBlocksIcon = nullptr;
99105
QLabel* progressBarLabel = nullptr;
100106
QProgressBar* progressBar = nullptr;
@@ -166,6 +172,9 @@ class BitcoinGUI : public QMainWindow
166172

167173
void updateHeadersSyncProgressLabel();
168174

175+
/** Open the OptionsDialog on the specified tab index */
176+
void openOptionsDialogWithTab(OptionsDialog::Tab tab);
177+
169178
Q_SIGNALS:
170179
/** Signal raised when a URI was entered or dragged to the GUI */
171180
void receivedURI(const QString &uri);
@@ -266,9 +275,6 @@ private Q_SLOTS:
266275
/** When hideTrayIcon setting is changed in OptionsModel hide or show the icon accordingly. */
267276
void setTrayIconVisible(bool);
268277

269-
/** Toggle networking */
270-
void toggleNetworkActive();
271-
272278
void showModalOverlay();
273279
};
274280

src/qt/optionsdialog.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,16 @@ void OptionsDialog::setModel(OptionsModel *_model)
174174
connect(ui->thirdPartyTxUrls, SIGNAL(textChanged(const QString &)), this, SLOT(showRestartWarning()));
175175
}
176176

177+
void OptionsDialog::setCurrentTab(OptionsDialog::Tab tab)
178+
{
179+
QWidget *tab_widget = nullptr;
180+
if (tab == OptionsDialog::Tab::TAB_NETWORK) tab_widget = ui->tabNetwork;
181+
if (tab == OptionsDialog::Tab::TAB_MAIN) tab_widget = ui->tabMain;
182+
if (tab_widget && ui->tabWidget->currentWidget() != tab_widget) {
183+
ui->tabWidget->setCurrentWidget(tab_widget);
184+
}
185+
}
186+
177187
void OptionsDialog::setMapper()
178188
{
179189
/* Main */

src/qt/optionsdialog.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,14 @@ class OptionsDialog : public QDialog
4040
explicit OptionsDialog(QWidget *parent, bool enableWallet);
4141
~OptionsDialog();
4242

43+
enum Tab {
44+
TAB_MAIN,
45+
TAB_NETWORK,
46+
};
47+
4348
void setModel(OptionsModel *model);
4449
void setMapper();
50+
void setCurrentTab(OptionsDialog::Tab tab);
4551

4652
private Q_SLOTS:
4753
/* set OK button state (enabled / disabled) */

0 commit comments

Comments
 (0)