gui2/twml_error: Add a button to copy the WML error report to clipboard
This commit is contained in:
parent
798c7402f1
commit
e4bed0ce96
3 changed files with 60 additions and 11 deletions
|
@ -83,9 +83,9 @@
|
|||
horizontal_alignment = "left"
|
||||
|
||||
[label]
|
||||
id = "details_heading"
|
||||
definition = "default_bold"
|
||||
label = _ "Details:"
|
||||
id = "post_summary"
|
||||
definition = "default"
|
||||
wrap = true
|
||||
[/label]
|
||||
[/column]
|
||||
|
||||
|
@ -94,15 +94,42 @@
|
|||
[row]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
horizontal_grow = "true"
|
||||
|
||||
[grid]
|
||||
|
||||
[row]
|
||||
|
||||
[column]
|
||||
border = "all"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
vertical_alignment = "bottom"
|
||||
|
||||
[label]
|
||||
id = "details_heading"
|
||||
definition = "default_bold"
|
||||
label = _ "Details:"
|
||||
[/label]
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
border = "top,left,right"
|
||||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
|
||||
[button]
|
||||
id = "copy"
|
||||
definition = "action_copy"
|
||||
label = _ "clipboard^Copy"
|
||||
tooltip = _ "Copy this report to clipboard"
|
||||
[/button]
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
||||
[/grid]
|
||||
|
||||
[label]
|
||||
id = "post_summary"
|
||||
definition = "default"
|
||||
wrap = true
|
||||
[/label]
|
||||
[/column]
|
||||
|
||||
[/row]
|
||||
|
|
|
@ -16,13 +16,17 @@
|
|||
|
||||
#include "addon/info.hpp"
|
||||
#include "addon/manager.hpp"
|
||||
#include "clipboard.hpp"
|
||||
#include "filesystem.hpp"
|
||||
#include "gui/auxiliary/find_widget.tpp"
|
||||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/control.hpp"
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
#include "serialization/string_utils.hpp"
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
inline bool is_dir_separator(char c)
|
||||
|
@ -160,6 +164,10 @@ namespace gui2
|
|||
* details & & control & m &
|
||||
* Full report of the parser or preprocessor error(s) found. $
|
||||
*
|
||||
* copy & & button & m &
|
||||
* Button that the user can click on to copy the error report to the
|
||||
* system clipboard. $
|
||||
*
|
||||
* @end{table}
|
||||
*/
|
||||
|
||||
|
@ -171,6 +179,7 @@ twml_error::twml_error(const std::string& summary,
|
|||
const std::string& details)
|
||||
: have_files_(!files.empty())
|
||||
, have_post_summary_(!post_summary.empty())
|
||||
, report_(summary + "\n\n" + details)
|
||||
{
|
||||
register_label("summary", true, summary);
|
||||
register_label("post_summary", true, post_summary);
|
||||
|
@ -190,6 +199,16 @@ void twml_error::pre_show(CVideo& /*video*/, twindow& window)
|
|||
"post_summary", false);
|
||||
post_summary.set_visible(tcontrol::tvisible::invisible);
|
||||
}
|
||||
|
||||
tbutton& copy_button = find_widget<tbutton>(&window, "copy", false);
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
copy_button, boost::bind(&twml_error::copy_report_callback, this));
|
||||
}
|
||||
|
||||
void twml_error::copy_report_callback()
|
||||
{
|
||||
copy_to_clipboard(report_, false);
|
||||
}
|
||||
|
||||
} // end namespace gui2
|
||||
|
|
|
@ -48,12 +48,15 @@ public:
|
|||
private:
|
||||
bool have_files_;
|
||||
bool have_post_summary_;
|
||||
std::string report_;
|
||||
|
||||
/** Inherited from tdialog, implemented by REGISTER_DIALOG. */
|
||||
virtual const std::string& window_id() const;
|
||||
|
||||
/** Inherited from tdialog. */
|
||||
void pre_show(CVideo& video, twindow& window);
|
||||
|
||||
void copy_report_callback();
|
||||
};
|
||||
|
||||
} // end namespace gui2
|
||||
|
|
Loading…
Add table
Reference in a new issue