5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 #include "progress_bar.h"
28 #include "wireshark_application.h"
30 #include <QGraphicsOpacityEffect>
31 #include <QPropertyAnimation>
33 // XXX We should probably call ITaskbarList3::SetProgressState and
34 // ::SetProgressState on Windows and add an NSProgressIndicator to the
38 common_create_progress_dlg(bool animate
, const gpointer top_level_window
,
39 gboolean terminate_is_stop
, gboolean
*stop_flag
,
45 if (!top_level_window
) {
49 main_window
= qobject_cast
<QWidget
*>((QObject
*)top_level_window
);
55 pb
= main_window
->findChild
<ProgressBar
*>();
60 return pb
->show(animate
, terminate_is_stop
, stop_flag
, value
);
64 create_progress_dlg(const gpointer top_level_window
, const gchar
*task_title
, const gchar
*item_title
,
65 gboolean terminate_is_stop
, gboolean
*stop_flag
,
66 const GTimeVal
*start_time
, gfloat progress
)
72 return common_create_progress_dlg(false, top_level_window
, terminate_is_stop
, stop_flag
, progress
* 100);
76 delayed_create_progress_dlg(const gpointer top_level_window
, const gchar
*task_title
, const gchar
*item_title
,
77 gboolean terminate_is_stop
, gboolean
*stop_flag
,
78 const GTimeVal
*start_time
, gfloat progress
)
84 return common_create_progress_dlg(true, top_level_window
, terminate_is_stop
, stop_flag
, progress
* 100);
88 * Update the progress information of the progress bar box.
91 update_progress_dlg(progdlg_t
*dlg
, gfloat percentage
, const gchar
*status
)
95 dlg
->progress_bar
->setValue(percentage
* 100);
98 * Flush out the update and process any input events.
100 WiresharkApplication::processEvents();
104 * Destroy the progress bar.
107 destroy_progress_dlg(progdlg_t
*dlg
)
109 dlg
->progress_bar
->hide();
112 // XXX - Add a "stop what you're doing this instant" button.
113 // XXX - We need to show the task and item titles. Maybe as a tooltip or popped
114 // into our sibling status message?
115 ProgressBar::ProgressBar(QWidget
*parent
) :
116 QProgressBar(parent
), terminate_is_stop_(false), stop_flag_(NULL
)
118 progress_dialog_
.progress_bar
= this;
119 progress_dialog_
.top_level_window
= window();
122 // // https://bugreports.qt-project.org/browse/QTBUG-11569
123 // setAttribute(Qt::WA_MacSmallSize, true);
125 setTextVisible(false);
126 setStyleSheet(QString(
129 " min-height: 0.8em;"
132 " background: transparent;"
138 progdlg_t
* ProgressBar::show(bool animate
, bool terminate_is_stop
, gboolean
*stop_flag
, int value
) {
140 terminate_is_stop_
= terminate_is_stop
;
141 stop_flag_
= stop_flag
;
145 #if !defined(Q_OS_MAC) || QT_VERSION > QT_VERSION_CHECK(5, 0, 0)
147 QGraphicsOpacityEffect
*effect
= new QGraphicsOpacityEffect(this);
148 this->setGraphicsEffect(effect
);
150 QPropertyAnimation
*animation
= new QPropertyAnimation(effect
, "opacity");
152 animation
->setDuration(750);
153 animation
->setStartValue(0.1);
154 animation
->setEndValue(1.0);
155 animation
->setEasingCurve(QEasingCurve::InOutQuad
);
162 QProgressBar::show();
163 return &progress_dialog_
;
172 * indent-tabs-mode: nil
175 * ex: set shiftwidth=4 tabstop=8 expandtab:
176 * :indentSize=4:tabSize=8:noTabs=true: