Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add-ons manager: handle the selected add-on changing in small-screen mode #6490

Merged
merged 1 commit into from
Feb 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Version 1.16.2+dev
### Add-ons client
* Fixed: using the up or down arrow keys in small-screen mode returned to the title screen (issue #6485)
### Add-ons server
### Campaigns
* Delfador’s Memoirs
Expand Down
17 changes: 10 additions & 7 deletions src/gui/dialogs/addon/manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,7 +688,8 @@ void addon_manager::apply_filters()
// In the small-screen layout, the text_box for the filter keeps keyboard focus even when the
// details panel is visible, which means this can be called when the list isn't visible. That
// causes problems both because find_widget can throw exceptions, but also because changing the
// filters can trigger on_addon_select and thus affect which add-on's details are shown.
// filters can hide the currently-shown add-on, triggering a different one to be selected in a
// way that would seem random unless the user realised that they were typing into a filter box.
//
// Quick workaround is to not process the new filter if the list isn't visible.
auto list = find_widget<addon_list>(get_window(), "addons", false, false);
Expand Down Expand Up @@ -971,15 +972,17 @@ static std::string format_addon_time(std::time_t time)

void addon_manager::on_addon_select()
{
const addon_info* info = find_widget<addon_list>(get_window(), "addons", false).get_selected_addon();

if(info == nullptr) {
return;
}

widget* parent = get_window();
widget* parent_of_addons_list = parent;
if(stacked_widget* stk = find_widget<stacked_widget>(get_window(), "main_stack", false, false)) {
parent = stk->get_layer_grid(1);
parent_of_addons_list = stk->get_layer_grid(0);
}

const addon_info* info = find_widget<addon_list>(parent_of_addons_list, "addons", false).get_selected_addon();

if(info == nullptr) {
return;
}

find_widget<drawing>(parent, "image", false).set_label(info->display_icon());
Expand Down