The Battle for Wesnoth
1.19.5+dev
gui
dialogs
addon
connect.cpp
Go to the documentation of this file.
1
/*
2
Copyright (C) 2008 - 2024
3
by Mark de Wever <koraq@xs4all.nl>
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
#define GETTEXT_DOMAIN "wesnoth-lib"
17
18
#include "
gui/dialogs/addon/connect.hpp
"
19
20
#include "
gui/widgets/button.hpp
"
21
#include "
gui/widgets/window.hpp
"
22
#include "
gui/widgets/text_box.hpp
"
23
#include "
help/help.hpp
"
24
25
#include <functional>
26
27
namespace
gui2::dialogs
28
{
29
30
REGISTER_DIALOG
(addon_connect)
31
32
addon_connect
::
addon_connect
(std::
string
& host_name,
bool
allow_remove)
33
:
modal_dialog
(window_id())
34
, allow_remove_(allow_remove)
35
{
36
register_text(
"host_name"
,
false
, host_name,
true
);
37
}
38
39
void
addon_connect::help_button_callback
()
40
{
41
help::show_help
(
"installing_addons"
);
42
}
43
44
void
addon_connect::pre_show
()
45
{
46
find_widget<button>(
"remove_addons"
)
47
.set_active(
allow_remove_
);
48
49
connect_signal_mouse_left_click
(
50
find_widget<button>(
"show_help"
),
51
std::bind(&
addon_connect::help_button_callback
,
this
));
52
}
53
54
void
addon_connect::post_show
()
55
{
56
if
(
get_retval
() ==
retval::OK
) {
57
text_box
& host_widget
58
= find_widget<text_box>(
"host_name"
);
59
60
host_widget.
save_to_history
();
61
}
62
}
63
64
}
// namespace dialogs
gui2::dialogs::addon_connect
Definition:
connect.hpp:24
gui2::dialogs::addon_connect::help_button_callback
void help_button_callback()
Definition:
connect.cpp:39
gui2::dialogs::addon_connect::pre_show
virtual void pre_show() override
Actions to be taken before showing the window.
Definition:
connect.cpp:44
gui2::dialogs::addon_connect::allow_remove_
bool allow_remove_
Enable the addon remove button?
Definition:
connect.hpp:40
gui2::dialogs::addon_connect::post_show
virtual void post_show() override
Actions to be taken after the window has been shown.
Definition:
connect.cpp:54
gui2::dialogs::modal_dialog
Abstract base class for all modal dialogs.
Definition:
modal_dialog.hpp:146
gui2::dialogs::modal_dialog::get_retval
int get_retval() const
Returns the cached window exit code.
Definition:
modal_dialog.hpp:176
gui2::text_box
A widget that allows the user to input text in single line.
Definition:
text_box.hpp:125
gui2::text_box::save_to_history
void save_to_history()
Saves the text in the widget to the history.
Definition:
text_box.hpp:132
connect.hpp
button.hpp
window.hpp
This file contains the window object, this object is a top level container which has the event manage...
help.hpp
gui2::dialogs
Definition:
achievements_dialog.cpp:36
gui2::dialogs::REGISTER_DIALOG
REGISTER_DIALOG(editor_edit_unit)
gui2::event::connect_signal_mouse_left_click
void connect_signal_mouse_left_click(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a left mouse button click.
Definition:
dispatcher.cpp:177
gui2::OK
@ OK
Dialog was closed with the OK button.
Definition:
retval.hpp:35
help::show_help
void show_help(const std::string &show_topic)
Open the help browser, show topic with id show_topic.
Definition:
help.cpp:140
text_box.hpp
Generated by
1.9.1