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)
This commit is contained in:
Jonas Schnelli 2016-12-04 20:57:25 +01:00
commit 4d955fc582
No known key found for this signature in database
GPG Key ID: 29D4BCB6416F53EC
4 changed files with 39 additions and 33 deletions

View File

@ -199,8 +199,8 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle *
unitDisplayControl = new UnitDisplayStatusBarControl(platformStyle); unitDisplayControl = new UnitDisplayStatusBarControl(platformStyle);
labelWalletEncryptionIcon = new QLabel(); labelWalletEncryptionIcon = new QLabel();
labelWalletHDStatusIcon = new QLabel(); labelWalletHDStatusIcon = new QLabel();
connectionsControl = new NetworkToggleStatusBarControl(); connectionsControl = new GUIUtil::ClickableLabel();
labelBlocksIcon = new QLabel(); labelBlocksIcon = new GUIUtil::ClickableLabel();
if(enableWallet) if(enableWallet)
{ {
frameBlocksLayout->addStretch(); frameBlocksLayout->addStretch();
@ -244,10 +244,14 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle *
// Subscribe to notifications from core // Subscribe to notifications from core
subscribeToCoreSignals(); subscribeToCoreSignals();
connect(connectionsControl, SIGNAL(clicked(QPoint)), this, SLOT(toggleNetworkActive()));
modalOverlay = new ModalOverlay(this->centralWidget()); modalOverlay = new ModalOverlay(this->centralWidget());
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
if(enableWallet) if(enableWallet) {
connect(walletFrame, SIGNAL(requestedSyncWarningInfo()), this, SLOT(showModalOverlay())); connect(walletFrame, SIGNAL(requestedSyncWarningInfo()), this, SLOT(showModalOverlay()));
connect(labelBlocksIcon, SIGNAL(clicked(QPoint)), this, SLOT(showModalOverlay()));
}
#endif #endif
} }
@ -490,7 +494,6 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel)
} }
#endif // ENABLE_WALLET #endif // ENABLE_WALLET
unitDisplayControl->setOptionsModel(_clientModel->getOptionsModel()); unitDisplayControl->setOptionsModel(_clientModel->getOptionsModel());
connectionsControl->setClientModel(_clientModel);
OptionsModel* optionsModel = _clientModel->getOptionsModel(); OptionsModel* optionsModel = _clientModel->getOptionsModel();
if(optionsModel) if(optionsModel)
@ -517,7 +520,6 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel)
walletFrame->setClientModel(nullptr); walletFrame->setClientModel(nullptr);
#endif // ENABLE_WALLET #endif // ENABLE_WALLET
unitDisplayControl->setOptionsModel(nullptr); unitDisplayControl->setOptionsModel(nullptr);
connectionsControl->setClientModel(nullptr);
} }
} }
@ -1171,6 +1173,13 @@ void BitcoinGUI::unsubscribeFromCoreSignals()
uiInterface.ThreadSafeQuestion.disconnect(boost::bind(ThreadSafeMessageBox, this, _1, _3, _4)); uiInterface.ThreadSafeQuestion.disconnect(boost::bind(ThreadSafeMessageBox, this, _1, _3, _4));
} }
void BitcoinGUI::toggleNetworkActive()
{
if (clientModel) {
clientModel->setNetworkActive(!clientModel->getNetworkActive());
}
}
UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *platformStyle) : UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle *platformStyle) :
optionsModel(0), optionsModel(0),
menu(0) menu(0)
@ -1244,16 +1253,3 @@ void UnitDisplayStatusBarControl::onMenuSelection(QAction* action)
optionsModel->setDisplayUnit(action->data()); optionsModel->setDisplayUnit(action->data());
} }
} }
void NetworkToggleStatusBarControl::mousePressEvent(QMouseEvent *event)
{
if (clientModel) {
clientModel->setNetworkActive(!clientModel->getNetworkActive());
}
}
/** Lets the control know about the Client Model */
void NetworkToggleStatusBarControl::setClientModel(ClientModel *_clientModel)
{
this->clientModel = _clientModel;
}

View File

@ -26,7 +26,6 @@ class PlatformStyle;
class RPCConsole; class RPCConsole;
class SendCoinsRecipient; class SendCoinsRecipient;
class UnitDisplayStatusBarControl; class UnitDisplayStatusBarControl;
class NetworkToggleStatusBarControl;
class WalletFrame; class WalletFrame;
class WalletModel; class WalletModel;
class HelpMessageDialog; class HelpMessageDialog;
@ -86,7 +85,7 @@ private:
UnitDisplayStatusBarControl *unitDisplayControl; UnitDisplayStatusBarControl *unitDisplayControl;
QLabel *labelWalletEncryptionIcon; QLabel *labelWalletEncryptionIcon;
QLabel *labelWalletHDStatusIcon; QLabel *labelWalletHDStatusIcon;
NetworkToggleStatusBarControl *connectionsControl; QLabel *connectionsControl;
QLabel *labelBlocksIcon; QLabel *labelBlocksIcon;
QLabel *progressBarLabel; QLabel *progressBarLabel;
QProgressBar *progressBar; QProgressBar *progressBar;
@ -238,6 +237,9 @@ 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();
}; };
@ -270,17 +272,4 @@ private Q_SLOTS:
void onMenuSelection(QAction* action); void onMenuSelection(QAction* action);
}; };
class NetworkToggleStatusBarControl : public QLabel
{
Q_OBJECT
public:
void setClientModel(ClientModel *clientModel);
protected:
void mousePressEvent(QMouseEvent *event);
private:
ClientModel *clientModel;
};
#endif // BITCOIN_QT_BITCOINGUI_H #endif // BITCOIN_QT_BITCOINGUI_H

View File

@ -55,6 +55,7 @@
#include <QSettings> #include <QSettings>
#include <QTextDocument> // for Qt::mightBeRichText #include <QTextDocument> // for Qt::mightBeRichText
#include <QThread> #include <QThread>
#include <QMouseEvent>
#if QT_VERSION < 0x050000 #if QT_VERSION < 0x050000
#include <QUrl> #include <QUrl>
@ -986,4 +987,10 @@ QString formateNiceTimeOffset(qint64 secs)
} }
return timeBehindText; return timeBehindText;
} }
void ClickableLabel::mousePressEvent(QMouseEvent *event)
{
Q_EMIT clicked(event->pos());
}
} // namespace GUIUtil } // namespace GUIUtil

View File

@ -14,6 +14,7 @@
#include <QProgressBar> #include <QProgressBar>
#include <QString> #include <QString>
#include <QTableView> #include <QTableView>
#include <QLabel>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
@ -215,6 +216,19 @@ namespace GUIUtil
typedef QProgressBar ProgressBar; typedef QProgressBar ProgressBar;
#endif #endif
class ClickableLabel : public QLabel
{
Q_OBJECT
Q_SIGNALS:
/** Emitted when the label is clicked. The relative mouse coordinates of the click are
* passed to the signal.
*/
void clicked(const QPoint& point);
protected:
void mousePressEvent(QMouseEvent *event);
};
} // namespace GUIUtil } // namespace GUIUtil
#endif // BITCOIN_QT_GUIUTIL_H #endif // BITCOIN_QT_GUIUTIL_H