gui2/tgamestate_inspector: Add a button to copy contents to clipboard
This copies the contents of the main display area to clipboard. The button currently lacks a tooltip because the tooltip causes map labels to glitch through the dialog when displayed (noticeable in e.g. the test scenario). I'll file a bug for this issue later using a (commented-out) line introduced by this commit as a test case.
This commit is contained in:
parent
821feef111
commit
6a56da5f0f
3 changed files with 65 additions and 13 deletions
|
@ -22,6 +22,8 @@ Version 1.11.15+dev:
|
|||
* Fixed bug #22144: An assertion failure with empty labels in a listbox.
|
||||
* The :inspect dialog now uses the same function as saved games to generate
|
||||
WML in text form instead of a simplified version.
|
||||
* Added a button to copy the currently displayed content from the :inspect
|
||||
dialog to clipboard.
|
||||
* WML engine:
|
||||
* Fixed a regression in 1.11.14 causing WML parser/preprocessor errors to
|
||||
not interrupt the game load sequence or display an error message in-game,
|
||||
|
|
|
@ -204,29 +204,54 @@
|
|||
|
||||
[column]
|
||||
grow_factor = 6
|
||||
border = "all"
|
||||
border_size = 5
|
||||
vertical_alignment = "top"
|
||||
horizontal_alignment = "left"
|
||||
[grid]
|
||||
[row]
|
||||
[column]
|
||||
#
|
||||
# Emulate the listbox headers' top/bottom padding
|
||||
# here relative to the scroll_label below.
|
||||
#
|
||||
border = "top,bottom"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
[label]
|
||||
definition = "default"
|
||||
label = _ "Contents"
|
||||
[/label]
|
||||
horizontal_grow = "true"
|
||||
[grid]
|
||||
[row]
|
||||
[column]
|
||||
#
|
||||
# Emulate the listbox headers' top/bottom padding
|
||||
# here relative to the scroll_label below.
|
||||
#
|
||||
border = "top,left,right"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[label]
|
||||
definition = "default"
|
||||
label = _ "Contents"
|
||||
[/label]
|
||||
[/column]
|
||||
|
||||
[column]
|
||||
border = "top,left,right"
|
||||
border_size = 5
|
||||
horizontal_alignment = "right"
|
||||
|
||||
[button]
|
||||
id = "copy"
|
||||
definition = "action_copy"
|
||||
label = _ "clipboard^Copy"
|
||||
# FIXME: tooltips cause weird interactions with map
|
||||
# labels while running a GUI2 dialog, so let's
|
||||
# not use a tooltip yet.
|
||||
#tooltip = _ "Copy this report to clipboard"
|
||||
[/button]
|
||||
[/column]
|
||||
[/row]
|
||||
[/grid]
|
||||
[/column]
|
||||
[/row]
|
||||
[row]
|
||||
[column]
|
||||
border = "left,bottom,right"
|
||||
border_size = 5
|
||||
horizontal_alignment = "left"
|
||||
|
||||
[scroll_label]
|
||||
id = "inspect"
|
||||
definition = "default"
|
||||
|
|
|
@ -26,6 +26,8 @@
|
|||
#endif
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
|
||||
#include "clipboard.hpp"
|
||||
#include "serialization/parser.hpp" // for write()
|
||||
#include "utils/foreach.tpp"
|
||||
|
||||
|
@ -72,6 +74,9 @@ namespace gui2
|
|||
* inspect & & control & m &
|
||||
* The state of the variable or event. $
|
||||
*
|
||||
* copy & & button & m &
|
||||
* A button to copy the state to clipboard. $
|
||||
*
|
||||
* @end{table}
|
||||
*/
|
||||
|
||||
|
@ -120,6 +125,7 @@ public:
|
|||
, stuff_types_list()
|
||||
, inspect()
|
||||
, inspector_name()
|
||||
, copy_button()
|
||||
{
|
||||
name = cfg["name"].str();
|
||||
}
|
||||
|
@ -131,6 +137,7 @@ public:
|
|||
tlistbox* stuff_types_list;
|
||||
tcontrol* inspect;
|
||||
tcontrol* inspector_name;
|
||||
tbutton* copy_button;
|
||||
|
||||
|
||||
void clear_stuff_list()
|
||||
|
@ -574,6 +581,11 @@ public:
|
|||
c->update_view_from_model(); // TODO: 'activate'
|
||||
}
|
||||
|
||||
void handle_copy_button_clicked()
|
||||
{
|
||||
copy_to_clipboard(model_.inspect->label(), false);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
model& model_;
|
||||
|
@ -610,6 +622,11 @@ public:
|
|||
window.invalidate_layout(); // workaround for assertion failure
|
||||
}
|
||||
|
||||
void handle_copy_button_clicked(twindow& /*window*/)
|
||||
{
|
||||
controller_.handle_copy_button_clicked();
|
||||
}
|
||||
|
||||
|
||||
void bind(twindow& window)
|
||||
{
|
||||
|
@ -620,6 +637,8 @@ public:
|
|||
model_.inspect = find_widget<tcontrol>(&window, "inspect", false, true);
|
||||
model_.inspector_name
|
||||
= &find_widget<tcontrol>(&window, "inspector_name", false);
|
||||
model_.copy_button
|
||||
= &find_widget<tbutton>(&window, "copy", false);
|
||||
|
||||
#ifdef GUI2_EXPERIMENTAL_LISTBOX
|
||||
connect_signal_notify_modified(
|
||||
|
@ -649,6 +668,12 @@ public:
|
|||
&tgamestate_inspector::view::
|
||||
handle_stuff_types_list_item_clicked>);
|
||||
#endif
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
*model_.copy_button,
|
||||
boost::bind(&tgamestate_inspector::view::handle_copy_button_clicked,
|
||||
this,
|
||||
boost::ref(window)));
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Reference in a new issue