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