From 1e11116d654debe4e1d09b7bea0bf74a78186ec9 Mon Sep 17 00:00:00 2001 From: tetektoza Date: Fri, 29 Sep 2023 20:24:14 +0200 Subject: [PATCH] VideoPlayer: Port VideoPlayer to GML compilation --- Userland/Applications/VideoPlayer/CMakeLists.txt | 7 ++----- Userland/Applications/VideoPlayer/VideoFrameWidget.cpp | 2 -- Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp | 6 ++---- .../{VideoPlayerWindow.gml => VideoPlayerWidget.gml} | 8 ++++---- Userland/Applications/VideoPlayer/VideoPlayerWidget.h | 1 + Userland/Applications/VideoPlayer/main.cpp | 2 +- 6 files changed, 10 insertions(+), 16 deletions(-) rename Userland/Applications/VideoPlayer/{VideoPlayerWindow.gml => VideoPlayerWidget.gml} (86%) diff --git a/Userland/Applications/VideoPlayer/CMakeLists.txt b/Userland/Applications/VideoPlayer/CMakeLists.txt index c6a0b96c6f..16ed221736 100644 --- a/Userland/Applications/VideoPlayer/CMakeLists.txt +++ b/Userland/Applications/VideoPlayer/CMakeLists.txt @@ -4,17 +4,14 @@ serenity_component( DEPENDS AudioServer ) -stringify_gml(VideoPlayerWindow.gml VideoPlayerWindowGML.h videoplayer_window_gml) +compile_gml(VideoPlayerWidget.gml VideoPlayerWidgetGML.cpp) set(SOURCES main.cpp + VideoPlayerWidgetGML.cpp VideoFrameWidget.cpp VideoPlayerWidget.cpp ) -set(GENERATED_SOURCES - VideoPlayerWindowGML.h -) - serenity_app(VideoPlayer ICON app-video-player) target_link_libraries(VideoPlayer PRIVATE LibVideo LibAudio LibConfig LibCore LibGfx LibGUI LibMain LibFileSystemAccessClient) diff --git a/Userland/Applications/VideoPlayer/VideoFrameWidget.cpp b/Userland/Applications/VideoPlayer/VideoFrameWidget.cpp index bbeca22bb2..f219617b7b 100644 --- a/Userland/Applications/VideoPlayer/VideoFrameWidget.cpp +++ b/Userland/Applications/VideoPlayer/VideoFrameWidget.cpp @@ -9,8 +9,6 @@ #include "VideoFrameWidget.h" -REGISTER_WIDGET(VideoPlayer, VideoFrameWidget); - namespace VideoPlayer { VideoFrameWidget::VideoFrameWidget() diff --git a/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp b/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp index c6cc777ee6..4cf4d42399 100644 --- a/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp +++ b/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp @@ -19,16 +19,14 @@ #include #include #include -#include #include "VideoPlayerWidget.h" namespace VideoPlayer { -ErrorOr> VideoPlayerWidget::try_create() +ErrorOr> VideoPlayerWidget::create() { - auto main_widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) VideoPlayerWidget())); - TRY(main_widget->load_from_gml(videoplayer_window_gml)); + auto main_widget = TRY(try_create()); TRY(main_widget->setup_interface()); diff --git a/Userland/Applications/VideoPlayer/VideoPlayerWindow.gml b/Userland/Applications/VideoPlayer/VideoPlayerWidget.gml similarity index 86% rename from Userland/Applications/VideoPlayer/VideoPlayerWindow.gml rename to Userland/Applications/VideoPlayer/VideoPlayerWidget.gml index 162ea5f469..86c1977a1b 100644 --- a/Userland/Applications/VideoPlayer/VideoPlayerWindow.gml +++ b/Userland/Applications/VideoPlayer/VideoPlayerWidget.gml @@ -1,4 +1,4 @@ -@GUI::Widget { +@VideoPlayer::VideoPlayerWidget { fill_with_background_color: true layout: @GUI::VerticalBoxLayout {} @@ -25,7 +25,7 @@ @GUI::Button { name: "playback" - icon: "/res/icons/16x16/play.png" + icon_from_path: "/res/icons/16x16/play.png" fixed_width: 24 button_style: "Coolbar" } @@ -41,7 +41,7 @@ @GUI::Button { name: "sizing" - icon: "/res/icons/16x16/fit-image-to-view.png" + icon_from_path: "/res/icons/16x16/fit-image-to-view.png" fixed_width: 24 button_style: "Coolbar" } @@ -59,7 +59,7 @@ @GUI::Button { name: "fullscreen" - icon: "/res/icons/16x16/fullscreen.png" + icon_from_path: "/res/icons/16x16/fullscreen.png" fixed_width: 24 button_style: "Coolbar" } diff --git a/Userland/Applications/VideoPlayer/VideoPlayerWidget.h b/Userland/Applications/VideoPlayer/VideoPlayerWidget.h index 745577b045..3275bc5155 100644 --- a/Userland/Applications/VideoPlayer/VideoPlayerWidget.h +++ b/Userland/Applications/VideoPlayer/VideoPlayerWidget.h @@ -25,6 +25,7 @@ class VideoPlayerWidget final : public GUI::Widget { public: static ErrorOr> try_create(); + static ErrorOr> create(); virtual ~VideoPlayerWidget() override = default; void close_file(); void open_file(FileSystemAccessClient::File filename); diff --git a/Userland/Applications/VideoPlayer/main.cpp b/Userland/Applications/VideoPlayer/main.cpp index 97d485548d..58166dad1a 100644 --- a/Userland/Applications/VideoPlayer/main.cpp +++ b/Userland/Applications/VideoPlayer/main.cpp @@ -34,7 +34,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/res", "r")); TRY(Core::System::unveil(nullptr, nullptr)); - auto main_widget = TRY(VideoPlayer::VideoPlayerWidget::try_create()); + auto main_widget = TRY(VideoPlayer::VideoPlayerWidget::create()); window->set_main_widget(main_widget); main_widget->update_title(); TRY(main_widget->initialize_menubar(window));