The Battle for Wesnoth  1.19.2+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 
21 #include "gui/widgets/button.hpp"
22 #include "gui/widgets/window.hpp"
23 #include "gui/widgets/text_box.hpp"
24 #include "help/help.hpp"
25 
26 #include <functional>
27 
28 namespace gui2::dialogs
29 {
30 
31 REGISTER_DIALOG(addon_connect)
32 
33 addon_connect::addon_connect(std::string& host_name, bool allow_remove)
34  : modal_dialog(window_id())
35  , allow_remove_(allow_remove)
36 {
37  register_text("host_name", false, host_name, true);
38 }
39 
41 {
42  help::show_help("installing_addons");
43 }
44 
46 {
47  find_widget<button>(&window, "remove_addons", false)
48  .set_active(allow_remove_);
49 
51  find_widget<button>(&window, "show_help", false),
52  std::bind(&addon_connect::help_button_callback, this));
53 }
54 
56 {
57  if(get_retval() == retval::OK) {
58  text_box& host_widget
59  = find_widget<text_box>(&window, "host_name", false);
60 
61  host_widget.save_to_history();
62  }
63 }
64 
65 } // namespace dialogs
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
Definition: connect.cpp:45
bool allow_remove_
Enable the addon remove button?
Definition: connect.hpp:40
virtual void post_show(window &window) override
Actions to be taken after the window has been shown.
Definition: connect.cpp:55
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
base class of top level items, the only item which needs to store the final canvases to draw on.
Definition: window.hpp:61
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, int xloc, int yloc)
Open the help browser, show topic with id show_topic.
Definition: help.cpp:140