解决扫描尺寸驱动层和UI不一致的问题

This commit is contained in:
luoliangyi 2022-05-17 18:09:21 +08:00
parent 2aad8ef728
commit 75ee563a11
5 changed files with 57 additions and 44 deletions

View File

@ -3,6 +3,8 @@
#include <QDebug>
#include <QToolTip>
#include <qpainterpath.h>
#include "../../utility/HGString.h"
#include "sane/sane_option_definitions.h"
cutDialog::cutDialog(QWidget *parent) :
QWidget(parent),
@ -35,24 +37,28 @@ void cutDialog::setPaperSize(QString type, const int w)
{
paperType = type;
if(paperType == "A3") h_w = 420.0/297;
else if(paperType == "A4") h_w = 297.0/210;
else if(paperType == std::string("A4横向").c_str()) h_w = 210/297.0;
else if(paperType == "A5") h_w = 210.0/148;
else if(paperType == std::string("A5横向").c_str()) h_w = 148/210.0;
else if(paperType == "A6") h_w = 148.0/105;
else if(paperType == std::string("A6横向").c_str()) h_w = 105/148.0;
else if(paperType == "B4") h_w = 353.0/250;
else if(paperType == "B5") h_w = 250.0/176;
else if(paperType == std::string("B5横向").c_str()) h_w = 176/250.0;
else if(paperType == "B6") h_w = 176.0/125;
else if(paperType == std::string("B6横向").c_str()) h_w = 125/176.0;
else if(paperType == std::string("信封").c_str()) h_w = 279.0/210;
else if(paperType == std::string("信封横向").c_str()) h_w = 210.0/279;
else if(paperType == std::string("双倍信封").c_str()) h_w = 850.0/550;
else if(paperType == "Legal") h_w = 2800.0/1700;
else if(paperType == std::string("最大尺寸").c_str()) h_w = 3307.0*2/2338;
else if(paperType == std::string("匹配原始尺寸").c_str()) {
if (paperType == OPTION_VALUE_ZZCC_A3) h_w = 420.0 / 297.0;
else if (paperType == OPTION_VALUE_ZZCC_8K) h_w = 390.0 / 270.0;
else if (paperType == OPTION_VALUE_ZZCC_16K) h_w = 270.0 / 190.0;
else if (paperType == OPTION_VALUE_ZZCC_16KHX) h_w = 190.0 / 270.0;
else if (paperType == OPTION_VALUE_ZZCC_A4) h_w = 297.0 / 210.0;
else if (paperType == OPTION_VALUE_ZZCC_A4HX) h_w = 210.0 / 297.0;
else if (paperType == OPTION_VALUE_ZZCC_A5) h_w = 210.0 / 148.0;
else if (paperType == OPTION_VALUE_ZZCC_A5HX) h_w = 148.0 / 210.0;
else if (paperType == OPTION_VALUE_ZZCC_A6) h_w = 148.0 / 105.0;
else if (paperType == OPTION_VALUE_ZZCC_A6HX) h_w = 105.0 / 148.0;
else if (paperType == OPTION_VALUE_ZZCC_B4) h_w = 353.0 / 250.0;
else if (paperType == OPTION_VALUE_ZZCC_B5) h_w = 250.0 / 176.0;
else if (paperType == OPTION_VALUE_ZZCC_B5HX) h_w = 176.0 / 250.0;
else if (paperType == OPTION_VALUE_ZZCC_B6) h_w = 176.0 / 125.0;
else if (paperType == OPTION_VALUE_ZZCC_B6HX) h_w = 125.0 / 176.0;
else if (paperType == OPTION_VALUE_ZZCC_Letter) h_w = 279.0 / 216.0;
else if (paperType == OPTION_VALUE_ZZCC_LetterHX) h_w = 216.0 / 279.0;
else if (paperType == OPTION_VALUE_ZZCC_DoubleLetter) h_w = 559.0 / 216.0;
else if (paperType == OPTION_VALUE_ZZCC_LEGAL) h_w = 356.0 / 216.0;
else if (paperType == OPTION_VALUE_ZZCC_SLSJ) h_w = 560.0 / 270.0;
else if(paperType == OPTION_VALUE_ZZCC_ZDSMCC) h_w = 3307.0*2/2338;
else if(paperType == OPTION_VALUE_ZZCC_PPYSCC) {
if(dpi == 100.0) h_w = 1795.0/1189;
if(dpi == 150.0) h_w = 1795.0/1784;
if(dpi == 200.0) h_w = 3307.0/2338;
@ -67,22 +73,26 @@ void cutDialog::setPaperSize(QString type, const int w)
else if (type.contains("6")) divisor = 8;
else divisor = 4;
paperWidth = w;
if(type.contains(std::string("横向").c_str())) paperWidth = paperWidth*h_w*1.5;
if(type.contains(StdStringToUtf8("横向").c_str()))
paperWidth = paperWidth*h_w*1.5;
double realW = paperWidth;
if(paperType == "A3" || paperType == std::string("A4横向").c_str()) realRate = 297.0/realW;
else if(paperType == "A4" || paperType == std::string("A5横向").c_str()) realRate = 210.0/realW;
else if(paperType == "A5" || paperType == std::string("A6横向").c_str()) realRate = 148.0/realW;
else if(paperType == "A6") realRate = 105.0/realW;
else if(paperType == "B4" || paperType == std::string("B5横向").c_str()) realRate = 250.0/realW;
else if(paperType == "B5" || paperType == std::string("B6横向").c_str()) realRate = 176.0/realW;
else if(paperType == "B6") realRate = 125.0/realW;
else if(paperType == std::string("信封").c_str()) realRate = 216.0/realW;
else if(paperType == std::string("信封横向").c_str()) realRate = 279.0/realW;
else if(paperType == std::string("双倍信封").c_str()) realRate = 432.0/realW;
else if(paperType == "Legal") realRate = 297.0/realW;
else if(paperType == std::string("最大尺寸").c_str()) realRate = 297.0/realW;
else if(paperType == std::string("匹配原始尺寸").c_str()) {
if (paperType == OPTION_VALUE_ZZCC_A3 || paperType == OPTION_VALUE_ZZCC_A4HX) realRate = 297.0 / realW;
else if (paperType == OPTION_VALUE_ZZCC_A4 || paperType == OPTION_VALUE_ZZCC_A5HX) realRate = 210.0 / realW;
else if (paperType == OPTION_VALUE_ZZCC_A5 || paperType == OPTION_VALUE_ZZCC_A6HX) realRate = 148.0 / realW;
else if (paperType == OPTION_VALUE_ZZCC_A6) realRate = 105.0 / realW;
else if (paperType == OPTION_VALUE_ZZCC_16K) realRate = 190.0 / realW;
else if (paperType == OPTION_VALUE_ZZCC_8K || paperType == OPTION_VALUE_ZZCC_16KHX) realRate = 270.0 / realW;
else if (paperType == OPTION_VALUE_ZZCC_B4 || paperType == OPTION_VALUE_ZZCC_B5HX) realRate = 250.0 / realW;
else if (paperType == OPTION_VALUE_ZZCC_B5 || paperType == OPTION_VALUE_ZZCC_B6HX) realRate = 176.0 / realW;
else if (paperType == OPTION_VALUE_ZZCC_B6) realRate = 125.0 / realW;
else if (paperType == OPTION_VALUE_ZZCC_Letter) realRate = 216.0 / realW;
else if (paperType == OPTION_VALUE_ZZCC_LetterHX) realRate = 279.0 / realW;
else if (paperType == OPTION_VALUE_ZZCC_DoubleLetter) realRate = 216.0 / realW;
else if (paperType == OPTION_VALUE_ZZCC_LEGAL) realRate = 216.0 / realW;
else if (paperType == OPTION_VALUE_ZZCC_SLSJ) realRate = 270.0 / realW;
else if(paperType == OPTION_VALUE_ZZCC_ZDSMCC) realRate = 297.0/realW;
else if(paperType == OPTION_VALUE_ZZCC_PPYSCC) {
if(dpi == 100.0) realRate = 1189.0*0.039377/dpi/realW;
if(dpi == 150.0) realRate = 1784*0.039377/dpi/realW;
if(dpi == 200.0) realRate = 2338*0.039377/dpi/realW;

View File

@ -17,6 +17,7 @@ CutPaperTool::CutPaperTool(QWidget *parent) :
//setPaperType(200,"A4",400);
ui->widget->setSizeType(MILLIM);
setSizeLabel();
ui->pbtn_init->setFixedWidth(160);
this->setFixedWidth(ui->widget->width()+20);
}

View File

@ -32,7 +32,7 @@ Dialog_AquireInto::Dialog_AquireInto(QWidget* parent) :
ui->cbtn_subFolderByColor->setChecked(getCfgValue("aquire", "subFolderByColor", false));
#if defined(OEM_HANWANG)
ui->lineEdit_fileName->setText(getCfgValue("aquire", "namePrefix", QString("HWScan")));
#elif defined(OEM_LISICHEN)
#elif defined(OEM_LISICHENG)
ui->lineEdit_fileName->setText(getCfgValue("aquire", "namePrefix", QString("LXScan")));
#else
ui->lineEdit_fileName->setText(getCfgValue("aquire", "namePrefix", QString("HGScan")));

View File

@ -941,13 +941,20 @@ void hg_settingdialog::slot_string_list_comboBoxClicked()
std::string comboBoxcurrentItem(comboBox->currentText().toUtf8());
int type = comboBox->property(hg_settingdialog::property_combox_data_type_.c_str()).toInt();
if (id == m_paperSizeId)
if (id == m_dpiId)
{
m_dpiValue = atoi(comboBoxcurrentItem.c_str());
qDebug("dpi=%d", m_dpiValue);
}
else if (id == m_paperSizeId)
{
m_paperSizeValue = comboBoxcurrentItem.c_str();
qDebug("paperSize=%s", comboBoxcurrentItem.c_str());
}
else if (id == m_colorModeId)
{
m_colorModeValue = comboBoxcurrentItem.c_str();
qDebug("colorMode=%s", comboBoxcurrentItem.c_str());
}
const SANE_Option_Descriptor* opt = nullptr;
@ -1004,7 +1011,7 @@ void hg_settingdialog::slot_cutButtonClicked()
int bottom = 0.03937 * m_cutBottomValue * m_dpiValue;
CutPaperTool dlg(this);
dlg.setPaperType(m_dpiValue, m_paperSizeValue, m_cutWidth);
dlg.setPaperType(m_dpiValue, m_paperSizeValue, 300);
QRectF rc(left, top, right - left, bottom - top);
dlg.setCutRect(rc);
if (dlg.exec())
@ -1241,11 +1248,6 @@ void hg_settingdialog::slot_sliderClicked(int value)
QSlider *slider = qobject_cast<QSlider*>(sender());
SANE_Int id = slider->property("controls_id").toInt();
if (id == m_dpiId)
{
m_dpiValue = value;
}
const SANE_Option_Descriptor* opt = nullptr;
for(int i = 0; i < m_list_getOpt.size(); i++)
if (m_list_getOpt.at(i).first == id)

View File

@ -64,7 +64,7 @@ MainWindow::MainWindow(QWidget *parent)
#if defined(OEM_HANWANG)
this->setWindowIcon(QIcon(":images/image_rsc/logo/Hanvon_logo1.ico"));
this->setWindowTitle(tr("HanvonScan"));
#elif defined(OEM_LISICHEN)
#elif defined(OEM_LISICHENG)
this->setWindowIcon(QIcon(":images/image_rsc/logo/Lanxum_logo.ico"));
this->setWindowTitle(tr("LanxumScan"));
#else
@ -240,7 +240,7 @@ MainWindow::MainWindow(QWidget *parent)
if (password.isEmpty())
#if defined(OEM_HANWANG)
m_password = "hanvonscan";
#elif defined(OEM_LISICHEN)
#elif defined(OEM_LISICHENG)
m_password = "lanxum";
#else
m_password = "huagoscan";
@ -2273,7 +2273,7 @@ void MainWindow::on_act_help_triggered()
#if defined(HG_CMP_MSC)
#if defined(OEM_HANWANG)
QString filename = QApplication::applicationDirPath() + "/HanvonScan_App_Help_manual.pdf";
#elif defined(OEM_LISICHEN)
#elif defined(OEM_LISICHENG)
QString filename = QApplication::applicationDirPath() + "/Lanxum_App_Help_manual.pdf";
#else
QString filename = QApplication::applicationDirPath() + "/HuaGoScan_App_Help_manual.pdf";
@ -2281,7 +2281,7 @@ void MainWindow::on_act_help_triggered()
#else
#if defined(OEM_HANWANG)
QString filename = "/opt/apps/com.huagaochina.huagoscan/entries/help/HanvonScan_App_Help_manual.pdf";
#elif defined(OEM_LISICHEN)
#elif defined(OEM_LISICHENG)
QString filename = "/opt/apps/com.huagaochina.huagoscan/entries/help/Lanxum_App_Help_manual.pdf";
#else
QString filename = "/opt/apps/com.huagaochina.huagoscan/entries/help/HuaGoScan_App_Help_manual.pdf";