From 8006bdf6b4d4690f3f3060988d585b51270d5644 Mon Sep 17 00:00:00 2001 From: Slimey <117548228+sl1m3yy@users.noreply.github.com> Date: Sun, 6 Nov 2022 13:14:29 +0000 Subject: [PATCH] VideoPlayer: Show current open file in the title --- .../VideoPlayer/VideoPlayerWidget.cpp | 16 ++++++++++++++++ .../Applications/VideoPlayer/VideoPlayerWidget.h | 4 ++++ Userland/Applications/VideoPlayer/main.cpp | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp b/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp index 774c378ec9..36317349bf 100644 --- a/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp +++ b/Userland/Applications/VideoPlayer/VideoPlayerWidget.cpp @@ -77,6 +77,9 @@ void VideoPlayerWidget::open_file(StringView filename) return; } + m_path = filename; + update_title(); + m_playback_manager = load_file_result.release_value(); resume_playback(); } @@ -184,4 +187,17 @@ void VideoPlayerWidget::cycle_sizing_modes() m_video_display->update(); } +void VideoPlayerWidget::update_title() +{ + StringBuilder string_builder; + if (m_path.is_empty()) { + string_builder.append("No video"sv); + } else { + string_builder.append(m_path.view()); + } + + string_builder.append("[*] - Video Player"sv); + window()->set_title(string_builder.to_string()); +} + } diff --git a/Userland/Applications/VideoPlayer/VideoPlayerWidget.h b/Userland/Applications/VideoPlayer/VideoPlayerWidget.h index 83852d2608..c31fe638d8 100644 --- a/Userland/Applications/VideoPlayer/VideoPlayerWidget.h +++ b/Userland/Applications/VideoPlayer/VideoPlayerWidget.h @@ -27,6 +27,8 @@ public: void pause_playback(); void toggle_pause(); + void update_title(); + private: VideoPlayerWidget(GUI::Window&); @@ -40,6 +42,8 @@ private: GUI::Window& m_window; + String m_path; + RefPtr m_video_display; RefPtr m_seek_slider; diff --git a/Userland/Applications/VideoPlayer/main.cpp b/Userland/Applications/VideoPlayer/main.cpp index 0fa7178882..673077b96c 100644 --- a/Userland/Applications/VideoPlayer/main.cpp +++ b/Userland/Applications/VideoPlayer/main.cpp @@ -25,11 +25,11 @@ ErrorOr serenity_main(Main::Arguments arguments) auto app = TRY(GUI::Application::try_create(arguments)); auto window = TRY(GUI::Window::try_create()); - window->set_title("Video Player"); window->resize(640, 480); window->set_resizable(true); auto main_widget = TRY(window->try_set_main_widget(window)); + main_widget->update_title(); if (!filename.is_empty()) main_widget->open_file(filename);