解决设置界面异常弹窗
This commit is contained in:
parent
4fe11b4e49
commit
7cacce1d66
|
@ -29,6 +29,7 @@ hg_settingdialog::hg_settingdialog(class Manager *mgr, SANE_Handle handle, const
|
|||
, m_showScan(showScan)
|
||||
, m_devName(devName)
|
||||
, m_callback(callback)
|
||||
, m_isRefreshUi(false)
|
||||
{
|
||||
m_mgr = mgr;
|
||||
m_langCode = lang_get_cur_code_page();
|
||||
|
@ -116,15 +117,14 @@ hg_settingdialog::hg_settingdialog(class Manager *mgr, SANE_Handle handle, const
|
|||
initUi();
|
||||
on_current_scheme_changed();
|
||||
|
||||
saveDefaultCfgValue("deviceName", "name", QString::fromStdString(m_devName));
|
||||
|
||||
HGChar cfgPath[512];
|
||||
GetConfigPath(cfgPath, 512);
|
||||
QString oldFile = QString::fromStdString(cfgPath) + "default.ini";
|
||||
QString newFile = QString::fromStdString(cfgPath) + "olddefault.ini";
|
||||
QFile::copy(oldFile, newFile);
|
||||
|
||||
comb_->setCurrentIndex(getDefaultCfgValue("current", "index", 0));
|
||||
int index = getDefaultCfgValue("current", "index", 0);
|
||||
comb_->setCurrentIndex(index < 0 ? 0 : index);
|
||||
}
|
||||
|
||||
hg_settingdialog::~hg_settingdialog()
|
||||
|
@ -1030,7 +1030,10 @@ void hg_settingdialog::slot_checkedClicked()
|
|||
SANE_Int id = checkBox->property("controls_id").toInt();
|
||||
SANE_Bool checkBoxcurrentState = checkBox->isChecked();
|
||||
|
||||
// //m_list_IdValueTitle.append(QPair<QPair<int, QVariant>, QString>(QPair<int, QVariant>(id, checkBoxcurrentState), md5(opt->title)));
|
||||
if (checkBox->underMouse())
|
||||
{
|
||||
m_isRefreshUi = false;
|
||||
}
|
||||
|
||||
SANE_Int method = 0;
|
||||
SANE_Status ret = m_saneAPI.sane_control_option_api(m_devHandle, id, SANE_ACTION_SET_VALUE, &checkBoxcurrentState, &method);
|
||||
|
@ -1066,7 +1069,7 @@ void hg_settingdialog::slot_checkedClicked()
|
|||
btn_gamma_->setEnabled(checkBoxcurrentState);
|
||||
cur_scheme_->config_changed(id, (char*)&checkBoxcurrentState, sizeof(checkBoxcurrentState));
|
||||
|
||||
if (checkBoxcurrentState && (0 == strcmp(opt->name, SANE_STD_OPT_NAME_RID_MORR) || 0 == strcmp(opt->name, SANE_STD_OPT_NAME_RID_GRID)))
|
||||
if (!m_isRefreshUi && checkBoxcurrentState && (0 == strcmp(opt->name, SANE_STD_OPT_NAME_RID_MORR) || 0 == strcmp(opt->name, SANE_STD_OPT_NAME_RID_GRID)))
|
||||
{
|
||||
QMessageBox::information(this, tr("Prompt"), tr("This function may cause a decrease in the speed of drawing."));
|
||||
}
|
||||
|
@ -1111,8 +1114,6 @@ void hg_settingdialog::slot_string_list_comboBoxClicked()
|
|||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
if(type == COMBO_VAL_INT)
|
||||
|
@ -1153,7 +1154,12 @@ void hg_settingdialog::slot_string_list_comboBoxClicked()
|
|||
if (0 == strcmp(opt->name, SANE_STD_OPT_NAME_TEXT_DIRECTION))
|
||||
{
|
||||
if (comboBox->currentText() == OPTION_VALUE_WGFX_ZDWBFXSB)
|
||||
QMessageBox::information(this, tr("Prompt"), tr("This function may cause a decrease in the speed of drawing."));
|
||||
{
|
||||
comboBox->installEventFilter(this);
|
||||
if (!m_isRefreshUi)
|
||||
QMessageBox::information(this, tr("Prompt"), tr("This function may cause a decrease in the speed of drawing."));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (0 == comb_->currentIndex())
|
||||
|
@ -1899,6 +1905,7 @@ void hg_settingdialog::closeEvent(QCloseEvent* e)
|
|||
}
|
||||
|
||||
saveDefaultCfgValue("current", "index", index);
|
||||
saveDefaultCfgValue("deviceName", "name", QString::fromStdString(m_devName));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1920,6 +1927,14 @@ bool hg_settingdialog::eventFilter(QObject *target, QEvent *event)
|
|||
}
|
||||
}
|
||||
|
||||
if (target->findChild<QComboBox*>("QComboBox"));
|
||||
{
|
||||
if (event->type() == QEvent::MouseButtonPress)
|
||||
{
|
||||
m_isRefreshUi = false;
|
||||
}
|
||||
}
|
||||
|
||||
return QDialog::eventFilter(target, event);
|
||||
}
|
||||
|
||||
|
@ -2186,6 +2201,7 @@ void hg_settingdialog::updateDefaultScheme()
|
|||
{
|
||||
updateOpt();
|
||||
|
||||
m_isRefreshUi = true;
|
||||
SANE_Int dev_options = 0;
|
||||
m_saneAPI.sane_control_option_api(m_devHandle, 0, SANE_ACTION_GET_VALUE, &dev_options, nullptr);
|
||||
for(int id = 1, optons = dev_options; id < optons; id++)
|
||||
|
@ -2384,23 +2400,6 @@ void hg_settingdialog::processIniFile()
|
|||
QFile::copy(newFile, oldFile);
|
||||
}
|
||||
|
||||
void hg_settingdialog::setDefault()
|
||||
{
|
||||
SANE_Int dev_options = 0;
|
||||
m_saneAPI.sane_control_option_api(m_devHandle, 0, SANE_ACTION_GET_VALUE, &dev_options, nullptr);
|
||||
for (int i = 1; i < dev_options; ++i)
|
||||
{
|
||||
const SANE_Option_Descriptor* opt = m_saneAPI.sane_get_option_descriptor_api(m_devHandle, i);
|
||||
if (!opt)
|
||||
continue;
|
||||
|
||||
if (opt->type == SANE_TYPE_BUTTON || opt->type == SANE_TYPE_GROUP)
|
||||
continue;
|
||||
|
||||
m_saneAPI.sane_control_option_api(m_devHandle, i, SANE_ACTION_SET_AUTO, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
std::string sane_val_to_string(const char* val, SANE_Value_Type type)
|
||||
{
|
||||
char buf[128] = {0};
|
||||
|
|
|
@ -111,7 +111,6 @@ private:
|
|||
void setIcon();
|
||||
void updateDefaultScheme();
|
||||
void processIniFile();
|
||||
void setDefault();
|
||||
|
||||
private:
|
||||
QVector<QPair<QPair<int, QVariant>, QString>> m_list_IdValueTitle;
|
||||
|
@ -161,6 +160,8 @@ private:
|
|||
SANE_Gamma m_gammaData;
|
||||
QComboBox *comb_;
|
||||
std::function<void(ui_result)> m_callback;
|
||||
|
||||
bool m_isRefreshUi;
|
||||
};
|
||||
|
||||
#endif // HG_SETTING_DIALOG_H
|
||||
|
|
Loading…
Reference in New Issue