mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-12 09:20:36 +00:00
FileManager: Use a GTextEditor for the location bar + tweak icons.
This commit is contained in:
parent
367bb9e4eb
commit
daa1dcb5e8
Notes:
sideshowbarker
2024-07-19 14:59:23 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/daa1dcb5e86
6 changed files with 14 additions and 7 deletions
|
@ -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");
|
||||
});
|
||||
|
||||
|
|
BIN
Base/res/icons/16x16/delete.png
Normal file
BIN
Base/res/icons/16x16/delete.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 448 B |
BIN
Base/res/icons/16x16/delete.rgb
Normal file
BIN
Base/res/icons/16x16/delete.rgb
Normal file
Binary file not shown.
BIN
Base/res/icons/16x16/mkdir.png
Normal file
BIN
Base/res/icons/16x16/mkdir.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.9 KiB |
BIN
Base/res/icons/16x16/mkdir.rgb
Normal file
BIN
Base/res/icons/16x16/mkdir.rgb
Normal file
Binary file not shown.
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue