2019-12-12 22:01:06 +01:00
|
|
|
#include "Profile.h"
|
2019-12-14 18:44:29 +01:00
|
|
|
#include "ProfileTimelineWidget.h"
|
2019-12-15 22:55:11 +01:00
|
|
|
#include <LibGUI/GAction.h>
|
2019-12-12 22:01:06 +01:00
|
|
|
#include <LibGUI/GApplication.h>
|
2019-12-14 18:44:29 +01:00
|
|
|
#include <LibGUI/GBoxLayout.h>
|
2019-12-15 22:55:11 +01:00
|
|
|
#include <LibGUI/GMenu.h>
|
|
|
|
#include <LibGUI/GMenuBar.h>
|
2019-12-12 22:01:06 +01:00
|
|
|
#include <LibGUI/GTreeView.h>
|
|
|
|
#include <LibGUI/GWindow.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
int main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
if (argc != 2) {
|
|
|
|
printf("usage: %s <profile-file>\n", argv[0]);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-12-13 23:38:17 +01:00
|
|
|
const char* path = argv[1];
|
|
|
|
|
|
|
|
auto profile = Profile::load_from_file(path);
|
2019-12-12 22:01:06 +01:00
|
|
|
if (!profile) {
|
2019-12-13 23:38:17 +01:00
|
|
|
fprintf(stderr, "Unable to load profile '%s'\n", path);
|
2019-12-12 22:01:06 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
GApplication app(argc, argv);
|
|
|
|
|
|
|
|
auto window = GWindow::construct();
|
|
|
|
window->set_title("ProfileViewer");
|
|
|
|
window->set_rect(100, 100, 800, 600);
|
|
|
|
|
2019-12-14 18:44:29 +01:00
|
|
|
auto main_widget = GWidget::construct();
|
|
|
|
window->set_main_widget(main_widget);
|
|
|
|
main_widget->set_fill_with_background_color(true);
|
|
|
|
main_widget->set_layout(make<GBoxLayout>(Orientation::Vertical));
|
|
|
|
|
|
|
|
auto timeline_widget = ProfileTimelineWidget::construct(*profile, main_widget);
|
|
|
|
|
|
|
|
auto tree_view = GTreeView::construct(main_widget);
|
2019-12-13 23:38:17 +01:00
|
|
|
tree_view->set_headers_visible(true);
|
|
|
|
tree_view->set_size_columns_to_fit_content(true);
|
2019-12-12 22:01:06 +01:00
|
|
|
tree_view->set_model(profile->model());
|
|
|
|
|
2019-12-15 22:55:11 +01:00
|
|
|
auto menubar = make<GMenuBar>();
|
|
|
|
auto app_menu = GMenu::construct("ProfileViewer");
|
|
|
|
app_menu->add_action(GCommonActions::make_quit_action([&](auto&) { app.quit(); }));
|
|
|
|
|
|
|
|
menubar->add_menu(move(app_menu));
|
|
|
|
|
2019-12-16 18:21:05 +01:00
|
|
|
auto view_menu = GMenu::construct("View");
|
|
|
|
auto invert_action = GAction::create("Invert tree", { Mod_Ctrl, Key_I }, [&](auto& action) {
|
|
|
|
action.set_checked(!action.is_checked());
|
|
|
|
profile->set_inverted(action.is_checked());
|
|
|
|
});
|
|
|
|
invert_action->set_checkable(true);
|
2019-12-16 23:46:39 -05:00
|
|
|
invert_action->set_checked(false);
|
2019-12-16 18:21:05 +01:00
|
|
|
view_menu->add_action(invert_action);
|
|
|
|
|
|
|
|
menubar->add_menu(move(view_menu));
|
|
|
|
|
2019-12-15 22:55:11 +01:00
|
|
|
app.set_menubar(move(menubar));
|
|
|
|
|
2019-12-12 22:01:06 +01:00
|
|
|
window->show();
|
|
|
|
return app.exec();
|
|
|
|
}
|