mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:48:10 +00:00
SoundPlayer: Rename NoVisualization to AlbumCoverVisualization
Since the NoVisualization widget now shows the album cover, it should be called AlbumCoverVisualization instead.
This commit is contained in:
parent
2b1ac91764
commit
2470997fc9
4 changed files with 15 additions and 15 deletions
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Cesar Torres <shortanemoia@protonmail.com>
|
||||
* Copyright (c) 2022, the SerenityOS developers.
|
||||
* Copyright (c) 2022, Nícolas F. R. A. Prado <n@nfraprado.net>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include "AlbumCoverVisualizationWidget.h"
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibGUI/Painter.h>
|
||||
|
||||
void AlbumCoverVisualizationWidget::paint_event(GUI::PaintEvent& event)
|
||||
{
|
||||
Frame::paint_event(event);
|
||||
GUI::Painter painter(*this);
|
||||
|
||||
if (m_album_cover) {
|
||||
painter.draw_scaled_bitmap(frame_inner_rect(), *m_album_cover, m_album_cover->rect(), 1.0f);
|
||||
} else {
|
||||
if (!m_serenity_bg)
|
||||
m_serenity_bg = Gfx::Bitmap::try_load_from_file("/res/wallpapers/sunset-retro.png").release_value_but_fixme_should_propagate_errors();
|
||||
painter.draw_scaled_bitmap(frame_inner_rect(), *m_serenity_bg, m_serenity_bg->rect(), 1.0f);
|
||||
}
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<Gfx::Bitmap>> AlbumCoverVisualizationWidget::get_album_cover(StringView const filename)
|
||||
{
|
||||
auto directory = LexicalPath::dirname(filename);
|
||||
|
||||
static constexpr auto possible_cover_filenames = Array { "cover.png"sv, "cover.jpg"sv };
|
||||
for (auto& it : possible_cover_filenames) {
|
||||
LexicalPath cover_path = LexicalPath::join(directory, it);
|
||||
if (Core::File::exists(cover_path.string()))
|
||||
return Gfx::Bitmap::try_load_from_file(cover_path.string());
|
||||
}
|
||||
|
||||
return Error::from_string_literal("No cover file found");
|
||||
}
|
||||
|
||||
void AlbumCoverVisualizationWidget::start_new_file(StringView filename)
|
||||
{
|
||||
auto album_cover_or_error = get_album_cover(filename);
|
||||
if (album_cover_or_error.is_error())
|
||||
m_album_cover = nullptr;
|
||||
else
|
||||
m_album_cover = album_cover_or_error.value();
|
||||
}
|
||||
|
||||
void AlbumCoverVisualizationWidget::set_buffer(RefPtr<Audio::Buffer>)
|
||||
{
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue