diff options
-rw-r--r-- | ui/qt/progress_frame.cpp | 9 | ||||
-rw-r--r-- | ui/qt/progress_frame.h | 2 | ||||
-rw-r--r-- | ui/qt/splash_overlay.cpp | 8 | ||||
-rw-r--r-- | ui/qt/splash_overlay.h | 4 |
4 files changed, 16 insertions, 7 deletions
diff --git a/ui/qt/progress_frame.cpp b/ui/qt/progress_frame.cpp index a41db8d539..d6cae5b425 100644 --- a/ui/qt/progress_frame.cpp +++ b/ui/qt/progress_frame.cpp @@ -27,6 +27,7 @@ #include "ui/progress_dlg.h" #include <QDialogButtonBox> +#include <QElapsedTimer> #include <QGraphicsOpacityEffect> #include <QBoxLayout> #include <QPropertyAnimation> @@ -76,10 +77,11 @@ delayed_create_progress_dlg(const gpointer top_level_window, const gchar *task_t /* * Update the progress information of the progress bar box. */ +static const int app_update_freq_ = 100; // ms void update_progress_dlg(progdlg_t *dlg, gfloat percentage, const gchar *) { - if (!dlg) return; + if (!dlg || dlg->elapsed_timer->elapsed() < app_update_freq_) return; dlg->progress_frame->setValue(percentage * 100); @@ -87,6 +89,7 @@ update_progress_dlg(progdlg_t *dlg, gfloat percentage, const gchar *) * Flush out the update and process any input events. */ WiresharkApplication::processEvents(); + dlg->elapsed_timer->restart(); } /* @@ -116,6 +119,7 @@ ProgressFrame::ProgressFrame(QWidget *parent) : ui->setupUi(this); progress_dialog_.progress_frame = this; + progress_dialog_.elapsed_timer = new QElapsedTimer(); progress_dialog_.top_level_window = window(); ui->progressBar->setStyleSheet(QString( @@ -156,12 +160,14 @@ ProgressFrame::ProgressFrame(QWidget *parent) : ProgressFrame::~ProgressFrame() { delete ui; + delete progress_dialog_.elapsed_timer; } struct progdlg *ProgressFrame::showProgress(bool animate, bool terminate_is_stop, gboolean *stop_flag, int value) { setMaximumValue(100); ui->progressBar->setValue(value); + progress_dialog_.elapsed_timer->start(); emit showRequested(animate, terminate_is_stop, stop_flag); return &progress_dialog_; } @@ -253,6 +259,7 @@ void ProgressFrame::timerEvent(QTimerEvent *event) void ProgressFrame::hide() { + progress_dialog_.elapsed_timer->invalidate(); #if !defined(Q_OS_MAC) || QT_VERSION > QT_VERSION_CHECK(5, 0, 0) show_timer_ = -1; #endif diff --git a/ui/qt/progress_frame.h b/ui/qt/progress_frame.h index 65ea72a9b7..719af1484b 100644 --- a/ui/qt/progress_frame.h +++ b/ui/qt/progress_frame.h @@ -37,12 +37,14 @@ class ProgressFrame; class ProgressFrame; class QDialogButtonBox; +class QElapsedTimer; class QGraphicsOpacityEffect; class QPropertyAnimation; // Define the structure describing a progress dialog. struct progdlg { ProgressFrame *progress_frame; // This progress frame + QElapsedTimer *elapsed_timer; // Application event processing QWidget *top_level_window; // Progress frame's main window }; diff --git a/ui/qt/splash_overlay.cpp b/ui/qt/splash_overlay.cpp index b797df7454..a38dcf86bb 100644 --- a/ui/qt/splash_overlay.cpp +++ b/ui/qt/splash_overlay.cpp @@ -39,7 +39,7 @@ /* * Update frequency for the splash screen, given in milliseconds. */ -int info_update_freq_ = 100; +static int info_update_freq_ = 100; void splash_update(register_action_e action, const char *message, void *) { emit wsApp->registerUpdate(action, message); @@ -60,7 +60,7 @@ SplashOverlay::SplashOverlay(QWidget *parent) : register_add += wslua_count_plugins(); /* get count of lua plugins */ #endif so_ui_->progressBar->setMaximum((int)register_count() + register_add); - time_.start(); + elapsed_timer_.start(); setPalette(Qt::transparent); setStyleSheet(QString( @@ -119,7 +119,7 @@ void SplashOverlay::splashUpdate(register_action_e action, const char *message) #endif register_cur_++; - if (last_action_ == action && time_.elapsed() < info_update_freq_ && register_cur_ != so_ui_->progressBar->maximum()) { + if (last_action_ == action && elapsed_timer_.elapsed() < info_update_freq_ && register_cur_ != so_ui_->progressBar->maximum()) { /* Only update every splash_register_freq milliseconds */ return; } @@ -173,7 +173,7 @@ void SplashOverlay::splashUpdate(register_action_e action, const char *message) so_ui_->progressBar->setValue(register_cur_); wsApp->processEvents(); - time_.restart(); + elapsed_timer_.restart(); } void SplashOverlay::paintEvent(QPaintEvent *) diff --git a/ui/qt/splash_overlay.h b/ui/qt/splash_overlay.h index 4fc6631b7c..2cae0c1694 100644 --- a/ui/qt/splash_overlay.h +++ b/ui/qt/splash_overlay.h @@ -29,7 +29,7 @@ #include "register.h" #include <QWidget> -#include <QTime> +#include <QElapsedTimer> void splash_update(register_action_e action, const char *message, void *dummy); @@ -53,7 +53,7 @@ private: bool blurred_; register_action_e last_action_; int register_cur_; - QTime time_; + QElapsedTimer elapsed_timer_; private slots: void splashUpdate(register_action_e action, const char *message); |