1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 13:18:13 +00:00

SoundPlayer: Replace two manual key event checks with action shortcut

This commit is contained in:
Linus Groh 2022-05-29 12:20:29 +01:00 committed by Andreas Kling
parent 1940363e0b
commit 094487b5d4

View file

@ -62,13 +62,13 @@ SoundPlayerWidgetAdvancedView::SoundPlayerWidgetAdvancedView(GUI::Window& window
auto& toolbar_container = m_player_view->add<GUI::ToolbarContainer>();
auto& menubar = toolbar_container.add<GUI::Toolbar>();
m_play_action = GUI::Action::create("Play", m_play_icon, [&](auto&) {
m_play_action = GUI::Action::create("Play", { Key_Space }, m_play_icon, [&](auto&) {
toggle_pause();
});
m_play_action->set_enabled(false);
menubar.add_action(*m_play_action);
m_stop_action = GUI::Action::create("Stop", m_stop_icon, [&](auto&) {
m_stop_action = GUI::Action::create("Stop", { Key_S }, m_stop_icon, [&](auto&) {
stop();
});
m_stop_action->set_enabled(false);
@ -132,15 +132,9 @@ void SoundPlayerWidgetAdvancedView::drop_event(GUI::DropEvent& event)
void SoundPlayerWidgetAdvancedView::keydown_event(GUI::KeyEvent& event)
{
if (event.key() == Key_Space)
m_play_action->activate();
if (event.key() == Key_M)
toggle_mute();
if (event.key() == Key_S)
m_stop_action->activate();
if (event.key() == Key_Up)
m_volume_slider->increase_slider_by_page_steps(1);