mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 17:58:18 +03:00
SoundPlayer: Create only one playlist widget
Prior this change, opening a playlist always spawned a new widget. This could end up with having a few the same widgets, which you couldn't even close (besides the last one).
This commit is contained in:
parent
09685d0239
commit
83c412ee9e
Notes:
sideshowbarker
2024-07-19 17:15:28 +09:00
Author: https://github.com/krkk Commit: https://github.com/SerenityOS/serenity/commit/83c412ee9ef Pull-request: https://github.com/SerenityOS/serenity/pull/9803
@ -38,6 +38,10 @@ SoundPlayerWidgetAdvancedView::SoundPlayerWidgetAdvancedView(GUI::Window& window
|
||||
m_player_view = m_splitter->add<GUI::Widget>();
|
||||
m_playlist_model = adopt_ref(*new PlaylistModel());
|
||||
|
||||
m_playlist_widget = PlaylistWidget::construct();
|
||||
m_playlist_widget->set_data_model(m_playlist_model);
|
||||
m_playlist_widget->set_fixed_width(150);
|
||||
|
||||
m_player_view->set_layout<GUI::VerticalBoxLayout>();
|
||||
|
||||
m_play_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/play.png");
|
||||
@ -283,9 +287,9 @@ void SoundPlayerWidgetAdvancedView::read_playlist(StringView path)
|
||||
void SoundPlayerWidgetAdvancedView::set_playlist_visible(bool visible)
|
||||
{
|
||||
if (visible) {
|
||||
m_playlist_widget = m_player_view->parent_widget()->add<PlaylistWidget>();
|
||||
m_playlist_widget->set_data_model(m_playlist_model);
|
||||
m_playlist_widget->set_fixed_width(150);
|
||||
if (!m_playlist_widget->parent()) {
|
||||
m_player_view->parent_widget()->add_child(*m_playlist_widget);
|
||||
}
|
||||
} else {
|
||||
m_playlist_widget->remove_from_parent();
|
||||
m_player_view->set_max_width(window()->width());
|
||||
|
Loading…
Reference in New Issue
Block a user