Skip to content

Commit e15660c

Browse files
committed
Merge #9280: [Qt] Show ModalOverlay by pressing the progress bar, allow hiding
89a3723 [Qt] Show ModalOverlay by pressing the progress bar, disabled show() in sync mode (Jonas Schnelli)
2 parents 919db03 + 89a3723 commit e15660c

File tree

5 files changed

+46
-19
lines changed

5 files changed

+46
-19
lines changed

src/qt/bitcoingui.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
#include <QMenuBar>
4747
#include <QMessageBox>
4848
#include <QMimeData>
49-
#include <QProgressBar>
5049
#include <QProgressDialog>
5150
#include <QSettings>
5251
#include <QShortcut>
@@ -251,6 +250,7 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle *
251250
if(enableWallet) {
252251
connect(walletFrame, SIGNAL(requestedSyncWarningInfo()), this, SLOT(showModalOverlay()));
253252
connect(labelBlocksIcon, SIGNAL(clicked(QPoint)), this, SLOT(showModalOverlay()));
253+
connect(progressBar, SIGNAL(clicked(QPoint)), this, SLOT(showModalOverlay()));
254254
}
255255
#endif
256256
}
@@ -1138,8 +1138,8 @@ void BitcoinGUI::setTrayIconVisible(bool fHideTrayIcon)
11381138

11391139
void BitcoinGUI::showModalOverlay()
11401140
{
1141-
if (modalOverlay)
1142-
modalOverlay->showHide(false, true);
1141+
if (modalOverlay && (progressBar->isVisible() || modalOverlay->isLayerVisible()))
1142+
modalOverlay->toggleVisibility();
11431143
}
11441144

11451145
static bool ThreadSafeMessageBox(BitcoinGUI *gui, const std::string& message, const std::string& caption, unsigned int style)

src/qt/guiutil.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,12 @@ QString formateNiceTimeOffset(qint64 secs)
988988
return timeBehindText;
989989
}
990990

991-
void ClickableLabel::mousePressEvent(QMouseEvent *event)
991+
void ClickableLabel::mouseReleaseEvent(QMouseEvent *event)
992+
{
993+
Q_EMIT clicked(event->pos());
994+
}
995+
996+
void ClickableProgressBar::mouseReleaseEvent(QMouseEvent *event)
992997
{
993998
Q_EMIT clicked(event->pos());
994999
}

src/qt/guiutil.h

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -202,20 +202,6 @@ namespace GUIUtil
202202

203203
QString formateNiceTimeOffset(qint64 secs);
204204

205-
#if defined(Q_OS_MAC) && QT_VERSION >= 0x050000
206-
// workaround for Qt OSX Bug:
207-
// https://bugreports.qt-project.org/browse/QTBUG-15631
208-
// QProgressBar uses around 10% CPU even when app is in background
209-
class ProgressBar : public QProgressBar
210-
{
211-
bool event(QEvent *e) {
212-
return (e->type() != QEvent::StyleAnimationUpdate) ? QProgressBar::event(e) : false;
213-
}
214-
};
215-
#else
216-
typedef QProgressBar ProgressBar;
217-
#endif
218-
219205
class ClickableLabel : public QLabel
220206
{
221207
Q_OBJECT
@@ -226,8 +212,35 @@ namespace GUIUtil
226212
*/
227213
void clicked(const QPoint& point);
228214
protected:
229-
void mousePressEvent(QMouseEvent *event);
215+
void mouseReleaseEvent(QMouseEvent *event);
216+
};
217+
218+
class ClickableProgressBar : public QProgressBar
219+
{
220+
Q_OBJECT
221+
222+
Q_SIGNALS:
223+
/** Emitted when the progressbar is clicked. The relative mouse coordinates of the click are
224+
* passed to the signal.
225+
*/
226+
void clicked(const QPoint& point);
227+
protected:
228+
void mouseReleaseEvent(QMouseEvent *event);
229+
};
230+
231+
#if defined(Q_OS_MAC) && QT_VERSION >= 0x050000
232+
// workaround for Qt OSX Bug:
233+
// https://bugreports.qt-project.org/browse/QTBUG-15631
234+
// QProgressBar uses around 10% CPU even when app is in background
235+
class ProgressBar : public ClickableProgressBar
236+
{
237+
bool event(QEvent *e) {
238+
return (e->type() != QEvent::StyleAnimationUpdate) ? QProgressBar::event(e) : false;
239+
}
230240
};
241+
#else
242+
typedef ClickableProgressBar ProgressBar;
243+
#endif
231244

232245
} // namespace GUIUtil
233246

src/qt/modaloverlay.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ void ModalOverlay::tipUpdate(int count, const QDateTime& blockDate, double nVeri
137137
}
138138
}
139139

140+
void ModalOverlay::toggleVisibility()
141+
{
142+
showHide(layerIsVisible, true);
143+
if (!layerIsVisible)
144+
userClosed = true;
145+
}
146+
140147
void ModalOverlay::showHide(bool hide, bool userRequested)
141148
{
142149
if ( (layerIsVisible && !hide) || (!layerIsVisible && hide) || (!hide && userClosed && !userRequested))

src/qt/modaloverlay.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@ public Q_SLOTS:
2525
void tipUpdate(int count, const QDateTime& blockDate, double nVerificationProgress);
2626
void setKnownBestHeight(int count, const QDateTime& blockDate);
2727

28+
void toggleVisibility();
2829
// will show or hide the modal layer
2930
void showHide(bool hide = false, bool userRequested = false);
3031
void closeClicked();
32+
bool isLayerVisible() { return layerIsVisible; }
3133

3234
protected:
3335
bool eventFilter(QObject * obj, QEvent * ev);

0 commit comments

Comments
 (0)