Skip to content

Commit

Permalink
feat(color): keep screen options when changing layout (#5530)
Browse files Browse the repository at this point in the history
  • Loading branch information
philmoz committed Sep 14, 2024
1 parent d417228 commit 349ae2e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions radio/src/gui/colorlcd/mainview/screen_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,33 @@ void ScreenSetupPage::build(Window* window)
// delete any options potentially accessing
// the old custom screen before re-creating it
clearLayoutOptions();

// If screen is not App Mode then save option values
auto layoutData = &g_model.screenData[customScreenIndex].layoutData;
auto layout = (Layout*)customScreens[customScreenIndex];
bool restoreOptions = false;
bool hasTopbar = true, hasFM = true, hasSliders = true, hasTrims = true, isMirrored = false;
if (!layout->isAppMode()) {
hasTopbar = layoutData->options[LAYOUT_OPTION_TOPBAR].value.boolValue;
hasFM = layoutData->options[LAYOUT_OPTION_FM].value.boolValue;
hasSliders = layoutData->options[LAYOUT_OPTION_SLIDERS].value.boolValue;
hasTrims = layoutData->options[LAYOUT_OPTION_TRIMS].value.boolValue;
isMirrored = layoutData->options[LAYOUT_OPTION_MIRRORED].value.boolValue;
restoreOptions = true;
}

factory->createCustomScreen(customScreenIndex);

// If new screen is not App Mode then restore saved option values
layout = (Layout*)customScreens[customScreenIndex];
if (restoreOptions && !layout->isAppMode()) {
layoutData->options[LAYOUT_OPTION_TOPBAR].value.boolValue = hasTopbar;
layoutData->options[LAYOUT_OPTION_FM].value.boolValue = hasFM;
layoutData->options[LAYOUT_OPTION_SLIDERS].value.boolValue = hasSliders;
layoutData->options[LAYOUT_OPTION_TRIMS].value.boolValue = hasTrims;
layoutData->options[LAYOUT_OPTION_MIRRORED].value.boolValue = isMirrored;
}

buildLayoutOptions();
};

Expand Down

0 comments on commit 349ae2e

Please sign in to comment.