main.cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include "Profile.h"
  2. #include "ProfileTimelineWidget.h"
  3. #include <LibGUI/GAction.h>
  4. #include <LibGUI/GApplication.h>
  5. #include <LibGUI/GBoxLayout.h>
  6. #include <LibGUI/GMenu.h>
  7. #include <LibGUI/GMenuBar.h>
  8. #include <LibGUI/GTreeView.h>
  9. #include <LibGUI/GWindow.h>
  10. #include <stdio.h>
  11. int main(int argc, char** argv)
  12. {
  13. if (argc != 2) {
  14. printf("usage: %s <profile-file>\n", argv[0]);
  15. return 0;
  16. }
  17. const char* path = argv[1];
  18. auto profile = Profile::load_from_file(path);
  19. if (!profile) {
  20. fprintf(stderr, "Unable to load profile '%s'\n", path);
  21. return 1;
  22. }
  23. GApplication app(argc, argv);
  24. auto window = GWindow::construct();
  25. window->set_title("ProfileViewer");
  26. window->set_rect(100, 100, 800, 600);
  27. auto main_widget = GWidget::construct();
  28. window->set_main_widget(main_widget);
  29. main_widget->set_fill_with_background_color(true);
  30. main_widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
  31. auto timeline_widget = ProfileTimelineWidget::construct(*profile, main_widget);
  32. auto tree_view = GTreeView::construct(main_widget);
  33. tree_view->set_headers_visible(true);
  34. tree_view->set_size_columns_to_fit_content(true);
  35. tree_view->set_model(profile->model());
  36. auto menubar = make<GMenuBar>();
  37. auto app_menu = GMenu::construct("ProfileViewer");
  38. app_menu->add_action(GCommonActions::make_quit_action([&](auto&) { app.quit(); }));
  39. menubar->add_menu(move(app_menu));
  40. app.set_menubar(move(menubar));
  41. window->show();
  42. return app.exec();
  43. }