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