12
12
#include " clientmodel.h"
13
13
#include " guiconstants.h"
14
14
#include " guiutil.h"
15
+ #include " modaloverlay.h"
15
16
#include " networkstyle.h"
16
17
#include " notificator.h"
17
18
#include " openuridialog.h"
@@ -115,6 +116,7 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle *
115
116
notificator(0 ),
116
117
rpcConsole(0 ),
117
118
helpMessageDialog(0 ),
119
+ modalOverlay(0 ),
118
120
prevBlocks(0 ),
119
121
spinnerFrame(0 ),
120
122
platformStyle(_platformStyle)
@@ -239,6 +241,12 @@ BitcoinGUI::BitcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle *
239
241
240
242
// Subscribe to notifications from core
241
243
subscribeToCoreSignals ();
244
+
245
+ modalOverlay = new ModalOverlay (this ->centralWidget ());
246
+ #ifdef ENABLE_WALLET
247
+ if (enableWallet)
248
+ connect (walletFrame, SIGNAL (requestedSyncWarningInfo ()), this , SLOT (showModalOverlay ()));
249
+ #endif
242
250
}
243
251
244
252
BitcoinGUI::~BitcoinGUI ()
@@ -489,6 +497,8 @@ void BitcoinGUI::setClientModel(ClientModel *_clientModel)
489
497
// initialize the disable state of the tray icon with the current value in the model.
490
498
setTrayIconVisible (optionsModel->getHideTrayIcon ());
491
499
}
500
+
501
+ modalOverlay->setKnownBestHeight (clientModel->getHeaderTipHeight (), QDateTime::fromTime_t (clientModel->getHeaderTipTime ()));
492
502
} else {
493
503
// Disable possibility to show main window via action
494
504
toggleHideAction->setEnabled (false );
@@ -703,7 +713,17 @@ void BitcoinGUI::setNumConnections(int count)
703
713
704
714
void BitcoinGUI::setNumBlocks (int count, const QDateTime& blockDate, double nVerificationProgress, bool header)
705
715
{
706
- if (!clientModel)
716
+ if (modalOverlay)
717
+ {
718
+ if (header) {
719
+ /* use clientmodels getHeaderTipHeight and getHeaderTipTime because the NotifyHeaderTip signal does not fire when updating the best header */
720
+ modalOverlay->setKnownBestHeight (clientModel->getHeaderTipHeight (), QDateTime::fromTime_t (clientModel->getHeaderTipTime ()));
721
+ }
722
+ else {
723
+ modalOverlay->tipUpdate (count, blockDate, nVerificationProgress);
724
+ }
725
+ }
726
+ if (!clientModel)
707
727
return ;
708
728
709
729
// Prevent orphan statusbar messages (e.g. hover Quit in main menu, wait until chain-sync starts -> garbelled text)
@@ -752,38 +772,18 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
752
772
753
773
#ifdef ENABLE_WALLET
754
774
if (walletFrame)
775
+ {
755
776
walletFrame->showOutOfSyncWarning (false );
777
+ modalOverlay->showHide (true , true );
778
+ }
756
779
#endif // ENABLE_WALLET
757
780
758
781
progressBarLabel->setVisible (false );
759
782
progressBar->setVisible (false );
760
783
}
761
784
else
762
785
{
763
- // Represent time from last generated block in human readable text
764
- QString timeBehindText;
765
- const int HOUR_IN_SECONDS = 60 *60 ;
766
- const int DAY_IN_SECONDS = 24 *60 *60 ;
767
- const int WEEK_IN_SECONDS = 7 *24 *60 *60 ;
768
- const int YEAR_IN_SECONDS = 31556952 ; // Average length of year in Gregorian calendar
769
- if (secs < 2 *DAY_IN_SECONDS)
770
- {
771
- timeBehindText = tr (" %n hour(s)" ," " ,secs/HOUR_IN_SECONDS);
772
- }
773
- else if (secs < 2 *WEEK_IN_SECONDS)
774
- {
775
- timeBehindText = tr (" %n day(s)" ," " ,secs/DAY_IN_SECONDS);
776
- }
777
- else if (secs < YEAR_IN_SECONDS)
778
- {
779
- timeBehindText = tr (" %n week(s)" ," " ,secs/WEEK_IN_SECONDS);
780
- }
781
- else
782
- {
783
- qint64 years = secs / YEAR_IN_SECONDS;
784
- qint64 remainder = secs % YEAR_IN_SECONDS;
785
- timeBehindText = tr (" %1 and %2" ).arg (tr (" %n year(s)" , " " , years)).arg (tr (" %n week(s)" ," " , remainder/WEEK_IN_SECONDS));
786
- }
786
+ QString timeBehindText = GUIUtil::formateNiceTimeOffset (secs);
787
787
788
788
progressBarLabel->setVisible (true );
789
789
progressBar->setFormat (tr (" %1 behind" ).arg (timeBehindText));
@@ -803,7 +803,10 @@ void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVer
803
803
804
804
#ifdef ENABLE_WALLET
805
805
if (walletFrame)
806
+ {
806
807
walletFrame->showOutOfSyncWarning (true );
808
+ modalOverlay->showHide ();
809
+ }
807
810
#endif // ENABLE_WALLET
808
811
809
812
tooltip += QString (" <br>" );
@@ -1099,6 +1102,12 @@ void BitcoinGUI::setTrayIconVisible(bool fHideTrayIcon)
1099
1102
}
1100
1103
}
1101
1104
1105
+ void BitcoinGUI::showModalOverlay ()
1106
+ {
1107
+ if (modalOverlay)
1108
+ modalOverlay->showHide (false , true );
1109
+ }
1110
+
1102
1111
static bool ThreadSafeMessageBox (BitcoinGUI *gui, const std::string& message, const std::string& caption, unsigned int style)
1103
1112
{
1104
1113
bool modal = (style & CClientUIInterface::MODAL);
0 commit comments