添加异常图片提示界面
This commit is contained in:
parent
beefaad609
commit
7b71fbaaaa
|
@ -0,0 +1,74 @@
|
||||||
|
#include "dialog_wrong_img.h"
|
||||||
|
#include "ui_dialog_wrong_img.h"
|
||||||
|
#include "sane/sane_ex.h"
|
||||||
|
#include "imgfmt/HGImgFmt.h"
|
||||||
|
|
||||||
|
dialog_wrong_img::dialog_wrong_img(QWidget *parent, QString img_file, int index, int statu)
|
||||||
|
: QDialog(parent)
|
||||||
|
, ui(new Ui::Dialog_wrong_img)
|
||||||
|
, save_(false), img_file_(img_file), index_(index), statu_(statu)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
// connect(pbtn_stop, SIGNAL(clicked(bool)), this, SLOT(on_pbtn_stop_clicked()));
|
||||||
|
if(statu == SANE_Image_Statu_Double) // 双张图片,请确认是否要保留
|
||||||
|
setWindowTitle(QString::fromStdString("\345\217\214\345\274\240\345\233\276\347\211\207\357\274\214\350\257\267\347\241\256\350\256\244\346\230\257\345\220\246\350\246\201\344\277\235\347\225\231"));
|
||||||
|
else if(statu == SANE_Image_Statu_Jammed) // 卡纸图片,请确认是否要保留
|
||||||
|
setWindowTitle(QString::fromStdString("\345\215\241\347\272\270\345\233\276\347\211\207\357\274\214\350\257\267\347\241\256\350\256\244\346\230\257\345\220\246\350\246\201\344\277\235\347\225\231"));
|
||||||
|
else {
|
||||||
|
// 异常(%d)图片,请确认是否要保留
|
||||||
|
char msg[256] = {0};
|
||||||
|
sprintf(msg, "\345\274\202\345\270\270\357\274\210%d\357\274\211\345\233\276\347\211\207\357\274\214\350\257\267\347\241\256\350\256\244\346\230\257\345\220\246\350\246\201\344\277\235\347\225\231", statu);
|
||||||
|
setWindowTitle(QString::fromStdString(msg));
|
||||||
|
}
|
||||||
|
|
||||||
|
view_ = new HGImgView(this);
|
||||||
|
|
||||||
|
view_->setFixedSize(300, 200);
|
||||||
|
|
||||||
|
HGImage img = nullptr;
|
||||||
|
HGImgFmtReader imgFmtReader = nullptr;
|
||||||
|
HGImgFmt_OpenImageReader(img_file.toStdString().c_str(), 0, &imgFmtReader);
|
||||||
|
if (nullptr != imgFmtReader)
|
||||||
|
{
|
||||||
|
HGImgFmt_LoadImageFromReader(imgFmtReader, (HGUInt)0, nullptr, 0, HGBASE_IMGORIGIN_TOP, &img);
|
||||||
|
HGImgFmt_CloseImageReader(imgFmtReader);
|
||||||
|
view_->addImage(img);
|
||||||
|
HGBase_DestroyImage(img);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dialog_wrong_img::~dialog_wrong_img()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString dialog_wrong_img::image_file(void)
|
||||||
|
{
|
||||||
|
return img_file_;
|
||||||
|
}
|
||||||
|
int dialog_wrong_img::index(void)
|
||||||
|
{
|
||||||
|
return index_;
|
||||||
|
}
|
||||||
|
int dialog_wrong_img::increase_index(void)
|
||||||
|
{
|
||||||
|
return ++index_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void dialog_wrong_img::closeEvent(QCloseEvent *event)
|
||||||
|
{
|
||||||
|
emit handle_wrong_img(this, save_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void dialog_wrong_img::on_buttonBox_accepted()
|
||||||
|
{
|
||||||
|
save_ = true;
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void dialog_wrong_img::on_buttonBox_rejected()
|
||||||
|
{
|
||||||
|
save_ = false;
|
||||||
|
close();
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
#ifndef DIALOG_WRONG_IMG_H
|
||||||
|
#define DIALOG_WRONG_IMG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include "HGImgView.h"
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class Dialog_wrong_img;
|
||||||
|
}
|
||||||
|
|
||||||
|
class dialog_wrong_img : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
bool save_;
|
||||||
|
QString img_file_;
|
||||||
|
int index_;
|
||||||
|
int statu_;
|
||||||
|
HGImgView *view_;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit dialog_wrong_img(QWidget *parent, QString img_file, int index, int statu);
|
||||||
|
~dialog_wrong_img();
|
||||||
|
|
||||||
|
QString image_file(void);
|
||||||
|
int index(void);
|
||||||
|
int increase_index(void);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void handle_wrong_img(dialog_wrong_img* dlg, bool save);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_buttonBox_accepted();
|
||||||
|
|
||||||
|
void on_buttonBox_rejected();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void closeEvent(QCloseEvent *event);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::Dialog_wrong_img *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DIALOG_WRONG_IMG_H
|
|
@ -0,0 +1,74 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>Dialog_wrong_img</class>
|
||||||
|
<widget class="QDialog" name="Dialog_wrong_img">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>320</width>
|
||||||
|
<height>240</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Dialog</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>10</x>
|
||||||
|
<y>200</y>
|
||||||
|
<width>301</width>
|
||||||
|
<height>32</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>Dialog_wrong_img</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>248</x>
|
||||||
|
<y>254</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>Dialog_wrong_img</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>316</x>
|
||||||
|
<y>260</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>286</x>
|
||||||
|
<y>274</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
|
@ -44,6 +44,7 @@
|
||||||
#include "HGString.h"
|
#include "HGString.h"
|
||||||
#include "app_cfg.h"
|
#include "app_cfg.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include "dialog_wrong_img.h"
|
||||||
|
|
||||||
#define PASSWORD_KEY 4
|
#define PASSWORD_KEY 4
|
||||||
#define MY_URL_SCHEME "inscanner"
|
#define MY_URL_SCHEME "inscanner"
|
||||||
|
@ -254,7 +255,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||||
|
|
||||||
connect(this, SIGNAL(sane_dev_arrive(QString, bool)), this, SLOT(on_sane_dev_arrive(QString, bool)), Qt::QueuedConnection);
|
connect(this, SIGNAL(sane_dev_arrive(QString, bool)), this, SLOT(on_sane_dev_arrive(QString, bool)), Qt::QueuedConnection);
|
||||||
connect(this, SIGNAL(sane_dev_remove(QString)), this, SLOT(on_sane_dev_remove(QString)), Qt::QueuedConnection);
|
connect(this, SIGNAL(sane_dev_remove(QString)), this, SLOT(on_sane_dev_remove(QString)), Qt::QueuedConnection);
|
||||||
connect(this, SIGNAL(new_image(void *)), this, SLOT(on_new_image(void *)), Qt::QueuedConnection);
|
connect(this, SIGNAL(new_image(void *, int)), this, SLOT(on_new_image(void *, int)), Qt::QueuedConnection);
|
||||||
connect(this, SIGNAL(scan_working(QString)), this, SLOT(on_scan_working(QString)), Qt::QueuedConnection);
|
connect(this, SIGNAL(scan_working(QString)), this, SLOT(on_scan_working(QString)), Qt::QueuedConnection);
|
||||||
connect(this, SIGNAL(scan_finish(QString, int)), this, SLOT(on_scan_finish(QString, int)), Qt::QueuedConnection);
|
connect(this, SIGNAL(scan_finish(QString, int)), this, SLOT(on_scan_finish(QString, int)), Qt::QueuedConnection);
|
||||||
connect(this, SIGNAL(sane_dev_error(QString)), this, SLOT(on_sane_dev_error(QString)), Qt::QueuedConnection);
|
connect(this, SIGNAL(sane_dev_error(QString)), this, SLOT(on_sane_dev_error(QString)), Qt::QueuedConnection);
|
||||||
|
@ -307,6 +308,11 @@ MainWindow::~MainWindow()
|
||||||
delete m_versionDll;
|
delete m_versionDll;
|
||||||
m_versionDll = NULL;
|
m_versionDll = NULL;
|
||||||
|
|
||||||
|
for(auto& v : wrong_imgs_)
|
||||||
|
{
|
||||||
|
v->hide();
|
||||||
|
delete v;
|
||||||
|
}
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -793,7 +799,7 @@ void MainWindow::on_sane_dev_error(QString errorInfo)
|
||||||
HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "%s", getStdString(errorInfo).c_str());
|
HGBase_WriteInfo(HGBASE_INFOTYPE_ERROR, "%s", getStdString(errorInfo).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_new_image(void *img)
|
void MainWindow::on_new_image(void *img, int statu)
|
||||||
{
|
{
|
||||||
HGImage image = (HGImage)img;
|
HGImage image = (HGImage)img;
|
||||||
HGBase_SetImageDpi(image, m_dpi, m_dpi);
|
HGBase_SetImageDpi(image, m_dpi, m_dpi);
|
||||||
|
@ -803,7 +809,20 @@ void MainWindow::on_new_image(void *img)
|
||||||
QString fileName = getCacheFileName(image);
|
QString fileName = getCacheFileName(image);
|
||||||
HGImgFmt_SaveImage(image, 0, nullptr, getStdString(fileName).c_str());
|
HGImgFmt_SaveImage(image, 0, nullptr, getStdString(fileName).c_str());
|
||||||
|
|
||||||
if (-1 == m_scanInsertPos)
|
if(statu != SANE_Image_Statu_OK)
|
||||||
|
{
|
||||||
|
int ind = 0;
|
||||||
|
if(m_scanInsertPos == -1)
|
||||||
|
m_thumb->getItemCount(&ind);
|
||||||
|
else
|
||||||
|
ind = m_scanInsertPos;
|
||||||
|
|
||||||
|
dialog_wrong_img *wi = new dialog_wrong_img(this, fileName, ind, statu);
|
||||||
|
connect(wi, SIGNAL(handle_wrong_img(dialog_wrong_img*, bool)), this, SLOT(on_wrong_image_decide(dialog_wrong_img*, bool)));
|
||||||
|
wrong_imgs_.push_back(wi);
|
||||||
|
wi->show();
|
||||||
|
}
|
||||||
|
else if (-1 == m_scanInsertPos)
|
||||||
{
|
{
|
||||||
m_thumb->addItem(fileName);
|
m_thumb->addItem(fileName);
|
||||||
}
|
}
|
||||||
|
@ -989,7 +1008,8 @@ void MainWindow::on_new_image(void *img)
|
||||||
}
|
}
|
||||||
|
|
||||||
HGBase_DestroyImage(image);
|
HGBase_DestroyImage(image);
|
||||||
m_dialogLog->image_received_from_scanner();
|
if(statu == SANE_Image_Statu_OK)
|
||||||
|
m_dialogLog->image_received_from_scanner();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_scan_working(QString workingInfo)
|
void MainWindow::on_scan_working(QString workingInfo)
|
||||||
|
@ -1096,6 +1116,38 @@ void MainWindow::on_statusInfoDblClick()
|
||||||
{
|
{
|
||||||
m_dialogLog->show();
|
m_dialogLog->show();
|
||||||
}
|
}
|
||||||
|
void MainWindow::on_wrong_image_decide(dialog_wrong_img* dlg, bool save)
|
||||||
|
{
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
for(; i < wrong_imgs_.size(); ++i)
|
||||||
|
{
|
||||||
|
if(wrong_imgs_[i] == dlg)
|
||||||
|
{
|
||||||
|
wrong_imgs_.erase(wrong_imgs_.begin() + i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(save)
|
||||||
|
{
|
||||||
|
// save the image ...
|
||||||
|
for(; i < wrong_imgs_.size(); ++i)
|
||||||
|
wrong_imgs_[i]->increase_index();
|
||||||
|
|
||||||
|
m_thumb->insertItem(dlg->image_file(), dlg->index());
|
||||||
|
if (-1 != m_scanInsertPos)
|
||||||
|
{
|
||||||
|
++m_scanInsertPos;
|
||||||
|
}
|
||||||
|
m_dialogLog->image_received_from_scanner();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
remove(dlg->image_file().toStdString().c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
delete dlg;
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::on_act_thumbnailBar_triggered(bool checked)
|
void MainWindow::on_act_thumbnailBar_triggered(bool checked)
|
||||||
{
|
{
|
||||||
|
@ -1675,6 +1727,14 @@ void MainWindow::on_act_closeAll_triggered()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(auto& v : wrong_imgs_)
|
||||||
|
{
|
||||||
|
v->hide();
|
||||||
|
remove(v->image_file().toStdString().c_str());
|
||||||
|
delete v;
|
||||||
|
}
|
||||||
|
wrong_imgs_.clear();
|
||||||
|
|
||||||
startSaveMessageBox(this);
|
startSaveMessageBox(this);
|
||||||
|
|
||||||
m_thumb->removeAllItems(HGImgThumb::ThumbRemoveFlag_NULL);
|
m_thumb->removeAllItems(HGImgThumb::ThumbRemoveFlag_NULL);
|
||||||
|
@ -2204,7 +2264,7 @@ int MainWindow::sane_ex_callback(SANE_Handle hdev, int code, void *data, unsigne
|
||||||
HGBase_CreateImageFromData(imgData, &imgInfo, nullptr, imgType, HGBASE_IMGORIGIN_TOP, &img);
|
HGBase_CreateImageFromData(imgData, &imgInfo, nullptr, imgType, HGBASE_IMGORIGIN_TOP, &img);
|
||||||
if (nullptr != img)
|
if (nullptr != img)
|
||||||
{
|
{
|
||||||
emit p->new_image(img);
|
emit p->new_image(img, sane_img->flag.statu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -14,6 +14,7 @@
|
||||||
#include "device_menu.h"
|
#include "device_menu.h"
|
||||||
#include "sane_device.h"
|
#include "sane_device.h"
|
||||||
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
namespace Ui { class MainWindow; }
|
namespace Ui { class MainWindow; }
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -49,9 +50,12 @@ enum askIfClear
|
||||||
notClearAndScan
|
notClearAndScan
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//class dialog_wrong_img;
|
||||||
|
|
||||||
class MainWindow : public QMainWindow
|
class MainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
std::vector<class dialog_wrong_img*> wrong_imgs_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MainWindow(QWidget *parent = nullptr);
|
MainWindow(QWidget *parent = nullptr);
|
||||||
|
@ -91,7 +95,7 @@ signals:
|
||||||
void sane_dev_arrive(QString devName, bool opened);
|
void sane_dev_arrive(QString devName, bool opened);
|
||||||
void sane_dev_remove(QString devName);
|
void sane_dev_remove(QString devName);
|
||||||
void sane_dev_error(QString errorInfo);
|
void sane_dev_error(QString errorInfo);
|
||||||
void new_image(void *img);
|
void new_image(void *img, int statu);
|
||||||
void scan_working(QString workingInfo);
|
void scan_working(QString workingInfo);
|
||||||
void scan_finish(QString finishInfo, int err);
|
void scan_finish(QString finishInfo, int err);
|
||||||
|
|
||||||
|
@ -115,13 +119,14 @@ private slots:
|
||||||
void on_sane_dev_arrive(QString devName, bool opened);
|
void on_sane_dev_arrive(QString devName, bool opened);
|
||||||
void on_sane_dev_remove(QString devName);
|
void on_sane_dev_remove(QString devName);
|
||||||
void on_sane_dev_error(QString errorInfo);
|
void on_sane_dev_error(QString errorInfo);
|
||||||
void on_new_image(void *img);
|
void on_new_image(void *img, int statu);
|
||||||
void on_scan_working(QString workingInfo);
|
void on_scan_working(QString workingInfo);
|
||||||
void on_scan_finish(QString finishInfo, int err);
|
void on_scan_finish(QString finishInfo, int err);
|
||||||
void on_export_scanned_image(void);
|
void on_export_scanned_image(void);
|
||||||
void on_continueScan();
|
void on_continueScan();
|
||||||
void on_stopScan();
|
void on_stopScan();
|
||||||
void on_statusInfoDblClick();
|
void on_statusInfoDblClick();
|
||||||
|
void on_wrong_image_decide(dialog_wrong_img* dlg, bool save);
|
||||||
|
|
||||||
void on_act_thumbnailBar_triggered(bool checked);
|
void on_act_thumbnailBar_triggered(bool checked);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue