gui2/tgame_version: Add plain text report and a button to save it to clipboard

Most of it is not translatable. This is intentional as it is intended to
serve as a Technical Support/bug tracker post aid.
This commit is contained in:
Ignacio R. Morelle 2015-07-14 00:58:58 -03:00
parent f608d4f46a
commit 948a3ae19a
3 changed files with 67 additions and 0 deletions

View file

@ -551,6 +551,20 @@
[row]
grow_factor = 0
[column]
horizontal_alignment = left
border = "all"
border_size = 5
[button]
id = "copy_all"
definition = "action_copy"
label = _ "page^Copy"
tooltip = _ "Copy the full report to clipboard"
[/button]
[/column]
[column]
horizontal_alignment = right
border = "all"

View file

@ -90,6 +90,7 @@ tgame_version::tgame_version()
, deps_()
, opts_(game_config::optional_features_table())
, tabs_()
, report_()
{
// NOTE: these path_map_ entries are referenced by the GUI2 WML
// definition of this dialog using preprocessor macros.
@ -109,6 +110,8 @@ tgame_version::tgame_version()
e[2] = game_config::library_runtime_version(lib);
deps_.push_back(e);
}
generate_plain_text_report();
}
void tgame_version::pre_show(CVideo& /*video*/, twindow& window)
@ -127,6 +130,11 @@ void tgame_version::pre_show(CVideo& /*video*/, twindow& window)
i18n_syms["os"] = desktop::os_version();
os_label.set_label(VGETTEXT("Running on $os", i18n_syms));
tbutton& copy_all = find_widget<tbutton>(&window, "copy_all", false);
connect_signal_mouse_left_click(
copy_all,
boost::bind(&tgame_version::report_copy_callback, this));
//
// Game paths tab.
//
@ -273,4 +281,40 @@ void tgame_version::copy_to_clipboard_callback(const std::string& path)
desktop::clipboard::copy_to_clipboard(path, false);
}
void tgame_version::report_copy_callback()
{
desktop::clipboard::copy_to_clipboard(report_, false);
}
void tgame_version::generate_plain_text_report()
{
std::ostringstream o;
o << "The Battle for Wesnoth version " << game_config::revision << '\n'
<< "Running on " << desktop::os_version() << '\n'
<< '\n'
<< "Game paths\n"
<< "==========\n"
<< '\n'
<< "Data dir: " << path_map_["datadir"] << '\n'
<< "User config dir: " << path_map_["config"] << '\n'
<< "User data dir: " << path_map_["userdata"] << '\n'
<< "Saves dir: " << path_map_["saves"] << '\n'
<< "Add-ons dir: " << path_map_["addons"] << '\n'
<< "Cache dir: " << path_map_["cache"] << '\n'
<< '\n'
<< "Libraries\n"
<< "=========\n"
<< '\n'
<< game_config::library_versions_report()
<< '\n'
<< "Features\n"
<< "========\n"
<< '\n'
<< game_config::optional_features_report();
report_ = o.str();
}
} // end namespace gui2

View file

@ -61,6 +61,10 @@ private:
std::vector<tselectable_*> tabs_;
std::string report_;
void generate_plain_text_report();
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
virtual const std::string& window_id() const;
@ -82,6 +86,11 @@ private:
*/
void tab_switch_callback(tselectable_& me, tstacked_widget& tab_container);
/**
* Callback function for the dialog-wide copy-to-clipboard button.
*/
void report_copy_callback();
/**
* Callback function for copy-to-clipboard action buttons.
*