The Battle for Wesnoth  1.19.5+dev
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 
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 
40 {
41  help::show_help("installing_addons");
42 }
43 
45 {
46  find_widget<button>("remove_addons")
47  .set_active(allow_remove_);
48 
50  find_widget<button>("show_help"),
51  std::bind(&addon_connect::help_button_callback, this));
52 }
53 
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
virtual void pre_show() override
Actions to be taken before showing the window.
Definition: connect.cpp:44
bool allow_remove_
Enable the addon remove button?
Definition: connect.hpp:40
virtual void post_show() override
Actions to be taken after the window has been shown.
Definition: connect.cpp:54
Abstract base class for all modal dialogs.
int get_retval() const
Returns the cached window exit code.
A widget that allows the user to input text in single line.
Definition: text_box.hpp:125
void save_to_history()
Saves the text in the widget to the history.
Definition: text_box.hpp:132
This file contains the window object, this object is a top level container which has the event manage...
REGISTER_DIALOG(editor_edit_unit)
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
@ OK
Dialog was closed with the OK button.
Definition: retval.hpp:35
void show_help(const std::string &show_topic)
Open the help browser, show topic with id show_topic.
Definition: help.cpp:140