The Battle for Wesnoth  1.17.0-dev
wml_error.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014 - 2021
3  by Iris Morelle <shadowm2006@gmail.com>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #pragma once
17 
19 
20 namespace gui2::dialogs
21 {
22 
23 /**
24  * @ingroup GUIWindowDefinitionWML
25  *
26  * WML preprocessor/parser error report dialog.
27  * Key |Type |Mandatory|Description
28  * ------------------|--------------|---------|-----------
29  * summary | control |yes |Label used for displaying a brief summary of the error(s).
30  * files | control |yes |Label used to display the list of affected add-ons or files, if applicable. It is hidden otherwise. It is recommended to place it after the summary label.
31  * post_summary | control |yes |Label used for displaying instructions for reporting the error. It is recommended to place it after the file list label. It may be hidden if empty.
32  * details | control |yes |Full report of the parser or preprocessor error(s) found.
33  * copy | @ref button |yes |Button that the user can click on to copy the error report to the system clipboard.
34  */
35 class wml_error : public modal_dialog
36 {
37 public:
38  /**
39  * Constructor.
40  *
41  * @param summary Leading summary line for the report.
42  * @param post_summary Additional line with instructions for the user, may
43  * be empty.
44  * @param files List of WML files on which errors were detected.
45  * @param details Detailed WML preprocessor/parser error report.
46  */
47  wml_error(const std::string& summary,
48  const std::string& post_summary,
49  const std::vector<std::string>& files,
50  const std::string& details);
51 
52  /** The display function; see @ref modal_dialog for more information. */
53  static void display(const std::string& summary,
54  const std::string& post_summary,
55  const std::vector<std::string>& files,
56  const std::string& details)
57  {
58  wml_error(summary, post_summary, files, details).show();
59  }
60 
61  /** The display function; see @ref modal_dialog for more information. */
62  static void display(const std::string& summary,
63  const std::string& details)
64  {
65  display(summary, "", std::vector<std::string>(), details);
66  }
67 
68 private:
71  std::string report_; // Plain text report for copying to clipboard.
72 
73  virtual const std::string& window_id() const override;
74 
75  virtual void pre_show(window& window) override;
76 
77  void copy_report_callback();
78 };
79 
80 } // end namespace dialogs
static void display(const std::string &summary, const std::string &details)
The display function; see modal_dialog for more information.
Definition: wml_error.hpp:62
WML preprocessor/parser error report dialog.
Definition: wml_error.hpp:35
wml_error(const std::string &summary, const std::string &post_summary, const std::vector< std::string > &files, const std::string &details)
Constructor.
Definition: wml_error.cpp:138
static void display(const std::string &summary, const std::string &post_summary, const std::vector< std::string > &files, const std::string &details)
The display function; see modal_dialog for more information.
Definition: wml_error.hpp:53
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
Definition: wml_error.cpp:173
Abstract base class for all modal dialogs.
virtual const std::string & window_id() const override
The id of the window to build.
base class of top level items, the only item which needs to store the final canvases to draw on...
Definition: window.hpp:65