mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 13:27:35 +00:00
VideoPlayer: Add quit action and help menu
I also moved the menubar initialization code to VideoPlayerWidget in order to keep all of the bulk out of main.cpp :)
This commit is contained in:
parent
8006bdf6b4
commit
bb95374b49
3 changed files with 21 additions and 10 deletions
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
#include <LibGUI/FilePicker.h>
|
||||
#include <LibGUI/ImageWidget.h>
|
||||
#include <LibGUI/Label.h>
|
||||
#include <LibGUI/MessageBox.h>
|
||||
|
@ -200,4 +201,21 @@ void VideoPlayerWidget::update_title()
|
|||
window()->set_title(string_builder.to_string());
|
||||
}
|
||||
|
||||
void VideoPlayerWidget::initialize_menubar(GUI::Window& window)
|
||||
{
|
||||
auto& file_menu = window.add_menu("&File");
|
||||
file_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) {
|
||||
Optional<String> path = GUI::FilePicker::get_open_filepath(&window, "Open video file...");
|
||||
if (path.has_value())
|
||||
open_file(path.value());
|
||||
}));
|
||||
file_menu.add_separator();
|
||||
file_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||
window.close();
|
||||
}));
|
||||
|
||||
auto& help_menu = window.add_menu("&Help");
|
||||
help_menu.add_action(GUI::CommonActions::make_about_action("Video Player", GUI::Icon::default_icon("window"sv), &window));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ public:
|
|||
|
||||
void update_title();
|
||||
|
||||
void initialize_menubar(GUI::Window&);
|
||||
|
||||
private:
|
||||
VideoPlayerWidget(GUI::Window&);
|
||||
|
||||
|
|
|
@ -8,11 +8,8 @@
|
|||
#include "LibVideo/MatroskaDemuxer.h"
|
||||
#include <LibCore/ArgsParser.h>
|
||||
#include <LibGUI/Application.h>
|
||||
#include <LibGUI/FilePicker.h>
|
||||
#include <LibGUI/Menu.h>
|
||||
#include <LibGUI/Window.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <LibVideo/PlaybackManager.h>
|
||||
|
||||
#include "VideoPlayerWidget.h"
|
||||
|
||||
|
@ -30,17 +27,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
auto main_widget = TRY(window->try_set_main_widget<VideoPlayer::VideoPlayerWidget>(window));
|
||||
main_widget->update_title();
|
||||
main_widget->initialize_menubar(window);
|
||||
|
||||
if (!filename.is_empty())
|
||||
main_widget->open_file(filename);
|
||||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"));
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_open_action([&](auto&) {
|
||||
Optional<String> path = GUI::FilePicker::get_open_filepath(window, "Open video file...");
|
||||
if (path.has_value())
|
||||
main_widget->open_file(path.value());
|
||||
})));
|
||||
|
||||
window->show();
|
||||
return app->exec();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue