blob: 27a4016e03fc787c70e030a7c8ded2a089464ebe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
/*
* Copyright (c) 2021, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include "SettingsDialog.h"
#include <LibGUI/BoxLayout.h>
#include <LibGUI/Button.h>
#include <LibGUI/Label.h>
#include <LibGUI/TextBox.h>
SettingsDialog::SettingsDialog(GUI::Window* parent, DeprecatedString player_name)
: GUI::Dialog(parent)
, m_player_name(move(player_name))
{
set_rect({ 0, 0, 250, 75 });
set_title("Settings");
set_icon(parent->icon());
set_resizable(false);
auto main_widget = set_main_widget<GUI::Widget>().release_value_but_fixme_should_propagate_errors();
main_widget->set_fill_with_background_color(true);
main_widget->set_layout<GUI::VerticalBoxLayout>(4);
auto& name_box = main_widget->add<GUI::Widget>();
name_box.set_layout<GUI::HorizontalBoxLayout>(GUI::Margins {}, 4);
auto& name_label = name_box.add<GUI::Label>("Name:");
name_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
auto& textbox = name_box.add<GUI::TextBox>();
textbox.set_text(m_player_name);
textbox.on_change = [&] {
m_player_name = textbox.text();
};
auto& button_box = main_widget->add<GUI::Widget>();
button_box.set_layout<GUI::HorizontalBoxLayout>(GUI::Margins {}, 12);
button_box.add<GUI::Button>(String::from_utf8_short_string("Cancel"sv)).on_click = [this](auto) {
done(ExecResult::Cancel);
};
button_box.add<GUI::Button>(String::from_utf8_short_string("OK"sv)).on_click = [this](auto) {
done(ExecResult::OK);
};
}
|