summaryrefslogtreecommitdiff
path: root/Applications/TextEditor
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-09-14 16:03:32 +0200
committerAndreas Kling <kling@serenityos.org>2020-09-14 16:16:36 +0200
commit119a0c5deeec19e8018ab1913e1c096a3d28ab83 (patch)
treeca1594a2518bf65734194e670abc5c6144754ee1 /Applications/TextEditor
parent093de0e3234bc1765d439c7b8a6249e92821bb08 (diff)
downloadserenity-119a0c5deeec19e8018ab1913e1c096a3d28ab83.zip
TextEditor: Move the find/replace buttons to JSON GUI
Diffstat (limited to 'Applications/TextEditor')
-rw-r--r--Applications/TextEditor/MainWindow.json48
-rw-r--r--Applications/TextEditor/TextEditorWidget.cpp20
2 files changed, 51 insertions, 17 deletions
diff --git a/Applications/TextEditor/MainWindow.json b/Applications/TextEditor/MainWindow.json
index 8028c5dbe3..c46f14d417 100644
--- a/Applications/TextEditor/MainWindow.json
+++ b/Applications/TextEditor/MainWindow.json
@@ -53,7 +53,25 @@
"preferred_height": 22,
"layout": {
"class": "GUI::HorizontalBoxLayout"
- }
+ },
+ "children": [
+ {
+ "class": "GUI::Button",
+ "name": "find_previous_button",
+ "text": "Find previous",
+ "horizontal_size_policy": "Fixed",
+ "vertical_size_policy": "Fill",
+ "preferred_width": 150
+ },
+ {
+ "class": "GUI::Button",
+ "name": "find_next_button",
+ "text": "Find next",
+ "horizontal_size_policy": "Fixed",
+ "vertical_size_policy": "Fill",
+ "preferred_width": 150
+ }
+ ]
},
{
"class": "GUI::Widget",
@@ -64,7 +82,33 @@
"preferred_height": 22,
"layout": {
"class": "GUI::HorizontalBoxLayout"
- }
+ },
+ "children": [
+ {
+ "class": "GUI::Button",
+ "name": "replace_previous_button",
+ "text": "Replace previous",
+ "horizontal_size_policy": "Fixed",
+ "vertical_size_policy": "Fill",
+ "preferred_width": 100
+ },
+ {
+ "class": "GUI::Button",
+ "name": "replace_next_button",
+ "text": "Replace next",
+ "horizontal_size_policy": "Fixed",
+ "vertical_size_policy": "Fill",
+ "preferred_width": 100
+ },
+ {
+ "class": "GUI::Button",
+ "name": "replace_all_button",
+ "text": "Replace all",
+ "horizontal_size_policy": "Fixed",
+ "vertical_size_policy": "Fill",
+ "preferred_width": 100
+ }
+ ]
}
]
},
diff --git a/Applications/TextEditor/TextEditorWidget.cpp b/Applications/TextEditor/TextEditorWidget.cpp
index ddf0312cfd..35a01efcff 100644
--- a/Applications/TextEditor/TextEditorWidget.cpp
+++ b/Applications/TextEditor/TextEditorWidget.cpp
@@ -213,14 +213,10 @@ TextEditorWidget::TextEditorWidget()
}
});
- m_find_previous_button = m_find_widget->add<GUI::Button>("Find previous");
- m_find_previous_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
- m_find_previous_button->set_preferred_size(150, 0);
+ m_find_previous_button = static_cast<GUI::Button&>(*find_descendant_by_name("find_previous_button"));
m_find_previous_button->set_action(*m_find_previous_action);
- m_find_next_button = m_find_widget->add<GUI::Button>("Find next");
- m_find_next_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
- m_find_next_button->set_preferred_size(150, 0);
+ m_find_next_button = static_cast<GUI::Button&>(*find_descendant_by_name("find_next_button"));
m_find_next_button->set_action(*m_find_next_action);
m_find_textbox->on_return_pressed = [this] {
@@ -232,19 +228,13 @@ TextEditorWidget::TextEditorWidget()
m_editor->set_focus(true);
};
- m_replace_previous_button = m_replace_widget->add<GUI::Button>("Replace previous");
- m_replace_previous_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
- m_replace_previous_button->set_preferred_size(100, 0);
+ m_replace_previous_button = static_cast<GUI::Button&>(*find_descendant_by_name("replace_previous_button"));
m_replace_previous_button->set_action(*m_replace_previous_action);
- m_replace_next_button = m_replace_widget->add<GUI::Button>("Replace next");
- m_replace_next_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
- m_replace_next_button->set_preferred_size(100, 0);
+ m_replace_next_button = static_cast<GUI::Button&>(*find_descendant_by_name("replace_next_button"));
m_replace_next_button->set_action(*m_replace_next_action);
- m_replace_all_button = m_replace_widget->add<GUI::Button>("Replace all");
- m_replace_all_button->set_size_policy(GUI::SizePolicy::Fixed, GUI::SizePolicy::Fill);
- m_replace_all_button->set_preferred_size(100, 0);
+ m_replace_all_button = static_cast<GUI::Button&>(*find_descendant_by_name("replace_all_button"));
m_replace_all_button->set_action(*m_replace_all_action);
m_replace_textbox->on_return_pressed = [this] {