Qt+wslua: Add back progress bar titles.

As part of the Qt migration we dropped support for showing progress bar
titles. Add them back.

Fix the title and task arguments in wslua.

Change-Id: I76f008ff1f73e868a9b3833d24d355513692ae8b
Reviewed-on: https://code.wireshark.org/review/36612
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Gerald Combs 2020-03-28 13:10:39 -07:00 committed by Anders Broman
parent 6f59b8e84d
commit 3069129fe5
5 changed files with 41 additions and 13 deletions

View File

@ -922,7 +922,7 @@ void Iax2AnalysisDialog::saveAudio(Iax2AnalysisDialog::StreamDirection direction
}
ui->hintLabel->setText(tr("Saving %1" UTF8_HORIZONTAL_ELLIPSIS).arg(save_file.fileName()));
ui->progressFrame->showProgress(true, true, &stop_flag);
ui->progressFrame->showProgress(tr("Analyzing IAX2"), true, true, &stop_flag);
if (save_format == save_audio_au_) { /* au format; https://pubs.opengroup.org/external/auformat.html */
/* First we write the .au header. All values in the header are

View File

@ -28,27 +28,32 @@
// - Don't complain so loudly when the user stops a capture.
progdlg_t *
create_progress_dlg(gpointer top_level_window, const gchar *, const gchar *,
create_progress_dlg(gpointer top_level_window, const gchar *task_title, const gchar *item_title,
gboolean terminate_is_stop, gboolean *stop_flag) {
ProgressFrame *pf;
QWidget *main_window;
if (!top_level_window) {
return NULL;
return nullptr;
}
main_window = qobject_cast<QWidget *>((QObject *)top_level_window);
if (!main_window) {
return NULL;
return nullptr;
}
pf = main_window->findChild<ProgressFrame *>();
if (!pf) {
return NULL;
return nullptr;
}
return pf->showProgress(true, terminate_is_stop, stop_flag, 0);
QString title = task_title;
if (item_title && strlen(item_title) > 0) {
title.append(" ").append(item_title);
}
return pf->showProgress(title, true, terminate_is_stop, stop_flag, 0);
}
progdlg_t *
@ -69,7 +74,7 @@ update_progress_dlg(progdlg_t *dlg, gfloat percentage, const gchar *)
{
if (!dlg) return;
dlg->progress_frame->setValue(percentage * 100);
dlg->progress_frame->setValue((int)(percentage * 100));
/*
* Flush out the update and process any input events.
@ -90,10 +95,10 @@ ProgressFrame::ProgressFrame(QWidget *parent) :
QFrame(parent),
ui(new Ui::ProgressFrame)
, terminate_is_stop_(false)
, stop_flag_(NULL)
, stop_flag_(nullptr)
, show_timer_(-1)
, effect_(NULL)
, animation_(NULL)
, effect_(nullptr)
, animation_(nullptr)
#ifdef QWINTASKBARPROGRESS_H
, update_taskbar_(false)
, taskbar_progress_(NULL)
@ -104,6 +109,15 @@ ProgressFrame::ProgressFrame(QWidget *parent) :
progress_dialog_.progress_frame = this;
progress_dialog_.top_level_window = window();
#ifdef Q_OS_MAC
ui->label->setAttribute(Qt::WA_MacSmallSize, true);
#endif
ui->label->setStyleSheet(QString(
"QLabel {"
" background: transparent;"
"}"));
ui->progressBar->setStyleSheet(QString(
"QProgressBar {"
" max-width: 20em;"
@ -141,10 +155,17 @@ ProgressFrame::~ProgressFrame()
delete ui;
}
struct progdlg *ProgressFrame::showProgress(bool animate, bool terminate_is_stop, gboolean *stop_flag, int value)
struct progdlg *ProgressFrame::showProgress(const QString &title, bool animate, bool terminate_is_stop, gboolean *stop_flag, int value)
{
setMaximumValue(100);
ui->progressBar->setValue(value);
QString elided_title = title;
int max_w = fontMetrics().height() * 20; // em-widths, arbitrary
if (fontMetrics().width(title) > max_w) {
elided_title = fontMetrics().elidedText(title, Qt::ElideRight, max_w);
}
// If we're in the main status bar, should we push this as a status message instead?
ui->label->setText(elided_title);
emit showRequested(animate, terminate_is_stop, stop_flag);
return &progress_dialog_;
}

View File

@ -50,7 +50,7 @@ public:
void captureFileClosing();
public slots:
struct progdlg *showProgress(bool animate, bool terminate_is_stop, gboolean *stop_flag, int value = 0);
struct progdlg *showProgress(const QString &title, bool animate, bool terminate_is_stop, gboolean *stop_flag, int value = 0);
struct progdlg *showBusy(bool animate, bool terminate_is_stop, gboolean *stop_flag);
void setValue(int value);
void hide();

View File

@ -29,6 +29,13 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="progressBar">
<property name="value">

View File

@ -1460,7 +1460,7 @@ void RtpAnalysisDialog::saveAudio(RtpAnalysisDialog::StreamDirection direction,
}
ui->hintLabel->setText(tr("Saving %1" UTF8_HORIZONTAL_ELLIPSIS).arg(save_file.fileName()));
ui->progressFrame->showProgress(true, true, &stop_flag);
ui->progressFrame->showProgress(tr("Analyzing RTP"), true, true, &stop_flag);
clearSAEErrors();
if (save_format == save_audio_au_) { /* au format */