diff --git a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp index ab4899210a..b4bf495131 100644 --- a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp +++ b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp @@ -62,42 +62,35 @@ SoundPlayerWidgetAdvancedView::SoundPlayerWidgetAdvancedView(GUI::Window& window auto& toolbar_container = m_player_view->add(); auto& menubar = toolbar_container.add(); - m_play_button = menubar.add(); - m_play_button->set_icon(*m_play_icon); - m_play_button->set_fixed_width(50); - m_play_button->set_enabled(false); - m_play_button->on_click = [&](unsigned) { + m_play_action = GUI::Action::create("Play", m_play_icon, [&](auto&) { toggle_pause(); - }; + }); + m_play_action->set_enabled(false); + menubar.add_action(*m_play_action); - m_stop_button = menubar.add(); - m_stop_button->set_icon(*m_stop_icon); - m_stop_button->set_fixed_width(50); - m_stop_button->set_enabled(false); - m_stop_button->on_click = [&](unsigned) { + m_stop_action = GUI::Action::create("Stop", m_stop_icon, [&](auto&) { stop(); - }; + }); + m_stop_action->set_enabled(false); + menubar.add_action(*m_stop_action); m_timestamp_label = menubar.add(); m_timestamp_label->set_fixed_width(110); - // filler_label + // Filler label menubar.add(); - m_back_button = menubar.add(); - m_back_button->set_fixed_width(50); - m_back_button->set_icon(*m_back_icon); - m_back_button->set_enabled(false); - m_back_button->on_click = [&](unsigned) { - play_file_path(playlist().previous()); - }; - m_next_button = menubar.add(); - m_next_button->set_fixed_width(50); - m_next_button->set_icon(*m_next_icon); - m_next_button->set_enabled(false); - m_next_button->on_click = [&](unsigned) { + m_back_action = GUI::Action::create("Back", m_back_icon, [&](auto&) { + play_file_path(playlist().previous()); + }); + m_back_action->set_enabled(false); + menubar.add_action(*m_back_action); + + m_next_action = GUI::Action::create("Next", m_next_icon, [&](auto&) { play_file_path(playlist().next()); - }; + }); + m_next_action->set_enabled(false); + menubar.add_action(*m_next_action); m_volume_label = &menubar.add(); m_volume_label->set_fixed_width(30); @@ -140,13 +133,13 @@ void SoundPlayerWidgetAdvancedView::drop_event(GUI::DropEvent& event) void SoundPlayerWidgetAdvancedView::keydown_event(GUI::KeyEvent& event) { if (event.key() == Key_Space) - m_play_button->click(); + m_play_action->activate(); if (event.key() == Key_M) toggle_mute(); if (event.key() == Key_S) - m_stop_button->click(); + m_stop_action->activate(); if (event.key() == Key_Up) m_volume_slider->increase_slider_by_page_steps(1); @@ -169,12 +162,12 @@ void SoundPlayerWidgetAdvancedView::set_playlist_visible(bool visible) void SoundPlayerWidgetAdvancedView::play_state_changed(Player::PlayState state) { - sync_previous_next_buttons(); + sync_previous_next_actions(); - m_play_button->set_enabled(state != PlayState::NoFileLoaded); - m_play_button->set_icon(state == PlayState::Playing ? *m_pause_icon : *m_play_icon); + m_play_action->set_enabled(state != PlayState::NoFileLoaded); + m_play_action->set_icon(state == PlayState::Playing ? m_pause_icon : m_play_icon); - m_stop_button->set_enabled(state != PlayState::Stopped && state != PlayState::NoFileLoaded); + m_stop_action->set_enabled(state != PlayState::Stopped && state != PlayState::NoFileLoaded); m_playback_progress_slider->set_enabled(state != PlayState::NoFileLoaded); } @@ -188,15 +181,15 @@ void SoundPlayerWidgetAdvancedView::mute_changed(bool) // FIXME: Update the volume slider when player is muted } -void SoundPlayerWidgetAdvancedView::sync_previous_next_buttons() +void SoundPlayerWidgetAdvancedView::sync_previous_next_actions() { - m_back_button->set_enabled(playlist().size() > 1 && !playlist().shuffling()); - m_next_button->set_enabled(playlist().size() > 1); + m_back_action->set_enabled(playlist().size() > 1 && !playlist().shuffling()); + m_next_action->set_enabled(playlist().size() > 1); } void SoundPlayerWidgetAdvancedView::shuffle_mode_changed(Player::ShuffleMode) { - sync_previous_next_buttons(); + sync_previous_next_actions(); } void SoundPlayerWidgetAdvancedView::time_elapsed(int seconds) diff --git a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.h b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.h index 858a07c11e..d87ed4de15 100644 --- a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.h +++ b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.h @@ -55,7 +55,7 @@ protected: private: SoundPlayerWidgetAdvancedView(GUI::Window&, Audio::ConnectionFromClient&); - void sync_previous_next_buttons(); + void sync_previous_next_actions(); void drop_event(GUI::DropEvent& event) override; GUI::Window& m_window; @@ -71,10 +71,11 @@ private: RefPtr m_back_icon; RefPtr m_next_icon; - RefPtr m_play_button; - RefPtr m_stop_button; - RefPtr m_back_button; - RefPtr m_next_button; + RefPtr m_play_action; + RefPtr m_stop_action; + RefPtr m_back_action; + RefPtr m_next_action; + RefPtr m_playback_progress_slider; RefPtr m_volume_label; RefPtr m_volume_slider;