调整设置界面配置对话框
This commit is contained in:
parent
b823e7effb
commit
40ffb376a7
|
@ -428,6 +428,24 @@ namespace gb
|
|||
return false;
|
||||
}
|
||||
|
||||
int json::count()
|
||||
{
|
||||
if(!obj_ || !obj_->child)
|
||||
return 0;
|
||||
|
||||
cJSON* child = obj_->child;
|
||||
int cnt = 0;
|
||||
|
||||
while(child)
|
||||
{
|
||||
cnt++;
|
||||
child = child->next;
|
||||
}
|
||||
|
||||
return cnt;
|
||||
}
|
||||
|
||||
|
||||
bool json::first_child(std::string& val, std::string* name)
|
||||
{
|
||||
cur_child_ = obj_->child;
|
||||
|
@ -1368,10 +1386,15 @@ namespace gb
|
|||
else
|
||||
jsn_->set_value(name, hex_v.c_str());
|
||||
}
|
||||
bool sane_config_schm::has_changed(void)
|
||||
bool sane_config_schm::has_changed(int* items)
|
||||
{
|
||||
if(items)
|
||||
*items = jsn_ ? jsn_->count() : 0;
|
||||
|
||||
if(!bkp_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
std::map<std::string, std::string> old;
|
||||
std::string n(""), v("");
|
||||
|
|
|
@ -73,6 +73,7 @@ namespace gb
|
|||
bool get_value_as_string(const char* key, std::string& val, bool integer);
|
||||
bool get_as_array(const char* key, std::vector<std::string>& val);
|
||||
|
||||
int count(void);
|
||||
bool first_child(std::string& val, std::string* name = NULL);
|
||||
bool next_child(std::string& val, std::string* name = NULL);
|
||||
|
||||
|
@ -148,7 +149,7 @@ namespace gb
|
|||
void config_changed(int sn, const char* val, size_t bytes, bool extra = false);
|
||||
void remove_config(const char* name);
|
||||
void set_value(const char* name, const char* val, size_t bytes, bool extra = false);
|
||||
bool has_changed(void);
|
||||
bool has_changed(int* items = nullptr);
|
||||
void end_setting(bool cancel);
|
||||
int id_from_name(const char* name);
|
||||
std::string to_text_stream(bool b64 = true, bool with_ver = true);
|
||||
|
|
|
@ -18,7 +18,7 @@ hg_settingdialog::hg_settingdialog(void *handle, QWidget *parent
|
|||
: QDialog(parent)
|
||||
, dev_que_(dev), save_(false)
|
||||
, btn_cut_area_(nullptr), btn_gamma_(nullptr), clicked_gamma_(false)
|
||||
, custom_area_lable_(nullptr), comb_(nullptr),m_cover(true)
|
||||
, custom_area_lable_(nullptr), comb_(nullptr)
|
||||
{
|
||||
std::string n(dev->opened_scanner_name());
|
||||
for(int i = 0; i < dev->scanners(); ++i)
|
||||
|
@ -1533,14 +1533,15 @@ bool hg_settingdialog::createMsgBoxUi(bool add, std::string &name)
|
|||
label_name->setVisible(false);
|
||||
m_lineEdit_name->setVisible(false);
|
||||
|
||||
connect(radioButtonCover, &QRadioButton::clicked, this, [=, &add, this](){
|
||||
m_cover = true;
|
||||
bool cover = true;
|
||||
connect(radioButtonCover, &QRadioButton::clicked, this, [=, &add, &cover](){
|
||||
cover = true;
|
||||
add = false;
|
||||
label_name->setVisible(false);
|
||||
m_lineEdit_name->setVisible(false);
|
||||
});
|
||||
connect(radioButtonNew, &QRadioButton::clicked, this, [=, &add, this](){
|
||||
m_cover = false;
|
||||
connect(radioButtonNew, &QRadioButton::clicked, this, [=, &add, &cover](){
|
||||
cover = false;
|
||||
add = true;
|
||||
label_name->setVisible(true);
|
||||
m_lineEdit_name->setVisible(true);
|
||||
|
@ -1552,7 +1553,8 @@ bool hg_settingdialog::createMsgBoxUi(bool add, std::string &name)
|
|||
QSpacerItem *spacer2 = new QSpacerItem(20, 20, QSizePolicy::Expanding);
|
||||
QPushButton *pbtnOk = new QPushButton;
|
||||
pbtnOk->setText(tr("ok"));
|
||||
connect(pbtnOk, &QPushButton::clicked, this, [=, &name,this](){
|
||||
connect(pbtnOk, &QPushButton::clicked, this, [=, &name, &cover](){
|
||||
|
||||
QString text = m_lineEdit_name->text();
|
||||
static QRegularExpression re("\\s");
|
||||
text.remove(re);//Remove space
|
||||
|
@ -1566,7 +1568,7 @@ bool hg_settingdialog::createMsgBoxUi(bool add, std::string &name)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!m_cover)
|
||||
if (!cover)
|
||||
{
|
||||
std::vector<std::string> now;
|
||||
cur_cfg_->get_all_schemes(now);
|
||||
|
@ -1663,10 +1665,17 @@ void hg_settingdialog::save_scheme(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
add = cur_scheme_->has_changed();
|
||||
int items = 0;
|
||||
add = cur_scheme_->has_changed(&items);
|
||||
if(add)
|
||||
{
|
||||
add = createMsgBoxUi(add, name);
|
||||
if(items == 0) // while shemes is default
|
||||
{
|
||||
cur_cfg_->select_scheme(nullptr);
|
||||
return;
|
||||
}
|
||||
else
|
||||
add = createMsgBoxUi(add, name);
|
||||
}
|
||||
}
|
||||
if(add)
|
||||
|
|
|
@ -124,7 +124,6 @@ private:
|
|||
double m_cutBottomValue; // 单位是毫米
|
||||
|
||||
int m_colorModeId;
|
||||
volatile bool m_cover = true;
|
||||
QString m_colorModeValue;
|
||||
SANE_Gamma m_gammaData;
|
||||
QComboBox *comb_;
|
||||
|
|
Loading…
Reference in New Issue