Addons Manager: allow installing addons on list row double click (bug #25547)

This commit is contained in:
Charles Dang 2017-03-01 09:12:52 +11:00
parent 09d9054e4a
commit 097867429b
6 changed files with 48 additions and 27 deletions

View file

@ -22,7 +22,7 @@
horizontal_scrollbar_mode = "never"
[header]
[row]
grow_factor = 1
@ -91,7 +91,7 @@
[/toggle_button]
[/column]
[column]
grow_factor = 1
horizontal_grow = "true"
@ -105,11 +105,11 @@
[/toggle_button]
[/column]
[column]
grow_factor = 1
horizontal_grow = "true"
[toggle_button]
id = "sort_4"
definition = "listbox_header"
@ -142,10 +142,9 @@
[toggle_panel]
## linked_group = "list_item"
id = "list_panel"
definition = "default"
return_value_id = "ok"
[grid]
[row]
@ -164,7 +163,7 @@
width = 72
height = 72
[draw]
[image]
@ -222,9 +221,9 @@
linked_group = "name"
[/label]
[/column]
[/row]
[/grid]
[/column]
@ -416,7 +415,7 @@
[addon_list_definition]
id = "default"
description = "List of one or more add-ons."
[resolution]
[linked_group]
id = "icon"

View file

@ -64,11 +64,11 @@
[column]
horizontal_alignment = "left"
[grid]
[row]
[column]
border = "left,top,bottom"
border_size = 5
@ -82,7 +82,7 @@
[/label]
[/column]
[column]
border = "all"
border_size = 5
@ -97,7 +97,7 @@
[/scroll_label]
[/column]
[column]
[spacer]
@ -119,7 +119,7 @@
[/label]
[/column]
[column]
border = "left,top,bottom"
border_size = 5
@ -134,15 +134,15 @@
[/scroll_label]
[/column]
[/row]
[/grid]
[/column]
[/row]
[row]
grow_factor = 1
@ -249,7 +249,7 @@
[/label]
[/column]
[column]
grow_factor = 0
border = "all"
@ -281,7 +281,7 @@
[/row]
[row]
[column]
grow_factor = 0
border = "all"
@ -410,7 +410,7 @@
{GUI_HORIZONTAL_SPACER_LINE}
[row]
[column]
horizontal_grow = "true"
vertical_alignment = "bottom"
@ -449,9 +449,9 @@
[/scroll_label]
[/column]
[/row]
[row]
[column]
@ -777,7 +777,7 @@
[panel]
definition = "box_display_no_blur_no_border"
[grid]
[row]

View file

@ -414,6 +414,9 @@ void addon_manager::pre_show(window& window)
window.keyboard_capture(&filter);
//window.add_to_keyboard_chain(&list.get_listbox());
// Use handle the special addon_list retval to allow installing addons on double click
window.set_exit_hook(std::bind(&addon_manager::exit_hook, this, std::ref(window)));
}
void addon_manager::load_addon_list(window& window)
@ -753,5 +756,15 @@ void addon_manager::on_addon_select(window& window)
find_widget<button>(&window, "uninstall", false).set_active(installed);
}
bool addon_manager::exit_hook(window& window)
{
if(window.get_retval() == addon_list::INSTALL_ADDON_RETVAL) {
install_selected_addon(window);
return false;
}
return true;
}
} // namespace dialogs
} // namespace gui2

View file

@ -93,6 +93,8 @@ private:
boost::dynamic_bitset<> get_status_filter_visibility(const window& window) const;
boost::dynamic_bitset<> get_type_filter_visibility(const window& window) const;
bool exit_hook(window& window);
};
} // namespace dialogs

View file

@ -26,6 +26,7 @@
#include "gui/widgets/listbox.hpp"
#include "gui/widgets/settings.hpp"
#include "gui/widgets/stacked_widget.hpp"
#include "gui/widgets/toggle_panel.hpp"
#include "wml_exception.hpp"
#include <algorithm>
@ -164,6 +165,9 @@ void addon_list::set_addons(const addons_list& addons)
grid* row_grid = &list.add_row(data);
// Set special retval for the toggle panels
find_widget<toggle_panel>(row_grid, "list_panel", false).set_retval(INSTALL_ADDON_RETVAL);
stacked_widget& install_update_stack = find_widget<stacked_widget>(row_grid, "install_update_stack", false);
if(!tracking_info.can_publish) {

View file

@ -50,6 +50,9 @@ public:
, delete_function_()
{}
/** Special retval for the toggle panels in the addons list */
static const int INSTALL_ADDON_RETVAL = 200;
/** Sets the add-ons to show. */
void set_addons(const addons_list& addons);