1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 09:17:45 +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:
Linus Groh 2022-12-04 18:02:33 +00:00 committed by Andreas Kling
parent f74251606d
commit 6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions

View file

@ -155,7 +155,7 @@ ClockWidget::ClockWidget()
};
}
void ClockWidget::update_format(String const& format)
void ClockWidget::update_format(DeprecatedString const& format)
{
m_time_format = format;
m_time_width = font().width(Core::DateTime::create(122, 2, 22, 22, 22, 22).to_string(format));

View file

@ -24,7 +24,7 @@ class ClockWidget final : public GUI::Frame {
public:
virtual ~ClockWidget() override = default;
void update_format(String const&);
void update_format(DeprecatedString const&);
private:
ClockWidget();
@ -45,7 +45,7 @@ private:
void position_calendar_window();
void jump_to_current_date();
String m_time_format;
DeprecatedString m_time_format;
RefPtr<GUI::Window> m_calendar_window;
RefPtr<GUI::Calendar> m_calendar;
RefPtr<GUI::Button> m_next_date;

View file

@ -57,7 +57,7 @@ GUI::Icon QuickLaunchEntryExecutable::icon() const
return GUI::FileIconProvider::icon_for_executable(m_path);
}
String QuickLaunchEntryExecutable::name() const
DeprecatedString QuickLaunchEntryExecutable::name() const
{
return LexicalPath { m_path }.basename();
}
@ -76,7 +76,7 @@ GUI::Icon QuickLaunchEntryFile::icon() const
return GUI::FileIconProvider::icon_for_path(m_path);
}
String QuickLaunchEntryFile::name() const
DeprecatedString QuickLaunchEntryFile::name() const
{
// '=' is a special character in config files
return m_path;
@ -113,7 +113,7 @@ QuickLaunchWidget::QuickLaunchWidget()
OwnPtr<QuickLaunchEntry> QuickLaunchEntry::create_from_config_value(StringView value)
{
if (!value.starts_with('/') && value.ends_with(".af"sv)) {
auto af_path = String::formatted("{}/{}", Desktop::AppFile::APP_FILES_DIRECTORY, value);
auto af_path = DeprecatedString::formatted("{}/{}", Desktop::AppFile::APP_FILES_DIRECTORY, value);
return make<QuickLaunchEntryAppFile>(Desktop::AppFile::open(af_path));
}
return create_from_path(value);
@ -135,12 +135,12 @@ OwnPtr<QuickLaunchEntry> QuickLaunchEntry::create_from_path(StringView path)
return make<QuickLaunchEntryFile>(path);
}
static String sanitize_entry_name(String const& name)
static DeprecatedString sanitize_entry_name(DeprecatedString const& name)
{
return name.replace(" "sv, ""sv, ReplaceMode::All).replace("="sv, ""sv, ReplaceMode::All);
}
void QuickLaunchWidget::add_or_adjust_button(String const& button_name, NonnullOwnPtr<QuickLaunchEntry>&& entry)
void QuickLaunchWidget::add_or_adjust_button(DeprecatedString const& button_name, NonnullOwnPtr<QuickLaunchEntry>&& entry)
{
auto file_name_to_watch = entry->file_name_to_watch();
if (!file_name_to_watch.is_null()) {
@ -173,7 +173,7 @@ void QuickLaunchWidget::add_or_adjust_button(String const& button_name, NonnullO
auto result = entry->launch();
if (result.is_error()) {
// FIXME: This message box is displayed in a weird position
GUI::MessageBox::show_error(window(), String::formatted("Failed to open quick launch entry: {}", result.release_error()));
GUI::MessageBox::show_error(window(), DeprecatedString::formatted("Failed to open quick launch entry: {}", result.release_error()));
}
};
button->on_context_menu_request = [this, button_name](auto& context_menu_event) {
@ -182,7 +182,7 @@ void QuickLaunchWidget::add_or_adjust_button(String const& button_name, NonnullO
};
}
void QuickLaunchWidget::config_key_was_removed(String const& domain, String const& group, String const& key)
void QuickLaunchWidget::config_key_was_removed(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key)
{
if (domain == "Taskbar" && group == quick_launch) {
auto button = find_child_of_type_named<GUI::Button>(key);
@ -191,7 +191,7 @@ void QuickLaunchWidget::config_key_was_removed(String const& domain, String cons
}
}
void QuickLaunchWidget::config_string_did_change(String const& domain, String const& group, String const& key, String const& value)
void QuickLaunchWidget::config_string_did_change(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& value)
{
if (domain == "Taskbar" && group == quick_launch) {
auto entry = QuickLaunchEntry::create_from_config_value(value);

View file

@ -19,8 +19,8 @@ public:
virtual ~QuickLaunchEntry() = default;
virtual ErrorOr<void> launch() const = 0;
virtual GUI::Icon icon() const = 0;
virtual String name() const = 0;
virtual String file_name_to_watch() const = 0;
virtual DeprecatedString name() const = 0;
virtual DeprecatedString file_name_to_watch() const = 0;
static OwnPtr<QuickLaunchEntry> create_from_config_value(StringView path);
static OwnPtr<QuickLaunchEntry> create_from_path(StringView path);
@ -35,8 +35,8 @@ public:
virtual ErrorOr<void> launch() const override;
virtual GUI::Icon icon() const override { return m_app_file->icon(); }
virtual String name() const override { return m_app_file->name(); }
virtual String file_name_to_watch() const override { return {}; }
virtual DeprecatedString name() const override { return m_app_file->name(); }
virtual DeprecatedString file_name_to_watch() const override { return {}; }
private:
NonnullRefPtr<Desktop::AppFile> m_app_file;
@ -44,33 +44,33 @@ private:
class QuickLaunchEntryExecutable : public QuickLaunchEntry {
public:
explicit QuickLaunchEntryExecutable(String path)
explicit QuickLaunchEntryExecutable(DeprecatedString path)
: m_path(move(path))
{
}
virtual ErrorOr<void> launch() const override;
virtual GUI::Icon icon() const override;
virtual String name() const override;
virtual String file_name_to_watch() const override { return m_path; }
virtual DeprecatedString name() const override;
virtual DeprecatedString file_name_to_watch() const override { return m_path; }
private:
String m_path;
DeprecatedString m_path;
};
class QuickLaunchEntryFile : public QuickLaunchEntry {
public:
explicit QuickLaunchEntryFile(String path)
explicit QuickLaunchEntryFile(DeprecatedString path)
: m_path(move(path))
{
}
virtual ErrorOr<void> launch() const override;
virtual GUI::Icon icon() const override;
virtual String name() const override;
virtual String file_name_to_watch() const override { return m_path; }
virtual DeprecatedString name() const override;
virtual DeprecatedString file_name_to_watch() const override { return m_path; }
private:
String m_path;
DeprecatedString m_path;
};
class QuickLaunchWidget : public GUI::Frame
@ -80,18 +80,18 @@ class QuickLaunchWidget : public GUI::Frame
public:
virtual ~QuickLaunchWidget() override = default;
virtual void config_key_was_removed(String const&, String const&, String const&) override;
virtual void config_string_did_change(String const&, String const&, String const&, String const&) override;
virtual void config_key_was_removed(DeprecatedString const&, DeprecatedString const&, DeprecatedString const&) override;
virtual void config_string_did_change(DeprecatedString const&, DeprecatedString const&, DeprecatedString const&, DeprecatedString const&) override;
virtual void drag_enter_event(GUI::DragEvent&) override;
virtual void drop_event(GUI::DropEvent&) override;
private:
QuickLaunchWidget();
void add_or_adjust_button(String const&, NonnullOwnPtr<QuickLaunchEntry>&&);
void add_or_adjust_button(DeprecatedString const&, NonnullOwnPtr<QuickLaunchEntry>&&);
RefPtr<GUI::Menu> m_context_menu;
RefPtr<GUI::Action> m_context_menu_default_action;
String m_context_menu_app_name;
DeprecatedString m_context_menu_app_name;
RefPtr<Core::FileWatcher> m_watcher;
};

View file

@ -5,7 +5,7 @@
*/
#include "ShutdownDialog.h"
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/Vector.h>
#include <LibGUI/BoxLayout.h>
#include <LibGUI/Button.h>
@ -17,7 +17,7 @@
#include <LibGfx/Font/FontDatabase.h>
struct Option {
String title;
DeprecatedString title;
Vector<char const*> cmd;
bool enabled;
bool default_action;

View file

@ -87,7 +87,7 @@ TaskbarWindow::TaskbarWindow()
m_show_desktop_button->on_click = TaskbarWindow::show_desktop_button_clicked;
main_widget.add_child(*m_show_desktop_button);
auto af_path = String::formatted("{}/{}", Desktop::AppFile::APP_FILES_DIRECTORY, "Assistant.af");
auto af_path = DeprecatedString::formatted("{}/{}", Desktop::AppFile::APP_FILES_DIRECTORY, "Assistant.af");
m_assistant_app_file = Desktop::AppFile::open(af_path);
}
@ -106,7 +106,7 @@ void TaskbarWindow::add_system_menu(NonnullRefPtr<GUI::Menu> system_menu)
main->insert_child_before(*m_start_button, *m_quick_launch);
}
void TaskbarWindow::config_string_did_change(String const& domain, String const& group, String const& key, String const& value)
void TaskbarWindow::config_string_did_change(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& value)
{
if (domain == "Taskbar" && group == "Clock" && key == "TimeFormat") {
m_clock_widget->update_format(value);

View file

@ -26,14 +26,14 @@ public:
static int taskbar_height() { return 27; }
static int taskbar_icon_size() { return 16; }
virtual void config_string_did_change(String const&, String const&, String const&, String const&) override;
virtual void config_string_did_change(DeprecatedString const&, DeprecatedString const&, DeprecatedString const&, DeprecatedString const&) override;
virtual void add_system_menu(NonnullRefPtr<GUI::Menu> system_menu);
private:
explicit TaskbarWindow();
static void show_desktop_button_clicked(unsigned);
static void toggle_show_desktop();
void set_quick_launch_button_data(GUI::Button&, String const&, NonnullRefPtr<Desktop::AppFile>);
void set_quick_launch_button_data(GUI::Button&, DeprecatedString const&, NonnullRefPtr<Desktop::AppFile>);
void on_screen_rects_change(Vector<Gfx::IntRect, 4> const&, size_t);
NonnullRefPtr<GUI::Button> create_button(WindowIdentifier const&);
void add_window_button(::Window&, WindowIdentifier const&);

View file

@ -7,8 +7,8 @@
#pragma once
#include "WindowIdentifier.h"
#include <AK/DeprecatedString.h>
#include <AK/HashMap.h>
#include <AK/String.h>
#include <LibGUI/Button.h>
#include <LibGfx/Rect.h>
@ -27,8 +27,8 @@ public:
WindowIdentifier const& identifier() const { return m_identifier; }
String title() const { return m_title; }
void set_title(String const& title) { m_title = title; }
DeprecatedString title() const { return m_title; }
void set_title(DeprecatedString const& title) { m_title = title; }
Gfx::IntRect rect() const { return m_rect; }
void set_rect(Gfx::IntRect const& rect) { m_rect = rect; }
@ -68,7 +68,7 @@ public:
private:
WindowIdentifier m_identifier;
String m_title;
DeprecatedString m_title;
Gfx::IntRect m_rect;
RefPtr<GUI::Button> m_button;
RefPtr<Gfx::Bitmap> m_icon;

View file

@ -34,7 +34,7 @@
#include <sys/wait.h>
#include <unistd.h>
static ErrorOr<Vector<String>> discover_apps_and_categories();
static ErrorOr<Vector<DeprecatedString>> discover_apps_and_categories();
static ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu(GUI::Window&);
ErrorOr<int> serenity_main(Main::Arguments arguments)
@ -75,10 +75,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
struct AppMetadata {
String executable;
String name;
String category;
String working_directory;
DeprecatedString executable;
DeprecatedString name;
DeprecatedString category;
DeprecatedString working_directory;
GUI::Icon icon;
bool run_in_terminal;
bool requires_root;
@ -91,9 +91,9 @@ Vector<Gfx::SystemThemeMetaData> g_themes;
RefPtr<GUI::Menu> g_themes_menu;
GUI::ActionGroup g_themes_group;
ErrorOr<Vector<String>> discover_apps_and_categories()
ErrorOr<Vector<DeprecatedString>> discover_apps_and_categories()
{
HashTable<String> seen_app_categories;
HashTable<DeprecatedString> seen_app_categories;
Desktop::AppFile::for_each([&](auto af) {
if (access(af->executable().characters(), X_OK) == 0) {
g_apps.append({ af->executable(), af->name(), af->category(), af->working_directory(), af->icon(), af->run_in_terminal(), af->requires_root() });
@ -102,7 +102,7 @@ ErrorOr<Vector<String>> discover_apps_and_categories()
});
quick_sort(g_apps, [](auto& a, auto& b) { return a.name < b.name; });
Vector<String> sorted_app_categories;
Vector<DeprecatedString> sorted_app_categories;
TRY(sorted_app_categories.try_ensure_capacity(seen_app_categories.size()));
for (auto const& category : seen_app_categories)
sorted_app_categories.unchecked_append(category);
@ -113,7 +113,7 @@ ErrorOr<Vector<String>> discover_apps_and_categories()
ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu(GUI::Window& window)
{
Vector<String> const sorted_app_categories = TRY(discover_apps_and_categories());
Vector<DeprecatedString> const sorted_app_categories = TRY(discover_apps_and_categories());
auto system_menu = TRY(GUI::Menu::try_create("\xE2\x9A\xA1")); // HIGH VOLTAGE SIGN
system_menu->add_action(GUI::Action::create("&About SerenityOS", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/ladyball.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
@ -124,13 +124,13 @@ ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu(GUI::Window& window)
// First we construct all the necessary app category submenus.
auto category_icons = TRY(Core::ConfigFile::open("/res/icons/SystemMenu.ini"));
HashMap<String, NonnullRefPtr<GUI::Menu>> app_category_menus;
HashMap<DeprecatedString, NonnullRefPtr<GUI::Menu>> app_category_menus;
Function<void(String const&)> create_category_menu;
create_category_menu = [&](String const& category) {
Function<void(DeprecatedString const&)> create_category_menu;
create_category_menu = [&](DeprecatedString const& category) {
if (app_category_menus.contains(category))
return;
String parent_category, child_category = category;
DeprecatedString parent_category, child_category = category;
for (ssize_t i = category.length() - 1; i >= 0; i--) {
if (category[i] == '/') {
parent_category = category.substring(0, i);
@ -183,7 +183,7 @@ ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu(GUI::Window& window)
dbgln("Activated app with ID {}", app_identifier);
auto& app = g_apps[app_identifier];
char const* argv[4] { nullptr, nullptr, nullptr, nullptr };
auto pls_with_executable = String::formatted("/bin/pls {}", app.executable);
auto pls_with_executable = DeprecatedString::formatted("/bin/pls {}", app.executable);
if (app.run_in_terminal && !app.requires_root) {
argv[0] = "/bin/Terminal";
argv[1] = "-e";