mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 17:27:35 +00:00
AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
This commit is contained in:
parent
f74251606d
commit
6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions
|
@ -20,10 +20,10 @@ NonnullOwnPtr<M3UParser> M3UParser::from_file(StringView path)
|
|||
auto file_result = Core::Stream::File::open(path, Core::Stream::OpenMode::Read).release_value_but_fixme_should_propagate_errors();
|
||||
auto contents = file_result->read_all().release_value_but_fixme_should_propagate_errors();
|
||||
auto use_utf8 = path.ends_with(".m3u8"sv, CaseSensitivity::CaseInsensitive);
|
||||
return from_memory(String { contents, NoChomp }, use_utf8);
|
||||
return from_memory(DeprecatedString { contents, NoChomp }, use_utf8);
|
||||
}
|
||||
|
||||
NonnullOwnPtr<M3UParser> M3UParser::from_memory(String const& m3u_contents, bool utf8)
|
||||
NonnullOwnPtr<M3UParser> M3UParser::from_memory(DeprecatedString const& m3u_contents, bool utf8)
|
||||
{
|
||||
auto parser = make<M3UParser>();
|
||||
VERIFY(!m3u_contents.is_null() && !m3u_contents.is_empty() && !m3u_contents.is_whitespace());
|
||||
|
|
|
@ -6,44 +6,44 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
// Extended M3U fields (de facto standard)
|
||||
struct M3UExtendedInfo {
|
||||
Optional<u32> track_length_in_seconds;
|
||||
Optional<String> track_display_title;
|
||||
Optional<String> group_name;
|
||||
Optional<String> album_title;
|
||||
Optional<String> album_artist;
|
||||
Optional<String> album_genre;
|
||||
Optional<DeprecatedString> track_display_title;
|
||||
Optional<DeprecatedString> group_name;
|
||||
Optional<DeprecatedString> album_title;
|
||||
Optional<DeprecatedString> album_artist;
|
||||
Optional<DeprecatedString> album_genre;
|
||||
Optional<u64> file_size_in_bytes;
|
||||
Optional<ReadonlyBytes> embedded_mp3;
|
||||
Optional<String> cover_path;
|
||||
Optional<DeprecatedString> cover_path;
|
||||
};
|
||||
|
||||
struct M3UEntry {
|
||||
String path;
|
||||
DeprecatedString path;
|
||||
Optional<M3UExtendedInfo> extended_info;
|
||||
};
|
||||
|
||||
class M3UParser {
|
||||
public:
|
||||
static NonnullOwnPtr<M3UParser> from_file(StringView path);
|
||||
static NonnullOwnPtr<M3UParser> from_memory(String const& m3u_contents, bool utf8);
|
||||
static NonnullOwnPtr<M3UParser> from_memory(DeprecatedString const& m3u_contents, bool utf8);
|
||||
|
||||
NonnullOwnPtr<Vector<M3UEntry>> parse(bool include_extended_info);
|
||||
|
||||
Optional<String>& get_playlist_title_metadata() { return m_parsed_playlist_title; }
|
||||
Optional<DeprecatedString>& get_playlist_title_metadata() { return m_parsed_playlist_title; }
|
||||
|
||||
M3UParser();
|
||||
|
||||
private:
|
||||
String m_m3u_raw_data;
|
||||
String m_playlist_path;
|
||||
DeprecatedString m_m3u_raw_data;
|
||||
DeprecatedString m_playlist_path;
|
||||
bool m_use_utf8;
|
||||
Optional<String> m_parsed_playlist_title;
|
||||
Optional<DeprecatedString> m_parsed_playlist_title;
|
||||
};
|
||||
|
|
|
@ -40,7 +40,7 @@ Player::Player(Audio::ConnectionToServer& audio_client_connection)
|
|||
};
|
||||
}
|
||||
|
||||
void Player::play_file_path(String const& path)
|
||||
void Player::play_file_path(DeprecatedString const& path)
|
||||
{
|
||||
if (path.is_null())
|
||||
return;
|
||||
|
@ -71,7 +71,7 @@ void Player::play_file_path(String const& path)
|
|||
play();
|
||||
}
|
||||
|
||||
bool Player::is_playlist(String const& path)
|
||||
bool Player::is_playlist(DeprecatedString const& path)
|
||||
{
|
||||
return (path.ends_with(".m3u"sv, AK::CaseSensitivity::CaseInsensitive)
|
||||
|| path.ends_with(".m3u8"sv, AK::CaseSensitivity::CaseInsensitive));
|
||||
|
|
|
@ -35,11 +35,11 @@ public:
|
|||
explicit Player(Audio::ConnectionToServer& audio_client_connection);
|
||||
virtual ~Player() = default;
|
||||
|
||||
void play_file_path(String const& path);
|
||||
bool is_playlist(String const& path);
|
||||
void play_file_path(DeprecatedString const& path);
|
||||
bool is_playlist(DeprecatedString const& path);
|
||||
|
||||
Playlist& playlist() { return m_playlist; }
|
||||
String const& loaded_filename() const { return m_loaded_filename; }
|
||||
DeprecatedString const& loaded_filename() const { return m_loaded_filename; }
|
||||
|
||||
PlayState play_state() const { return m_play_state; }
|
||||
void set_play_state(PlayState);
|
||||
|
@ -97,7 +97,7 @@ private:
|
|||
Audio::ConnectionToServer& m_audio_client_connection;
|
||||
PlaybackManager m_playback_manager;
|
||||
|
||||
String m_loaded_filename;
|
||||
DeprecatedString m_loaded_filename;
|
||||
double m_volume { 0 };
|
||||
bool m_muted { false };
|
||||
};
|
||||
|
|
|
@ -36,7 +36,7 @@ void Playlist::try_fill_missing_info(Vector<M3UEntry>& entries, StringView path)
|
|||
|
||||
for (auto& entry : entries) {
|
||||
if (!LexicalPath { entry.path }.is_absolute())
|
||||
entry.path = String::formatted("{}/{}", playlist_path.dirname(), entry.path);
|
||||
entry.path = DeprecatedString::formatted("{}/{}", playlist_path.dirname(), entry.path);
|
||||
|
||||
if (!entry.extended_info->file_size_in_bytes.has_value()) {
|
||||
auto size = Core::File::size(entry.path);
|
||||
|
|
|
@ -56,24 +56,24 @@ GUI::Variant PlaylistModel::data(const GUI::ModelIndex& index, GUI::ModelRole ro
|
|||
return {};
|
||||
}
|
||||
|
||||
String PlaylistModel::format_filesize(u64 size_in_bytes)
|
||||
DeprecatedString PlaylistModel::format_filesize(u64 size_in_bytes)
|
||||
{
|
||||
if (size_in_bytes > GiB)
|
||||
return String::formatted("{:.2f} GiB", (double)size_in_bytes / GiB);
|
||||
return DeprecatedString::formatted("{:.2f} GiB", (double)size_in_bytes / GiB);
|
||||
else if (size_in_bytes > MiB)
|
||||
return String::formatted("{:.2f} MiB", (double)size_in_bytes / MiB);
|
||||
return DeprecatedString::formatted("{:.2f} MiB", (double)size_in_bytes / MiB);
|
||||
else if (size_in_bytes > KiB)
|
||||
return String::formatted("{:.2f} KiB", (double)size_in_bytes / KiB);
|
||||
return DeprecatedString::formatted("{:.2f} KiB", (double)size_in_bytes / KiB);
|
||||
else
|
||||
return String::formatted("{} B", size_in_bytes);
|
||||
return DeprecatedString::formatted("{} B", size_in_bytes);
|
||||
}
|
||||
|
||||
String PlaylistModel::format_duration(u32 duration_in_seconds)
|
||||
DeprecatedString PlaylistModel::format_duration(u32 duration_in_seconds)
|
||||
{
|
||||
return String::formatted("{:02}:{:02}:{:02}", duration_in_seconds / 3600, duration_in_seconds / 60, duration_in_seconds % 60);
|
||||
return DeprecatedString::formatted("{:02}:{:02}:{:02}", duration_in_seconds / 3600, duration_in_seconds / 60, duration_in_seconds % 60);
|
||||
}
|
||||
|
||||
String PlaylistModel::column_name(int column) const
|
||||
DeprecatedString PlaylistModel::column_name(int column) const
|
||||
{
|
||||
switch (column) {
|
||||
case 0:
|
||||
|
|
|
@ -24,14 +24,14 @@ public:
|
|||
int row_count(const GUI::ModelIndex&) const override { return m_playlist_items.size(); }
|
||||
int column_count(const GUI::ModelIndex&) const override { return 6; }
|
||||
GUI::Variant data(const GUI::ModelIndex&, GUI::ModelRole) const override;
|
||||
String column_name(int column) const override;
|
||||
DeprecatedString column_name(int column) const override;
|
||||
Vector<M3UEntry>& items() { return m_playlist_items; }
|
||||
|
||||
private:
|
||||
Vector<M3UEntry> m_playlist_items;
|
||||
|
||||
static String format_filesize(u64 size_in_bytes);
|
||||
static String format_duration(u32 duration_in_seconds);
|
||||
static DeprecatedString format_filesize(u64 size_in_bytes);
|
||||
static DeprecatedString format_duration(u32 duration_in_seconds);
|
||||
};
|
||||
|
||||
class PlaylistTableView : public GUI::TableView {
|
||||
|
|
|
@ -199,13 +199,13 @@ void SoundPlayerWidgetAdvancedView::shuffle_mode_changed(Player::ShuffleMode)
|
|||
|
||||
void SoundPlayerWidgetAdvancedView::time_elapsed(int seconds)
|
||||
{
|
||||
m_timestamp_label->set_text(String::formatted("Elapsed: {:02}:{:02}:{:02}", seconds / 3600, seconds / 60, seconds % 60));
|
||||
m_timestamp_label->set_text(DeprecatedString::formatted("Elapsed: {:02}:{:02}:{:02}", seconds / 3600, seconds / 60, seconds % 60));
|
||||
}
|
||||
|
||||
void SoundPlayerWidgetAdvancedView::file_name_changed(StringView name)
|
||||
{
|
||||
m_visualization->start_new_file(name);
|
||||
m_window.set_title(String::formatted("{} - Sound Player", name));
|
||||
m_window.set_title(DeprecatedString::formatted("{} - Sound Player", name));
|
||||
}
|
||||
|
||||
void SoundPlayerWidgetAdvancedView::total_samples_changed(int total_samples)
|
||||
|
@ -225,13 +225,13 @@ void SoundPlayerWidgetAdvancedView::sound_buffer_played(FixedArray<Audio::Sample
|
|||
|
||||
void SoundPlayerWidgetAdvancedView::volume_changed(double volume)
|
||||
{
|
||||
m_volume_label->set_text(String::formatted("{}%", static_cast<int>(volume * 100)));
|
||||
m_volume_label->set_text(DeprecatedString::formatted("{}%", static_cast<int>(volume * 100)));
|
||||
}
|
||||
|
||||
void SoundPlayerWidgetAdvancedView::playlist_loaded(StringView path, bool loaded)
|
||||
{
|
||||
if (!loaded) {
|
||||
GUI::MessageBox::show(&m_window, String::formatted("Could not load playlist at \"{}\".", path), "Error opening playlist"sv, GUI::MessageBox::Type::Error);
|
||||
GUI::MessageBox::show(&m_window, DeprecatedString::formatted("Could not load playlist at \"{}\".", path), "Error opening playlist"sv, GUI::MessageBox::Type::Error);
|
||||
return;
|
||||
}
|
||||
set_playlist_visible(true);
|
||||
|
@ -240,6 +240,6 @@ void SoundPlayerWidgetAdvancedView::playlist_loaded(StringView path, bool loaded
|
|||
|
||||
void SoundPlayerWidgetAdvancedView::audio_load_error(StringView path, StringView error_string)
|
||||
{
|
||||
GUI::MessageBox::show(&m_window, String::formatted("Failed to load audio file: {} ({})", path, error_string.is_null() ? "Unknown error"sv : 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);
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
|
||||
auto file_menu = TRY(window->try_add_menu("&File"));
|
||||
TRY(file_menu->try_add_action(GUI::CommonActions::make_open_action([&](auto&) {
|
||||
Optional<String> path = GUI::FilePicker::get_open_filepath(window, "Open sound file...");
|
||||
Optional<DeprecatedString> path = GUI::FilePicker::get_open_filepath(window, "Open sound file...");
|
||||
if (path.has_value()) {
|
||||
player->play_file_path(path.value());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue