mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-11 20:32:35 -03:00
Merge #13248: [gui] Make proxy icon from statusbar clickable
6d5fcad576
[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
https://github.com/bitcoin/bitcoin/pull/11491#issuecomment-336685303
Tree-SHA512: c3549749296918818694a371326d1a3b1075478918aaee940b5c7119a7e2cb991dcfda78f20d44d6d001157b9b82951f0d5157b17f4f0d1a0a242795efade036
This commit is contained in:
commit
2a583406c0
4 changed files with 46 additions and 18 deletions
|
@ -146,7 +146,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
|
||||||
unitDisplayControl = new UnitDisplayStatusBarControl(platformStyle);
|
unitDisplayControl = new UnitDisplayStatusBarControl(platformStyle);
|
||||||
labelWalletEncryptionIcon = new QLabel();
|
labelWalletEncryptionIcon = new QLabel();
|
||||||
labelWalletHDStatusIcon = new QLabel();
|
labelWalletHDStatusIcon = new QLabel();
|
||||||
labelProxyIcon = new QLabel();
|
labelProxyIcon = new GUIUtil::ClickableLabel();
|
||||||
connectionsControl = new GUIUtil::ClickableLabel();
|
connectionsControl = new GUIUtil::ClickableLabel();
|
||||||
labelBlocksIcon = new GUIUtil::ClickableLabel();
|
labelBlocksIcon = new GUIUtil::ClickableLabel();
|
||||||
if(enableWallet)
|
if(enableWallet)
|
||||||
|
@ -193,7 +193,12 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty
|
||||||
// Subscribe to notifications from core
|
// Subscribe to notifications from core
|
||||||
subscribeToCoreSignals();
|
subscribeToCoreSignals();
|
||||||
|
|
||||||
connect(connectionsControl, SIGNAL(clicked(QPoint)), this, SLOT(toggleNetworkActive()));
|
connect(connectionsControl, &GUIUtil::ClickableLabel::clicked, [this] {
|
||||||
|
m_node.setNetworkActive(!m_node.getNetworkActive());
|
||||||
|
});
|
||||||
|
connect(labelProxyIcon, &GUIUtil::ClickableLabel::clicked, [this] {
|
||||||
|
openOptionsDialogWithTab(OptionsDialog::TAB_NETWORK);
|
||||||
|
});
|
||||||
|
|
||||||
modalOverlay = new ModalOverlay(this->centralWidget());
|
modalOverlay = new ModalOverlay(this->centralWidget());
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
|
@ -635,12 +640,7 @@ void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
|
||||||
|
|
||||||
void BitcoinGUI::optionsClicked()
|
void BitcoinGUI::optionsClicked()
|
||||||
{
|
{
|
||||||
if(!clientModel || !clientModel->getOptionsModel())
|
openOptionsDialogWithTab(OptionsDialog::TAB_MAIN);
|
||||||
return;
|
|
||||||
|
|
||||||
OptionsDialog dlg(this, enableWallet);
|
|
||||||
dlg.setModel(clientModel->getOptionsModel());
|
|
||||||
dlg.exec();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinGUI::aboutClicked()
|
void BitcoinGUI::aboutClicked()
|
||||||
|
@ -764,6 +764,17 @@ void BitcoinGUI::updateHeadersSyncProgressLabel()
|
||||||
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)
|
||||||
|
{
|
||||||
|
if (!clientModel || !clientModel->getOptionsModel())
|
||||||
|
return;
|
||||||
|
|
||||||
|
OptionsDialog dlg(this, enableWallet);
|
||||||
|
dlg.setCurrentTab(tab);
|
||||||
|
dlg.setModel(clientModel->getOptionsModel());
|
||||||
|
dlg.exec();
|
||||||
|
}
|
||||||
|
|
||||||
void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool header)
|
void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool header)
|
||||||
{
|
{
|
||||||
if (modalOverlay)
|
if (modalOverlay)
|
||||||
|
@ -1231,11 +1242,6 @@ void BitcoinGUI::unsubscribeFromCoreSignals()
|
||||||
m_handler_question->disconnect();
|
m_handler_question->disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinGUI::toggleNetworkActive()
|
|
||||||
{
|
|
||||||
m_node.setNetworkActive(!m_node.getNetworkActive());
|
|
||||||
}
|
|
||||||
|
|
||||||
UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *platformStyle) :
|
UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *platformStyle) :
|
||||||
optionsModel(0),
|
optionsModel(0),
|
||||||
menu(0)
|
menu(0)
|
||||||
|
|
|
@ -9,6 +9,8 @@
|
||||||
#include <config/bitcoin-config.h>
|
#include <config/bitcoin-config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <qt/optionsdialog.h>
|
||||||
|
|
||||||
#include <amount.h>
|
#include <amount.h>
|
||||||
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
@ -45,6 +47,10 @@ class QProgressBar;
|
||||||
class QProgressDialog;
|
class QProgressDialog;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
|
namespace GUIUtil {
|
||||||
|
class ClickableLabel;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Bitcoin GUI main class. This class represents the main window of the Bitcoin UI. It communicates with both the client and
|
Bitcoin GUI main class. This class represents the main window of the Bitcoin UI. It communicates with both the client and
|
||||||
wallet models to give the user an up-to-date view of the current core state.
|
wallet models to give the user an up-to-date view of the current core state.
|
||||||
|
@ -93,8 +99,8 @@ private:
|
||||||
UnitDisplayStatusBarControl* unitDisplayControl = nullptr;
|
UnitDisplayStatusBarControl* unitDisplayControl = nullptr;
|
||||||
QLabel* labelWalletEncryptionIcon = nullptr;
|
QLabel* labelWalletEncryptionIcon = nullptr;
|
||||||
QLabel* labelWalletHDStatusIcon = nullptr;
|
QLabel* labelWalletHDStatusIcon = nullptr;
|
||||||
QLabel* labelProxyIcon = nullptr;
|
GUIUtil::ClickableLabel* labelProxyIcon = nullptr;
|
||||||
QLabel* connectionsControl = nullptr;
|
GUIUtil::ClickableLabel* connectionsControl = nullptr;
|
||||||
QLabel* labelBlocksIcon = nullptr;
|
QLabel* labelBlocksIcon = nullptr;
|
||||||
QLabel* progressBarLabel = nullptr;
|
QLabel* progressBarLabel = nullptr;
|
||||||
QProgressBar* progressBar = nullptr;
|
QProgressBar* progressBar = nullptr;
|
||||||
|
@ -166,6 +172,9 @@ private:
|
||||||
|
|
||||||
void updateHeadersSyncProgressLabel();
|
void updateHeadersSyncProgressLabel();
|
||||||
|
|
||||||
|
/** Open the OptionsDialog on the specified tab index */
|
||||||
|
void openOptionsDialogWithTab(OptionsDialog::Tab tab);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
/** Signal raised when a URI was entered or dragged to the GUI */
|
/** Signal raised when a URI was entered or dragged to the GUI */
|
||||||
void receivedURI(const QString &uri);
|
void receivedURI(const QString &uri);
|
||||||
|
@ -266,9 +275,6 @@ private Q_SLOTS:
|
||||||
/** When hideTrayIcon setting is changed in OptionsModel hide or show the icon accordingly. */
|
/** When hideTrayIcon setting is changed in OptionsModel hide or show the icon accordingly. */
|
||||||
void setTrayIconVisible(bool);
|
void setTrayIconVisible(bool);
|
||||||
|
|
||||||
/** Toggle networking */
|
|
||||||
void toggleNetworkActive();
|
|
||||||
|
|
||||||
void showModalOverlay();
|
void showModalOverlay();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -174,6 +174,16 @@ void OptionsDialog::setModel(OptionsModel *_model)
|
||||||
connect(ui->thirdPartyTxUrls, SIGNAL(textChanged(const QString &)), this, SLOT(showRestartWarning()));
|
connect(ui->thirdPartyTxUrls, SIGNAL(textChanged(const QString &)), this, SLOT(showRestartWarning()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OptionsDialog::setCurrentTab(OptionsDialog::Tab tab)
|
||||||
|
{
|
||||||
|
QWidget *tab_widget = nullptr;
|
||||||
|
if (tab == OptionsDialog::Tab::TAB_NETWORK) tab_widget = ui->tabNetwork;
|
||||||
|
if (tab == OptionsDialog::Tab::TAB_MAIN) tab_widget = ui->tabMain;
|
||||||
|
if (tab_widget && ui->tabWidget->currentWidget() != tab_widget) {
|
||||||
|
ui->tabWidget->setCurrentWidget(tab_widget);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void OptionsDialog::setMapper()
|
void OptionsDialog::setMapper()
|
||||||
{
|
{
|
||||||
/* Main */
|
/* Main */
|
||||||
|
|
|
@ -40,8 +40,14 @@ public:
|
||||||
explicit OptionsDialog(QWidget *parent, bool enableWallet);
|
explicit OptionsDialog(QWidget *parent, bool enableWallet);
|
||||||
~OptionsDialog();
|
~OptionsDialog();
|
||||||
|
|
||||||
|
enum Tab {
|
||||||
|
TAB_MAIN,
|
||||||
|
TAB_NETWORK,
|
||||||
|
};
|
||||||
|
|
||||||
void setModel(OptionsModel *model);
|
void setModel(OptionsModel *model);
|
||||||
void setMapper();
|
void setMapper();
|
||||||
|
void setCurrentTab(OptionsDialog::Tab tab);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
/* set OK button state (enabled / disabled) */
|
/* set OK button state (enabled / disabled) */
|
||||||
|
|
Loading…
Reference in a new issue