#include "dialog_progress_ui.h" #include "ui_dialog_progress_ui.h" Dialog_progress_ui *Dialog_progress_ui::m_param = nullptr; Dialog_progress_ui::Dialog_progress_ui(std::function callback, std::function *notify, QWidget *parent) : QDialog(parent), ui(new Ui::Dialog_progress_ui) { ui->setupUi(this); m_callback = callback; *notify = FuncNotify; m_param = this; connect(this, SIGNAL(scan_finish(QString)), this, SLOT(on_scan_finish(QString)), Qt::QueuedConnection); } Dialog_progress_ui::~Dialog_progress_ui() { delete ui; } void Dialog_progress_ui::on_pbtn_cancelScan_clicked() { m_callback(UI_RESULT_CLOSE_CANCEL); close(); } void Dialog_progress_ui::on_scan_finish(QString finishInfo) { ui->label->setText(finishInfo); } void Dialog_progress_ui::FuncNotify(int event, void *msg, int flag) { Dialog_progress_ui *p = (Dialog_progress_ui *)m_param; switch (event) { case SANE_EVENT_SCAN_FINISHED: { QString finishInfo((char*)msg); emit p->scan_finish(finishInfo); } break; } }