diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-03-20 18:12:56 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-03-20 18:12:56 +0100 |
commit | daa1dcb5e8612da1aae8eaa146153a25e90dc60f (patch) | |
tree | 900b3a218cd1ee4105d089e814a89b07369fdbf7 | |
parent | 367bb9e4eb365bc0a03fc9eba65ce411397b2e77 (diff) | |
download | serenity-daa1dcb5e8612da1aae8eaa146153a25e90dc60f.zip |
FileManager: Use a GTextEditor for the location bar + tweak icons.
-rw-r--r-- | Applications/FileManager/main.cpp | 13 | ||||
-rw-r--r-- | Base/res/icons/16x16/delete.png | bin | 0 -> 448 bytes | |||
-rw-r--r-- | Base/res/icons/16x16/delete.rgb | bin | 0 -> 1024 bytes | |||
-rw-r--r-- | Base/res/icons/16x16/mkdir.png | bin | 0 -> 6070 bytes | |||
-rw-r--r-- | Base/res/icons/16x16/mkdir.rgb | bin | 0 -> 1024 bytes | |||
-rw-r--r-- | LibGUI/GTextEditor.cpp | 8 |
6 files changed, 14 insertions, 7 deletions
diff --git a/Applications/FileManager/main.cpp b/Applications/FileManager/main.cpp index d7b4ab5c9d..2fa31f2dc2 100644 --- a/Applications/FileManager/main.cpp +++ b/Applications/FileManager/main.cpp @@ -3,7 +3,7 @@ #include <LibGUI/GBoxLayout.h> #include <LibGUI/GApplication.h> #include <LibGUI/GStatusBar.h> -#include <LibGUI/GTextBox.h> +#include <LibGUI/GTextEditor.h> #include <LibGUI/GToolBar.h> #include <LibGUI/GMenuBar.h> #include <LibGUI/GAction.h> @@ -36,20 +36,21 @@ int main(int argc, char** argv) auto* main_toolbar = new GToolBar(widget); auto* location_toolbar = new GToolBar(widget); - auto* location_textbox = new GTextBox(location_toolbar); + location_toolbar->set_preferred_size({ 0, 21 }); + auto* location_textbox = new GTextEditor(GTextEditor::SingleLine, location_toolbar); auto* directory_table_view = new DirectoryTableView(widget); auto* statusbar = new GStatusBar(widget); - location_textbox->on_return_pressed = [directory_table_view] (GTextBox& textbox) { - directory_table_view->open(textbox.text()); + location_textbox->on_return_pressed = [directory_table_view] (auto& editor) { + directory_table_view->open(editor.text()); }; auto open_parent_directory_action = GAction::create("Open parent directory", { Mod_Alt, Key_Up }, GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, "/res/icons/parentdirectory16.rgb", { 16, 16 }), [directory_table_view] (const GAction&) { directory_table_view->open_parent_directory(); }); - auto mkdir_action = GAction::create("New directory...", GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, "/res/icons/mkdir16.rgb", { 16, 16 }), [] (const GAction&) { + auto mkdir_action = GAction::create("New directory...", GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, "/res/icons/16x16/mkdir.rgb", { 16, 16 }), [] (const GAction&) { dbgprintf("'New directory' action activated!\n"); }); @@ -57,7 +58,7 @@ int main(int argc, char** argv) dbgprintf("'Copy' action activated!\n"); }); - auto delete_action = GAction::create("Delete", GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, "/res/icons/trash16.rgb", { 16, 16 }), [] (const GAction&) { + auto delete_action = GAction::create("Delete", GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, "/res/icons/16x16/delete.rgb", { 16, 16 }), [] (const GAction&) { dbgprintf("'Delete' action activated!\n"); }); diff --git a/Base/res/icons/16x16/delete.png b/Base/res/icons/16x16/delete.png Binary files differnew file mode 100644 index 0000000000..f271da46e7 --- /dev/null +++ b/Base/res/icons/16x16/delete.png diff --git a/Base/res/icons/16x16/delete.rgb b/Base/res/icons/16x16/delete.rgb Binary files differnew file mode 100644 index 0000000000..460cd225d1 --- /dev/null +++ b/Base/res/icons/16x16/delete.rgb diff --git a/Base/res/icons/16x16/mkdir.png b/Base/res/icons/16x16/mkdir.png Binary files differnew file mode 100644 index 0000000000..012fff339d --- /dev/null +++ b/Base/res/icons/16x16/mkdir.png diff --git a/Base/res/icons/16x16/mkdir.rgb b/Base/res/icons/16x16/mkdir.rgb Binary files differnew file mode 100644 index 0000000000..a32de690b7 --- /dev/null +++ b/Base/res/icons/16x16/mkdir.rgb diff --git a/LibGUI/GTextEditor.cpp b/LibGUI/GTextEditor.cpp index 5a4d61584e..06ab76f1a2 100644 --- a/LibGUI/GTextEditor.cpp +++ b/LibGUI/GTextEditor.cpp @@ -26,6 +26,9 @@ GTextEditor::~GTextEditor() void GTextEditor::set_text(const String& text) { + if (is_single_line() && text.length() == m_lines[0]->length() && !memcmp(text.characters(), m_lines[0]->characters(), text.length())) + return; + m_lines.clear(); int start_of_current_line = 0; @@ -44,7 +47,10 @@ void GTextEditor::set_text(const String& text) } add_line(i); update_content_size(); - set_cursor(0, 0); + if (is_single_line()) + set_cursor(0, m_lines[0]->length()); + else + set_cursor(0, 0); update(); } |