Skip to content

Commit

Permalink
Skip switches with no state labels
Browse files Browse the repository at this point in the history
  • Loading branch information
groverlynn committed Mar 27, 2023
1 parent d0d227c commit e3addcf
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions src/rime/gear/switch_translator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,24 +218,26 @@ void SwitchTranslation::LoadSwitches(Switcher* switcher) {
switches.FindOption(
[this, switcher, context, &groups]
(Switches::SwitchOption option) -> Switches::FindResult {
if (option.type == Switches::kToggleOption) {
bool current_state = context->get_option(option.option_name);
Append(
New<Switch>(option,
current_state,
switcher->IsAutoSave(option.option_name)));
} else if (option.type == Switches::kRadioGroup) {
an<RadioGroup> group;
if (option.option_index == 0) {
group = New<RadioGroup>(context, switcher);
groups.push_back(group);
} else {
group = groups.back();
if (!get_state_label(option, 0).empty()) {
if (option.type == Switches::kToggleOption) {
bool current_state = context->get_option(option.option_name);
Append(
New<Switch>(option,
current_state,
switcher->IsAutoSave(option.option_name)));
} else if (option.type == Switches::kRadioGroup) {
an<RadioGroup> group;
if (option.option_index == 0) {
group = New<RadioGroup>(context, switcher);
groups.push_back(group);
} else {
group = groups.back();
}
Append(
group->CreateOption(option, option.option_index));
}
Append(
group->CreateOption(option, option.option_index));
return Switches::kContinue;
}
return Switches::kContinue;
});
for (auto& group : groups) {
group->SelectOption(group->GetSelectedOption());
Expand All @@ -247,9 +249,11 @@ void SwitchTranslation::LoadSwitches(Switcher* switcher) {
(Switches::SwitchOption option) -> Switches::FindResult {
bool current_state = context->get_option(option.option_name);
if (option.type == Switches::kToggleOption) {
folded_options->Append(option, current_state);
if (!get_state_label(option, current_state).empty()) {
folded_options->Append(option, current_state);
}
} else if (option.type == Switches::kRadioGroup) {
if (current_state) {
if (current_state && !get_state_label(option, option.option_index).empty()) {
folded_options->Append(option, option.option_index);
}
}
Expand Down

0 comments on commit e3addcf

Please sign in to comment.