增加“bind”属性,当默认值改变时,可即时同步到当前值上;修复修改其它值导致默认值丢失问题
This commit is contained in:
parent
9b1e2408a9
commit
736615ffa9
|
@ -353,6 +353,18 @@ known_file_util::IJsonW* CDlgOptJson::SANEOPT::to_json(void)
|
|||
jsn->set_value(L"desc", desc.c_str());
|
||||
jsn->set_value(L"type", type.c_str());
|
||||
|
||||
// more default values, make the non-condition value at last
|
||||
for (int i = 0; i < (int)def_val.size() - 1; ++i)
|
||||
{
|
||||
if (def_val[i].cond == "default")
|
||||
{
|
||||
CONDVAL cv = def_val[i];
|
||||
def_val.erase(def_val.begin() + i);
|
||||
def_val.push_back(cv);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(ver > 0)
|
||||
jsn->set_value(L"ver", ver);
|
||||
if(pos > 0)
|
||||
|
@ -368,6 +380,9 @@ known_file_util::IJsonW* CDlgOptJson::SANEOPT::to_json(void)
|
|||
jsn->set_value(L"unit", unit.c_str());
|
||||
if(readonly)
|
||||
jsn->set_value(L"readonly", readonly);
|
||||
if (bind_cur)
|
||||
jsn->set_value(L"bind", bind_cur);
|
||||
|
||||
if (visible.size())
|
||||
{
|
||||
if(visible.size() == 1 && visible[0].cond.empty())
|
||||
|
@ -765,6 +780,9 @@ bool CDlgOptJson::SANEOPT::from_json(known_file_util::IJsonW* jsn)
|
|||
|
||||
jsn->get_value(L"size", size);
|
||||
|
||||
if (!jsn->get_value(L"bind", bind_cur))
|
||||
bind_cur = false;
|
||||
|
||||
if (!jsn->get_value(L"auth", auth))
|
||||
auth = USER_PRIVILEGE_COMMON;
|
||||
if (!jsn->get_value(L"ui-pos", ui_pos))
|
||||
|
@ -1371,6 +1389,8 @@ void CDlgOptJson::from_ui(SANEOPT& sop)
|
|||
//sop.fix_id = GetDlgItemInt(IDC_EDIT_FIXED_ID);
|
||||
sop.fix_id = fix_id_edit_.value();
|
||||
sop.readonly = is_button_check(IDC_CHECK_READONLY);
|
||||
sop.bind_cur = is_button_check(IDC_CHECK_BIND);
|
||||
|
||||
//sop.open = visible_.GetCurSel(); // is_button_check(IDC_CHECK_PUBLIC);
|
||||
sop.visible.clear();
|
||||
for (int i = 0; i < visible_.GetCount(); ++i)
|
||||
|
@ -1490,6 +1510,8 @@ void CDlgOptJson::to_ui(const SANEOPT& sop)
|
|||
|
||||
set_button_check(IDC_CHECK_READONLY, sop.readonly);
|
||||
set_button_check(IDC_CHECK_OWN_READ, sop.own_read);
|
||||
set_button_check(IDC_CHECK_BIND, sop.bind_cur);
|
||||
|
||||
//set_button_check(IDC_CHECK_PUBLIC, sop.open);
|
||||
//visible_.SetCurSel(sop.open);
|
||||
clear_visible();
|
||||
|
@ -2008,6 +2030,8 @@ BOOL CDlgOptJson::OnInitDialog()
|
|||
tooltips_->add_tool_tip_for_ctrl(::GetDlgItem(m_hWnd, IDC_CHECK_AUTO_RESTORE), L"\u662F\u5426\u652F\u6301\u6062\u590D\u5230\u9ED8\u8BA4\u503C\u7684\u64CD\u4F5C");
|
||||
tooltips_->add_tool_tip_for_ctrl(::GetDlgItem(m_hWnd, IDC_CHECK_OWN_READ), L"\u8BE5\u5C5E\u6027\u5F53\u524D\u503C\u9700\u8981\u989D\u5916\u64CD\u4F5C\u4EE5\u4FDD\u8BC1\u5B9E\u65F6\u6027");
|
||||
tooltips_->add_tool_tip_for_ctrl(::GetDlgItem(m_hWnd, IDC_CHECK_PUBLIC), L"\u662F\u5426\u5BF9\u666E\u901A\u7528\u6237\u5F00\u653E");
|
||||
tooltips_->add_tool_tip_for_ctrl(::GetDlgItem(m_hWnd, IDC_CHECK_READONLY), L"\u53EA\u8BFB\uFF0C\u4E0D\u53EF\u66F4\u6539");
|
||||
tooltips_->add_tool_tip_for_ctrl(::GetDlgItem(m_hWnd, IDC_CHECK_BIND), L"\u9ED8\u8BA4\u503C\u6539\u53D8\u65F6\uFF0C\u540C\u6B65\u5E94\u7528\u5230\u5F53\u524D\u503C");
|
||||
|
||||
tooltips_->add_tool_tip_for_ctrl(::GetDlgItem(m_hWnd, IDC_COMBO_AFFECT), L"\u8BE5\u5C5E\u6027\u503C\u53D1\u751F\u6539\u53D8\u540E\uFF0C\u662F\u5426\u5F71\u54CD\u5176\u5B83\u5C5E\u6027\u6216\u8005\u56FE\u50CF\u53C2\u6570\uFF1F");
|
||||
tooltips_->add_tool_tip_for_ctrl(::GetDlgItem(m_hWnd, IDC_COMBO_CATEGORY), L"\u5C5E\u6027\u5206\u7C7B\u3002\u5982\u679C\u4E3A\u56FE\u50CF\u5206\u7C7B\uFF0C\u4F1A\u6309\u7167\u201Cposition\u201D\u503C\u6392\u5E8F\uFF0C\u4EE5\u786E\u5B9A\u6267\u884C\u7684\u5148\u540E\u987A\u5E8F");
|
||||
|
@ -2472,7 +2496,15 @@ void CDlgOptJson::OnBnClickedButtonModify()
|
|||
{
|
||||
if (v.name == sop.name)
|
||||
{
|
||||
std::string def(sop.def_val[0].val);
|
||||
|
||||
sop.range = std::move(v.range);
|
||||
for (auto& d : v.def_val)
|
||||
{
|
||||
if (d.val != def)
|
||||
sop.def_val.push_back(d);
|
||||
}
|
||||
|
||||
v = std::move(sop);
|
||||
modify_tree_title(v.name.c_str(), v.title.c_str());
|
||||
return;
|
||||
|
@ -2933,6 +2965,7 @@ void CDlgOptJson::OnBnClickedButtonSet()
|
|||
|
||||
|
||||
dlg.set_init_val_api(INIT_VAL_API_PROTO(), get_opts, get_range);
|
||||
dlg.set_title((L"\u8BBE\u7F6E \u201C" + get_item_text(IDC_EDIT_TITLE) + L"\u201D\u503C\uFF1A").c_str());
|
||||
|
||||
if (dlg.DoModal() == IDOK)
|
||||
{
|
||||
|
|
|
@ -99,6 +99,7 @@ public:
|
|||
int auth; // 用户权限
|
||||
bool readonly;
|
||||
bool enable;
|
||||
bool bind_cur; // Whether to synchronize and change current value as the same when default value changes
|
||||
bool auto_restore_default;
|
||||
bool own_read; // 通常读取属性值都返回当前值。如果某属性读操作不同于此,则设置该属性
|
||||
|
||||
|
|
|
@ -53,6 +53,9 @@ BOOL CDlgRange::OnInitDialog()
|
|||
|
||||
// Set the icon for this dialog. The framework does this automatically
|
||||
// when the application's main window is not a dialog
|
||||
if (!title_.empty())
|
||||
::SetWindowTextW(m_hWnd, title_.c_str());
|
||||
|
||||
list_.SetExtendedStyle(list_.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_INFOTIP);
|
||||
list_.InsertColumn(0, TEXT("Value lists"), 0, 150);
|
||||
list_.InsertColumn(1, TEXT("Condition"), 0, 159);
|
||||
|
@ -88,17 +91,18 @@ BOOL CDlgRange::OnInitDialog()
|
|||
{
|
||||
//list_.SetItemText(ind, 2, L"yes");
|
||||
cond.insert(0, L"default:");
|
||||
def = true;
|
||||
//def = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
list_.SetItemText(ind, 1, cond.c_str());
|
||||
}
|
||||
|
||||
if (!def && init_.size())
|
||||
for (auto& init : init_)
|
||||
{
|
||||
int ind = list_.InsertItem(list_.GetItemCount(), init_[0].val.c_str());
|
||||
list_.SetItemText(ind, 1, L"default:");
|
||||
int ind = list_.InsertItem(list_.GetItemCount(), init.val.c_str());
|
||||
|
||||
list_.SetItemText(ind, 1, (L"default:" + init.cond).c_str());
|
||||
}
|
||||
}
|
||||
//else if(type_ == TYPE_RANGE && vals_.size() == 3)
|
||||
|
|
|
@ -17,9 +17,11 @@ class CDlgRange : public CDialogEx
|
|||
std::function < std::wstring(const wchar_t*/*name*/, int/*index*/)> item_val_;
|
||||
std::function<std::wstring(int/*index*/, int*/*type*/, int*/*range type*/, std::wstring* /*name*/)> item_all_;
|
||||
std::wstring name_;
|
||||
std::wstring title_;
|
||||
|
||||
std::wstring get_item_text(UINT id);
|
||||
|
||||
|
||||
public:
|
||||
CDlgRange(const wchar_t* name, int type, CWnd* pParent = nullptr); // 标准构造函数
|
||||
virtual ~CDlgRange();
|
||||
|
@ -64,6 +66,10 @@ public:
|
|||
{
|
||||
visible_ = vals;
|
||||
}
|
||||
void set_title(const wchar_t* t)
|
||||
{
|
||||
title_ = t;
|
||||
}
|
||||
|
||||
afx_msg void OnBnClickedButton1();
|
||||
CListCtrl list_;
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue