16#define GETTEXT_DOMAIN "wesnoth-lib"
22#include "../../addon/manager.hpp"
38void strip_trailing_dir_separators(std::string& str)
41 str.erase(str.size() - 1);
45std::string format_file_list(
const std::vector<std::string>& files_original)
47 if(files_original.empty()) {
52 std::vector<std::string> files(files_original);
54 for(std::string & file : files)
58 std::string parent_path;
60 const bool is_main_cfg =
filename ==
"_main.cfg";
79 strip_trailing_dir_separators(base);
100 base.erase(suffix_pos);
111 if(!info_cfg.
empty() && !info_cfg[
"title"].
empty()) {
112 file = info_cfg[
"title"].str();
122 if(files.size() == 1) {
136 const
std::
string& post_summary,
137 const
std::vector<
std::
string>& files,
138 const
std::
string& details)
140 , have_files_(!files.empty())
141 , have_post_summary_(!post_summary.empty())
144 const std::string file_list_text =
lg::sanitize_log(format_file_list(files));
149 report_ = sanitized_summary;
151 if(!file_list_text.empty()) {
152 report_ +=
"\n" + file_list_text;
155 if(!sanitized_post_summary.empty()) {
156 report_ +=
"\n\n" + sanitized_post_summary;
160 report_ +=
_(
"Details:");
166 register_label(
"summary",
true, sanitized_summary);
167 register_label(
"post_summary",
true, sanitized_post_summary);
168 register_label(
"files",
true, file_list_text);
169 register_label(
"details",
true, sanitized_details);
175 styled_widget& filelist = find_widget<styled_widget>(
"files");
181 = find_widget<styled_widget>(
"post_summary");
185 button& copy_button = find_widget<button>(
"copy");
187 connect_signal_mouse_left_click(
void get_addon_install_info(const std::string &addon_name, config &cfg)
Gets the installation info (_info.cfg) for an add-on.
bool have_addon_install_info(const std::string &addon_name)
Returns true if there is a local installation info (_info.cfg) file for the add-on.
A config object defines a single node in a WML file, with access to child nodes.
Abstract base class for all modal dialogs.
virtual void pre_show() override
Actions to be taken before showing the window.
void copy_report_callback()
Declarations for File-IO.
static std::string _(const char *str)
std::string make_addon_title(const std::string &id)
Replaces underscores to dress up file or dirnames as add-on titles.
Standard logging facilities (interface).
#define REGISTER_DIALOG(window_id)
Wrapper for REGISTER_DIALOG2.
void copy_to_clipboard(const std::string &text)
Copies text to the clipboard.
const std::string wml_extension
std::string base_name(const std::string &file, const bool remove_extension=false)
Returns the base filename of a file, with directory name stripped.
std::string directory_name(const std::string &file)
Returns the directory name of a file, with filename stripped.
std::string get_addons_dir()
bool is_path_sep(char c)
Returns whether c is a path separator.
std::string normalize_path(const std::string &path, bool normalize_separators=false, bool resolve_dot_entries=false)
Returns the absolute path of a file.
std::string sanitize_log(const std::string &logstr)
std::string indent(const std::string &string, std::size_t indent_size)
Indent a block of text.
std::string bullet_list(const T &v, std::size_t indent=4, const std::string &bullet=font::unicode_bullet)
Generates a new string containing a bullet list.
std::string filename
Filename.