qs.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include <SharedGraphics/PNGLoader.h>
  2. #include <LibGUI/GApplication.h>
  3. #include <LibGUI/GWindow.h>
  4. #include <LibGUI/GLabel.h>
  5. #include <stdio.h>
  6. int main(int argc, char** argv)
  7. {
  8. GApplication app(argc, argv);
  9. #if 0
  10. if (argc != 2) {
  11. printf("usage: qs <image-file>\n");
  12. return 0;
  13. }
  14. #endif
  15. const char* path = "/res/wallpapers/sunset-retro.png";
  16. if (argc > 1)
  17. path = argv[1];
  18. auto bitmap = load_png(path);
  19. if (!bitmap) {
  20. fprintf(stderr, "Failed to load %s\n", path);
  21. return 1;
  22. }
  23. auto* window = new GWindow;
  24. window->set_title(String::format("QuickShow: %s %s", path, bitmap->size().to_string().characters()));
  25. window->set_rect(200, 200, bitmap->width(), bitmap->height());
  26. auto* widget = new GWidget;
  27. widget->set_fill_with_background_color(true);
  28. window->set_main_widget(widget);
  29. auto* label = new GLabel(widget);
  30. label->set_relative_rect({ 0, 0, bitmap->width(), bitmap->height() });
  31. label->set_icon(move(bitmap));
  32. window->set_should_exit_event_loop_on_close(true);
  33. window->show();
  34. return app.exec();
  35. }