From d00f489cdc2b4bd81165e4caf6977c6aeecf8f31 Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Wed, 19 Jul 2023 14:33:06 +0100 Subject: [PATCH] SoundPlayer: Rename main widget to SoundPlayerWidget This is the main widget, and is never replaced by something else, so having "AdvancedView" in there is a bit confusing. --- .../Applications/SoundPlayer/CMakeLists.txt | 2 +- ...AdvancedView.cpp => SoundPlayerWidget.cpp} | 40 +++++++++---------- ...dgetAdvancedView.h => SoundPlayerWidget.h} | 6 +-- Userland/Applications/SoundPlayer/main.cpp | 14 +++---- 4 files changed, 31 insertions(+), 31 deletions(-) rename Userland/Applications/SoundPlayer/{SoundPlayerWidgetAdvancedView.cpp => SoundPlayerWidget.cpp} (85%) rename Userland/Applications/SoundPlayer/{SoundPlayerWidgetAdvancedView.h => SoundPlayerWidget.h} (93%) diff --git a/Userland/Applications/SoundPlayer/CMakeLists.txt b/Userland/Applications/SoundPlayer/CMakeLists.txt index 66926eb5e48..568698bbe43 100644 --- a/Userland/Applications/SoundPlayer/CMakeLists.txt +++ b/Userland/Applications/SoundPlayer/CMakeLists.txt @@ -14,7 +14,7 @@ set(SOURCES Playlist.cpp PlaylistWidget.cpp SampleWidget.cpp - SoundPlayerWidgetAdvancedView.cpp + SoundPlayerWidget.cpp main.cpp ) diff --git a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp b/Userland/Applications/SoundPlayer/SoundPlayerWidget.cpp similarity index 85% rename from Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp rename to Userland/Applications/SoundPlayer/SoundPlayerWidget.cpp index 3de28edc230..c11085f5fd7 100644 --- a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp +++ b/Userland/Applications/SoundPlayer/SoundPlayerWidget.cpp @@ -5,7 +5,7 @@ * SPDX-License-Identifier: BSD-2-Clause */ -#include "SoundPlayerWidgetAdvancedView.h" +#include "SoundPlayerWidget.h" #include "AlbumCoverVisualizationWidget.h" #include "BarsVisualizationWidget.h" #include "M3UParser.h" @@ -28,7 +28,7 @@ #include #include -SoundPlayerWidgetAdvancedView::SoundPlayerWidgetAdvancedView(GUI::Window& window, Audio::ConnectionToServer& connection, ImageDecoderClient::Client& image_decoder_client) +SoundPlayerWidget::SoundPlayerWidget(GUI::Window& window, Audio::ConnectionToServer& connection, ImageDecoderClient::Client& image_decoder_client) : Player(connection) , m_window(window) , m_image_decoder_client(image_decoder_client) @@ -140,19 +140,19 @@ SoundPlayerWidgetAdvancedView::SoundPlayerWidgetAdvancedView(GUI::Window& window done_initializing(); } -void SoundPlayerWidgetAdvancedView::set_nonlinear_volume_slider(bool nonlinear) +void SoundPlayerWidget::set_nonlinear_volume_slider(bool nonlinear) { m_nonlinear_volume_slider = nonlinear; } -void SoundPlayerWidgetAdvancedView::drag_enter_event(GUI::DragEvent& event) +void SoundPlayerWidget::drag_enter_event(GUI::DragEvent& event) { auto const& mime_types = event.mime_types(); if (mime_types.contains_slow("text/uri-list")) event.accept(); } -void SoundPlayerWidgetAdvancedView::drop_event(GUI::DropEvent& event) +void SoundPlayerWidget::drop_event(GUI::DropEvent& event) { event.accept(); @@ -166,7 +166,7 @@ void SoundPlayerWidgetAdvancedView::drop_event(GUI::DropEvent& event) } } -void SoundPlayerWidgetAdvancedView::keydown_event(GUI::KeyEvent& event) +void SoundPlayerWidget::keydown_event(GUI::KeyEvent& event) { if (event.key() == Key_Up) m_volume_slider->increase_slider_by_page_steps(1); @@ -177,7 +177,7 @@ void SoundPlayerWidgetAdvancedView::keydown_event(GUI::KeyEvent& event) GUI::Widget::keydown_event(event); } -void SoundPlayerWidgetAdvancedView::set_playlist_visible(bool visible) +void SoundPlayerWidget::set_playlist_visible(bool visible) { if (!visible) { m_playlist_widget->remove_from_parent(); @@ -187,7 +187,7 @@ void SoundPlayerWidgetAdvancedView::set_playlist_visible(bool visible) } } -RefPtr SoundPlayerWidgetAdvancedView::get_image_from_music_file() +RefPtr SoundPlayerWidget::get_image_from_music_file() { auto const& pictures = this->pictures(); if (pictures.is_empty()) @@ -203,7 +203,7 @@ RefPtr SoundPlayerWidgetAdvancedView::get_image_from_music_file() return decoded_image.frames[0].bitmap; } -void SoundPlayerWidgetAdvancedView::play_state_changed(Player::PlayState state) +void SoundPlayerWidget::play_state_changed(Player::PlayState state) { sync_previous_next_actions(); @@ -220,34 +220,34 @@ void SoundPlayerWidgetAdvancedView::play_state_changed(Player::PlayState state) } } -void SoundPlayerWidgetAdvancedView::loop_mode_changed(Player::LoopMode) +void SoundPlayerWidget::loop_mode_changed(Player::LoopMode) { } -void SoundPlayerWidgetAdvancedView::mute_changed(bool muted) +void SoundPlayerWidget::mute_changed(bool muted) { m_mute_action->set_text(muted ? "Unmute"sv : "Mute"sv); m_mute_action->set_icon(muted ? m_muted_icon : m_volume_icon); m_volume_slider->set_enabled(!muted); } -void SoundPlayerWidgetAdvancedView::sync_previous_next_actions() +void SoundPlayerWidget::sync_previous_next_actions() { 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) +void SoundPlayerWidget::shuffle_mode_changed(Player::ShuffleMode) { sync_previous_next_actions(); } -void SoundPlayerWidgetAdvancedView::time_elapsed(int seconds) +void SoundPlayerWidget::time_elapsed(int seconds) { m_timestamp_label->set_text(String::formatted("Elapsed: {}", human_readable_digital_time(seconds)).release_value_but_fixme_should_propagate_errors()); } -void SoundPlayerWidgetAdvancedView::file_name_changed(StringView name) +void SoundPlayerWidget::file_name_changed(StringView name) { m_visualization->start_new_file(name); DeprecatedString title = name; @@ -263,13 +263,13 @@ void SoundPlayerWidgetAdvancedView::file_name_changed(StringView name) m_window.set_title(DeprecatedString::formatted("{} — Sound Player", title)); } -void SoundPlayerWidgetAdvancedView::total_samples_changed(int total_samples) +void SoundPlayerWidget::total_samples_changed(int total_samples) { m_playback_progress_slider->set_max(total_samples); m_playback_progress_slider->set_page_step(total_samples / 10); } -void SoundPlayerWidgetAdvancedView::sound_buffer_played(FixedArray const& buffer, int sample_rate, int samples_played) +void SoundPlayerWidget::sound_buffer_played(FixedArray const& buffer, int sample_rate, int samples_played) { m_visualization->set_buffer(buffer); m_visualization->set_samplerate(sample_rate); @@ -278,12 +278,12 @@ void SoundPlayerWidgetAdvancedView::sound_buffer_played(FixedArrayset_value(samples_played, GUI::AllowCallback::No); } -void SoundPlayerWidgetAdvancedView::volume_changed(double volume) +void SoundPlayerWidget::volume_changed(double volume) { m_volume_label->set_text(String::formatted("{}%", static_cast(volume * 100)).release_value_but_fixme_should_propagate_errors()); } -void SoundPlayerWidgetAdvancedView::playlist_loaded(StringView path, bool loaded) +void SoundPlayerWidget::playlist_loaded(StringView path, bool loaded) { if (!loaded) { GUI::MessageBox::show(&m_window, DeprecatedString::formatted("Could not load playlist at \"{}\".", path), "Error opening playlist"sv, GUI::MessageBox::Type::Error); @@ -293,7 +293,7 @@ void SoundPlayerWidgetAdvancedView::playlist_loaded(StringView path, bool loaded play_file_path(playlist().next()); } -void SoundPlayerWidgetAdvancedView::audio_load_error(StringView path, StringView error_string) +void SoundPlayerWidget::audio_load_error(StringView path, StringView error_string) { GUI::MessageBox::show(&m_window, DeprecatedString::formatted("Failed to load audio file: {} ({})", path, error_string.is_null() ? "Unknown error"sv : error_string), "Filetype error"sv, GUI::MessageBox::Type::Error); diff --git a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.h b/Userland/Applications/SoundPlayer/SoundPlayerWidget.h similarity index 93% rename from Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.h rename to Userland/Applications/SoundPlayer/SoundPlayerWidget.h index 51e335f1a3f..5977842661c 100644 --- a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.h +++ b/Userland/Applications/SoundPlayer/SoundPlayerWidget.h @@ -18,9 +18,9 @@ #include #include -class SoundPlayerWidgetAdvancedView final : public GUI::Widget +class SoundPlayerWidget final : public GUI::Widget , public Player { - C_OBJECT(SoundPlayerWidgetAdvancedView) + C_OBJECT(SoundPlayerWidget) public: void set_nonlinear_volume_slider(bool nonlinear); @@ -55,7 +55,7 @@ protected: void keydown_event(GUI::KeyEvent&) override; private: - SoundPlayerWidgetAdvancedView(GUI::Window&, Audio::ConnectionToServer&, ImageDecoderClient::Client&); + SoundPlayerWidget(GUI::Window&, Audio::ConnectionToServer&, ImageDecoderClient::Client&); void sync_previous_next_actions(); diff --git a/Userland/Applications/SoundPlayer/main.cpp b/Userland/Applications/SoundPlayer/main.cpp index 0df153da8a5..045b44ccd07 100644 --- a/Userland/Applications/SoundPlayer/main.cpp +++ b/Userland/Applications/SoundPlayer/main.cpp @@ -9,7 +9,7 @@ #include "BarsVisualizationWidget.h" #include "Player.h" #include "SampleWidget.h" -#include "SoundPlayerWidgetAdvancedView.h" +#include "SoundPlayerWidget.h" #include #include #include @@ -52,7 +52,7 @@ ErrorOr serenity_main(Main::Arguments arguments) window->set_icon(app_icon.bitmap_for_size(16)); // start in advanced view by default - Player* player = TRY(window->set_main_widget(window, audio_client, decoder_client)); + Player* player = TRY(window->set_main_widget(window, audio_client, decoder_client)); if (!file_path.is_empty()) { player->play_file_path(file_path); @@ -95,14 +95,14 @@ ErrorOr serenity_main(Main::Arguments arguments) playback_menu->add_action(loop_playlist); auto linear_volume_slider = GUI::Action::create_checkable("&Nonlinear Volume Slider", [&](auto& action) { - static_cast(player)->set_nonlinear_volume_slider(action.is_checked()); + static_cast(player)->set_nonlinear_volume_slider(action.is_checked()); }); TRY(playback_menu->try_add_separator()); TRY(playback_menu->try_add_action(linear_volume_slider)); TRY(playback_menu->try_add_separator()); auto playlist_toggle = GUI::Action::create_checkable("&Show Playlist", [&](auto& action) { - static_cast(player)->set_playlist_visible(action.is_checked()); + static_cast(player)->set_playlist_visible(action.is_checked()); }); if (player->loop_mode() == Player::LoopMode::Playlist) { playlist_toggle->set_checked(true); @@ -129,21 +129,21 @@ ErrorOr serenity_main(Main::Arguments arguments) }; auto bars = GUI::Action::create_checkable("&Bars", [&](auto&) { - static_cast(player)->set_visualization(); + static_cast(player)->set_visualization(); set_selected_visualization_in_config("bars"sv); }); TRY(visualization_menu->try_add_action(bars)); visualization_actions.add_action(bars); auto samples = GUI::Action::create_checkable("&Samples", [&](auto&) { - static_cast(player)->set_visualization(); + static_cast(player)->set_visualization(); set_selected_visualization_in_config("samples"sv); }); TRY(visualization_menu->try_add_action(samples)); visualization_actions.add_action(samples); auto album_cover_visualization = GUI::Action::create_checkable("&Album Cover", [&](auto&) { - auto* view = static_cast(player); + auto* view = static_cast(player); view->set_visualization([&view]() { return view->get_image_from_music_file(); });