Send custom event from worker(-thread) to MainWindow in order to update
progress bar.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include "ui_mainwindow.h"
|
||||
#include "worker.h"
|
||||
#include "utils.h"
|
||||
#include "progress_event.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QMessageBox>
|
||||
@@ -56,7 +57,6 @@ MainWindow::MainWindow(Worker *worker, QWidget *parent)
|
||||
connect(m_worker, SIGNAL(restartExitTimer()), this, SLOT(onRestartExitTimer()));
|
||||
connect(m_worker, SIGNAL(appendText(QString, QString)), this, SLOT(onAppendText(QString, QString)));
|
||||
connect(m_worker, SIGNAL(showErrorMessage(QString,QString)), this, SLOT(onShowErrorMessage(QString,QString)));
|
||||
connect(m_worker, SIGNAL(setProgress(quint8)), this, SLOT(onSetProgress(quint8)));
|
||||
|
||||
ui->updateStatus->setText(lst.join('\n'));
|
||||
ui->updateStatus->setEnabled(true);
|
||||
@@ -68,6 +68,13 @@ MainWindow::~MainWindow() {
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void MainWindow::customEvent(QEvent *event) {
|
||||
if (event->type() == ProgressEvent::type()) {
|
||||
int progress = ((ProgressEvent *)(event))->progressPercent();
|
||||
ui->updateProgress->setValue(progress);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::onStopStartTimer() {
|
||||
m_startTimer->stop();
|
||||
}
|
||||
@@ -91,11 +98,6 @@ void MainWindow::onQuit() {
|
||||
qApp->exit(m_worker->returnCode());
|
||||
}
|
||||
|
||||
void MainWindow::onSetProgress(quint8 v) {
|
||||
qCritical() << "ON SET PROGRESS" << v;
|
||||
ui->updateProgress->setValue(v);
|
||||
}
|
||||
|
||||
void MainWindow::onAppendText(QString text, QString suffix) {
|
||||
QString editText = ui->updateStatus->toPlainText();
|
||||
QStringList lines = editText.split('\n');
|
||||
|
Reference in New Issue
Block a user