2019-02-09 11:22:04 +03:00
|
|
|
#include <LibGUI/GWindow.h>
|
|
|
|
#include <LibGUI/GWidget.h>
|
2019-02-10 13:07:13 +03:00
|
|
|
#include <LibGUI/GBoxLayout.h>
|
2019-02-11 16:56:23 +03:00
|
|
|
#include <LibGUI/GApplication.h>
|
2019-02-10 13:07:13 +03:00
|
|
|
#include <LibGUI/GStatusBar.h>
|
2019-02-20 04:39:46 +03:00
|
|
|
#include <LibGUI/GToolBar.h>
|
2019-02-14 10:52:12 +03:00
|
|
|
#include <LibGUI/GMenuBar.h>
|
|
|
|
#include <LibGUI/GAction.h>
|
2019-02-09 11:22:04 +03:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdio.h>
|
2019-03-01 15:54:28 +03:00
|
|
|
#include "DirectoryTableView.h"
|
2019-02-09 11:22:04 +03:00
|
|
|
|
2019-02-11 16:56:23 +03:00
|
|
|
int main(int argc, char** argv)
|
2019-02-09 11:22:04 +03:00
|
|
|
{
|
2019-02-11 16:56:23 +03:00
|
|
|
GApplication app(argc, argv);
|
2019-02-09 11:22:04 +03:00
|
|
|
|
2019-02-20 04:39:46 +03:00
|
|
|
auto mkdir_action = GAction::create("New directory...", GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, "/res/icons/mkdir16.rgb", { 16, 16 }), [] (const GAction&) {
|
|
|
|
dbgprintf("'New directory' action activated!\n");
|
|
|
|
});
|
|
|
|
|
|
|
|
auto copy_action = GAction::create("Copy", GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, "/res/icons/copyfile16.rgb", { 16, 16 }), [] (const GAction&) {
|
|
|
|
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&) {
|
|
|
|
dbgprintf("'Delete' action activated!\n");
|
|
|
|
});
|
|
|
|
|
2019-02-14 10:52:12 +03:00
|
|
|
auto menubar = make<GMenuBar>();
|
|
|
|
|
|
|
|
auto app_menu = make<GMenu>("FileManager");
|
2019-02-20 04:39:46 +03:00
|
|
|
app_menu->add_action(GAction::create("Quit", String(), [] (const GAction&) {
|
2019-02-17 11:58:35 +03:00
|
|
|
GApplication::the().quit(0);
|
2019-02-14 10:52:12 +03:00
|
|
|
return;
|
|
|
|
}));
|
|
|
|
menubar->add_menu(move(app_menu));
|
|
|
|
|
|
|
|
auto file_menu = make<GMenu>("File");
|
2019-02-20 04:39:46 +03:00
|
|
|
file_menu->add_action(mkdir_action.copy_ref());
|
|
|
|
file_menu->add_action(copy_action.copy_ref());
|
|
|
|
file_menu->add_action(delete_action.copy_ref());
|
2019-02-14 10:52:12 +03:00
|
|
|
menubar->add_menu(move(file_menu));
|
|
|
|
|
|
|
|
auto help_menu = make<GMenu>("Help");
|
2019-02-20 04:39:46 +03:00
|
|
|
help_menu->add_action(GAction::create("About", [] (const GAction&) {
|
2019-02-14 10:52:12 +03:00
|
|
|
dbgprintf("FIXME: Implement Help/About\n");
|
|
|
|
}));
|
|
|
|
menubar->add_menu(move(help_menu));
|
|
|
|
|
|
|
|
app.set_menubar(move(menubar));
|
|
|
|
|
2019-02-09 11:22:04 +03:00
|
|
|
auto* window = new GWindow;
|
|
|
|
window->set_title("FileManager");
|
|
|
|
window->set_rect(20, 200, 240, 300);
|
|
|
|
|
|
|
|
auto* widget = new GWidget;
|
|
|
|
window->set_main_widget(widget);
|
|
|
|
|
2019-02-10 13:07:13 +03:00
|
|
|
widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
|
|
|
|
2019-02-20 04:39:46 +03:00
|
|
|
auto* toolbar = new GToolBar(widget);
|
|
|
|
toolbar->add_action(mkdir_action.copy_ref());
|
|
|
|
toolbar->add_action(copy_action.copy_ref());
|
|
|
|
toolbar->add_action(delete_action.copy_ref());
|
|
|
|
|
2019-03-01 15:54:28 +03:00
|
|
|
auto* directory_table_view = new DirectoryTableView(widget);
|
2019-02-10 13:07:13 +03:00
|
|
|
|
|
|
|
auto* statusbar = new GStatusBar(widget);
|
|
|
|
statusbar->set_text("Welcome!");
|
2019-02-09 11:22:04 +03:00
|
|
|
|
2019-03-01 15:54:28 +03:00
|
|
|
directory_table_view->on_path_change = [window] (const String& new_path) {
|
2019-02-09 11:22:04 +03:00
|
|
|
window->set_title(String::format("FileManager: %s", new_path.characters()));
|
|
|
|
};
|
|
|
|
|
2019-03-01 15:54:28 +03:00
|
|
|
directory_table_view->on_status_message = [statusbar] (String message) {
|
2019-02-10 13:07:13 +03:00
|
|
|
statusbar->set_text(move(message));
|
|
|
|
};
|
|
|
|
|
2019-03-01 15:54:28 +03:00
|
|
|
directory_table_view->open("/");
|
|
|
|
directory_table_view->set_focus(true);
|
2019-02-09 11:22:04 +03:00
|
|
|
|
2019-02-20 04:39:46 +03:00
|
|
|
window->set_should_exit_app_on_close(true);
|
|
|
|
window->show();
|
2019-02-09 11:22:04 +03:00
|
|
|
|
2019-02-20 04:39:46 +03:00
|
|
|
return app.exec();
|
|
|
|
}
|