aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2015-06-19 16:56:44 -0700
committerGerald Combs <gerald@wireshark.org>2015-06-23 06:06:37 +0000
commit1dc608a05e4caa378dda710b829eee4d83d7cd80 (patch)
tree55d1fbbec6e7d3902422fa4600056f26843e3d91
parent0c71b13b3e444f7d6d891aa3c9a2bc22601392f5 (diff)
Morph ProgressBar into CaptureProgressFrame.
Switch from a plain QProgressBar to a QFrame with a QProgressBar and a stop button. Add a stop_flag boolean to the capture_file struct. To do: - Start adding the progress bar to dialogs. - Don't complain so loudly when the user stops a capture. Change-Id: Iedd1d7d79f2044f1a53e4fb22186d25930a3ef03 Reviewed-on: https://code.wireshark.org/review/9029 Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
-rw-r--r--cfile.h2
-rw-r--r--file.c44
-rw-r--r--ui/qt/CMakeLists.txt5
-rw-r--r--ui/qt/Makefile.am2
-rw-r--r--ui/qt/Makefile.common6
-rw-r--r--ui/qt/Wireshark.pro5
-rw-r--r--ui/qt/capture_file.cpp9
-rw-r--r--ui/qt/capture_file.h13
-rw-r--r--ui/qt/capture_file_progress_frame.cpp (renamed from ui/qt/progress_bar.cpp)140
-rw-r--r--ui/qt/capture_file_progress_frame.h (renamed from ui/qt/progress_bar.h)45
-rw-r--r--ui/qt/capture_file_progress_frame.ui62
-rw-r--r--ui/qt/io_graph_dialog.cpp2
-rw-r--r--ui/qt/main_status_bar.cpp5
-rw-r--r--ui/qt/main_status_bar.h17
-rw-r--r--ui/qt/main_window.cpp6
-rw-r--r--ui/qt/main_window.h1
-rw-r--r--ui/qt/main_window_slots.cpp9
17 files changed, 232 insertions, 141 deletions
diff --git a/cfile.h b/cfile.h
index fda7815421..5d40dd8ce1 100644
--- a/cfile.h
+++ b/cfile.h
@@ -70,6 +70,8 @@ typedef struct _capture_file {
gchar *source; /* Temp file source, e.g. "Pipe from elsewhere" */
gboolean is_tempfile; /* Is capture file a temporary file? */
gboolean unsaved_changes; /* Does the capture file have changes that have not been saved? */
+ gboolean stop_flag; /* Stop current processing (loading, searching, etc.) */
+
gint64 f_datalen; /* Size of capture file data (uncompressed) */
guint16 cd_t; /* File type of capture file */
unsigned int open_type; /* open_routine index+1 used, if selected, or WTAP_TYPE_AUTO */
diff --git a/file.c b/file.c
index b08a73a7fd..79a8e11455 100644
--- a/file.c
+++ b/file.c
@@ -408,6 +408,7 @@ cf_add_encapsulation_type(capture_file *cf, int encap)
void
cf_close(capture_file *cf)
{
+ cf->stop_flag = FALSE;
if (cf->state == FILE_CLOSED)
return; /* Nothing to do */
@@ -533,7 +534,6 @@ cf_read(capture_file *cf, gboolean reloading)
gchar *err_info;
gchar *name_ptr;
progdlg_t *progbar = NULL;
- gboolean stop_flag;
GTimeVal start_time;
epan_dissect_t edt;
dfilter_t *dfcode;
@@ -569,7 +569,7 @@ cf_read(capture_file *cf, gboolean reloading)
/* The packet list window will be empty until the file is completly loaded */
packet_list_freeze();
- stop_flag = FALSE;
+ cf->stop_flag = FALSE;
g_get_current_time(&start_time);
epan_dissect_init(&edt, cf->epan, create_proto_tree, FALSE);
@@ -619,10 +619,10 @@ cf_read(capture_file *cf, gboolean reloading)
progbar_val = calc_progbar_val(cf, size, file_pos, status_str, sizeof(status_str));
if (reloading)
progbar = delayed_create_progress_dlg(cf->window, "Reloading", name_ptr,
- TRUE, &stop_flag, &start_time, progbar_val);
+ TRUE, &cf->stop_flag, &start_time, progbar_val);
else
progbar = delayed_create_progress_dlg(cf->window, "Loading", name_ptr,
- TRUE, &stop_flag, &start_time, progbar_val);
+ TRUE, &cf->stop_flag, &start_time, progbar_val);
}
/* Update the progress bar, but do it only N_PROGBAR_UPDATES times;
@@ -648,7 +648,7 @@ cf_read(capture_file *cf, gboolean reloading)
}
}
- if (stop_flag) {
+ if (cf->stop_flag) {
/* Well, the user decided to abort the read. He/She will be warned and
it might be enough for him/her to work with the already loaded
packets.
@@ -722,7 +722,7 @@ cf_read(capture_file *cf, gboolean reloading)
packet_list_select_first_row();
}
- if (stop_flag) {
+ if (cf->stop_flag) {
simple_message_box(ESD_TYPE_WARN, NULL,
"The remaining packets in the file were discarded.\n"
"\n"
@@ -1406,7 +1406,6 @@ cf_merge_files(char **out_filenamep, int in_file_count,
/* Progress so far. */
progbar_val = 0.0f;
- stop_flag = FALSE;
g_get_current_time(&start_time);
/* do the merge (or append) */
@@ -1798,7 +1797,6 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
guint32 framenum;
frame_data *fdata;
progdlg_t *progbar = NULL;
- gboolean stop_flag;
int count;
frame_data *selected_frame, *preceding_frame, *following_frame, *prev_frame;
int selected_frame_num, preceding_frame_num, following_frame_num, prev_frame_num;
@@ -1890,7 +1888,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
/* Progress so far. */
progbar_val = 0.0f;
- stop_flag = FALSE;
+ cf->stop_flag = FALSE;
g_get_current_time(&start_time);
/* no previous row yet */
@@ -1918,7 +1916,8 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
time in order to get to the next progress bar step). */
if (progbar == NULL)
progbar = delayed_create_progress_dlg(cf->window, action, action_item, TRUE,
- &stop_flag, &start_time,
+ &cf->stop_flag,
+ &start_time,
progbar_val);
/* Update the progress bar, but do it only N_PROGBAR_UPDATES times;
@@ -1942,7 +1941,7 @@ rescan_packets(capture_file *cf, const char *action, const char *action_item, gb
progbar_nextstep += progbar_quantum;
}
- if (stop_flag) {
+ if (cf->stop_flag) {
/* Well, the user decided to abort the filtering. Just stop.
XXX - go back to the previous filter? Users probably just
@@ -2211,7 +2210,6 @@ process_specified_records(capture_file *cf, packet_range_t *range,
progdlg_t *progbar = NULL;
int progbar_count;
float progbar_val;
- gboolean progbar_stop_flag;
GTimeVal progbar_start_time;
gchar progbar_status_str[100];
int progbar_nextstep;
@@ -2232,7 +2230,7 @@ process_specified_records(capture_file *cf, packet_range_t *range,
/* Progress so far. */
progbar_val = 0.0f;
- progbar_stop_flag = FALSE;
+ cf->stop_flag = FALSE;
g_get_current_time(&progbar_start_time);
if (range != NULL)
@@ -2251,7 +2249,7 @@ process_specified_records(capture_file *cf, packet_range_t *range,
if (progbar == NULL)
progbar = delayed_create_progress_dlg(cf->window, string1, string2,
terminate_is_stop,
- &progbar_stop_flag,
+ &cf->stop_flag,
&progbar_start_time,
progbar_val);
@@ -2276,7 +2274,7 @@ process_specified_records(capture_file *cf, packet_range_t *range,
progbar_nextstep += progbar_quantum;
}
- if (progbar_stop_flag) {
+ if (cf->stop_flag) {
/* Well, the user decided to abort the operation. Just stop,
and arrange to return PSP_STOPPED to our caller, so they know
it was stopped explicitly. */
@@ -3523,7 +3521,6 @@ find_packet(capture_file *cf,
frame_data *fdata;
frame_data *new_fd = NULL;
progdlg_t *progbar = NULL;
- gboolean stop_flag;
int count;
gboolean found;
float progbar_val;
@@ -3550,7 +3547,7 @@ find_packet(capture_file *cf,
/* Progress so far. */
progbar_val = 0.0f;
- stop_flag = FALSE;
+ cf->stop_flag = FALSE;
g_get_current_time(&start_time);
title = cf->sfilter?cf->sfilter:"";
@@ -3562,7 +3559,7 @@ find_packet(capture_file *cf,
time in order to get to the next progress bar step). */
if (progbar == NULL)
progbar = delayed_create_progress_dlg(cf->window, "Searching", title,
- FALSE, &stop_flag, &start_time, progbar_val);
+ FALSE, &cf->stop_flag, &start_time, progbar_val);
/* Update the progress bar, but do it only N_PROGBAR_UPDATES times;
when we update it, we have to run the GTK+ main loop to get it
@@ -3586,7 +3583,7 @@ find_packet(capture_file *cf,
progbar_nextstep += progbar_quantum;
}
- if (stop_flag) {
+ if (cf->stop_flag) {
/* Well, the user decided to abort the search. Go back to the
frame where we started. */
new_fd = start_fd;
@@ -4353,7 +4350,6 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
gchar *name_ptr;
gint64 data_offset;
progdlg_t *progbar = NULL;
- gboolean stop_flag;
gint64 size;
float progbar_val;
GTimeVal start_time;
@@ -4430,7 +4426,7 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
}else
progbar_quantum = 0;
- stop_flag = FALSE;
+ cf->stop_flag = FALSE;
g_get_current_time(&start_time);
framenum = 0;
@@ -4449,7 +4445,7 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
if ((progbar == NULL) && !(count % MIN_NUMBER_OF_PACKET)) {
progbar_val = calc_progbar_val(cf, size, cf->f_datalen, status_str, sizeof(status_str));
progbar = delayed_create_progress_dlg(cf->window, "Rescanning", name_ptr,
- TRUE, &stop_flag, &start_time, progbar_val);
+ TRUE, &cf->stop_flag, &start_time, progbar_val);
}
/* Update the progress bar, but do it only N_PROGBAR_UPDATES times;
@@ -4475,7 +4471,7 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
}
}
- if (stop_flag) {
+ if (cf->stop_flag) {
/* Well, the user decided to abort the rescan. Sadly, as this
isn't a reread, recovering is difficult, so we'll just
close the current capture. */
@@ -4515,7 +4511,7 @@ rescan_file(capture_file *cf, const char *fname, gboolean is_tempfile, int *err)
cf_callback_invoke(cf_cb_file_rescan_finished, cf);
- if (stop_flag) {
+ if (cf->stop_flag) {
/* Our caller will give up at this point. */
return CF_READ_ABORTED;
}
diff --git a/ui/qt/CMakeLists.txt b/ui/qt/CMakeLists.txt
index 91a13a2dab..a8cd6fe20f 100644
--- a/ui/qt/CMakeLists.txt
+++ b/ui/qt/CMakeLists.txt
@@ -30,6 +30,7 @@ set(WIRESHARK_QT_HEADERS
byte_view_text.h
capture_file.h
capture_file_dialog.h
+ capture_file_progress_frame.h
capture_file_properties_dialog.h
capture_filter_combo.h
capture_filter_edit.h
@@ -86,7 +87,6 @@ set(WIRESHARK_QT_HEADERS
preferences_dialog.h
print_dialog.h
profile_dialog.h
- progress_bar.h
proto_tree.h
protocol_hierarchy_dialog.h
protocol_preferences_menu.h
@@ -151,6 +151,7 @@ set(WIRESHARK_QT_SRC
byte_view_text.cpp
capture_file.cpp
capture_file_dialog.cpp
+ capture_file_progress_frame.cpp
capture_file_properties_dialog.cpp
capture_filter_combo.cpp
capture_filter_edit.cpp
@@ -205,7 +206,6 @@ set(WIRESHARK_QT_SRC
preferences_dialog.cpp
print_dialog.cpp
profile_dialog.cpp
- progress_bar.cpp
proto_tree.cpp
protocol_hierarchy_dialog.cpp
protocol_preferences_menu.cpp
@@ -272,6 +272,7 @@ set(WIRESHARK_QT_UI
about_dialog.ui
bluetooth_att_server_attributes_dialog.ui
bluetooth_devices_dialog.ui
+ capture_file_progress_frame.ui
capture_file_properties_dialog.ui
capture_interfaces_dialog.ui
capture_preferences_frame.ui
diff --git a/ui/qt/Makefile.am b/ui/qt/Makefile.am
index 89e4ada4f5..01cd6ab54b 100644
--- a/ui/qt/Makefile.am
+++ b/ui/qt/Makefile.am
@@ -126,6 +126,8 @@ bluetooth_att_server_attributes_dialog.cpp bluetooth_att_server_attributes_dialo
bluetooth_devices_dialog.cpp bluetooth_devices_dialog.h: ui_bluetooth_devices_dialog.h
+capture_file_progress_frame.cpp capture_file_progress_frame.h: ui_capture_file_progress_frame.h
+
capture_file_properties_dialog.cpp capture_file_properties_dialog.h: ui_capture_file_properties_dialog.h
capture_interfaces_dialog.cpp capture_interfaces_dialog.h: ui_capture_interfaces_dialog.h
diff --git a/ui/qt/Makefile.common b/ui/qt/Makefile.common
index e01bfb4bc3..ee46e60bfa 100644
--- a/ui/qt/Makefile.common
+++ b/ui/qt/Makefile.common
@@ -32,6 +32,7 @@ NODIST_GENERATED_HEADER_FILES = \
ui_about_dialog.h \
ui_bluetooth_att_server_attributes_dialog.h \
ui_bluetooth_devices_dialog.h \
+ ui_capture_file_progress_frame.h \
ui_capture_file_properties_dialog.h \
ui_capture_interfaces_dialog.h \
ui_capture_preferences_frame.h \
@@ -133,6 +134,7 @@ MOC_HDRS = \
byte_view_text.h \
capture_file.h \
capture_file_dialog.h \
+ capture_file_progress_frame.h \
capture_file_properties_dialog.h \
capture_filter_combo.h \
capture_filter_edit.h \
@@ -191,7 +193,6 @@ MOC_HDRS = \
preferences_dialog.h \
print_dialog.h \
profile_dialog.h \
- progress_bar.h \
proto_tree.h \
protocol_hierarchy_dialog.h \
protocol_preferences_menu.h \
@@ -233,6 +234,7 @@ UI_FILES = \
about_dialog.ui \
bluetooth_att_server_attributes_dialog.ui \
bluetooth_devices_dialog.ui \
+ capture_file_progress_frame.ui \
capture_file_properties_dialog.ui \
capture_interfaces_dialog.ui \
capture_preferences_frame.ui \
@@ -350,6 +352,7 @@ WIRESHARK_QT_SRC = \
byte_view_text.cpp \
capture_file.cpp \
capture_file_dialog.cpp \
+ capture_file_progress_frame.cpp \
capture_file_properties_dialog.cpp \
capture_filter_combo.cpp \
capture_filter_edit.cpp \
@@ -410,7 +413,6 @@ WIRESHARK_QT_SRC = \
preferences_dialog.cpp \
print_dialog.cpp \
profile_dialog.cpp \
- progress_bar.cpp \
proto_tree.cpp \
protocol_hierarchy_dialog.cpp \
protocol_preferences_menu.cpp \
diff --git a/ui/qt/Wireshark.pro b/ui/qt/Wireshark.pro
index 6c40828f69..b37f896f4a 100644
--- a/ui/qt/Wireshark.pro
+++ b/ui/qt/Wireshark.pro
@@ -208,6 +208,7 @@ FORMS += \
about_dialog.ui \
bluetooth_att_server_attributes_dialog.ui \
bluetooth_devices_dialog.ui \
+ capture_file_progress_frame.ui \
capture_file_properties_dialog.ui \
capture_interfaces_dialog.ui \
capture_preferences_frame.ui \
@@ -273,6 +274,7 @@ HEADERS += $$HEADERS_WS_C \
accordion_frame.h \
bluetooth_att_server_attributes_dialog.h \
bluetooth_devices_dialog.h \
+ capture_file_progress_frame.h \
capture_file_properties_dialog.h \
capture_interfaces_dialog.h \
capture_preferences_frame.h \
@@ -599,7 +601,6 @@ HEADERS += \
packet_list_model.h \
packet_list_record.h \
packet_range_group_box.h \
- progress_bar.h \
proto_tree.h \
qt_ui_utils.h \
qt_ui_utils.h \
@@ -625,6 +626,7 @@ SOURCES += \
byte_view_text.cpp \
capture_file.cpp \
capture_file_dialog.cpp \
+ capture_file_progress_frame.cpp \
capture_file_properties_dialog.cpp \
capture_filter_combo.cpp \
capture_filter_edit.cpp \
@@ -685,7 +687,6 @@ SOURCES += \
preferences_dialog.cpp \
print_dialog.cpp \
profile_dialog.cpp \
- progress_bar.cpp \
proto_tree.cpp \
protocol_hierarchy_dialog.cpp \
protocol_preferences_menu.cpp \
diff --git a/ui/qt/capture_file.cpp b/ui/qt/capture_file.cpp
index 05e480289b..37358e044d 100644
--- a/ui/qt/capture_file.cpp
+++ b/ui/qt/capture_file.cpp
@@ -96,9 +96,9 @@ void CaptureFile::retapPackets()
}
}
-void CaptureFile::stopTapping()
+void CaptureFile::stopLoading()
{
- emit setCaptureStopFlag(true);
+ setCaptureStopFlag(true);
}
capture_file *CaptureFile::globalCapFile()
@@ -112,6 +112,11 @@ gpointer CaptureFile::window()
return NULL;
}
+void CaptureFile::setCaptureStopFlag(bool stop_flag)
+{
+ if (cap_file_) cap_file_->stop_flag = stop_flag;
+}
+
void CaptureFile::captureFileCallback(gint event, gpointer data, gpointer user_data)
{
CaptureFile *capture_file = static_cast<CaptureFile *>(user_data);
diff --git a/ui/qt/capture_file.h b/ui/qt/capture_file.h
index 0b1809419c..9fd8ba92c8 100644
--- a/ui/qt/capture_file.h
+++ b/ui/qt/capture_file.h
@@ -40,6 +40,7 @@ public:
capture_file *capFile() const { return isValid() ? cap_file_ : NULL; }
void setCapFile(capture_file *cap_file) { cap_file_ = cap_file; }
+
/** Check capture file validity
*
* @return true if the file is open, readable, and tappable. false if the file
@@ -71,10 +72,6 @@ public:
*/
void retapPackets();
- /** Cancel any tapping that might be in progress.
- */
- void stopTapping();
-
// XXX This shouldn't be needed.
static capture_file *globalCapFile();
@@ -106,9 +103,13 @@ signals:
void captureCaptureStopping(capture_session *cap_session);
void captureCaptureFailed(capture_session *cap_session);
- void setCaptureStopFlag(bool);
-
public slots:
+ /** Cancel any tapping that might be in progress.
+ */
+ void stopLoading();
+
+ // XXX Not used.
+ void setCaptureStopFlag(bool stop_flag = true);
private:
static void captureFileCallback(gint event, gpointer data, gpointer user_data);
diff --git a/ui/qt/progress_bar.cpp b/ui/qt/capture_file_progress_frame.cpp
index b0c237ab54..d565145534 100644
--- a/ui/qt/progress_bar.cpp
+++ b/ui/qt/capture_file_progress_frame.cpp
@@ -1,4 +1,4 @@
-/* progress_bar.cpp
+/* capture_file_progress_frame.cpp
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
@@ -21,24 +21,33 @@
#include "config.h"
-#include "progress_bar.h"
-
-#include "wireshark_application.h"
+#include "capture_file_progress_frame.h"
+#include "ui_capture_file_progress_frame.h"
#include "ui/progress_dlg.h"
#include <QGraphicsOpacityEffect>
#include <QPropertyAnimation>
-// XXX We should probably add an NSProgressIndicator to the dock icon
-// on OS X.
+#include "stock_icon.h"
+#include "wireshark_application.h"
+
+// To do:
+// - Use a different icon?
+// - Add an NSProgressIndicator to the dock icon on OS X.
+// - Start adding the progress bar to dialogs.
+// - Don't complain so loudly when the user stops a capture.
-static progdlg_t *
-common_create_progress_dlg(bool animate, const gpointer top_level_window,
- gboolean terminate_is_stop, gboolean *stop_flag,
- int value)
+progdlg_t *
+delayed_create_progress_dlg(const gpointer top_level_window, const gchar *task_title, const gchar *item_title,
+ gboolean terminate_is_stop, gboolean *stop_flag,
+ const GTimeVal *start_time, gfloat progress)
{
- ProgressBar *pb;
+ Q_UNUSED(task_title);
+ Q_UNUSED(item_title);
+ Q_UNUSED(start_time);
+
+ CaptureFileProgressFrame *cfpf;
QWidget *main_window;
if (!top_level_window) {
@@ -51,38 +60,12 @@ common_create_progress_dlg(bool animate, const gpointer top_level_window,
return NULL;
}
- pb = main_window->findChild<ProgressBar *>();
+ cfpf = main_window->findChild<CaptureFileProgressFrame *>();
- if (!pb) {
+ if (!cfpf) {
return NULL;
}
- return pb->show(animate, terminate_is_stop, stop_flag, value);
-}
-
-#if 0
-progdlg_t *
-create_progress_dlg(const gpointer top_level_window, const gchar *task_title, const gchar *item_title,
- gboolean terminate_is_stop, gboolean *stop_flag,
- const GTimeVal *start_time, gfloat progress)
-{
- Q_UNUSED(task_title);
- Q_UNUSED(item_title);
- Q_UNUSED(start_time);
-
- return common_create_progress_dlg(false, top_level_window, terminate_is_stop, stop_flag, progress * 100);
-}
-#endif
-
-progdlg_t *
-delayed_create_progress_dlg(const gpointer top_level_window, const gchar *task_title, const gchar *item_title,
- gboolean terminate_is_stop, gboolean *stop_flag,
- const GTimeVal *start_time, gfloat progress)
-{
- Q_UNUSED(task_title);
- Q_UNUSED(item_title);
- Q_UNUSED(start_time);
-
- return common_create_progress_dlg(true, top_level_window, terminate_is_stop, stop_flag, progress * 100);
+ return cfpf->show(true, terminate_is_stop, stop_flag, progress * 100);
}
/*
@@ -92,8 +75,9 @@ void
update_progress_dlg(progdlg_t *dlg, gfloat percentage, const gchar *status)
{
Q_UNUSED(status);
+ if (!dlg) return;
- dlg->progress_bar->setValue(percentage * 100);
+ dlg->progress_frame->setValue(percentage * 100);
/*
* Flush out the update and process any input events.
@@ -107,44 +91,67 @@ update_progress_dlg(progdlg_t *dlg, gfloat percentage, const gchar *status)
void
destroy_progress_dlg(progdlg_t *dlg)
{
- dlg->progress_bar->hide();
+ dlg->progress_frame->hide();
}
-// XXX - Add a "stop what you're doing this instant" button.
-// XXX - We need to show the task and item titles. Maybe as a tooltip or popped
-// into our sibling status message?
-ProgressBar::ProgressBar(QWidget *parent) :
- QProgressBar(parent), terminate_is_stop_(false), stop_flag_(NULL)
+CaptureFileProgressFrame::CaptureFileProgressFrame(QWidget *parent) :
+ QFrame(parent),
+ ui(new Ui::CaptureFileProgressFrame)
+ , terminate_is_stop_(false)
+ , stop_flag_(NULL)
#ifdef QWINTASKBARPROGRESS_H
- , taskbar_progress_(NULL)
+ , taskbar_progress_(NULL)
#endif
{
- progress_dialog_.progress_bar = this;
+ ui->setupUi(this);
+
+ progress_dialog_.progress_frame = this;
progress_dialog_.top_level_window = window();
-//#ifdef Q_OS_MAC
-// // https://bugreports.qt-project.org/browse/QTBUG-11569
-// setAttribute(Qt::WA_MacSmallSize, true);
-//#endif
- setTextVisible(false);
- setStyleSheet(QString(
- "ProgressBar {"
+ ui->progressBar->setStyleSheet(QString(
+ "QProgressBar {"
" max-width: 20em;"
" min-height: 0.8em;"
" max-height: 1em;"
- " border-bottom: 0;"
+ " border-bottom: 0px;"
+ " border-top: 0px;"
" background: transparent;"
"}"));
+ int one_em = fontMetrics().height();
+ ui->pushButton->setIconSize(QSize(one_em, one_em));
+ ui->pushButton->setStyleSheet(QString(
+ "QPushButton {"
+ " image: url(:/dfilter/dfilter_erase_normal.png) center;"
+ " min-height: 0.8em;"
+ " max-height: 1em;"
+ " min-width: 0.8em;"
+ " max-width: 1em;"
+ " border: 0px;"
+ " padding: 0px;"
+ " margin: 0px;"
+ " background: transparent;"
+ "}"
+ "QPushButton:hover {"
+ " image: url(:/dfilter/dfilter_erase_active.png) center;"
+ "}"
+ "QPushButton:pressed {"
+ " image: url(:/dfilter/dfilter_erase_selected.png) center;"
+ "}"));
hide();
}
-progdlg_t * ProgressBar::show(bool animate, bool terminate_is_stop, gboolean *stop_flag, int value) {
+CaptureFileProgressFrame::~CaptureFileProgressFrame()
+{
+ delete ui;
+}
+struct progdlg *CaptureFileProgressFrame::show(bool animate, bool terminate_is_stop, gboolean *stop_flag, int value)
+{
terminate_is_stop_ = terminate_is_stop;
stop_flag_ = stop_flag;
- setValue(value);
+ ui->progressBar->setValue(value);
#if !defined(Q_OS_MAC) || QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
if (animate) {
@@ -180,26 +187,31 @@ progdlg_t * ProgressBar::show(bool animate, bool terminate_is_stop, gboolean *st
taskbar_progress_->resume();
#endif
- QProgressBar::show();
+ QFrame::show();
return &progress_dialog_;
}
-void ProgressBar::setStopFlag(bool stop_flag)
+void CaptureFileProgressFrame::setValue(int value)
{
- if (stop_flag_) *stop_flag_ = stop_flag;
+ ui->progressBar->setValue(value);
}
#ifdef QWINTASKBARPROGRESS_H
-void ProgressBar::hide()
+void CaptureFileProgressFrame::hide()
{
if (taskbar_progress_) {
taskbar_progress_->reset();
taskbar_progress_->hide();
}
- QProgressBar::hide();
+ QFrame::hide();
}
#endif
+void CaptureFileProgressFrame::on_pushButton_clicked()
+{
+ emit stopLoading();
+}
+
/*
* Editor modelines
*
diff --git a/ui/qt/progress_bar.h b/ui/qt/capture_file_progress_frame.h
index 2f83c39718..21521576cd 100644
--- a/ui/qt/progress_bar.h
+++ b/ui/qt/capture_file_progress_frame.h
@@ -1,4 +1,4 @@
-/* progress_bar.h
+/* capture_file_progress_frame.h
*
* Wireshark - Network traffic analyzer
* By Gerald Combs <gerald@wireshark.org>
@@ -19,42 +19,56 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
-#ifndef PROGRESS_BAR_H
-#define PROGRESS_BAR_H
+#ifndef CAPTURE_FILE_PROGRESS_FRAME_H
+#define CAPTURE_FILE_PROGRESS_FRAME_H
#include <glib.h>
-#include "ui/progress_dlg.h"
+#include <QFrame>
-#include <QProgressBar>
+namespace Ui {
+class CaptureFileProgressFrame;
+}
#if defined(Q_OS_WIN) && QT_VERSION >= QT_VERSION_CHECK(5, 2, 0)
#include <QWinTaskbarButton>
#include <QWinTaskbarProgress>
#endif
-class ProgressBar;
+class CaptureFileProgressFrame;
// Define the structure describing a progress dialog.
struct progdlg {
- ProgressBar *progress_bar; // This progress bar
- QWidget *top_level_window; // Top-level window widget
+ CaptureFileProgressFrame *progress_frame; // This progress frame
+ QWidget *top_level_window; // Progress frame's main window
};
-class ProgressBar : public QProgressBar
+class CaptureFileProgressFrame : public QFrame
{
Q_OBJECT
public:
- explicit ProgressBar(QWidget *parent = 0);
- progdlg_t *show(bool animate, bool terminate_is_stop, gboolean *stop_flag, int value);
+ explicit CaptureFileProgressFrame(QWidget *parent = 0);
+ ~CaptureFileProgressFrame();
+
+ struct progdlg *show(bool animate, bool terminate_is_stop, gboolean *stop_flag, int value);
#ifdef QWINTASKBARPROGRESS_H
void hide();
#endif
- void setStopFlag(bool stop_flag);
+
+public slots:
+ void setValue(int value);
+
+signals:
+ void stopLoading();
+
+private slots:
+ void on_pushButton_clicked();
private:
- progdlg_t progress_dialog_;
+ Ui::CaptureFileProgressFrame *ui;
+
+ struct progdlg progress_dialog_;
QString message_;
QString status_;
bool terminate_is_stop_;
@@ -62,12 +76,9 @@ private:
#ifdef QWINTASKBARPROGRESS_H
QWinTaskbarProgress *taskbar_progress_;
#endif
-
-public slots:
-
};
-#endif // PROGRESS_BAR_H
+#endif // CAPTURE_FILE_PROGRESS_FRAME_H
/*
* Editor modelines
diff --git a/ui/qt/capture_file_progress_frame.ui b/ui/qt/capture_file_progress_frame.ui
new file mode 100644
index 0000000000..bcbefd5117
--- /dev/null
+++ b/ui/qt/capture_file_progress_frame.ui
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>CaptureFileProgressFrame</class>
+ <widget class="QFrame" name="CaptureFileProgressFrame">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>210</width>
+ <height>38</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Frame</string>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <property name="lineWidth">
+ <number>0</number>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="bottomMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QProgressBar" name="progressBar">
+ <property name="value">
+ <number>24</number>
+ </property>
+ <property name="textVisible">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="pushButton">
+ <property name="text">
+ <string/>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>12</width>
+ <height>12</height>
+ </size>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/ui/qt/io_graph_dialog.cpp b/ui/qt/io_graph_dialog.cpp
index fb7c65a16b..4d2ff32fd7 100644
--- a/ui/qt/io_graph_dialog.cpp
+++ b/ui/qt/io_graph_dialog.cpp
@@ -314,7 +314,7 @@ IOGraphDialog::IOGraphDialog(QWidget &parent, CaptureFile &cf) :
IOGraphDialog::~IOGraphDialog()
{
- cap_file_.stopTapping();
+ cap_file_.stopLoading();
for (int i = 0; i < ui->graphTreeWidget->topLevelItemCount(); i++) {
IOGraph *iog = qvariant_cast<IOGraph *>(ui->graphTreeWidget->topLevelItem(i)->data(name_col_, Qt::UserRole));
delete iog;
diff --git a/ui/qt/main_status_bar.cpp b/ui/qt/main_status_bar.cpp
index a327bd9405..e12e319758 100644
--- a/ui/qt/main_status_bar.cpp
+++ b/ui/qt/main_status_bar.cpp
@@ -138,7 +138,7 @@ MainStatusBar::MainStatusBar(QWidget *parent) :
info_progress_hb->addWidget(&expert_status_);
info_progress_hb->addWidget(&comment_label_);
info_progress_hb->addWidget(&info_status_);
- info_progress_hb->addWidget(&progress_bar_);
+ info_progress_hb->addWidget(&progress_frame_);
info_progress_hb->addStretch(10);
splitter->addWidget(info_progress);
@@ -182,6 +182,9 @@ MainStatusBar::MainStatusBar(QWidget *parent) :
this, SLOT(pushProfileName()));
connect(&profile_status_, SIGNAL(mousePressedAt(QPoint,Qt::MouseButton)),
this, SLOT(showProfileMenu(QPoint,Qt::MouseButton)));
+
+ connect(&progress_frame_, SIGNAL(stopLoading()),
+ this, SIGNAL(stopLoading()));
}
void MainStatusBar::showExpert() {
diff --git a/ui/qt/main_status_bar.h b/ui/qt/main_status_bar.h
index 04148c0264..9a8aed0689 100644
--- a/ui/qt/main_status_bar.h
+++ b/ui/qt/main_status_bar.h
@@ -22,18 +22,20 @@
#ifndef MAIN_STATUS_BAR_H
#define MAIN_STATUS_BAR_H
-#include "wireshark_application.h"
+#include "config.h"
+
+#include "cfile.h"
+
+#include "capchild/capture_session.h"
+
+#include "capture_file_progress_frame.h"
#include "label_stack.h"
-#include "progress_bar.h"
+#include "wireshark_application.h"
#include <QLabel>
#include <QMenu>
#include <QStatusBar>
-#include "cfile.h"
-
-#include "capchild/capture_session.h"
-
class CaptureFile;
class MainStatusBar : public QStatusBar
@@ -50,7 +52,7 @@ private:
QLabel expert_status_;
QLabel comment_label_;
LabelStack info_status_;
- ProgressBar progress_bar_;
+ CaptureFileProgressFrame progress_frame_;
LabelStack packet_status_;
LabelStack profile_status_;
capture_file *cap_file_;
@@ -62,6 +64,7 @@ private:
signals:
void showExpertInfo();
void editCaptureComment();
+ void stopLoading();
public slots:
void setCaptureFile(capture_file *cf);
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp
index 9212c593c2..76d3924f77 100644
--- a/ui/qt/main_window.cpp
+++ b/ui/qt/main_window.cpp
@@ -347,9 +347,6 @@ MainWindow::MainWindow(QWidget *parent) :
connect(&capture_file_, SIGNAL(captureFileSaveStopped()),
main_ui_->statusBar, SLOT(popFileStatus()));
- connect(&capture_file_, SIGNAL(setCaptureStopFlag(bool)),
- this, SLOT(setCaptureStopFlag(bool)));
-
connect(&capture_file_, SIGNAL(captureFileReadStarted()),
wsApp, SLOT(captureFileReadStarted()));
connect(&capture_file_, SIGNAL(captureFileReadFinished()),
@@ -451,6 +448,9 @@ MainWindow::MainWindow(QWidget *parent) :
connect(main_ui_->statusBar, SIGNAL(showExpertInfo()),
this, SLOT(on_actionAnalyzeExpertInfo_triggered()));
+ connect(main_ui_->statusBar, SIGNAL(stopLoading()),
+ &capture_file_, SLOT(stopLoading()));
+
connect(main_ui_->statusBar, SIGNAL(editCaptureComment()),
this, SLOT(on_actionStatisticsCaptureFileProperties_triggered()));
diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h
index fe5e4db731..220bc63ffe 100644
--- a/ui/qt/main_window.h
+++ b/ui/qt/main_window.h
@@ -201,7 +201,6 @@ public slots:
// in main_window_slots.cpp
void openCaptureFile(QString& cf_path = *new QString(), QString& display_filter = *new QString(), unsigned int type = WTAP_TYPE_AUTO);
void filterPackets(QString& new_filter = *new QString(), bool force = false);
- void setCaptureStopFlag(bool stop_flag = true);
void updateForUnsavedChanges();
void layoutPanes();
void applyRecentPaneGeometry();
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index fabc408dd2..c717b5033d 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -261,15 +261,6 @@ void MainWindow::filterPackets(QString& new_filter, bool force)
}
}
-// XXX We should probably call common_create_progress_dlg in CaptureFile and
-// have it handle emitting progress signals and the stop flag.
-void MainWindow::setCaptureStopFlag(bool stop_flag)
-{
- ProgressBar *progress_bar = main_ui_->statusBar->findChild<ProgressBar *>();
-
- if (progress_bar) progress_bar->setStopFlag(stop_flag);
-}
-
// A new layout should be applied when it differs from the old layout AND
// at the following times:
// - At startup