mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:37:45 +00:00
VideoPlayer: Propagate errors from VideoPlayerWidget::initialize_menubar
This commit is contained in:
parent
a2ca2d8364
commit
f0a33b2a8e
3 changed files with 15 additions and 15 deletions
|
@ -283,36 +283,36 @@ void VideoPlayerWidget::update_seek_mode()
|
||||||
m_playback_manager->set_seek_mode(seek_mode());
|
m_playback_manager->set_seek_mode(seek_mode());
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoPlayerWidget::initialize_menubar(GUI::Window& window)
|
ErrorOr<void> VideoPlayerWidget::initialize_menubar(GUI::Window& window)
|
||||||
{
|
{
|
||||||
// FIXME: This should return ErrorOr and use try_... functions.
|
|
||||||
|
|
||||||
// File menu
|
// File menu
|
||||||
auto& file_menu = window.add_menu("&File");
|
auto file_menu = TRY(window.try_add_menu("&File"));
|
||||||
file_menu.add_action(GUI::CommonActions::make_open_action([&](auto&) {
|
TRY(file_menu->try_add_action(GUI::CommonActions::make_open_action([&](auto&) {
|
||||||
Optional<DeprecatedString> path = GUI::FilePicker::get_open_filepath(&window, "Open video file...");
|
Optional<DeprecatedString> path = GUI::FilePicker::get_open_filepath(&window, "Open video file...");
|
||||||
if (path.has_value())
|
if (path.has_value())
|
||||||
open_file(path.value());
|
open_file(path.value());
|
||||||
}));
|
})));
|
||||||
file_menu.add_separator();
|
TRY(file_menu->try_add_separator());
|
||||||
file_menu.add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([&](auto&) {
|
||||||
window.close();
|
window.close();
|
||||||
}));
|
})));
|
||||||
|
|
||||||
// Playback menu
|
// Playback menu
|
||||||
auto& playback_menu = window.add_menu("&Playback");
|
auto playback_menu = TRY(window.try_add_menu("&Playback"));
|
||||||
|
|
||||||
// FIXME: Maybe seek mode should be in an options dialog instead. The playback menu may get crowded.
|
// FIXME: Maybe seek mode should be in an options dialog instead. The playback menu may get crowded.
|
||||||
// For now, leave it here for convenience.
|
// For now, leave it here for convenience.
|
||||||
m_use_fast_seeking = GUI::Action::create_checkable("&Fast Seeking", [&](auto&) {
|
m_use_fast_seeking = GUI::Action::create_checkable("&Fast Seeking", [&](auto&) {
|
||||||
update_seek_mode();
|
update_seek_mode();
|
||||||
});
|
});
|
||||||
playback_menu.add_action(*m_use_fast_seeking);
|
TRY(playback_menu->try_add_action(*m_use_fast_seeking));
|
||||||
set_seek_mode(Video::PlaybackManager::DEFAULT_SEEK_MODE);
|
set_seek_mode(Video::PlaybackManager::DEFAULT_SEEK_MODE);
|
||||||
|
|
||||||
// Help menu
|
// Help menu
|
||||||
auto& help_menu = window.add_menu("&Help");
|
auto help_menu = TRY(window.try_add_menu("&Help"));
|
||||||
help_menu.add_action(GUI::CommonActions::make_about_action("Video Player", GUI::Icon::default_icon("app-video-player"sv), &window));
|
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Video Player", TRY(GUI::Icon::try_create_default_icon("app-video-player"sv)), &window)));
|
||||||
|
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ public:
|
||||||
Video::PlaybackManager::SeekMode seek_mode();
|
Video::PlaybackManager::SeekMode seek_mode();
|
||||||
void set_seek_mode(Video::PlaybackManager::SeekMode seek_mode);
|
void set_seek_mode(Video::PlaybackManager::SeekMode seek_mode);
|
||||||
|
|
||||||
void initialize_menubar(GUI::Window&);
|
ErrorOr<void> initialize_menubar(GUI::Window&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VideoPlayerWidget(GUI::Window&);
|
VideoPlayerWidget(GUI::Window&);
|
||||||
|
|
|
@ -26,7 +26,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
|
|
||||||
auto main_widget = TRY(window->set_main_widget<VideoPlayer::VideoPlayerWidget>(window));
|
auto main_widget = TRY(window->set_main_widget<VideoPlayer::VideoPlayerWidget>(window));
|
||||||
main_widget->update_title();
|
main_widget->update_title();
|
||||||
main_widget->initialize_menubar(window);
|
TRY(main_widget->initialize_menubar(window));
|
||||||
|
|
||||||
if (!filename.is_empty())
|
if (!filename.is_empty())
|
||||||
main_widget->open_file(filename);
|
main_widget->open_file(filename);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue