2022-10-18 10:51:24 +00:00
|
|
|
#include "hg_settingdialog.h"
|
2022-05-03 10:25:52 +00:00
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QLatin1String>
|
2022-05-06 09:25:17 +00:00
|
|
|
#include "cutpapertool.h"
|
|
|
|
#include "setpicclrtool.h"
|
|
|
|
#include "base/HGDef.h"
|
2022-05-18 03:39:16 +00:00
|
|
|
#include "HGString.h"
|
2022-05-07 03:00:11 +00:00
|
|
|
#include "sane/sane_option_definitions.h"
|
2023-02-01 11:06:24 +00:00
|
|
|
#include "lang/app_language.h"
|
2022-05-12 07:34:40 +00:00
|
|
|
#include "dialog_input.h"
|
2022-05-24 05:45:07 +00:00
|
|
|
#include <typeinfo>
|
2022-10-28 01:03:22 +00:00
|
|
|
#include "device_menu.h"
|
2022-05-07 03:00:11 +00:00
|
|
|
|
|
|
|
std::string hg_settingdialog::property_combox_data_type_ = "combox_value_type";
|
2022-05-03 10:25:52 +00:00
|
|
|
|
|
|
|
hg_settingdialog::hg_settingdialog(void *handle, QWidget *parent
|
2022-10-28 01:03:22 +00:00
|
|
|
, dev_que* dev)
|
2022-05-03 10:25:52 +00:00
|
|
|
: QDialog(parent)
|
2022-10-28 01:03:22 +00:00
|
|
|
, dev_que_(dev), save_(false)
|
|
|
|
, btn_cut_area_(nullptr), btn_gamma_(nullptr), clicked_gamma_(false)
|
2022-11-26 09:32:54 +00:00
|
|
|
, custom_area_lable_(nullptr), comb_(nullptr)
|
2022-05-03 10:25:52 +00:00
|
|
|
{
|
2022-10-28 01:03:22 +00:00
|
|
|
std::string n(dev->opened_scanner_name());
|
|
|
|
for(int i = 0; i < dev->scanners(); ++i)
|
|
|
|
{
|
|
|
|
SCANNER s = dev->get_at(i);
|
|
|
|
if(s.name == n)
|
|
|
|
{
|
|
|
|
cur_cfg_ = s.cfg;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cur_scheme_ = cur_cfg_->get_scheme();
|
|
|
|
if(!cur_scheme_)
|
|
|
|
cur_scheme_ = new gb::sane_config_schm();
|
|
|
|
cur_scheme_->begin_setting();
|
|
|
|
|
2022-05-06 09:25:17 +00:00
|
|
|
m_dpiId = -1;
|
|
|
|
m_dpiValue = 200;
|
|
|
|
m_paperSizeId = -1;
|
|
|
|
m_paperSizeValue.clear();
|
|
|
|
m_cutLeftId = -1;
|
|
|
|
m_cutTopId = -1;
|
|
|
|
m_cutRightId = -1;
|
|
|
|
m_cutBottomId = -1;
|
|
|
|
m_cutWidth = 210;
|
|
|
|
m_cutHeight = 297;
|
|
|
|
m_cutLeftValue = 0;
|
|
|
|
m_cutTopValue = 0;
|
|
|
|
m_cutRightValue = 210;
|
|
|
|
m_cutBottomValue = 297;
|
|
|
|
|
|
|
|
m_colorModeId = -1;
|
|
|
|
m_colorModeValue.clear();
|
|
|
|
memset(&m_gammaData, 0, sizeof(m_gammaData));
|
2022-05-07 08:12:34 +00:00
|
|
|
for(int i = 0; i < sizeof(m_gammaData.table) / sizeof(m_gammaData.table[0]); ++i)
|
|
|
|
m_gammaData.table[i] = i & 0x0ff;
|
2022-05-06 09:25:17 +00:00
|
|
|
|
2022-05-03 10:25:52 +00:00
|
|
|
m_handle = handle;
|
|
|
|
initUi();
|
2022-10-28 01:03:22 +00:00
|
|
|
on_current_scheme_changed();
|
2022-10-13 07:45:19 +00:00
|
|
|
getAppVersion();
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
hg_settingdialog::~hg_settingdialog()
|
|
|
|
{
|
2022-10-28 01:03:22 +00:00
|
|
|
cur_scheme_->release();
|
|
|
|
cur_cfg_->release();
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void hg_settingdialog::initUi()
|
|
|
|
{
|
|
|
|
updateOpt();
|
|
|
|
createUI();
|
2023-02-09 10:01:10 +00:00
|
|
|
|
|
|
|
#if defined(OEM_ZHONGJING)
|
|
|
|
setWindowTitle("Microtek DocWizard EX TWAIN");
|
|
|
|
#else
|
2022-10-28 01:03:22 +00:00
|
|
|
setWindowTitle(QString::fromStdString(dev_que_->opened_scanner_name()));
|
2023-02-09 10:01:10 +00:00
|
|
|
#endif
|
|
|
|
|
2022-08-31 10:12:47 +00:00
|
|
|
setWindowFlags(Qt::Dialog | Qt::WindowCloseButtonHint);
|
2022-05-12 07:34:40 +00:00
|
|
|
resize(690, height());
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void hg_settingdialog::updateOpt()
|
|
|
|
{
|
2022-10-28 01:03:22 +00:00
|
|
|
bool first = true;
|
2022-05-03 10:25:52 +00:00
|
|
|
|
|
|
|
m_list_defaultOptions.clear();
|
|
|
|
|
|
|
|
SANE_Int dev_options = 0;
|
|
|
|
sane_control_option(m_handle, 0, SANE_ACTION_GET_VALUE, &dev_options, nullptr);
|
|
|
|
for (int i = 1, j= dev_options; i < j; i++)
|
|
|
|
{
|
|
|
|
const SANE_Option_Descriptor* opt = sane_get_option_descriptor(m_handle, i);
|
|
|
|
SANE_Int method = 0;
|
|
|
|
if (opt == nullptr)
|
|
|
|
{
|
|
|
|
m_list_defaultOptions.append(QPair<const void*, QVariant>(opt, QVariant(0)));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if(opt->type == SANE_TYPE_INT)
|
|
|
|
{
|
|
|
|
SANE_Int init = 0;
|
|
|
|
|
|
|
|
sane_control_option(m_handle, i, SANE_ACTION_GET_VALUE, &init, &method);
|
|
|
|
m_list_defaultOptions.append(QPair<const void*, QVariant>(opt, QVariant(init)));
|
|
|
|
|
|
|
|
if(first)
|
|
|
|
{
|
2022-10-28 01:03:22 +00:00
|
|
|
unsigned int n = i;
|
|
|
|
sane_io_control(m_handle, IO_CTRL_CODE_GET_DEFAULT_VALUE, &init, &n);
|
|
|
|
cur_scheme_->set_default_value(i, opt->name, (char*)&init, sizeof(init));
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(opt->type == SANE_TYPE_FIXED)
|
|
|
|
{
|
|
|
|
SANE_Fixed init = 0;
|
|
|
|
|
|
|
|
sane_control_option(m_handle, i, SANE_ACTION_GET_VALUE, &init, &method);
|
|
|
|
m_list_defaultOptions.append(QPair<const void*, QVariant>(opt, QVariant(init)));
|
|
|
|
|
|
|
|
if(first)
|
|
|
|
{
|
2022-10-28 01:03:22 +00:00
|
|
|
unsigned int n = i;
|
|
|
|
sane_io_control(m_handle, IO_CTRL_CODE_GET_DEFAULT_VALUE, &init, &n);
|
|
|
|
cur_scheme_->set_default_value(i, opt->name, (char*)&init, sizeof(init));
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(opt->type == SANE_TYPE_BOOL)
|
|
|
|
{
|
|
|
|
SANE_Bool init = 0;
|
|
|
|
|
|
|
|
sane_control_option(m_handle, i, SANE_ACTION_GET_VALUE, &init, &method);
|
|
|
|
m_list_defaultOptions.append(QPair<const void*, QVariant>(opt, QVariant(init)));
|
|
|
|
|
|
|
|
if(first)
|
|
|
|
{
|
2022-10-28 01:03:22 +00:00
|
|
|
unsigned int n = i;
|
|
|
|
sane_io_control(m_handle, IO_CTRL_CODE_GET_DEFAULT_VALUE, &init, &n);
|
|
|
|
cur_scheme_->set_default_value(i, opt->name, (char*)&init, sizeof(init));
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(opt->type == SANE_TYPE_STRING)
|
|
|
|
{
|
|
|
|
char *init = (char*)malloc(opt->size * 2 + 4);
|
|
|
|
|
|
|
|
sane_control_option(m_handle, i, SANE_ACTION_GET_VALUE, init, &method);
|
|
|
|
m_list_defaultOptions.append(QPair<const void*, QVariant>(opt, QVariant(QString::fromStdString(init))));
|
|
|
|
|
|
|
|
if(first)
|
|
|
|
{
|
2022-10-28 01:03:22 +00:00
|
|
|
unsigned int n = i;
|
|
|
|
int err = sane_io_control(m_handle, IO_CTRL_CODE_GET_DEFAULT_VALUE, init, &n);
|
2022-05-03 10:25:52 +00:00
|
|
|
(void)err;
|
2023-02-02 03:44:17 +00:00
|
|
|
std::string langCN(to_default_language(init, nullptr));
|
|
|
|
cur_scheme_->set_default_value(i, opt->name, &langCN[0], langCN.length());
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
|
|
|
free(init);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_list_defaultOptions.append(QPair<const void*, QVariant>(opt, QVariant(0)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-12 07:34:40 +00:00
|
|
|
QString hg_settingdialog::find_current_scheme_menu(int *scheme_id)
|
2022-05-03 10:25:52 +00:00
|
|
|
{
|
2022-05-12 07:34:40 +00:00
|
|
|
QString text(comb_->currentText());
|
2022-05-03 10:25:52 +00:00
|
|
|
|
2022-05-12 07:34:40 +00:00
|
|
|
if(scheme_id)
|
|
|
|
{
|
|
|
|
if(comb_->currentIndex() >= 0 && comb_->currentIndex() < comb_->count())
|
|
|
|
*scheme_id = comb_->currentIndex();
|
|
|
|
else {
|
2022-05-03 10:25:52 +00:00
|
|
|
*scheme_id = -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-12 07:34:40 +00:00
|
|
|
return text;
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
|
|
|
void hg_settingdialog::create_scheme_management_ui(QVBoxLayout* layout)
|
|
|
|
{
|
|
|
|
QLabel *title = new QLabel(this);
|
|
|
|
bool enabled = false;
|
2022-05-12 07:34:40 +00:00
|
|
|
QHBoxLayout *hbox = new QHBoxLayout();
|
|
|
|
int width = 180;
|
2022-10-28 01:03:22 +00:00
|
|
|
std::vector<std::string> schemes;
|
|
|
|
std::string cur_schm(cur_cfg_->get_current_scheme_name());
|
2022-05-03 10:25:52 +00:00
|
|
|
|
2022-10-28 01:03:22 +00:00
|
|
|
cur_cfg_->get_all_schemes(schemes);
|
2022-05-12 07:34:40 +00:00
|
|
|
comb_ = new QComboBox(this);
|
|
|
|
layout->addSpacing(30);
|
2022-10-28 01:03:22 +00:00
|
|
|
for(int i = 1; i < (int)schemes.size(); ++i)
|
2022-05-03 10:25:52 +00:00
|
|
|
{
|
2022-10-28 01:03:22 +00:00
|
|
|
comb_->addItem(QString::fromStdString(schemes[i]));
|
|
|
|
if(cur_schm == schemes[i])
|
2022-05-03 10:25:52 +00:00
|
|
|
{
|
|
|
|
enabled = true;
|
2022-10-28 01:03:22 +00:00
|
|
|
comb_->setCurrentText(QString::fromStdString(schemes[i]));
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-12 09:52:22 +00:00
|
|
|
if(!enabled)
|
|
|
|
comb_->setCurrentIndex(-1);
|
|
|
|
|
2022-05-12 07:34:40 +00:00
|
|
|
title->setFixedWidth(width);
|
|
|
|
comb_->setFixedWidth(width);
|
2022-05-03 10:25:52 +00:00
|
|
|
|
2022-06-06 02:28:27 +00:00
|
|
|
title->setText(tr("existing configuration scheme"));
|
2022-05-03 10:25:52 +00:00
|
|
|
layout->addWidget(title);
|
2022-05-12 07:34:40 +00:00
|
|
|
layout->addWidget(comb_);
|
2022-05-03 10:25:52 +00:00
|
|
|
|
|
|
|
rename_ = new QPushButton(this);
|
2022-06-06 02:28:27 +00:00
|
|
|
rename_->setText(tr("change name"));
|
2022-05-03 10:25:52 +00:00
|
|
|
rename_->setEnabled(enabled);
|
2022-05-12 07:34:40 +00:00
|
|
|
rename_->setFixedWidth(width/3);
|
|
|
|
hbox->addWidget(rename_);
|
2022-05-03 10:25:52 +00:00
|
|
|
connect(rename_, SIGNAL(clicked(bool)), this, SLOT(slot_pushButton_scheme_management()));
|
|
|
|
|
2022-05-12 07:34:40 +00:00
|
|
|
del_this_ = new QPushButton(this);
|
2022-06-06 02:28:27 +00:00
|
|
|
del_this_->setText(tr("delete"));
|
2022-05-12 07:34:40 +00:00
|
|
|
del_this_->setEnabled(enabled);
|
|
|
|
del_this_->setFixedWidth(width / 3);
|
|
|
|
hbox->addWidget(del_this_);
|
|
|
|
connect(del_this_, SIGNAL(clicked(bool)), this, SLOT(slot_pushButton_scheme_management()));
|
|
|
|
|
2022-05-03 10:25:52 +00:00
|
|
|
apply_ = new QPushButton(this);
|
2022-06-06 02:28:27 +00:00
|
|
|
apply_->setText(tr("apply"));
|
2022-05-03 10:25:52 +00:00
|
|
|
apply_->setEnabled(enabled);
|
2022-05-12 07:34:40 +00:00
|
|
|
apply_->setFixedWidth(width / 3);
|
|
|
|
hbox->addWidget(apply_);
|
2022-05-03 10:25:52 +00:00
|
|
|
connect(apply_, SIGNAL(clicked(bool)), this, SLOT(slot_pushButton_scheme_management()));
|
2022-05-12 07:34:40 +00:00
|
|
|
hbox->setSizeConstraint(QLayout::SetFixedSize);
|
2022-05-03 10:25:52 +00:00
|
|
|
|
2022-05-12 07:34:40 +00:00
|
|
|
layout->addLayout(hbox);
|
2022-05-03 10:25:52 +00:00
|
|
|
layout->addSpacing(10);
|
|
|
|
|
|
|
|
del_all_ = new QPushButton(this);
|
|
|
|
del_all_->setText(tr("delete all configurations"));
|
|
|
|
del_all_->setEnabled(enabled);
|
2022-05-12 07:34:40 +00:00
|
|
|
del_all_->setFixedWidth(width);
|
2022-05-03 10:25:52 +00:00
|
|
|
layout->addWidget(del_all_);
|
|
|
|
connect(del_all_, SIGNAL(clicked(bool)), this, SLOT(slot_pushButton_scheme_management()));
|
|
|
|
|
2022-05-12 07:34:40 +00:00
|
|
|
layout->addStretch();
|
|
|
|
|
|
|
|
title = new QLabel(this);
|
2022-06-06 02:28:27 +00:00
|
|
|
title->setText(tr("confgiuration information:"));
|
2022-05-12 07:34:40 +00:00
|
|
|
layout->addWidget(title);
|
|
|
|
|
2022-05-03 10:25:52 +00:00
|
|
|
sketch_ = new QTextEdit(this);
|
|
|
|
sketch_->setReadOnly(true);
|
2022-05-12 07:34:40 +00:00
|
|
|
sketch_->setFixedSize(width, 200);
|
2022-05-03 10:25:52 +00:00
|
|
|
layout->addWidget(sketch_);
|
|
|
|
|
2022-05-12 07:34:40 +00:00
|
|
|
connect(comb_, SIGNAL(currentTextChanged(const QString)), this, SLOT(on_current_scheme_changed()));
|
|
|
|
on_current_scheme_changed();
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
|
|
|
void hg_settingdialog::createUI()
|
|
|
|
{
|
|
|
|
QTabWidget *tabWidgetCreation = new QTabWidget(this);
|
|
|
|
|
|
|
|
QPushButton *buttonOk = new QPushButton(this);
|
|
|
|
buttonOk->setText(tr("ok"));
|
|
|
|
QPushButton *buttonCancel = new QPushButton(this);
|
|
|
|
buttonCancel->setText(tr("cancel"));
|
|
|
|
QHBoxLayout *hlayoutOkAndCancel = new QHBoxLayout;
|
|
|
|
hlayoutOkAndCancel->addStretch();
|
|
|
|
hlayoutOkAndCancel->addWidget(buttonOk);
|
|
|
|
hlayoutOkAndCancel->addWidget(buttonCancel);
|
|
|
|
QWidget *widgetOkAndCancel = new QWidget();
|
|
|
|
widgetOkAndCancel->setLayout(hlayoutOkAndCancel);
|
|
|
|
connect(buttonOk, SIGNAL(clicked(bool)), this, SLOT(slot_buttonOkClicked()));
|
|
|
|
connect(buttonCancel, SIGNAL(clicked(bool)), this, SLOT(slot_buttonCancelClicked()));
|
|
|
|
|
|
|
|
|
|
|
|
QHBoxLayout *h = new QHBoxLayout();
|
|
|
|
QVBoxLayout *v1 = new QVBoxLayout(),
|
|
|
|
*v2 = new QVBoxLayout();
|
|
|
|
create_scheme_management_ui(v1);
|
|
|
|
v2->addWidget(tabWidgetCreation);
|
2022-05-12 07:34:40 +00:00
|
|
|
|
2022-06-06 06:32:43 +00:00
|
|
|
QGroupBox *grp = new QGroupBox(tr("configuration scheme management"), this);
|
2022-05-12 07:34:40 +00:00
|
|
|
grp->setLayout(v1);
|
|
|
|
grp->setFixedSize(195, 500);
|
|
|
|
|
|
|
|
h->addWidget(grp);
|
|
|
|
h->addLayout(v2);
|
2022-05-03 10:25:52 +00:00
|
|
|
|
|
|
|
QVBoxLayout* mainVerticalLayout = new QVBoxLayout(this);
|
2022-05-12 07:34:40 +00:00
|
|
|
mainVerticalLayout->addLayout(h);
|
2022-05-03 10:25:52 +00:00
|
|
|
// mainVerticalLayout->addWidget(tabWidgetCreation);
|
|
|
|
mainVerticalLayout->addWidget(widgetOkAndCancel);
|
|
|
|
this->setLayout(mainVerticalLayout);
|
|
|
|
|
|
|
|
QScrollArea* scrollArea = new QScrollArea;
|
|
|
|
scrollArea->setWidgetResizable(true);
|
|
|
|
scrollArea->setAlignment(Qt::AlignCenter);
|
|
|
|
QFormLayout* layout = new QFormLayout;
|
|
|
|
|
|
|
|
QWidget* widget = new QWidget;
|
|
|
|
widget->setLayout(layout);
|
|
|
|
|
|
|
|
bool isBegin = true;
|
2022-10-28 01:03:22 +00:00
|
|
|
std::string cur_val("");
|
2022-05-03 10:25:52 +00:00
|
|
|
for (int i = 0; i < m_list_defaultOptions.size(); i++)
|
|
|
|
{
|
|
|
|
const SANE_Option_Descriptor* opt = reinterpret_cast<const SANE_Option_Descriptor*>(m_list_defaultOptions.at(i).first);
|
2022-10-28 01:03:22 +00:00
|
|
|
int ind = -1;
|
2022-05-03 10:25:52 +00:00
|
|
|
|
|
|
|
if(opt == nullptr) continue;
|
2022-05-07 08:12:34 +00:00
|
|
|
h = nullptr;
|
2022-10-28 01:03:22 +00:00
|
|
|
cur_scheme_->get_config(opt->name, cur_val);
|
2022-05-03 10:25:52 +00:00
|
|
|
switch (opt->type)
|
|
|
|
{
|
|
|
|
case SANE_TYPE_BOOL:
|
|
|
|
{
|
2022-12-05 10:08:46 +00:00
|
|
|
QCheckBox *checkBoxCreation = new QCheckBox;
|
|
|
|
|
2022-10-10 03:46:28 +00:00
|
|
|
if (strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA) == 0)
|
2022-05-07 08:12:34 +00:00
|
|
|
{
|
2022-12-05 10:08:46 +00:00
|
|
|
QWidget* widget_cbtn_pbtn = new QWidget;
|
|
|
|
widget_cbtn_pbtn->setMaximumWidth(150);
|
|
|
|
|
|
|
|
QLabel *label = new QLabel;
|
|
|
|
label->setText(QString::fromStdString(opt->title) + QString(" : "));
|
2022-05-07 08:12:34 +00:00
|
|
|
|
2022-12-05 10:08:46 +00:00
|
|
|
btn_cut_area_ = new QPushButton;
|
2022-06-06 02:28:27 +00:00
|
|
|
btn_cut_area_->setText(tr("regional crop"));
|
2022-05-07 08:12:34 +00:00
|
|
|
btn_cut_area_->setFixedWidth(120);
|
|
|
|
|
2022-12-05 10:08:46 +00:00
|
|
|
QHBoxLayout *hLayout = new QHBoxLayout;
|
|
|
|
hLayout->addWidget(checkBoxCreation);
|
|
|
|
hLayout->addWidget(btn_cut_area_);
|
|
|
|
widget_cbtn_pbtn->setLayout(hLayout);
|
|
|
|
|
|
|
|
custom_area_lable_ = label;
|
|
|
|
|
|
|
|
reinterpret_cast<QFormLayout*>(widget->layout())->addRow(label, widget_cbtn_pbtn);
|
|
|
|
|
2022-05-07 08:12:34 +00:00
|
|
|
connect(btn_cut_area_, SIGNAL(clicked(bool)), this, SLOT(slot_cutButtonClicked()));
|
|
|
|
}
|
2022-10-10 03:46:28 +00:00
|
|
|
else if (strcmp(opt->name, SANE_STD_OPT_NAME_IS_CUSTOM_GAMMA) == 0)
|
2022-05-07 08:12:34 +00:00
|
|
|
{
|
2022-12-05 10:08:46 +00:00
|
|
|
QWidget* widget_cbtn_pbtn = new QWidget(scrollArea);
|
|
|
|
widget_cbtn_pbtn->setMaximumWidth(150);
|
|
|
|
btn_gamma_ = new QPushButton(widget_cbtn_pbtn);
|
2022-06-06 02:28:27 +00:00
|
|
|
btn_gamma_->setText(tr("custom tone curve"));
|
2022-05-07 08:12:34 +00:00
|
|
|
btn_gamma_->setFixedWidth(120);
|
|
|
|
|
2022-12-05 10:08:46 +00:00
|
|
|
QHBoxLayout *hLayout = new QHBoxLayout;
|
|
|
|
hLayout->addWidget(checkBoxCreation);
|
|
|
|
hLayout->addWidget(btn_gamma_);
|
|
|
|
widget_cbtn_pbtn->setLayout(hLayout);
|
|
|
|
|
|
|
|
reinterpret_cast<QFormLayout*>(widget->layout())->addRow(opt->title + QString(" : "), widget_cbtn_pbtn);
|
2022-05-07 08:12:34 +00:00
|
|
|
connect(btn_gamma_, SIGNAL(clicked(bool)), this, SLOT(slot_gammaButtonClicked()));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
reinterpret_cast<QFormLayout*>(widget->layout())->addRow(opt->title + QString(" : "), checkBoxCreation);
|
|
|
|
|
2022-12-05 10:08:46 +00:00
|
|
|
checkBoxCreation->setToolTip(opt->desc);
|
2022-05-03 10:25:52 +00:00
|
|
|
int id = i + 1;
|
2022-10-28 01:03:22 +00:00
|
|
|
bool enable = *(bool*)&cur_val[0];
|
2022-05-03 10:25:52 +00:00
|
|
|
checkBoxCreation->setProperty("controls_id", id);
|
2022-10-28 01:03:22 +00:00
|
|
|
checkBoxCreation->setChecked(enable);
|
2022-10-10 03:46:28 +00:00
|
|
|
if (strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA) == 0)
|
2022-10-28 01:03:22 +00:00
|
|
|
btn_cut_area_->setEnabled(enable);
|
2022-10-10 03:46:28 +00:00
|
|
|
else if (strcmp(opt->name, SANE_STD_OPT_NAME_IS_CUSTOM_GAMMA) == 0)
|
2022-10-28 01:03:22 +00:00
|
|
|
btn_gamma_->setEnabled(enable);
|
2022-05-03 10:25:52 +00:00
|
|
|
connect(checkBoxCreation, SIGNAL(stateChanged(int)), this, SLOT(slot_checkedClicked()));
|
|
|
|
m_list_widgets.append(checkBoxCreation);
|
|
|
|
|
|
|
|
m_list_getOpt.append(QPair<int, const void*>(id, opt));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SANE_TYPE_INT:
|
|
|
|
{
|
|
|
|
switch(opt->constraint_type)
|
|
|
|
{
|
|
|
|
case SANE_CONSTRAINT_NONE:
|
|
|
|
{
|
|
|
|
QSpinBox* spinBox = new QSpinBox(scrollArea);
|
|
|
|
spinBox->setMinimumWidth(150);
|
|
|
|
spinBox->setToolTip(opt->desc);
|
2022-11-25 04:03:48 +00:00
|
|
|
spinBox->setRange(1, 1000);
|
2022-05-03 10:25:52 +00:00
|
|
|
int id = i + 1;
|
|
|
|
spinBox->setProperty("controls_id", id);
|
|
|
|
|
|
|
|
QHBoxLayout* hLayout = new QHBoxLayout;
|
|
|
|
hLayout->addWidget(spinBox);
|
|
|
|
hLayout->addStretch();
|
|
|
|
reinterpret_cast<QFormLayout*>(widget->layout())->addRow(opt->title + QString(" : "), spinBox);
|
|
|
|
|
|
|
|
m_list_widgets.append(spinBox);
|
|
|
|
m_list_getOpt.append(QPair<int, const void*>(id, opt));
|
|
|
|
|
2022-10-28 01:03:22 +00:00
|
|
|
spinBox->setValue(*(int*)&cur_val[0]);
|
2022-05-03 10:25:52 +00:00
|
|
|
connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(slot_spinBoxClicked(int)));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SANE_CONSTRAINT_RANGE:
|
|
|
|
{
|
|
|
|
QWidget* widget_slider_spin = new QWidget(scrollArea);
|
2022-12-05 10:08:46 +00:00
|
|
|
//widget_slider_spin->setMinimumWidth(250);
|
2022-05-03 10:25:52 +00:00
|
|
|
|
|
|
|
QSlider* sliderCreation = new QSlider(widget_slider_spin);
|
|
|
|
sliderCreation->setOrientation(Qt::Horizontal);
|
|
|
|
sliderCreation->setMinimumWidth(120);
|
|
|
|
sliderCreation->setRange(opt->constraint.range->min, opt->constraint.range->max);
|
|
|
|
sliderCreation->setToolTip(opt->desc);
|
|
|
|
sliderCreation->setProperty("controls_id", i+1);
|
|
|
|
sliderCreation->setValue(m_list_defaultOptions.at(i).second.toInt());
|
|
|
|
|
|
|
|
QSpinBox* spinBox = new QSpinBox(widget_slider_spin);
|
2022-12-05 10:08:46 +00:00
|
|
|
spinBox->setMinimumWidth(100);
|
2022-05-03 10:25:52 +00:00
|
|
|
spinBox->setToolTip(opt->desc);
|
|
|
|
spinBox->setRange(opt->constraint.range->min, opt->constraint.range->max);
|
|
|
|
|
|
|
|
spinBox->setSingleStep(1);
|
|
|
|
spinBox->setValue(m_list_defaultOptions.at(i).second.toInt());
|
|
|
|
int id = i + 1;
|
|
|
|
spinBox->setProperty("controls_id", id);
|
|
|
|
m_list_sliderSpinbox.append(QPair<QObject*, QObject*>(sliderCreation, spinBox));
|
|
|
|
|
|
|
|
QHBoxLayout* hLayout = new QHBoxLayout;
|
|
|
|
hLayout->addWidget(sliderCreation);
|
|
|
|
hLayout->addWidget(spinBox);
|
2022-12-05 10:08:46 +00:00
|
|
|
// hLayout->addStretch();
|
2022-05-03 10:25:52 +00:00
|
|
|
widget_slider_spin->setLayout(hLayout);
|
|
|
|
reinterpret_cast<QFormLayout*>(widget->layout())->addRow(opt->title + QString(" : "), widget_slider_spin);
|
|
|
|
|
|
|
|
m_list_widgets.append(sliderCreation);
|
|
|
|
m_list_widgets.append(spinBox);
|
|
|
|
m_list_getOpt.append(QPair<int, const void*>(id, opt));
|
|
|
|
|
2022-10-28 01:03:22 +00:00
|
|
|
int cur = *(int*)&cur_val[0];
|
|
|
|
spinBox->setValue(cur);
|
|
|
|
sliderCreation->setValue(cur);
|
2022-05-03 10:25:52 +00:00
|
|
|
|
|
|
|
connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(slot_spinBoxClicked(int)));
|
|
|
|
connect(sliderCreation, SIGNAL(valueChanged(int)), this, SLOT(slot_sliderClicked(int)));
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SANE_CONSTRAINT_WORD_LIST:
|
|
|
|
{
|
2022-05-07 03:00:11 +00:00
|
|
|
QComboBox* comboBoxCreation = new QComboBox(scrollArea);
|
|
|
|
comboBoxCreation->setToolTip(opt->desc);
|
|
|
|
int id = i + 1;
|
|
|
|
comboBoxCreation->setProperty("controls_id", id);
|
|
|
|
reinterpret_cast<QFormLayout*>(widget->layout())->addRow(opt->title + QString(" : "), comboBoxCreation);
|
|
|
|
|
|
|
|
auto p_str = opt->constraint.word_list;
|
|
|
|
char buf[20];
|
|
|
|
for(SANE_Int i = 0; i < p_str[0]; ++i)
|
|
|
|
{
|
|
|
|
sprintf(buf, "%d", p_str[i + 1]);
|
|
|
|
comboBoxCreation->addItem(QString::fromStdString(buf));
|
|
|
|
}
|
|
|
|
sprintf(buf, "%d", m_list_defaultOptions.at(i).second.toInt());
|
|
|
|
comboBoxCreation->setProperty(hg_settingdialog::property_combox_data_type_.c_str(), COMBO_VAL_INT);
|
|
|
|
m_list_widgets.append(comboBoxCreation);
|
|
|
|
m_list_getOpt.append(QPair<int, const void*>(id, opt));
|
2022-05-03 10:25:52 +00:00
|
|
|
|
2022-10-28 01:03:22 +00:00
|
|
|
char nstr[40] = {0};
|
|
|
|
sprintf(nstr, "%d", *(int*)&cur_val[0]);
|
|
|
|
comboBoxCreation->setCurrentText(QString::fromStdString(nstr));
|
2022-05-07 03:00:11 +00:00
|
|
|
connect(comboBoxCreation, SIGNAL(currentTextChanged(const QString)), this, SLOT(slot_string_list_comboBoxClicked()));
|
2022-05-03 10:25:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SANE_CONSTRAINT_STRING_LIST:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SANE_TYPE_FIXED:
|
|
|
|
{
|
|
|
|
QWidget* widget_slider_spin = new QWidget(scrollArea);
|
2022-12-05 10:08:46 +00:00
|
|
|
// widget_slider_spin->setMinimumWidth(250);
|
2022-05-03 10:25:52 +00:00
|
|
|
QSlider* sliderCreation = new QSlider(widget_slider_spin);
|
|
|
|
sliderCreation->setOrientation(Qt::Horizontal);
|
|
|
|
sliderCreation->setMinimumWidth(120);
|
|
|
|
sliderCreation->setToolTip(opt->desc);
|
|
|
|
int id = i + 1;
|
|
|
|
sliderCreation->setProperty("controls_id", id);
|
|
|
|
sliderCreation->setRange(SANE_UNFIX(opt->constraint.range->min) * 100, SANE_UNFIX(opt->constraint.range->max) * 100);
|
|
|
|
sliderCreation->setValue(SANE_UNFIX(m_list_defaultOptions.at(i).second.toDouble()) * 100);
|
|
|
|
|
|
|
|
QDoubleSpinBox* spinBox = new QDoubleSpinBox(widget_slider_spin);
|
2022-12-05 10:08:46 +00:00
|
|
|
spinBox->setMinimumWidth(100);
|
2022-05-03 10:25:52 +00:00
|
|
|
spinBox->setToolTip(opt->desc);
|
|
|
|
spinBox->setDecimals(2);
|
|
|
|
spinBox->setSingleStep(0.01);
|
|
|
|
spinBox->setRange(SANE_UNFIX(opt->constraint.range->min), SANE_UNFIX(opt->constraint.range->max));
|
|
|
|
spinBox->setValue(sliderCreation->value() * spinBox->singleStep());
|
|
|
|
spinBox->setProperty("controls_id", id);
|
|
|
|
|
|
|
|
m_list_sliderSpinbox.append(QPair<QObject*, QObject*>(sliderCreation, spinBox));
|
|
|
|
|
|
|
|
QHBoxLayout* hLayout = new QHBoxLayout;
|
|
|
|
hLayout->addWidget(sliderCreation);
|
|
|
|
hLayout->addWidget(spinBox);
|
2022-12-05 10:08:46 +00:00
|
|
|
// hLayout->addStretch();
|
2022-05-03 10:25:52 +00:00
|
|
|
widget_slider_spin->setLayout(hLayout);
|
|
|
|
reinterpret_cast<QFormLayout*>(widget->layout())->addRow(opt->title + QString(" : "), widget_slider_spin);
|
|
|
|
|
|
|
|
m_list_widgets.append(sliderCreation);
|
|
|
|
m_list_widgets.append(spinBox);
|
|
|
|
|
|
|
|
m_list_getOpt.append(QPair<int, const void*>(id, opt));
|
|
|
|
// iniRead(md5(opt->title), id, sliderCreation);
|
|
|
|
// iniRead(md5(opt->title), id, spinBox);
|
|
|
|
|
2022-10-28 01:03:22 +00:00
|
|
|
float v = SANE_UNFIX(*(SANE_Fixed*)&cur_val[0]);
|
|
|
|
sliderCreation->setValue(v * 100);
|
2022-05-03 10:25:52 +00:00
|
|
|
spinBox->setValue(sliderCreation->value() * spinBox->singleStep());
|
|
|
|
connect(spinBox, SIGNAL(valueChanged(double)), this, SLOT(slot_doubleSpinboxClicked(double)));
|
|
|
|
connect(sliderCreation, SIGNAL(valueChanged(int)), this, SLOT(slot_sliderClicked(int)));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SANE_TYPE_STRING:
|
|
|
|
{
|
|
|
|
switch(opt->constraint_type)
|
|
|
|
{
|
|
|
|
case SANE_CONSTRAINT_NONE:
|
|
|
|
{
|
|
|
|
QLineEdit *lineEdit = new QLineEdit(scrollArea);
|
|
|
|
lineEdit->setToolTip(opt->desc);
|
|
|
|
int id = i + 1;
|
|
|
|
lineEdit->setProperty("controls_id", id);
|
|
|
|
reinterpret_cast<QFormLayout*>(widget->layout())->addRow(opt->title + QString(" : "), lineEdit);
|
|
|
|
|
|
|
|
m_list_widgets.append(lineEdit);
|
|
|
|
m_list_getOpt.append(QPair<int, const void*>(id, opt));
|
|
|
|
// iniRead(md5(opt->title), id, lineEdit);
|
|
|
|
|
2022-10-28 01:03:22 +00:00
|
|
|
lineEdit->setText(QString::fromStdString(cur_val));
|
2022-05-03 10:25:52 +00:00
|
|
|
connect(lineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slot_lineEditInput()));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SANE_CONSTRAINT_RANGE:
|
|
|
|
break;
|
|
|
|
case SANE_CONSTRAINT_WORD_LIST:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case SANE_CONSTRAINT_STRING_LIST:
|
|
|
|
{
|
|
|
|
QComboBox* comboBoxCreation = new QComboBox(scrollArea);
|
|
|
|
comboBoxCreation->setToolTip(opt->desc);
|
|
|
|
int id = i + 1;
|
|
|
|
comboBoxCreation->setProperty("controls_id", id);
|
|
|
|
reinterpret_cast<QFormLayout*>(widget->layout())->addRow(opt->title + QString(" : "), comboBoxCreation);
|
|
|
|
|
|
|
|
auto p_str = opt->constraint.string_list;
|
|
|
|
QStringList stringList;
|
|
|
|
while(*p_str)
|
|
|
|
{
|
|
|
|
stringList.append(*p_str);
|
|
|
|
p_str++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(stringList.isEmpty() != true)
|
|
|
|
{
|
|
|
|
for(int i = 0; i < (stringList.size()); i++)
|
|
|
|
comboBoxCreation->addItem(stringList.at(i));
|
|
|
|
}
|
|
|
|
comboBoxCreation->setCurrentText(m_list_defaultOptions.at(i).second.toString());
|
2022-05-07 03:00:11 +00:00
|
|
|
comboBoxCreation->setProperty(hg_settingdialog::property_combox_data_type_.c_str(), COMBO_VAL_STRING);
|
2022-05-03 10:25:52 +00:00
|
|
|
//printf("Option %02d default value is: %s\n", i + 1, m_list_defaultOptions.at(i).second.toString().data());
|
|
|
|
|
|
|
|
m_list_widgets.append(comboBoxCreation);
|
|
|
|
|
|
|
|
m_list_getOpt.append(QPair<int, const void*>(id, opt));
|
|
|
|
// iniRead(md5(opt->title), id, comboBoxCreation);
|
|
|
|
|
2022-10-28 01:03:22 +00:00
|
|
|
comboBoxCreation->setCurrentText(QString::fromStdString(cur_val));
|
2022-05-03 10:25:52 +00:00
|
|
|
connect(comboBoxCreation, SIGNAL(currentTextChanged(const QString)), this, SLOT(slot_string_list_comboBoxClicked()));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SANE_TYPE_BUTTON:
|
|
|
|
{
|
|
|
|
QPushButton* pushButton = new QPushButton(this);
|
|
|
|
pushButton->setText(opt->title);
|
|
|
|
pushButton->setToolTip(opt->desc);
|
|
|
|
int id = i + 1;
|
|
|
|
pushButton->setProperty("controls_id", id);
|
|
|
|
hlayoutOkAndCancel->insertWidget(0, pushButton, 0, Qt::AlignRight);
|
|
|
|
|
|
|
|
connect(pushButton, SIGNAL(clicked(bool)), this, SLOT(slot_pushButtonClicked()));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case SANE_TYPE_GROUP:
|
|
|
|
{
|
|
|
|
if (isBegin)
|
|
|
|
{
|
|
|
|
scrollArea->setWindowTitle(opt->title);
|
|
|
|
isBegin = false;
|
|
|
|
}else{
|
|
|
|
scrollArea->setWidget(widget);
|
|
|
|
tabWidgetCreation->addTab(scrollArea, scrollArea->windowTitle());
|
|
|
|
scrollArea = new QScrollArea;
|
|
|
|
scrollArea->setWidgetResizable(true);
|
|
|
|
scrollArea->setWindowTitle(opt->title);
|
|
|
|
layout = new QFormLayout;
|
|
|
|
widget = new QWidget;
|
|
|
|
widget->setLayout(layout);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_list_widgets.append(nullptr);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} //switch(opt->type)
|
2022-05-06 09:25:17 +00:00
|
|
|
|
2022-05-07 03:00:11 +00:00
|
|
|
// if (Utf8ToStdString(opt->title) == "分辨率")
|
2022-10-10 03:46:28 +00:00
|
|
|
if (strcmp(opt->name, SANE_STD_OPT_NAME_RESOLUTION) == 0)
|
2022-05-06 09:25:17 +00:00
|
|
|
{
|
|
|
|
m_dpiId = i + 1;
|
|
|
|
m_dpiValue = m_list_defaultOptions.at(i).second.toInt();
|
|
|
|
}
|
2022-05-07 03:00:11 +00:00
|
|
|
// else if (Utf8ToStdString(opt->title) == "纸张尺寸")
|
2022-10-10 03:46:28 +00:00
|
|
|
else if (strcmp(opt->name, SANE_STD_OPT_NAME_PAPER) == 0)
|
2022-05-06 09:25:17 +00:00
|
|
|
{
|
|
|
|
m_paperSizeId = i + 1;
|
|
|
|
m_paperSizeValue = m_list_defaultOptions.at(i).second.toString();
|
|
|
|
}
|
|
|
|
|
2022-05-23 03:50:56 +00:00
|
|
|
if (0 == strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA_LEFT))
|
2022-05-06 09:25:17 +00:00
|
|
|
{
|
|
|
|
m_cutLeftId = i + 1;
|
2022-05-06 10:14:14 +00:00
|
|
|
m_cutLeftValue = SANE_UNFIX(m_list_defaultOptions.at(i).second.toInt());
|
2022-05-06 09:25:17 +00:00
|
|
|
if (opt->constraint_type == SANE_CONSTRAINT_RANGE)
|
2022-05-06 10:14:14 +00:00
|
|
|
m_cutWidth = SANE_UNFIX(opt->constraint.range->max);
|
2022-05-06 09:25:17 +00:00
|
|
|
}
|
2022-05-23 03:50:56 +00:00
|
|
|
else if (0 == strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA_TOP))
|
2022-05-06 09:25:17 +00:00
|
|
|
{
|
|
|
|
m_cutTopId = i + 1;
|
2022-05-06 10:14:14 +00:00
|
|
|
m_cutTopValue = SANE_UNFIX(m_list_defaultOptions.at(i).second.toInt());
|
2022-05-06 09:25:17 +00:00
|
|
|
if (opt->constraint_type == SANE_CONSTRAINT_RANGE)
|
2022-05-06 10:14:14 +00:00
|
|
|
m_cutHeight = SANE_UNFIX(opt->constraint.range->max);
|
2022-05-06 09:25:17 +00:00
|
|
|
}
|
2022-05-23 03:50:56 +00:00
|
|
|
else if (0 == strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA_RIGHT))
|
2022-05-06 09:25:17 +00:00
|
|
|
{
|
|
|
|
m_cutRightId = i + 1;
|
2022-05-06 10:14:14 +00:00
|
|
|
m_cutRightValue = SANE_UNFIX(m_list_defaultOptions.at(i).second.toInt());
|
2022-05-06 09:25:17 +00:00
|
|
|
}
|
2022-05-23 03:50:56 +00:00
|
|
|
else if (0 == strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA_BOTTOM))
|
2022-05-06 09:25:17 +00:00
|
|
|
{
|
|
|
|
m_cutBottomId = i + 1;
|
2022-05-06 10:14:14 +00:00
|
|
|
m_cutBottomValue = SANE_UNFIX(m_list_defaultOptions.at(i).second.toInt());
|
2022-05-06 09:25:17 +00:00
|
|
|
}
|
|
|
|
|
2022-05-07 03:00:11 +00:00
|
|
|
// else if (Utf8ToStdString(opt->title) == "颜色模式")
|
2022-10-10 03:46:28 +00:00
|
|
|
if (strcmp(opt->name, SANE_STD_OPT_NAME_COLOR_MODE) == 0)
|
2022-05-06 09:25:17 +00:00
|
|
|
{
|
|
|
|
m_colorModeId = i + 1;
|
|
|
|
m_colorModeValue = m_list_defaultOptions.at(i).second.toString();
|
|
|
|
}
|
2022-05-07 03:00:11 +00:00
|
|
|
// else if (Utf8ToStdString(opt->title) == "伽玛" || Utf8ToStdString(opt->title) == "伽玛值")
|
2022-05-06 09:25:17 +00:00
|
|
|
|
2022-05-03 10:25:52 +00:00
|
|
|
} //for
|
|
|
|
|
|
|
|
updateUIStatus();
|
|
|
|
|
|
|
|
scrollArea->setWidget(widget);
|
|
|
|
tabWidgetCreation->addTab(scrollArea, scrollArea->windowTitle());
|
|
|
|
}
|
|
|
|
|
|
|
|
void hg_settingdialog::refresh_control_value(int op_id)
|
|
|
|
{
|
|
|
|
QVector<QWidget*> ctrls = find_control(op_id);
|
|
|
|
|
|
|
|
if(ctrls.empty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
const SANE_Option_Descriptor* opt = (const SANE_Option_Descriptor*)m_list_defaultOptions.at(op_id - 1).first;
|
|
|
|
if(opt->type == SANE_TYPE_BOOL)
|
|
|
|
{
|
|
|
|
for(size_t i = 0; i < (size_t)ctrls.size(); ++i)
|
|
|
|
{
|
|
|
|
QCheckBox* cb = qobject_cast<QCheckBox*>(ctrls[i]);
|
|
|
|
if(cb)
|
|
|
|
{
|
|
|
|
disconnect(cb, SIGNAL(stateChanged(int)), this, SLOT(slot_checkedClicked()));
|
|
|
|
cb->setChecked(m_list_defaultOptions.at(op_id - 1).second.toBool());
|
|
|
|
connect(cb, SIGNAL(stateChanged(int)), this, SLOT(slot_checkedClicked()));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(opt->type == SANE_TYPE_INT)
|
|
|
|
{
|
|
|
|
for(size_t i = 0; i < (size_t)ctrls.size(); ++i)
|
|
|
|
{
|
2022-05-07 03:00:11 +00:00
|
|
|
QComboBox* comb = qobject_cast<QComboBox*>(ctrls[i]);
|
|
|
|
if(comb)
|
2022-05-03 10:25:52 +00:00
|
|
|
{
|
2022-05-07 03:00:11 +00:00
|
|
|
char buf[40] = {0};
|
|
|
|
sprintf(buf, "%d", m_list_defaultOptions.at(op_id - 1).second.toInt());
|
|
|
|
comb->disconnect(comb, SIGNAL(currentTextChanged(const QString)), this, SLOT(slot_string_list_comboBoxClicked()));
|
|
|
|
comb->setCurrentText(QString::fromStdString(buf));
|
|
|
|
connect(comb, SIGNAL(currentTextChanged(const QString)), this, SLOT(slot_string_list_comboBoxClicked()));
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-05-07 03:00:11 +00:00
|
|
|
QSlider* slider = qobject_cast<QSlider*>(ctrls[i]);
|
|
|
|
if(slider)
|
2022-05-03 10:25:52 +00:00
|
|
|
{
|
2022-05-07 03:00:11 +00:00
|
|
|
disconnect(slider, SIGNAL(valueChanged(int)), this, SLOT(slot_sliderClicked(int)));
|
|
|
|
slider->setValue(m_list_defaultOptions.at(op_id - 1).second.toInt());
|
|
|
|
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(slot_sliderClicked(int)));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QSpinBox* spin = qobject_cast<QSpinBox*>(ctrls[i]);
|
|
|
|
if(spin)
|
|
|
|
{
|
|
|
|
disconnect(spin, SIGNAL(valueChanged(int)), this, SLOT(slot_spinBoxClicked(int)));
|
|
|
|
spin->setValue(m_list_defaultOptions.at(op_id - 1).second.toInt());
|
|
|
|
connect(spin, SIGNAL(valueChanged(int)), this, SLOT(slot_spinBoxClicked(int)));
|
|
|
|
}
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if(opt->type == SANE_TYPE_FIXED)
|
|
|
|
{
|
|
|
|
double val = SANE_UNFIX(m_list_defaultOptions.at(op_id - 1).second.toInt());
|
|
|
|
QSlider *slider = NULL;
|
|
|
|
QDoubleSpinBox* spin = NULL;
|
|
|
|
for(size_t i = 0; i < (size_t)ctrls.size(); ++i)
|
|
|
|
{
|
2022-05-07 03:00:11 +00:00
|
|
|
QComboBox* comb = qobject_cast<QComboBox*>(ctrls[i]);
|
|
|
|
if(comb)
|
|
|
|
{
|
|
|
|
char buf[40] = {0};
|
|
|
|
sprintf(buf, "%f", val);
|
|
|
|
comb->disconnect(comb, SIGNAL(currentTextChanged(const QString)), this, SLOT(slot_string_list_comboBoxClicked()));
|
|
|
|
comb->setCurrentText(QString::fromStdString(buf));
|
|
|
|
connect(comb, SIGNAL(currentTextChanged(const QString)), this, SLOT(slot_string_list_comboBoxClicked()));
|
|
|
|
}
|
|
|
|
else if(!slider)
|
2022-05-03 10:25:52 +00:00
|
|
|
{
|
|
|
|
slider = qobject_cast<QSlider*>(ctrls[i]);
|
|
|
|
if(slider)
|
|
|
|
disconnect(slider, SIGNAL(valueChanged(int)), this, SLOT(slot_sliderClicked(int)));
|
|
|
|
}
|
2022-05-07 03:00:11 +00:00
|
|
|
else if(!spin)
|
2022-05-03 10:25:52 +00:00
|
|
|
{
|
|
|
|
spin = qobject_cast<QDoubleSpinBox*>(ctrls[i]);
|
|
|
|
if(spin)
|
|
|
|
disconnect(spin, SIGNAL(valueChanged(double)), this, SLOT(slot_spinBoxClicked(double)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(slider)
|
|
|
|
slider->setValue(val * 100);
|
|
|
|
if(spin)
|
|
|
|
spin->setValue(val);
|
|
|
|
if(slider)
|
|
|
|
connect(slider, SIGNAL(valueChanged(int)), this, SLOT(slot_sliderClicked(int)));
|
|
|
|
if(spin)
|
|
|
|
connect(spin, SIGNAL(valueChanged(double)), this, SLOT(slot_spinBoxClicked(double)));
|
|
|
|
}
|
|
|
|
else if(opt->type == SANE_TYPE_STRING)
|
|
|
|
{
|
|
|
|
for(size_t i = 0; i < (size_t)ctrls.size(); ++i)
|
|
|
|
{
|
|
|
|
QComboBox* comb = qobject_cast<QComboBox*>(ctrls[i]);
|
|
|
|
if(comb)
|
|
|
|
{
|
|
|
|
disconnect(comb, SIGNAL(currentTextChanged(const QString)), this, SLOT(slot_string_list_comboBoxClicked()));
|
|
|
|
comb->setCurrentText(m_list_defaultOptions.at(op_id - 1).second.toString());
|
2022-05-07 03:00:11 +00:00
|
|
|
// comb->setProperty(hg_settingdialog::property_combox_data_type_.c_str(), COMBO_VAL_STRING);
|
2022-05-03 10:25:52 +00:00
|
|
|
connect(comb, SIGNAL(currentTextChanged(const QString)), this, SLOT(slot_string_list_comboBoxClicked()));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QLineEdit* edit = qobject_cast<QLineEdit*>(ctrls[i]);
|
|
|
|
if(edit)
|
|
|
|
{
|
|
|
|
disconnect(edit, SIGNAL(textChanged(const QString&)), this, SLOT(slot_lineEditInput()));
|
|
|
|
edit->setText(m_list_defaultOptions.at(op_id - 1).second.toString());
|
|
|
|
connect(edit, SIGNAL(textChanged(const QString&)), this, SLOT(slot_lineEditInput()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
QVector<QWidget*> hg_settingdialog::find_control(int opt_num)
|
|
|
|
{
|
|
|
|
QVector<QWidget*> list_w;
|
|
|
|
for(int i = 0; i< m_list_widgets.size(); i++)
|
|
|
|
{
|
|
|
|
if (m_list_widgets.at(i) == nullptr) continue;
|
|
|
|
QWidget* w = m_list_widgets.at(i);
|
|
|
|
int id = w->property("controls_id").toInt();
|
|
|
|
if(opt_num == id)
|
|
|
|
list_w.append(w);
|
|
|
|
}
|
|
|
|
return list_w;
|
|
|
|
}
|
|
|
|
|
|
|
|
void hg_settingdialog::updateUIStatus()
|
|
|
|
{
|
|
|
|
updateOpt();
|
|
|
|
|
|
|
|
SANE_Int dev_options = 0;
|
|
|
|
sane_control_option(m_handle, 0, SANE_ACTION_GET_VALUE, &dev_options, nullptr);
|
|
|
|
for(int id = 1, optons = dev_options; id < optons; id++)
|
|
|
|
{
|
|
|
|
QVector<QWidget*> list_widgets = find_control(id);
|
|
|
|
if (list_widgets.empty()) continue;
|
|
|
|
QWidget* widget = list_widgets.first();
|
|
|
|
if (widget == nullptr) continue;
|
|
|
|
QWidget* parentWidget = widget->parentWidget();
|
|
|
|
|
2022-05-07 08:12:34 +00:00
|
|
|
while (parentWidget->layout() &&
|
|
|
|
typeid(*(parentWidget->layout())) != typeid(QFormLayout))
|
2022-05-03 10:25:52 +00:00
|
|
|
{
|
|
|
|
widget = parentWidget;
|
|
|
|
parentWidget = widget->parentWidget();
|
|
|
|
}
|
|
|
|
|
|
|
|
QFormLayout* layout = reinterpret_cast<QFormLayout*>(parentWidget->layout());
|
|
|
|
const SANE_Option_Descriptor* opt = reinterpret_cast<const SANE_Option_Descriptor*>(m_list_defaultOptions.at(id - 1).first);
|
2022-05-07 08:12:34 +00:00
|
|
|
bool hide = (opt->cap & SANE_CAP_INACTIVE) == SANE_CAP_INACTIVE;
|
|
|
|
QWidget* w_label = layout ? layout->labelForField(widget) : nullptr;
|
|
|
|
|
2022-10-10 03:46:28 +00:00
|
|
|
if( strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA_LEFT) == 0 ||
|
|
|
|
strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA_TOP) == 0 ||
|
|
|
|
strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA_RIGHT) == 0 ||
|
|
|
|
strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA_BOTTOM) == 0 )
|
2022-05-07 08:12:34 +00:00
|
|
|
hide = true;
|
|
|
|
|
2022-05-03 10:25:52 +00:00
|
|
|
refresh_control_value(id);
|
2022-05-07 08:12:34 +00:00
|
|
|
if(w_label)
|
|
|
|
hide ? w_label->hide() : w_label->show();
|
|
|
|
widget->setVisible(!hide);
|
2022-10-10 03:46:28 +00:00
|
|
|
if(strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA) == 0)
|
2022-05-10 02:33:02 +00:00
|
|
|
{
|
|
|
|
if(hide)
|
|
|
|
{
|
|
|
|
custom_area_lable_->hide();
|
|
|
|
btn_cut_area_->hide();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
custom_area_lable_->show();
|
|
|
|
btn_cut_area_->show();
|
|
|
|
}
|
|
|
|
}
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void hg_settingdialog::slot_checkedClicked()
|
|
|
|
{
|
|
|
|
QCheckBox *checkBox = qobject_cast<QCheckBox*>(sender());
|
|
|
|
SANE_Int id = checkBox->property("controls_id").toInt();
|
|
|
|
SANE_Bool checkBoxcurrentState = checkBox->isChecked();
|
|
|
|
|
|
|
|
const SANE_Option_Descriptor* opt = nullptr;
|
|
|
|
for(int i = 0; i < m_list_getOpt.size(); i++)
|
|
|
|
if (m_list_getOpt.at(i).first == id)
|
|
|
|
{
|
|
|
|
opt = reinterpret_cast<const SANE_Option_Descriptor*>(m_list_getOpt.at(i).second);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_list_IdValueTitle.append(QPair<QPair<int, QVariant>, QString>(QPair<int, QVariant>(id, checkBoxcurrentState), md5(opt->title)));
|
|
|
|
|
|
|
|
SANE_Int method = 0;
|
|
|
|
sane_control_option(m_handle, id, SANE_ACTION_SET_VALUE, &checkBoxcurrentState, &method);
|
|
|
|
if((method & SANE_INFO_RELOAD_OPTIONS) == SANE_INFO_RELOAD_OPTIONS)
|
|
|
|
updateUIStatus();
|
|
|
|
else if(method & SANE_INFO_INEXACT)
|
|
|
|
checkBox->setCheckState(checkBoxcurrentState ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
|
|
|
|
|
2022-10-10 03:46:28 +00:00
|
|
|
if(strcmp(opt->name, SANE_STD_OPT_NAME_CUSTOM_AREA) == 0)
|
2022-05-07 08:12:34 +00:00
|
|
|
btn_cut_area_->setEnabled(checkBoxcurrentState);
|
2022-10-10 03:46:28 +00:00
|
|
|
else if (strcmp(opt->name, SANE_STD_OPT_NAME_IS_CUSTOM_GAMMA) == 0)
|
2022-05-07 08:12:34 +00:00
|
|
|
btn_gamma_->setEnabled(checkBoxcurrentState);
|
2022-10-28 01:03:22 +00:00
|
|
|
cur_scheme_->config_changed(id, (char*)&checkBoxcurrentState, sizeof(checkBoxcurrentState));
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void hg_settingdialog::slot_string_list_comboBoxClicked()
|
|
|
|
{
|
|
|
|
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
|
|
|
|
SANE_Int id = comboBox->property("controls_id").toInt();
|
|
|
|
std::string comboBoxcurrentItem(comboBox->currentText().toUtf8());
|
2022-05-07 03:00:11 +00:00
|
|
|
int type = comboBox->property(hg_settingdialog::property_combox_data_type_.c_str()).toInt();
|
2022-05-03 10:25:52 +00:00
|
|
|
|
2022-05-17 10:09:21 +00:00
|
|
|
if (id == m_dpiId)
|
|
|
|
{
|
|
|
|
m_dpiValue = atoi(comboBoxcurrentItem.c_str());
|
|
|
|
qDebug("dpi=%d", m_dpiValue);
|
|
|
|
}
|
|
|
|
else if (id == m_paperSizeId)
|
2022-05-06 09:25:17 +00:00
|
|
|
{
|
|
|
|
m_paperSizeValue = comboBoxcurrentItem.c_str();
|
2022-05-17 10:09:21 +00:00
|
|
|
qDebug("paperSize=%s", comboBoxcurrentItem.c_str());
|
2022-05-06 09:25:17 +00:00
|
|
|
}
|
|
|
|
else if (id == m_colorModeId)
|
|
|
|
{
|
|
|
|
m_colorModeValue = comboBoxcurrentItem.c_str();
|
2022-05-17 10:09:21 +00:00
|
|
|
qDebug("colorMode=%s", comboBoxcurrentItem.c_str());
|
2022-05-06 09:25:17 +00:00
|
|
|
}
|
|
|
|
|
2022-05-03 10:25:52 +00:00
|
|
|
const SANE_Option_Descriptor* opt = nullptr;
|
|
|
|
for(int i = 0; i < m_list_getOpt.size(); i++)
|
|
|
|
if (m_list_getOpt.at(i).first == id)
|
|
|
|
{
|
|
|
|
opt = reinterpret_cast<const SANE_Option_Descriptor*>(m_list_getOpt.at(i).second);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_list_IdValueTitle.append(QPair<QPair<int, QVariant>, QString>(QPair<int, QVariant>(id, &comboBoxcurrentItem.at(0)), md5(opt->title)));
|
|
|
|
|
|
|
|
SANE_Int method = 0;
|
|
|
|
SANE_String buf = (SANE_String)malloc(opt->size * 2 + 4);
|
2022-05-07 03:00:11 +00:00
|
|
|
if(type == COMBO_VAL_INT)
|
|
|
|
*((SANE_Int*)buf) = atoi(comboBoxcurrentItem.c_str());
|
|
|
|
else if(type == COMBO_VAL_FLOAT)
|
|
|
|
*((SANE_Fixed*)buf) = SANE_FIX(atof(comboBoxcurrentItem.c_str()));
|
|
|
|
else
|
|
|
|
strcpy(buf, comboBoxcurrentItem.c_str());
|
2022-05-03 10:25:52 +00:00
|
|
|
sane_control_option(m_handle, id, SANE_ACTION_SET_VALUE, buf, &method);
|
|
|
|
if((method & SANE_INFO_RELOAD_OPTIONS) == SANE_INFO_RELOAD_OPTIONS)
|
|
|
|
updateUIStatus();
|
|
|
|
else if(method & SANE_INFO_INEXACT)
|
|
|
|
comboBox->setCurrentText(QString::fromStdString(buf));
|
|
|
|
|
2022-05-07 03:00:11 +00:00
|
|
|
if(type == COMBO_VAL_INT)
|
2022-10-28 01:03:22 +00:00
|
|
|
cur_scheme_->config_changed(id, buf, sizeof(SANE_Int));
|
2022-05-07 03:00:11 +00:00
|
|
|
else if(type == COMBO_VAL_FLOAT)
|
2022-10-28 01:03:22 +00:00
|
|
|
cur_scheme_->config_changed(id, buf, sizeof(SANE_Fixed));
|
2022-05-07 03:00:11 +00:00
|
|
|
else
|
2023-02-01 11:06:24 +00:00
|
|
|
{
|
|
|
|
std::string langCN(to_default_language(buf, nullptr));
|
|
|
|
cur_scheme_->config_changed(id, &langCN[0], langCN.length());
|
|
|
|
}
|
2022-05-03 10:25:52 +00:00
|
|
|
free(buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
void hg_settingdialog::slot_pushButtonClicked()
|
|
|
|
{
|
|
|
|
QPushButton *pushButton = qobject_cast<QPushButton*>(sender());
|
|
|
|
SANE_Int id = pushButton->property("controls_id").toInt(),
|
|
|
|
after = 0;
|
|
|
|
|
2022-10-28 01:03:22 +00:00
|
|
|
// restore to default setting ?
|
|
|
|
sane_control_option(m_handle, id, SANE_ACTION_SET_VALUE, NULL, &after);
|
2022-05-03 10:25:52 +00:00
|
|
|
if((after & SANE_INFO_RELOAD_OPTIONS) == SANE_INFO_RELOAD_OPTIONS)
|
|
|
|
updateUIStatus();
|
2022-10-28 01:03:22 +00:00
|
|
|
|
|
|
|
const SANE_Option_Descriptor* opt = sane_get_option_descriptor(m_handle, id);
|
|
|
|
if(opt && strcmp(opt->name, SANE_STD_OPT_NAME_RESTORE) == 0)
|
|
|
|
{
|
2022-10-28 01:45:02 +00:00
|
|
|
restore_2_default_settings();
|
2022-10-28 01:03:22 +00:00
|
|
|
}
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
|
|
|
|
2022-05-06 09:25:17 +00:00
|
|
|
void hg_settingdialog::slot_cutButtonClicked()
|
|
|
|
{
|
|
|
|
//int width = 0.03937 * m_cutWidth * m_dpiValue;
|
|
|
|
//int height = 0.03937 * m_cutHeight * m_dpiValue;
|
|
|
|
int left = 0.03937 * m_cutLeftValue * m_dpiValue;
|
|
|
|
int top = 0.03937 * m_cutTopValue * m_dpiValue;
|
|
|
|
int right = 0.03937 * m_cutRightValue * m_dpiValue;
|
|
|
|
int bottom = 0.03937 * m_cutBottomValue * m_dpiValue;
|
|
|
|
|
|
|
|
CutPaperTool dlg(this);
|
2022-05-17 10:09:21 +00:00
|
|
|
dlg.setPaperType(m_dpiValue, m_paperSizeValue, 300);
|
2022-05-06 09:25:17 +00:00
|
|
|
QRectF rc(left, top, right - left, bottom - top);
|
|
|
|
dlg.setCutRect(rc);
|
|
|
|
if (dlg.exec())
|
|
|
|
{
|
|
|
|
QRectF rcRet = dlg.getCutRectPixel();
|
|
|
|
|
|
|
|
m_cutLeftValue = rcRet.left() / (0.03937 * m_dpiValue);
|
|
|
|
m_cutTopValue = rcRet.top() / (0.03937 * m_dpiValue);
|
|
|
|
m_cutRightValue = rcRet.right() / (0.03937 * m_dpiValue);
|
|
|
|
m_cutBottomValue = rcRet.bottom() / (0.03937 * m_dpiValue);
|
|
|
|
|
|
|
|
SANE_Int info;
|
2022-05-06 10:14:14 +00:00
|
|
|
SANE_Word value = SANE_FIX(m_cutLeftValue);
|
|
|
|
sane_control_option(m_handle, m_cutLeftId, SANE_ACTION_SET_VALUE, &value, &info);
|
2022-10-28 01:03:22 +00:00
|
|
|
cur_scheme_->config_changed(m_cutLeftId, (char*)&value, sizeof(value));
|
2022-05-06 10:14:14 +00:00
|
|
|
value = SANE_FIX(m_cutTopValue);
|
|
|
|
sane_control_option(m_handle, m_cutTopId, SANE_ACTION_SET_VALUE, &value, &info);
|
2022-10-28 01:03:22 +00:00
|
|
|
cur_scheme_->config_changed(m_cutTopId, (char*)&value, sizeof(value));
|
2022-05-06 10:14:14 +00:00
|
|
|
value = SANE_FIX(m_cutRightValue);
|
|
|
|
sane_control_option(m_handle, m_cutRightId, SANE_ACTION_SET_VALUE, &value, &info);
|
2022-10-28 01:03:22 +00:00
|
|
|
cur_scheme_->config_changed(m_cutRightId, (char*)&value, sizeof(value));
|
2022-05-06 10:14:14 +00:00
|
|
|
value = SANE_FIX(m_cutBottomValue);
|
|
|
|
sane_control_option(m_handle, m_cutBottomId, SANE_ACTION_SET_VALUE, &value, &info);
|
2022-10-28 01:03:22 +00:00
|
|
|
cur_scheme_->config_changed(m_cutBottomId, (char*)&value, sizeof(value));
|
2022-05-06 09:25:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void hg_settingdialog::slot_gammaButtonClicked()
|
|
|
|
{
|
|
|
|
setPicClrTool dlg(this);
|
|
|
|
|
|
|
|
int colorMode; // 0-彩色, 1-灰度
|
2022-05-24 01:48:58 +00:00
|
|
|
if (m_colorModeValue.toStdString() == OPTION_VALUE_YSMS_256JHD
|
|
|
|
|| m_colorModeValue.toStdString() == OPTION_VALUE_YSMS_HB)
|
2022-05-06 09:25:17 +00:00
|
|
|
{
|
|
|
|
colorMode = 1;
|
|
|
|
|
|
|
|
QList<QPoint> keyTable;
|
|
|
|
for (int i = 0; i < m_gammaData.pt_count; ++i)
|
|
|
|
{
|
|
|
|
QPoint pt(m_gammaData.keypoint[i].x, m_gammaData.keypoint[i].y);
|
|
|
|
keyTable.append(pt);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!keyTable.empty())
|
|
|
|
{
|
|
|
|
dlg.setGrayKeyTable(keyTable);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
colorMode = 0;
|
|
|
|
|
|
|
|
QList<QPoint> keyTable;
|
|
|
|
for (int i = 0; i < m_gammaData.pt_count; ++i)
|
|
|
|
{
|
|
|
|
QPoint pt(m_gammaData.keypoint[i].x, m_gammaData.keypoint[i].y);
|
|
|
|
keyTable.append(pt);
|
|
|
|
}
|
|
|
|
|
|
|
|
QList<QPoint> rKeyTable;
|
|
|
|
for (int i = 0; i < m_gammaData.pt_count_r; ++i)
|
|
|
|
{
|
|
|
|
QPoint pt(m_gammaData.keypoint_r[i].x, m_gammaData.keypoint_r[i].y);
|
|
|
|
rKeyTable.append(pt);
|
|
|
|
}
|
|
|
|
|
|
|
|
QList<QPoint> gKeyTable;
|
|
|
|
for (int i = 0; i < m_gammaData.pt_count_g; ++i)
|
|
|
|
{
|
|
|
|
QPoint pt(m_gammaData.keypoint_g[i].x, m_gammaData.keypoint_g[i].y);
|
|
|
|
gKeyTable.append(pt);
|
|
|
|
}
|
|
|
|
|
|
|
|
QList<QPoint> bKeyTable;
|
|
|
|
for (int i = 0; i < m_gammaData.pt_count_b; ++i)
|
|
|
|
{
|
|
|
|
QPoint pt(m_gammaData.keypoint_b[i].x, m_gammaData.keypoint_b[i].y);
|
|
|
|
bKeyTable.append(pt);
|
|
|
|
}
|
|
|
|
|
|
|
|
QVector<QList<QPoint>> keyTableList;
|
|
|
|
if (!keyTable.empty() && !rKeyTable.empty() && !gKeyTable.empty() && !bKeyTable.empty())
|
|
|
|
{
|
|
|
|
keyTableList.append(keyTable);
|
|
|
|
keyTableList.append(rKeyTable);
|
|
|
|
keyTableList.append(gKeyTable);
|
|
|
|
keyTableList.append(bKeyTable);
|
|
|
|
dlg.setRGBKeyTable(keyTableList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dlg.setColorMode(colorMode);
|
|
|
|
if (dlg.exec())
|
|
|
|
{
|
|
|
|
memset(&m_gammaData, 0, sizeof(m_gammaData));
|
2022-05-07 10:43:43 +00:00
|
|
|
clicked_gamma_ = true;
|
2022-05-06 09:25:17 +00:00
|
|
|
|
|
|
|
if (1 == colorMode)
|
|
|
|
{
|
|
|
|
QList<QPoint> keyTable = dlg.getGrayKeyTable();
|
|
|
|
|
|
|
|
m_gammaData.pt_count = HGMIN(4, keyTable.size());
|
|
|
|
int i = 0;
|
|
|
|
for (QPoint pt : keyTable)
|
|
|
|
{
|
|
|
|
if (i >= 4)
|
|
|
|
break;
|
|
|
|
|
|
|
|
m_gammaData.keypoint[i].x = pt.x();
|
|
|
|
m_gammaData.keypoint[i].y = pt.y();
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
uchar data[256];
|
|
|
|
dlg.getGrayTable(data, 256);
|
|
|
|
for (int i = 0; i < 256; ++i)
|
|
|
|
{
|
|
|
|
m_gammaData.table[i] = data[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QVector<QList<QPoint>> keyTableList = dlg.getRGBKeyTable();
|
|
|
|
|
|
|
|
m_gammaData.pt_count = HGMIN(4, keyTableList[0].size());
|
|
|
|
int i = 0;
|
|
|
|
for (QPoint pt : keyTableList[0])
|
|
|
|
{
|
|
|
|
if (i >= 4)
|
|
|
|
break;
|
|
|
|
|
|
|
|
m_gammaData.keypoint[i].x = pt.x();
|
|
|
|
m_gammaData.keypoint[i].y = pt.y();
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_gammaData.pt_count_r = HGMIN(4, keyTableList[1].size());
|
|
|
|
i = 0;
|
|
|
|
for (QPoint pt : keyTableList[1])
|
|
|
|
{
|
|
|
|
if (i >= 4)
|
|
|
|
break;
|
|
|
|
|
|
|
|
m_gammaData.keypoint_r[i].x = pt.x();
|
|
|
|
m_gammaData.keypoint_r[i].y = pt.y();
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_gammaData.pt_count_g = HGMIN(4, keyTableList[2].size());
|
|
|
|
i = 0;
|
|
|
|
for (QPoint pt : keyTableList[2])
|
|
|
|
{
|
|
|
|
if (i >= 4)
|
|
|
|
break;
|
|
|
|
|
|
|
|
m_gammaData.keypoint_g[i].x = pt.x();
|
|
|
|
m_gammaData.keypoint_g[i].y = pt.y();
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_gammaData.pt_count_b = HGMIN(4, keyTableList[3].size());
|
|
|
|
i = 0;
|
|
|
|
for (QPoint pt : keyTableList[3])
|
|
|
|
{
|
|
|
|
if (i >= 4)
|
|
|
|
break;
|
|
|
|
|
|
|
|
m_gammaData.keypoint_b[i].x = pt.x();
|
|
|
|
m_gammaData.keypoint_b[i].y = pt.y();
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
uchar data[256 * 3];
|
|
|
|
dlg.getRGBTable(data, 256 * 3);
|
|
|
|
for (int i = 0; i < 256; ++i)
|
|
|
|
{
|
|
|
|
m_gammaData.table[i] = data[i * 3 + 2];
|
|
|
|
m_gammaData.table[i + 256] = data[i * 3 + 1];
|
|
|
|
m_gammaData.table[i + 512] = data[i * 3 + 0];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned int len = sizeof(SANE_Gamma);
|
|
|
|
sane_io_control(m_handle, IO_CTRL_CODE_SET_CUSTOM_GAMMA, &m_gammaData, &len);
|
2022-10-28 01:03:22 +00:00
|
|
|
cur_scheme_->config_changed(SANE_STD_OPT_NAME_IS_CUSTOM_GAMMA, (char*)&m_gammaData, sizeof(m_gammaData), true);
|
2022-05-06 09:25:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-03 10:25:52 +00:00
|
|
|
void hg_settingdialog::slot_word_list_comboBoxClicked(int value)
|
|
|
|
{
|
|
|
|
QComboBox *comboBox = qobject_cast<QComboBox*>(sender());
|
|
|
|
SANE_Int id = comboBox->property("controls_id").toInt();
|
|
|
|
SANE_Int temp = 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)
|
|
|
|
{
|
|
|
|
opt = reinterpret_cast<const SANE_Option_Descriptor*>(m_list_getOpt.at(i).second);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
m_list_IdValueTitle.append(QPair<QPair<int, QVariant>, QString>(QPair<int, QVariant>(id, temp), md5(opt->title)));
|
|
|
|
|
|
|
|
|
|
|
|
SANE_Int method = 0;
|
|
|
|
sane_control_option(m_handle, id, SANE_ACTION_SET_VALUE, &temp, &method);
|
|
|
|
if((method & SANE_INFO_RELOAD_OPTIONS) == SANE_INFO_RELOAD_OPTIONS)
|
|
|
|
updateUIStatus();
|
|
|
|
else if(method & SANE_INFO_INEXACT)
|
|
|
|
{
|
|
|
|
char buf[20];
|
|
|
|
sprintf(buf, "%d", temp);
|
|
|
|
comboBox->setCurrentText(QString::fromStdString(buf));
|
|
|
|
}
|
2022-10-28 01:03:22 +00:00
|
|
|
cur_scheme_->config_changed(id, (char*)&temp, sizeof(temp));
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void hg_settingdialog::slot_sliderClicked(int value)
|
|
|
|
{
|
|
|
|
QSlider *slider = qobject_cast<QSlider*>(sender());
|
|
|
|
SANE_Int id = slider->property("controls_id").toInt();
|
|
|
|
|
|
|
|
const SANE_Option_Descriptor* opt = nullptr;
|
|
|
|
for(int i = 0; i < m_list_getOpt.size(); i++)
|
|
|
|
if (m_list_getOpt.at(i).first == id)
|
|
|
|
{
|
|
|
|
opt = reinterpret_cast<const SANE_Option_Descriptor*>(m_list_getOpt.at(i).second);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
QAbstractSpinBox* spin = nullptr;
|
|
|
|
for(int i = 0; i < m_list_sliderSpinbox.size(); i++)
|
|
|
|
if (m_list_sliderSpinbox.at(i).first == slider)
|
|
|
|
{
|
|
|
|
spin = reinterpret_cast<QAbstractSpinBox*>(m_list_sliderSpinbox.at(i).second);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (spin != nullptr)
|
|
|
|
{
|
|
|
|
SANE_Int val = value, method = 0;
|
|
|
|
bool db_val = false;
|
|
|
|
if (typeid(*spin) == typeid(QSpinBox))
|
|
|
|
{
|
|
|
|
QSpinBox* spin_ = reinterpret_cast<QSpinBox*>(spin);
|
|
|
|
spin_->setValue(value);
|
|
|
|
|
|
|
|
m_list_IdValueTitle.append(QPair<QPair<int, QVariant>, QString>(QPair<int, QVariant>(id, val), md5(opt->title)));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
QDoubleSpinBox* spin_ = reinterpret_cast<QDoubleSpinBox*>(spin);
|
|
|
|
double temp = value * spin_->singleStep();
|
|
|
|
if(temp != spin_->value())
|
|
|
|
spin_->setValue(temp);
|
|
|
|
|
|
|
|
val = SANE_FIX(temp);
|
|
|
|
db_val = true;
|
|
|
|
|
|
|
|
m_list_IdValueTitle.append(QPair<QPair<int, QVariant>, QString>(QPair<int, QVariant>(id, temp), md5(opt->title)));
|
|
|
|
}
|
|
|
|
sane_control_option(m_handle, id, SANE_ACTION_SET_VALUE, &val, &method);
|
|
|
|
if((method & SANE_INFO_RELOAD_OPTIONS) == SANE_INFO_RELOAD_OPTIONS)
|
|
|
|
updateUIStatus();
|
|
|
|
else if(method & SANE_INFO_INEXACT)
|
|
|
|
{
|
|
|
|
if(db_val)
|
|
|
|
{
|
|
|
|
QDoubleSpinBox* spin_ = reinterpret_cast<QDoubleSpinBox*>(spin);
|
|
|
|
double v = SANE_UNFIX(val);
|
|
|
|
spin_->setValue(v);
|
|
|
|
slider->setValue(spin_->value() / spin_->singleStep());
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
QSpinBox* spin_ = reinterpret_cast<QSpinBox*>(spin);
|
|
|
|
spin_->setValue(val);
|
|
|
|
slider->setValue(spin_->value() / spin_->singleStep());
|
|
|
|
}
|
|
|
|
}
|
2022-10-28 01:03:22 +00:00
|
|
|
cur_scheme_->config_changed(id, (char*)&val, sizeof(val));
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void hg_settingdialog::slot_doubleSpinboxClicked(double value)
|
|
|
|
{
|
|
|
|
QDoubleSpinBox* spinBox = qobject_cast<QDoubleSpinBox*>(sender());
|
|
|
|
QAbstractSlider* slider = nullptr;
|
|
|
|
int id = spinBox->property("controls_id").toInt();
|
|
|
|
for (int i = 0; i < m_list_sliderSpinbox.size(); i++)
|
|
|
|
if (m_list_sliderSpinbox.at(i).second == spinBox)
|
|
|
|
{
|
|
|
|
slider = reinterpret_cast<QAbstractSlider*>(m_list_sliderSpinbox.at(i).first);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(slider != nullptr)
|
|
|
|
{
|
|
|
|
int temp = static_cast<int>(value / spinBox->singleStep() + 0.5);
|
|
|
|
QSlider* slider_ = reinterpret_cast<QSlider*>(slider);
|
|
|
|
if (slider_->value() != temp)
|
|
|
|
slider_->setValue(temp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void hg_settingdialog::slot_spinBoxClicked(int value)
|
|
|
|
{
|
|
|
|
QSpinBox* spinBox = qobject_cast<QSpinBox*>(sender());
|
|
|
|
int id = spinBox->property("controls_id").toInt();
|
|
|
|
|
|
|
|
const SANE_Option_Descriptor* opt = nullptr;
|
|
|
|
for(int i = 0; i < m_list_getOpt.size(); i++)
|
|
|
|
if (m_list_getOpt.at(i).first == id)
|
|
|
|
{
|
|
|
|
opt = reinterpret_cast<const SANE_Option_Descriptor*>(m_list_getOpt.at(i).second);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
QAbstractSlider* slider = nullptr;
|
|
|
|
for (int i = 0; i < m_list_sliderSpinbox.size(); i++)
|
|
|
|
if (m_list_sliderSpinbox.at(i).second == spinBox)
|
|
|
|
{
|
|
|
|
slider = reinterpret_cast<QAbstractSlider*>(m_list_sliderSpinbox.at(i).first);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if(slider == nullptr)
|
|
|
|
{
|
|
|
|
SANE_Int temp = value;
|
|
|
|
|
|
|
|
m_list_IdValueTitle.append(QPair<QPair<int, QVariant>, QString>(QPair<int, QVariant>(id, temp), md5(opt->title)));
|
|
|
|
|
|
|
|
SANE_Int method = 0;
|
|
|
|
sane_control_option(m_handle, id, SANE_ACTION_SET_VALUE, &temp, &method);
|
|
|
|
if((method & SANE_INFO_RELOAD_OPTIONS) == SANE_INFO_RELOAD_OPTIONS)
|
|
|
|
updateUIStatus();
|
|
|
|
else if(value != temp)
|
|
|
|
{
|
|
|
|
disconnect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(slot_spinBoxClicked(int)));
|
|
|
|
spinBox->setValue(temp);
|
|
|
|
connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(slot_spinBoxClicked(int)));
|
|
|
|
}
|
2022-10-28 01:03:22 +00:00
|
|
|
cur_scheme_->config_changed(id, (char*)&temp, sizeof(temp));
|
2022-05-03 10:25:52 +00:00
|
|
|
}else
|
|
|
|
{
|
|
|
|
QSlider* slider_ = reinterpret_cast<QSlider*>(slider);
|
|
|
|
slider_->setValue(spinBox->value());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void hg_settingdialog::slot_lineEditInput()
|
|
|
|
{
|
|
|
|
QLineEdit* lineEdit = qobject_cast<QLineEdit*>(sender());
|
|
|
|
int id = lineEdit->property("controls_id").toInt();
|
|
|
|
std::string lineEditCurrentText(lineEdit->text().toUtf8());
|
|
|
|
|
|
|
|
const SANE_Option_Descriptor* opt = nullptr;
|
|
|
|
for(int i = 0; i < m_list_getOpt.size(); i++)
|
|
|
|
if (m_list_getOpt.at(i).first == id)
|
|
|
|
{
|
|
|
|
opt = reinterpret_cast<const SANE_Option_Descriptor*>(m_list_getOpt.at(i).second);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_list_IdValueTitle.append(QPair<QPair<int, QVariant>, QString>(QPair<int, QVariant>(id, &lineEditCurrentText.at(0)), md5(opt->title)));
|
|
|
|
|
|
|
|
SANE_Int method = 0;
|
|
|
|
void *buf = NULL;
|
|
|
|
SANE_Int nv = 0;
|
|
|
|
if(opt->type == SANE_TYPE_INT)
|
|
|
|
{
|
|
|
|
nv = atoi(lineEditCurrentText.c_str());
|
|
|
|
buf = &nv;
|
|
|
|
}
|
|
|
|
else if(opt->type == SANE_TYPE_FIXED)
|
|
|
|
{
|
|
|
|
nv = SANE_FIX(atof(lineEditCurrentText.c_str()));
|
|
|
|
buf = &nv;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
buf = malloc(opt->size * 2 + 4);
|
|
|
|
strcpy((char*)buf, lineEditCurrentText.c_str());
|
|
|
|
}
|
|
|
|
sane_control_option(m_handle, id, SANE_ACTION_SET_VALUE, buf, &method);
|
|
|
|
if((method & SANE_INFO_RELOAD_OPTIONS) == SANE_INFO_RELOAD_OPTIONS)
|
|
|
|
updateUIStatus();
|
|
|
|
else if(method & SANE_INFO_INEXACT)
|
|
|
|
{
|
|
|
|
char mem[20], *v = mem;
|
|
|
|
if(opt->type == SANE_TYPE_INT)
|
|
|
|
sprintf(mem, "%d", nv);
|
|
|
|
else if(opt->type == SANE_TYPE_FIXED)
|
|
|
|
sprintf(mem, "%f", SANE_UNFIX(nv));
|
|
|
|
else
|
|
|
|
v = (char*)buf;
|
|
|
|
lineEdit->setText(QString::fromStdString(v));
|
|
|
|
}
|
|
|
|
|
2022-10-28 01:03:22 +00:00
|
|
|
if(opt->type == SANE_TYPE_INT || opt->type == SANE_TYPE_FIXED)
|
2022-05-03 10:25:52 +00:00
|
|
|
{
|
2022-10-28 01:03:22 +00:00
|
|
|
cur_scheme_->config_changed(id, (char*)buf, sizeof(SANE_Int));
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
2022-10-28 01:03:22 +00:00
|
|
|
else
|
2022-05-03 10:25:52 +00:00
|
|
|
{
|
2023-02-01 11:06:24 +00:00
|
|
|
std::string langCN(to_default_language((char*)buf, nullptr));
|
|
|
|
cur_scheme_->config_changed(id, &langCN[0], langCN.length());
|
2022-10-28 01:03:22 +00:00
|
|
|
free(buf);
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void hg_settingdialog::slot_buttonOkClicked()
|
|
|
|
{
|
|
|
|
save_ = true;
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
|
|
|
void hg_settingdialog::slot_buttonCancelClicked()
|
|
|
|
{
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
|
|
|
void hg_settingdialog::keyPressEvent(QKeyEvent *e)
|
|
|
|
{
|
|
|
|
if (e->key() == Qt::Key_Escape) {
|
|
|
|
e->ignore();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
QDialog::keyPressEvent(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int hg_settingdialog::get_changed_items(void)
|
|
|
|
{
|
|
|
|
return changed_count_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void hg_settingdialog::iniWrite(QString title, int id, QVariant value)
|
|
|
|
{
|
|
|
|
(void)title;
|
|
|
|
(void)id;
|
|
|
|
(void)value;
|
|
|
|
// m_qstrFileName = QCoreApplication::applicationDirPath() + "/config.ini";
|
|
|
|
// m_configIniWrite = new QSettings(m_qstrFileName, QSettings::IniFormat);
|
|
|
|
// m_configIniWrite->setIniCodec(QTextCodec::codecForName("UTF-8"));
|
|
|
|
// m_configIniWrite->setValue(title + "/id", id);
|
|
|
|
// m_configIniWrite->setValue(title + "/value", value);
|
|
|
|
|
|
|
|
// delete m_configIniWrite;
|
|
|
|
// m_configIniWrite = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void hg_settingdialog::iniRead(QString title, int id, QWidget *w)
|
|
|
|
{
|
|
|
|
(void)title;
|
|
|
|
(void)id;
|
|
|
|
(void)w;
|
|
|
|
// m_configIniRead = new QSettings("config.ini", QSettings::IniFormat);
|
|
|
|
// m_configIniRead->setIniCodec(QTextCodec::codecForName("UTF-8"));
|
|
|
|
// int id_ini = m_configIniRead->value(title + "/id").toInt();
|
|
|
|
// QVariant value = m_configIniRead->value(title + "/value");
|
|
|
|
|
|
|
|
// if(id_ini == id)
|
|
|
|
// {
|
|
|
|
// if(typeid(*w) == typeid(QCheckBox))
|
|
|
|
// reinterpret_cast<QCheckBox*>(w)->setChecked(value.toBool());
|
|
|
|
|
|
|
|
// else if(typeid(*w) == typeid(QSlider))
|
|
|
|
// reinterpret_cast<QSlider*>(w)->setValue(value.toInt());
|
|
|
|
|
|
|
|
// else if(typeid(*w) == typeid(QSpinBox))
|
|
|
|
// reinterpret_cast<QSpinBox*>(w)->setValue(value.toInt());
|
|
|
|
|
|
|
|
// else if(typeid(*w) == typeid(QDoubleSpinBox))
|
|
|
|
// reinterpret_cast<QDoubleSpinBox*>(w)->setValue(value.toDouble());
|
|
|
|
|
|
|
|
// else if(typeid(*w) == typeid(QComboBox))
|
|
|
|
// reinterpret_cast<QComboBox*>(w)->setCurrentText(value.toString());
|
|
|
|
// }
|
|
|
|
|
|
|
|
// delete m_configIniRead;
|
|
|
|
// m_configIniRead = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
//生成UTF-8编码的MD5值
|
|
|
|
QString hg_settingdialog::md5(QString key)
|
|
|
|
{
|
|
|
|
QCryptographicHash md5(QCryptographicHash::Md5);
|
|
|
|
md5.addData(key.toUtf8());
|
|
|
|
return QString(md5.result().toHex());
|
|
|
|
}
|
|
|
|
const void* hg_settingdialog::find_option_description(int id)
|
|
|
|
{
|
|
|
|
for(int i = 0; i < m_list_getOpt.size(); i++)
|
|
|
|
{
|
|
|
|
if (m_list_getOpt.at(i).first == id)
|
|
|
|
return reinterpret_cast<const SANE_Option_Descriptor*>(m_list_getOpt.at(i).second);
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
const void* hg_settingdialog::find_option_description(const std::string& title, int* id)
|
|
|
|
{
|
|
|
|
for(int i = 0; i < m_list_getOpt.size(); i++)
|
|
|
|
{
|
2022-10-13 04:41:25 +00:00
|
|
|
std::string t((reinterpret_cast<const SANE_Option_Descriptor*>(m_list_getOpt.at(i).second))->name);
|
2022-05-03 10:25:52 +00:00
|
|
|
|
|
|
|
if (title == t)
|
|
|
|
{
|
|
|
|
if(id)
|
|
|
|
*id = m_list_getOpt.at(i).first;
|
|
|
|
return reinterpret_cast<const SANE_Option_Descriptor*>(m_list_getOpt.at(i).second);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void hg_settingdialog::closeEvent(QCloseEvent* e)
|
|
|
|
{
|
|
|
|
if(e->type() == QEvent::Close) // consider as cancel ...
|
|
|
|
{
|
|
|
|
if(save_)
|
|
|
|
save_scheme();
|
|
|
|
else
|
|
|
|
cancel_setting();
|
|
|
|
}
|
|
|
|
|
|
|
|
e->accept();
|
|
|
|
}
|
2022-11-26 06:26:57 +00:00
|
|
|
|
|
|
|
bool hg_settingdialog::createMsgBoxUi(bool add, std::string &name)
|
2022-05-03 10:25:52 +00:00
|
|
|
{
|
2022-11-26 06:26:57 +00:00
|
|
|
QString text(tr("Please select to overwrite the original configuration:"));
|
|
|
|
text += QString::fromStdString(name);
|
|
|
|
text += tr(",or add a new configuration");
|
|
|
|
|
|
|
|
QDialog *dlg = new QDialog(this);
|
|
|
|
dlg->setWindowTitle(tr("save the configuration"));
|
|
|
|
QLabel *label_question = new QLabel;
|
|
|
|
label_question->setText(text);
|
|
|
|
|
|
|
|
QRadioButton *radioButtonCover = new QRadioButton;
|
|
|
|
radioButtonCover->setText(tr("cover original configuration:") + QString::fromStdString(name));
|
|
|
|
radioButtonCover->setChecked(true);
|
|
|
|
add = false;
|
|
|
|
QRadioButton *radioButtonNew = new QRadioButton;
|
|
|
|
radioButtonNew->setText(tr("add new configuration"));
|
|
|
|
|
|
|
|
QHBoxLayout *hLayoutName = new QHBoxLayout;
|
|
|
|
QLabel *label_name = new QLabel;
|
|
|
|
label_name->setText(tr("rename:"));
|
|
|
|
m_lineEdit_name = new QLineEdit;
|
|
|
|
std::string name2;
|
|
|
|
m_lineEdit_name->setText(QString::fromStdString(getCurUiShemeName(name2)));
|
|
|
|
|
|
|
|
QSpacerItem *spacer1 = new QSpacerItem(20, 20, QSizePolicy::Expanding);
|
|
|
|
hLayoutName->addWidget(label_name);
|
|
|
|
hLayoutName->addWidget(m_lineEdit_name);
|
|
|
|
hLayoutName->addSpacerItem(spacer1);
|
|
|
|
label_name->setVisible(false);
|
|
|
|
m_lineEdit_name->setVisible(false);
|
|
|
|
|
2022-11-26 09:32:54 +00:00
|
|
|
bool cover = true;
|
|
|
|
connect(radioButtonCover, &QRadioButton::clicked, this, [=, &add, &cover](){
|
|
|
|
cover = true;
|
2022-11-26 06:26:57 +00:00
|
|
|
add = false;
|
|
|
|
label_name->setVisible(false);
|
|
|
|
m_lineEdit_name->setVisible(false);
|
|
|
|
});
|
2022-11-26 09:32:54 +00:00
|
|
|
connect(radioButtonNew, &QRadioButton::clicked, this, [=, &add, &cover](){
|
|
|
|
cover = false;
|
2022-11-26 06:26:57 +00:00
|
|
|
add = true;
|
|
|
|
label_name->setVisible(true);
|
|
|
|
m_lineEdit_name->setVisible(true);
|
|
|
|
|
|
|
|
m_lineEdit_name->setFocus();
|
|
|
|
QTimer::singleShot(0, m_lineEdit_name, &QLineEdit::selectAll);
|
|
|
|
});
|
|
|
|
|
|
|
|
QSpacerItem *spacer2 = new QSpacerItem(20, 20, QSizePolicy::Expanding);
|
|
|
|
QPushButton *pbtnOk = new QPushButton;
|
|
|
|
pbtnOk->setText(tr("ok"));
|
2022-11-26 09:32:54 +00:00
|
|
|
connect(pbtnOk, &QPushButton::clicked, this, [=, &name, &cover](){
|
|
|
|
|
2022-11-26 06:26:57 +00:00
|
|
|
QString text = m_lineEdit_name->text();
|
|
|
|
static QRegularExpression re("\\s");
|
|
|
|
text.remove(re);//Remove space
|
|
|
|
|
|
|
|
name = text.toStdString();
|
|
|
|
|
|
|
|
if(name.empty())
|
|
|
|
{
|
|
|
|
QMessageBox::information(this, tr("tips"), tr("scheme name cannot be empty"));
|
|
|
|
m_lineEdit_name->setText(QString::fromStdString(getCurUiShemeName(name)));
|
|
|
|
return;
|
|
|
|
}
|
2022-05-03 10:25:52 +00:00
|
|
|
|
2022-11-26 09:32:54 +00:00
|
|
|
if (!cover)
|
2022-11-26 06:26:57 +00:00
|
|
|
{
|
|
|
|
std::vector<std::string> now;
|
|
|
|
cur_cfg_->get_all_schemes(now);
|
|
|
|
for(auto& v: now)
|
|
|
|
{
|
|
|
|
if(v == name)
|
|
|
|
{
|
|
|
|
|
|
|
|
QMessageBox::information(this, tr("tips"), tr("scheme name: ") + QString::fromStdString(name) + tr(" already exists"));
|
|
|
|
m_lineEdit_name->setText(QString::fromStdString(getCurUiShemeName(name)));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dlg->close();
|
|
|
|
});
|
|
|
|
|
|
|
|
QHBoxLayout *hLayout_pbtnOk = new QHBoxLayout;
|
|
|
|
hLayout_pbtnOk->addSpacerItem(spacer2);
|
|
|
|
hLayout_pbtnOk->addWidget(pbtnOk);
|
|
|
|
|
|
|
|
QVBoxLayout *vLayout = new QVBoxLayout;
|
|
|
|
vLayout->addWidget(label_question);
|
|
|
|
vLayout->addWidget(radioButtonCover);
|
|
|
|
vLayout->addWidget(radioButtonNew);
|
|
|
|
vLayout->addLayout(hLayoutName);
|
|
|
|
vLayout->addLayout(hLayout_pbtnOk);
|
|
|
|
dlg->setLayout(vLayout);
|
|
|
|
|
|
|
|
dlg->exec();
|
2022-05-12 07:34:40 +00:00
|
|
|
|
2022-11-26 06:26:57 +00:00
|
|
|
return add;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string hg_settingdialog::getCurUiShemeName(std::string name)
|
|
|
|
{
|
|
|
|
std::string k(""), val("");
|
|
|
|
int id = 0;
|
|
|
|
const SANE_Option_Descriptor* opt = nullptr;
|
|
|
|
|
|
|
|
if (cur_scheme_->first_config(k, val))
|
|
|
|
{
|
|
|
|
int count = 0;
|
|
|
|
do
|
2022-05-03 10:25:52 +00:00
|
|
|
{
|
2022-11-26 06:26:57 +00:00
|
|
|
id = cur_scheme_->id_from_name(k.c_str());
|
2023-02-10 09:24:04 +00:00
|
|
|
opt = id == -1 ? nullptr : sane_get_option_descriptor(m_handle, id);
|
2022-11-26 06:26:57 +00:00
|
|
|
if (opt)
|
2022-05-03 10:25:52 +00:00
|
|
|
{
|
2022-11-26 06:26:57 +00:00
|
|
|
if (count++)
|
|
|
|
name += " + ";
|
|
|
|
|
|
|
|
if (opt->type == SANE_TYPE_STRING)
|
2023-02-01 11:06:24 +00:00
|
|
|
name += from_default_language(val.c_str(), nullptr);
|
2022-11-26 06:26:57 +00:00
|
|
|
else
|
2022-05-07 10:43:43 +00:00
|
|
|
{
|
2022-11-26 06:26:57 +00:00
|
|
|
name += opt->title;
|
|
|
|
if (opt->type == SANE_TYPE_BOOL)
|
|
|
|
{
|
|
|
|
name += std::string("(");
|
|
|
|
if (*(SANE_Bool*)&val[0] == SANE_TRUE)
|
|
|
|
name += "true)";
|
|
|
|
else
|
|
|
|
name += "false)";
|
|
|
|
}
|
|
|
|
else if (opt->type == SANE_TYPE_INT)
|
|
|
|
{
|
|
|
|
char buf[128] = { 0 };
|
|
|
|
sprintf(buf, "(%d)", *(int*)&val[0]);
|
|
|
|
name += buf;
|
|
|
|
}
|
|
|
|
else if (opt->type == SANE_TYPE_FIXED)
|
|
|
|
{
|
|
|
|
char buf[128] = { 0 };
|
|
|
|
sprintf(buf, "(%.4f)", SANE_UNFIX(*(SANE_Fixed*)&val[0]));
|
|
|
|
name += buf;
|
2022-10-28 01:03:22 +00:00
|
|
|
}
|
2022-05-07 10:43:43 +00:00
|
|
|
}
|
2022-11-26 06:26:57 +00:00
|
|
|
}
|
|
|
|
} while (count < 3 && cur_scheme_->next_config(k, val));
|
|
|
|
}
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
void hg_settingdialog::save_scheme(void)
|
|
|
|
{
|
|
|
|
std::string name(cur_scheme_->get_scheme_name());
|
2023-02-01 11:06:24 +00:00
|
|
|
|
2022-11-26 06:26:57 +00:00
|
|
|
bool add = name.empty();
|
|
|
|
|
|
|
|
if(add)
|
|
|
|
{
|
|
|
|
name = getCurUiShemeName(name);
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
2022-10-28 01:03:22 +00:00
|
|
|
else
|
2022-05-03 10:25:52 +00:00
|
|
|
{
|
2022-11-26 09:32:54 +00:00
|
|
|
int items = 0;
|
|
|
|
add = cur_scheme_->has_changed(&items);
|
2022-10-28 01:03:22 +00:00
|
|
|
if(add)
|
2022-05-03 10:25:52 +00:00
|
|
|
{
|
2022-11-26 09:32:54 +00:00
|
|
|
if(items == 0) // while shemes is default
|
|
|
|
{
|
|
|
|
cur_cfg_->select_scheme(nullptr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
add = createMsgBoxUi(add, name);
|
2022-05-07 08:12:34 +00:00
|
|
|
}
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
2022-10-28 01:03:22 +00:00
|
|
|
if(add)
|
2022-05-03 10:25:52 +00:00
|
|
|
{
|
2022-10-28 01:03:22 +00:00
|
|
|
if(name.empty() && cur_scheme_->get_scheme_name().empty())
|
2022-05-03 10:25:52 +00:00
|
|
|
{
|
2022-10-28 01:03:22 +00:00
|
|
|
cur_scheme_->end_setting(true);
|
|
|
|
return;
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
|
|
|
|
2022-10-28 01:03:22 +00:00
|
|
|
gb::sane_config_schm* cp = cur_scheme_->copy();
|
2022-05-03 10:25:52 +00:00
|
|
|
|
2022-10-28 01:03:22 +00:00
|
|
|
cur_scheme_->end_setting(true);
|
|
|
|
cur_scheme_->release();
|
|
|
|
cur_scheme_ = cp;
|
2022-05-03 10:25:52 +00:00
|
|
|
|
2022-10-28 01:03:22 +00:00
|
|
|
size_t pos = name.rfind('-');
|
|
|
|
int ind = 0;
|
|
|
|
char append[20] = {0};
|
2022-05-03 10:25:52 +00:00
|
|
|
|
2022-10-28 01:03:22 +00:00
|
|
|
if(pos != std::string::npos)
|
2022-05-03 10:25:52 +00:00
|
|
|
{
|
2022-10-28 01:03:22 +00:00
|
|
|
ind = atoi(name.c_str() + pos + 1);
|
|
|
|
if(ind > 0)
|
2023-02-01 11:06:24 +00:00
|
|
|
{
|
2022-10-28 01:03:22 +00:00
|
|
|
name.erase(pos);
|
|
|
|
sprintf(append, "-%d", ++ind);
|
|
|
|
}
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
2022-10-28 01:03:22 +00:00
|
|
|
while(!cur_cfg_->add_scheme(cur_scheme_, (name + append).c_str()))
|
2022-05-03 10:25:52 +00:00
|
|
|
{
|
2022-10-28 01:03:22 +00:00
|
|
|
sprintf(append, "-%d", ++ind);
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
|
|
|
}
|
2022-11-26 06:26:57 +00:00
|
|
|
else
|
|
|
|
{
|
2022-10-28 01:03:22 +00:00
|
|
|
cur_scheme_->end_setting(false);
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
2023-02-01 11:06:24 +00:00
|
|
|
|
2022-10-28 01:03:22 +00:00
|
|
|
cur_cfg_->select_scheme(cur_scheme_->get_scheme_name().c_str());
|
2023-02-01 11:06:24 +00:00
|
|
|
|
2022-10-28 01:03:22 +00:00
|
|
|
cur_cfg_->save();
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
2022-10-28 01:03:22 +00:00
|
|
|
void hg_settingdialog::cancel_setting(void)
|
2022-05-07 03:00:11 +00:00
|
|
|
{
|
2022-10-28 01:03:22 +00:00
|
|
|
// restore changed value ...
|
|
|
|
cur_scheme_->end_setting(true);
|
2022-10-31 09:53:41 +00:00
|
|
|
dev_que::apply_scheme(m_handle, cur_scheme_);
|
2022-05-07 03:00:11 +00:00
|
|
|
}
|
2022-05-03 10:25:52 +00:00
|
|
|
|
2022-10-13 07:45:19 +00:00
|
|
|
void hg_settingdialog::getAppVersion()
|
|
|
|
{
|
|
|
|
SANE_About *about = nullptr;
|
|
|
|
unsigned int len = 0;
|
|
|
|
std::string versionNum;
|
|
|
|
if (sane_io_control(m_handle, IO_CTRL_CODE_ABOUT_INFO, about, &len) == SANE_STATUS_NO_MEM)
|
|
|
|
{
|
|
|
|
about = (SANE_About*)malloc(len + 128);
|
|
|
|
if (about)
|
|
|
|
{
|
|
|
|
memset(about, 0, len + 128);
|
|
|
|
if (sane_io_control(m_handle, IO_CTRL_CODE_ABOUT_INFO, about, &len) == SANE_STATUS_GOOD)
|
|
|
|
{
|
|
|
|
versionNum = about->version;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-10-28 01:03:22 +00:00
|
|
|
void hg_settingdialog::apply_current_scheme(void)
|
|
|
|
{
|
|
|
|
dev_que::apply_scheme(m_handle, cur_scheme_);
|
|
|
|
}
|
|
|
|
std::string sane_val_to_string(const char* val, SANE_Value_Type type)
|
|
|
|
{
|
|
|
|
char buf[128] = {0};
|
|
|
|
std::string ret("");
|
|
|
|
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case SANE_TYPE_BOOL:
|
|
|
|
ret = *(SANE_Bool*)val == SANE_TRUE ? "true" : "false";
|
|
|
|
break;
|
|
|
|
case SANE_TYPE_INT:
|
|
|
|
sprintf(buf, "%d", *(int*)val);
|
|
|
|
ret = buf;
|
|
|
|
break;
|
|
|
|
case SANE_TYPE_FIXED:
|
|
|
|
sprintf(buf, "%.4f", SANE_UNFIX(*(SANE_Fixed*)val));
|
|
|
|
ret = buf;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ret = val;
|
|
|
|
break;
|
|
|
|
}
|
2022-10-13 07:45:19 +00:00
|
|
|
|
2022-10-28 01:03:22 +00:00
|
|
|
return ret;
|
|
|
|
}
|
2022-05-12 07:34:40 +00:00
|
|
|
void hg_settingdialog::on_current_scheme_changed()
|
2022-05-03 10:25:52 +00:00
|
|
|
{
|
2022-05-12 07:34:40 +00:00
|
|
|
QString scheme(comb_->currentText());
|
2022-10-18 10:51:24 +00:00
|
|
|
bool enabled = false;
|
2022-10-28 01:03:22 +00:00
|
|
|
gb::sane_config_schm *schm = cur_cfg_->get_scheme(scheme.toStdString().c_str());
|
2022-10-18 10:51:24 +00:00
|
|
|
|
2022-10-28 01:03:22 +00:00
|
|
|
if(schm)
|
|
|
|
enabled = true;
|
2022-05-03 10:25:52 +00:00
|
|
|
|
|
|
|
rename_->setEnabled(enabled);
|
|
|
|
apply_->setEnabled(enabled);
|
|
|
|
del_this_->setEnabled(enabled);
|
|
|
|
del_all_->setEnabled(enabled);
|
2022-10-28 01:03:22 +00:00
|
|
|
memset(&m_gammaData, 0, sizeof(m_gammaData));
|
|
|
|
for(int i = 0; i < sizeof(m_gammaData.table) / sizeof(m_gammaData.table[0]); ++i)
|
|
|
|
m_gammaData.table[i] = i & 0x0ff;
|
2022-10-18 10:51:24 +00:00
|
|
|
|
2022-05-03 10:25:52 +00:00
|
|
|
QString info(tr(""));
|
2022-10-28 01:03:22 +00:00
|
|
|
std::string name(""), val("");
|
|
|
|
if(schm && schm->first_config(name, val))
|
2022-05-03 10:25:52 +00:00
|
|
|
{
|
2022-10-28 01:03:22 +00:00
|
|
|
do
|
2022-05-03 10:25:52 +00:00
|
|
|
{
|
2022-10-12 09:42:55 +00:00
|
|
|
QString title;
|
2022-10-28 01:03:22 +00:00
|
|
|
SANE_Value_Type type = SANE_TYPE_STRING;
|
2022-10-12 09:42:55 +00:00
|
|
|
for (int ii = 0; ii < m_list_defaultOptions.size(); ii++)
|
|
|
|
{
|
|
|
|
const SANE_Option_Descriptor* opt = reinterpret_cast<const SANE_Option_Descriptor*>(m_list_defaultOptions.at(ii).first);
|
2022-10-28 01:03:22 +00:00
|
|
|
if(strcmp(opt->name, name.c_str()) == 0)
|
2022-10-12 09:42:55 +00:00
|
|
|
{
|
2022-10-28 01:03:22 +00:00
|
|
|
title = QString::fromStdString(opt->title);
|
|
|
|
type = opt->type;
|
2022-10-12 09:42:55 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2022-10-28 01:03:22 +00:00
|
|
|
|
2023-02-01 11:06:24 +00:00
|
|
|
val = from_default_language(val.c_str(), nullptr);
|
2022-10-28 01:03:22 +00:00
|
|
|
if(title.length())
|
|
|
|
{
|
|
|
|
info += tr("<h6><b>") + title + tr(":</b></h6>");
|
|
|
|
info += tr("<p> ") + QString::fromStdString(sane_val_to_string(val.c_str(), type)) + tr("</p>");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(val.length() == sizeof(SANE_Gamma))
|
|
|
|
memcpy(&m_gammaData, val.c_str(), sizeof(SANE_Gamma));
|
|
|
|
}
|
|
|
|
}while(schm->next_config(name, val));
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
2022-10-28 01:03:22 +00:00
|
|
|
if(schm)
|
|
|
|
schm->release();
|
2022-05-03 10:25:52 +00:00
|
|
|
|
|
|
|
sketch_->setHtml(info);
|
|
|
|
}
|
|
|
|
void hg_settingdialog::slot_pushButton_scheme_management(void)
|
|
|
|
{
|
|
|
|
QPushButton* btn = qobject_cast<QPushButton*>(sender());
|
|
|
|
|
|
|
|
if(btn == rename_)
|
|
|
|
{
|
|
|
|
int id = 0;
|
2022-05-12 07:34:40 +00:00
|
|
|
QString text(find_current_scheme_menu(&id));
|
2022-10-28 01:03:22 +00:00
|
|
|
if(!text.isEmpty() && id >= 0)
|
2022-05-12 07:34:40 +00:00
|
|
|
{
|
|
|
|
Dialog_Input dlg;
|
2022-05-03 10:25:52 +00:00
|
|
|
|
2022-05-12 07:34:40 +00:00
|
|
|
dlg.init_value(text);
|
2022-06-06 02:28:27 +00:00
|
|
|
dlg.setWindowTitle(tr("configuration scheme name change"));
|
2022-10-28 01:03:22 +00:00
|
|
|
if(dlg.exec() && text != dlg.get_inputting_value())
|
2022-05-12 07:34:40 +00:00
|
|
|
{
|
2022-10-28 01:03:22 +00:00
|
|
|
std::vector<std::string> now;
|
|
|
|
std::string str = dlg.get_inputting_value().toStdString();
|
2022-05-12 07:34:40 +00:00
|
|
|
|
2022-10-28 01:03:22 +00:00
|
|
|
cur_cfg_->get_all_schemes(now);
|
|
|
|
for(auto& v: now)
|
|
|
|
{
|
|
|
|
if(v == str)
|
|
|
|
{
|
2022-11-26 06:26:57 +00:00
|
|
|
QMessageBox::information(this, tr("tips"), tr("scheme name: ") + QString::fromStdString(str) + tr(" already exists"));
|
2022-10-28 01:03:22 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2022-05-12 07:34:40 +00:00
|
|
|
disconnect(comb_, SIGNAL(currentTextChanged(const QString)), this, SLOT(on_current_scheme_changed()));
|
|
|
|
comb_->removeItem(id);
|
2022-10-28 01:03:22 +00:00
|
|
|
comb_->insertItem(id, QString::fromStdString(str));
|
2022-05-12 07:34:40 +00:00
|
|
|
comb_->setCurrentIndex(id);
|
|
|
|
connect(comb_, SIGNAL(currentTextChanged(const QString)), this, SLOT(on_current_scheme_changed()));
|
|
|
|
|
2022-10-28 01:03:22 +00:00
|
|
|
cur_cfg_->rename_scheme(text.toStdString().c_str(), str.c_str());
|
|
|
|
cur_cfg_->save();
|
2022-05-12 07:34:40 +00:00
|
|
|
changed_count_++;
|
|
|
|
}
|
|
|
|
}
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
|
|
|
else if(btn == apply_)
|
|
|
|
{
|
2022-10-28 01:03:22 +00:00
|
|
|
QString text(find_current_scheme_menu());
|
|
|
|
gb::sane_config_schm *cur = nullptr;
|
|
|
|
|
|
|
|
cur_cfg_->select_scheme(text.toStdString().c_str());
|
|
|
|
cur = cur_cfg_->get_scheme();
|
|
|
|
if(!cur)
|
|
|
|
cur = new gb::sane_config_schm();
|
|
|
|
cur->copy_default_value(cur_scheme_);
|
|
|
|
cur_scheme_->end_setting(true);
|
|
|
|
cur_scheme_->release();
|
|
|
|
cur_scheme_ = cur;
|
|
|
|
cur_scheme_->begin_setting();
|
|
|
|
|
|
|
|
apply_current_scheme();
|
|
|
|
updateUIStatus();
|
2022-05-03 10:25:52 +00:00
|
|
|
changed_count_++;
|
|
|
|
}
|
|
|
|
else if(btn == del_this_)
|
|
|
|
{
|
2022-05-12 07:34:40 +00:00
|
|
|
int id = -1;
|
|
|
|
QString text(find_current_scheme_menu(&id));
|
2022-05-03 10:25:52 +00:00
|
|
|
|
2022-05-12 07:34:40 +00:00
|
|
|
if(text.isEmpty())
|
2022-05-03 10:25:52 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
QMessageBox msg(QMessageBox::Question, tr("be sure to delete the configuration"),
|
2022-05-12 07:34:40 +00:00
|
|
|
tr("Are you sure you want to delete the configuration \"") + text + tr("\" ?"), QMessageBox::Yes | QMessageBox::No, this);
|
2022-05-03 10:25:52 +00:00
|
|
|
msg.setButtonText(QMessageBox::Yes, tr("yes"));
|
|
|
|
msg.setButtonText(QMessageBox::No, tr("no"));
|
|
|
|
msg.exec();
|
|
|
|
if (msg.clickedButton() != msg.button(QMessageBox::Yes))
|
|
|
|
return;
|
|
|
|
|
2022-10-28 01:03:22 +00:00
|
|
|
gb::sane_config_schm *sch = cur_cfg_->get_scheme(text.toStdString().c_str());
|
|
|
|
cur_cfg_->remove_scheme(text.toStdString().c_str());
|
2022-05-12 07:34:40 +00:00
|
|
|
comb_->removeItem(id);
|
2022-10-28 01:03:22 +00:00
|
|
|
sch->release();
|
|
|
|
if(sch == cur_scheme_)
|
2022-05-12 07:34:40 +00:00
|
|
|
{
|
2022-10-28 01:45:02 +00:00
|
|
|
restore_2_default_settings();
|
|
|
|
updateUIStatus();
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
2022-05-12 07:34:40 +00:00
|
|
|
|
|
|
|
on_current_scheme_changed();
|
2022-05-03 10:25:52 +00:00
|
|
|
changed_count_++;
|
2022-10-31 09:53:41 +00:00
|
|
|
cur_cfg_->save();
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
|
|
|
else if(btn == del_all_)
|
|
|
|
{
|
|
|
|
QMessageBox msg(QMessageBox::Question, tr("be sure to delete the configuration"),
|
|
|
|
tr("Are you sure you want to delete the configuration?"), QMessageBox::Yes | QMessageBox::No, this);
|
|
|
|
msg.setButtonText(QMessageBox::Yes, tr("yes"));
|
|
|
|
msg.setButtonText(QMessageBox::No, tr("no"));
|
|
|
|
msg.exec();
|
|
|
|
if (msg.clickedButton() != msg.button(QMessageBox::Yes))
|
|
|
|
return;
|
|
|
|
|
2022-10-28 01:45:02 +00:00
|
|
|
restore_2_default_settings();
|
|
|
|
updateUIStatus();
|
|
|
|
comb_->clear();
|
2022-05-03 10:25:52 +00:00
|
|
|
changed_count_++;
|
2022-10-31 09:53:41 +00:00
|
|
|
cur_cfg_->remove_all_schemes();
|
|
|
|
cur_cfg_->save();
|
2022-05-03 10:25:52 +00:00
|
|
|
}
|
|
|
|
}
|
2022-10-28 01:45:02 +00:00
|
|
|
void hg_settingdialog::restore_2_default_settings(void)
|
|
|
|
{
|
|
|
|
cur_scheme_->end_setting(true);
|
2022-11-26 06:26:57 +00:00
|
|
|
cur_cfg_->select_scheme(nullptr);
|
2022-11-26 11:33:00 +00:00
|
|
|
dev_que_->apply_scheme(nullptr);
|
2022-10-28 01:45:02 +00:00
|
|
|
cur_cfg_->save();
|
|
|
|
|
|
|
|
gb::sane_config_schm *s = new gb::sane_config_schm();
|
|
|
|
s->copy_default_value(cur_scheme_);
|
|
|
|
cur_scheme_->release();
|
|
|
|
cur_scheme_ = s;
|
|
|
|
cur_scheme_->begin_setting();
|
|
|
|
|
|
|
|
on_current_scheme_changed();
|
|
|
|
}
|