diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-08-22 11:02:03 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-08-22 11:02:03 +0200 |
commit | 96c5c9ce12fcd798f690e134b7707350468cc171 (patch) | |
tree | 58ce3e98d17772f216d6a8c56218c73e017b73ad /Applications | |
parent | 933a98f8fac2835a59f0777dc4672f33c713becb (diff) | |
download | serenity-96c5c9ce12fcd798f690e134b7707350468cc171.zip |
TextEditor: Hide the search bar until the user asks for it
You can get to it via Edit/Find, or by pressing Ctrl+F.
Diffstat (limited to 'Applications')
-rw-r--r-- | Applications/TextEditor/TextEditorWidget.cpp | 8 | ||||
-rw-r--r-- | Applications/TextEditor/TextEditorWidget.h | 1 |
2 files changed, 9 insertions, 0 deletions
diff --git a/Applications/TextEditor/TextEditorWidget.cpp b/Applications/TextEditor/TextEditorWidget.cpp index 85941be96c..8e80520895 100644 --- a/Applications/TextEditor/TextEditorWidget.cpp +++ b/Applications/TextEditor/TextEditorWidget.cpp @@ -30,6 +30,7 @@ TextEditorWidget::TextEditorWidget() find_widget->set_preferred_size(0, 22); find_widget->set_layout(make<GBoxLayout>(Orientation::Horizontal)); find_widget->layout()->set_margins({ 2, 2, 2, 2 }); + find_widget->set_visible(false); m_find_textbox = new GTextBox(find_widget); @@ -52,6 +53,11 @@ TextEditorWidget::TextEditorWidget() } }; + m_find_action = GAction::create("Find...", { Mod_Ctrl, Key_F }, [this, find_widget](auto&) { + find_widget->set_visible(true); + m_find_textbox->set_focus(true); + }); + auto* statusbar = new GStatusBar(this); m_editor->on_cursor_change = [statusbar, this] { @@ -120,6 +126,8 @@ TextEditorWidget::TextEditorWidget() edit_menu->add_action(m_editor->copy_action()); edit_menu->add_action(m_editor->paste_action()); edit_menu->add_action(m_editor->delete_action()); + edit_menu->add_separator(); + edit_menu->add_action(*m_find_action); menubar->add_menu(move(edit_menu)); auto font_menu = make<GMenu>("Font"); diff --git a/Applications/TextEditor/TextEditorWidget.h b/Applications/TextEditor/TextEditorWidget.h index c8e7c1e28d..d8dab46777 100644 --- a/Applications/TextEditor/TextEditorWidget.h +++ b/Applications/TextEditor/TextEditorWidget.h @@ -28,6 +28,7 @@ private: RefPtr<GAction> m_open_action; RefPtr<GAction> m_save_action; RefPtr<GAction> m_save_as_action; + RefPtr<GAction> m_find_action; GTextBox* m_find_textbox { nullptr }; GButton* m_find_button { nullptr }; |