Skip to content

Commit 4d955fc

Browse files
committed
Merge #9218: qt: Show progress overlay when clicking spinner icon
042f9fa qt: Show progress overlay when clicking spinner icon (Wladimir J. van der Laan) 827d9a3 qt: Replace NetworkToggleStatusBarControl with generic ClickableLabel (Wladimir J. van der Laan)
2 parents 2efcfa5 + 042f9fa commit 4d955fc

File tree

4 files changed

+39
-33
lines changed

4 files changed

+39
-33
lines changed

src/qt/bitcoingui.cpp

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle *
199199
unitDisplayControl = new UnitDisplayStatusBarControl(platformStyle);
200200
labelWalletEncryptionIcon = new QLabel();
201201
labelWalletHDStatusIcon = new QLabel();
202-
connectionsControl = new NetworkToggleStatusBarControl();
203-
labelBlocksIcon = new QLabel();
202+
connectionsControl = new GUIUtil::ClickableLabel();
203+
labelBlocksIcon = new GUIUtil::ClickableLabel();
204204
if(enableWallet)
205205
{
206206
frameBlocksLayout->addStretch();
@@ -244,10 +244,14 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle *
244244
// Subscribe to notifications from core
245245
subscribeToCoreSignals();
246246

247+
connect(connectionsControl, SIGNAL(clicked(QPoint)), this, SLOT(toggleNetworkActive()));
248+
247249
modalOverlay = new ModalOverlay(this->centralWidget());
248250
#ifdef ENABLE_WALLET
249-
if(enableWallet)
251+
if(enableWallet) {
250252
connect(walletFrame, SIGNAL(requestedSyncWarningInfo()), this, SLOT(showModalOverlay()));
253+
connect(labelBlocksIcon, SIGNAL(clicked(QPoint)), this, SLOT(showModalOverlay()));
254+
}
251255
#endif
252256
}
253257

@@ -490,7 +494,6 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel)
490494
}
491495
#endif // ENABLE_WALLET
492496
unitDisplayControl->setOptionsModel(_clientModel->getOptionsModel());
493-
connectionsControl->setClientModel(_clientModel);
494497

495498
OptionsModel* optionsModel = _clientModel->getOptionsModel();
496499
if(optionsModel)
@@ -517,7 +520,6 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel)
517520
walletFrame->setClientModel(nullptr);
518521
#endif // ENABLE_WALLET
519522
unitDisplayControl->setOptionsModel(nullptr);
520-
connectionsControl->setClientModel(nullptr);
521523
}
522524
}
523525

@@ -1171,6 +1173,13 @@ void BitcoinGUI::unsubscribeFromCoreSignals()
11711173
uiInterface.ThreadSafeQuestion.disconnect(boost::bind(ThreadSafeMessageBox, this, _1, _3, _4));
11721174
}
11731175

1176+
void BitcoinGUI::toggleNetworkActive()
1177+
{
1178+
if (clientModel) {
1179+
clientModel->setNetworkActive(!clientModel->getNetworkActive());
1180+
}
1181+
}
1182+
11741183
UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *platformStyle) :
11751184
optionsModel(0),
11761185
menu(0)
@@ -1244,16 +1253,3 @@ void UnitDisplayStatusBarControl::onMenuSelection(QAction* action)
12441253
optionsModel->setDisplayUnit(action->data());
12451254
}
12461255
}
1247-
1248-
void NetworkToggleStatusBarControl::mousePressEvent(QMouseEvent *event)
1249-
{
1250-
if (clientModel) {
1251-
clientModel->setNetworkActive(!clientModel->getNetworkActive());
1252-
}
1253-
}
1254-
1255-
/** Lets the control know about the Client Model */
1256-
void NetworkToggleStatusBarControl::setClientModel(ClientModel *_clientModel)
1257-
{
1258-
this->clientModel = _clientModel;
1259-
}

src/qt/bitcoingui.h

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ class PlatformStyle;
2626
class RPCConsole;
2727
class SendCoinsRecipient;
2828
class UnitDisplayStatusBarControl;
29-
class NetworkToggleStatusBarControl;
3029
class WalletFrame;
3130
class WalletModel;
3231
class HelpMessageDialog;
@@ -86,7 +85,7 @@ class BitcoinGUI : public QMainWindow
8685
UnitDisplayStatusBarControl *unitDisplayControl;
8786
QLabel *labelWalletEncryptionIcon;
8887
QLabel *labelWalletHDStatusIcon;
89-
NetworkToggleStatusBarControl *connectionsControl;
88+
QLabel *connectionsControl;
9089
QLabel *labelBlocksIcon;
9190
QLabel *progressBarLabel;
9291
QProgressBar *progressBar;
@@ -238,6 +237,9 @@ private Q_SLOTS:
238237
/** When hideTrayIcon setting is changed in OptionsModel hide or show the icon accordingly. */
239238
void setTrayIconVisible(bool);
240239

240+
/** Toggle networking */
241+
void toggleNetworkActive();
242+
241243
void showModalOverlay();
242244
};
243245

@@ -270,17 +272,4 @@ private Q_SLOTS:
270272
void onMenuSelection(QAction* action);
271273
};
272274

273-
class NetworkToggleStatusBarControl : public QLabel
274-
{
275-
Q_OBJECT
276-
277-
public:
278-
void setClientModel(ClientModel *clientModel);
279-
protected:
280-
void mousePressEvent(QMouseEvent *event);
281-
282-
private:
283-
ClientModel *clientModel;
284-
};
285-
286275
#endif // BITCOIN_QT_BITCOINGUI_H

src/qt/guiutil.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
#include <QSettings>
5656
#include <QTextDocument> // for Qt::mightBeRichText
5757
#include <QThread>
58+
#include <QMouseEvent>
5859

5960
#if QT_VERSION < 0x050000
6061
#include <QUrl>
@@ -986,4 +987,10 @@ QString formateNiceTimeOffset(qint64 secs)
986987
}
987988
return timeBehindText;
988989
}
990+
991+
void ClickableLabel::mousePressEvent(QMouseEvent *event)
992+
{
993+
Q_EMIT clicked(event->pos());
994+
}
995+
989996
} // namespace GUIUtil

src/qt/guiutil.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <QProgressBar>
1515
#include <QString>
1616
#include <QTableView>
17+
#include <QLabel>
1718

1819
#include <boost/filesystem.hpp>
1920

@@ -215,6 +216,19 @@ namespace GUIUtil
215216
typedef QProgressBar ProgressBar;
216217
#endif
217218

219+
class ClickableLabel : public QLabel
220+
{
221+
Q_OBJECT
222+
223+
Q_SIGNALS:
224+
/** Emitted when the label is clicked. The relative mouse coordinates of the click are
225+
* passed to the signal.
226+
*/
227+
void clicked(const QPoint& point);
228+
protected:
229+
void mousePressEvent(QMouseEvent *event);
230+
};
231+
218232
} // namespace GUIUtil
219233

220234
#endif // BITCOIN_QT_GUIUTIL_H

0 commit comments

Comments
 (0)