1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 13:27:36 +00:00

Everywhere: Add sv suffix to strings relying on StringView(char const*)

Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
This commit is contained in:
sin-ack 2022-07-11 17:32:29 +00:00 committed by Andreas Kling
parent e5f09ea170
commit 3f3f45580a
762 changed files with 8315 additions and 8316 deletions

View file

@ -31,7 +31,7 @@ RefPtr<Mesh> WavefrontOBJLoader::load(Core::File& file)
if (object_line.starts_with("#"))
continue;
if (object_line.starts_with("vt")) {
if (object_line.starts_with("vt"sv)) {
auto tex_coord_line = object_line.split_view(' ');
if (tex_coord_line.size() != 3) {
dbgln("Wavefront: Malformed TexCoord line. Aborting.");
@ -44,7 +44,7 @@ RefPtr<Mesh> WavefrontOBJLoader::load(Core::File& file)
continue;
}
if (object_line.starts_with("vn")) {
if (object_line.starts_with("vn"sv)) {
auto normal_line = object_line.split_view(' ');
if (normal_line.size() != 4) {
dbgln("Wavefront: Malformed vertex normal line. Aborting.");

View file

@ -284,7 +284,7 @@ bool GLContextWidget::load_path(String const& filename)
auto file = Core::File::construct(filename);
if (!file->open(Core::OpenMode::ReadOnly) && file->error() != ENOENT) {
GUI::MessageBox::show(window(), String::formatted("Opening \"{}\" failed: {}", filename, strerror(errno)), "Error", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), String::formatted("Opening \"{}\" failed: {}", filename, strerror(errno)), "Error"sv, GUI::MessageBox::Type::Error);
return false;
}
@ -294,31 +294,31 @@ bool GLContextWidget::load_path(String const& filename)
bool GLContextWidget::load_file(Core::File& file)
{
auto const& filename = file.filename();
if (!filename.ends_with(".obj")) {
GUI::MessageBox::show(window(), String::formatted("Opening \"{}\" failed: invalid file type", filename), "Error", GUI::MessageBox::Type::Error);
if (!filename.ends_with(".obj"sv)) {
GUI::MessageBox::show(window(), String::formatted("Opening \"{}\" failed: invalid file type", filename), "Error"sv, GUI::MessageBox::Type::Error);
return false;
}
if (file.is_device()) {
GUI::MessageBox::show(window(), String::formatted("Opening \"{}\" failed: Can't open device files", filename), "Error", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), String::formatted("Opening \"{}\" failed: Can't open device files", filename), "Error"sv, GUI::MessageBox::Type::Error);
return false;
}
if (file.is_directory()) {
GUI::MessageBox::show(window(), String::formatted("Opening \"{}\" failed: Can't open directories", filename), "Error", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), String::formatted("Opening \"{}\" failed: Can't open directories", filename), "Error"sv, GUI::MessageBox::Type::Error);
return false;
}
auto new_mesh = m_mesh_loader->load(file);
if (new_mesh.is_null()) {
GUI::MessageBox::show(window(), String::formatted("Reading \"{}\" failed.", filename), "Error", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), String::formatted("Reading \"{}\" failed.", filename), "Error"sv, GUI::MessageBox::Type::Error);
return false;
}
// Determine whether or not a texture for this model resides within the same directory
StringBuilder builder;
builder.append(filename.split('.').at(0));
builder.append(".bmp");
builder.append(".bmp"sv);
String texture_path = Core::File::absolute_path(builder.string_view());
@ -368,7 +368,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
// Construct the main window
auto window = GUI::Window::construct();
auto app_icon = GUI::Icon::default_icon("app-3d-file-viewer");
auto app_icon = GUI::Icon::default_icon("app-3d-file-viewer"sv);
window->set_icon(app_icon.bitmap_for_size(16));
window->set_title("3D File Viewer");
window->resize(640 + 4, 480 + 4);

View file

@ -20,7 +20,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
auto app_icon = TRY(GUI::Icon::try_create_default_icon("ladyball"));
GUI::AboutDialog::show("SerenityOS", app_icon.bitmap_for_size(32), nullptr, app_icon.bitmap_for_size(16), Core::Version::read_long_version_string());
auto app_icon = TRY(GUI::Icon::try_create_default_icon("ladyball"sv));
GUI::AboutDialog::show("SerenityOS"sv, app_icon.bitmap_for_size(32), nullptr, app_icon.bitmap_for_size(16), Core::Version::read_long_version_string());
return app->exec();
}

View file

@ -130,7 +130,7 @@ void AnalogClock::paint_event(GUI::PaintEvent& event)
void AnalogClock::update_title_date()
{
window()->set_title(Core::DateTime::now().to_string("%Y-%m-%d"));
window()->set_title(Core::DateTime::now().to_string("%Y-%m-%d"sv));
}
void AnalogClock::context_menu_event(GUI::ContextMenuEvent& event)

View file

@ -24,9 +24,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-analog-clock"));
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-analog-clock"sv));
auto window = TRY(GUI::Window::try_create());
window->set_title(Core::DateTime::now().to_string("%Y-%m-%d"));
window->set_title(Core::DateTime::now().to_string("%Y-%m-%d"sv));
window->set_icon(app_icon.bitmap_for_size(16));
window->resize(170, 170);
window->set_resizable(false);

View file

@ -52,7 +52,7 @@ void TerminalResult::activate() const
// FIXME: This should be a GUI::Process::spawn_or_show_error(), however this is a
// Assistant::Result object, which does not have access to the application's GUI::Window* pointer
// (which spawn_or_show_error() needs incase it has to open a error message box).
(void)Core::Process::spawn("/bin/Terminal", Array { "-k", "-e", title().characters() });
(void)Core::Process::spawn("/bin/Terminal"sv, Array { "-k", "-e", title().characters() });
}
void URLResult::activate() const

View file

@ -72,7 +72,7 @@ class CalculatorResult final : public Result {
public:
explicit CalculatorResult(String title)
: Result(move(title), "'Enter' will copy to clipboard"sv, 100)
, m_bitmap(GUI::Icon::default_icon("app-calculator").bitmap_for_size(16))
, m_bitmap(GUI::Icon::default_icon("app-calculator"sv).bitmap_for_size(16))
{
}
~CalculatorResult() override = default;
@ -100,7 +100,7 @@ class TerminalResult final : public Result {
public:
explicit TerminalResult(String command)
: Result(move(command), "Run command in Terminal"sv, 100)
, m_bitmap(GUI::Icon::default_icon("app-terminal").bitmap_for_size(16))
, m_bitmap(GUI::Icon::default_icon("app-terminal"sv).bitmap_for_size(16))
{
}
~TerminalResult() override = default;
@ -116,7 +116,7 @@ class URLResult final : public Result {
public:
explicit URLResult(const URL& url)
: Result(url.to_string(), "'Enter' will open this URL in the browser"sv, 50)
, m_bitmap(GUI::Icon::default_icon("app-browser").bitmap_for_size(16))
, m_bitmap(GUI::Icon::default_icon("app-browser"sv).bitmap_for_size(16))
{
}
~URLResult() override = default;

View file

@ -45,7 +45,7 @@ static String bookmarks_file_path()
{
StringBuilder builder;
builder.append(Core::StandardPaths::config_directory());
builder.append("/bookmarks.json");
builder.append("/bookmarks.json"sv);
return builder.to_string();
}
@ -53,7 +53,7 @@ static String search_engines_file_path()
{
StringBuilder builder;
builder.append(Core::StandardPaths::config_directory());
builder.append("/SearchEngines.json");
builder.append("/SearchEngines.json"sv);
return builder.to_string();
}
@ -61,7 +61,7 @@ BrowserWindow::BrowserWindow(CookieJar& cookie_jar, URL url)
: m_cookie_jar(cookie_jar)
, m_window_actions(*this)
{
auto app_icon = GUI::Icon::default_icon("app-browser");
auto app_icon = GUI::Icon::default_icon("app-browser"sv);
m_bookmarks_bar = Browser::BookmarksBarWidget::construct(Browser::bookmarks_file_path(), true);
resize(730, 560);
@ -123,25 +123,25 @@ BrowserWindow::BrowserWindow(CookieJar& cookie_jar, URL url)
});
m_window_actions.on_about = [this] {
auto app_icon = GUI::Icon::default_icon("app-browser");
GUI::AboutDialog::show("Browser", app_icon.bitmap_for_size(32), this);
auto app_icon = GUI::Icon::default_icon("app-browser"sv);
GUI::AboutDialog::show("Browser"sv, app_icon.bitmap_for_size(32), this);
};
m_window_actions.on_show_bookmarks_bar = [](auto& action) {
Browser::BookmarksBarWidget::the().set_visible(action.is_checked());
Config::write_bool("Browser", "Preferences", "ShowBookmarksBar", action.is_checked());
Config::write_bool("Browser"sv, "Preferences"sv, "ShowBookmarksBar"sv, action.is_checked());
};
bool show_bookmarks_bar = Config::read_bool("Browser", "Preferences", "ShowBookmarksBar", true);
bool show_bookmarks_bar = Config::read_bool("Browser"sv, "Preferences"sv, "ShowBookmarksBar"sv, true);
m_window_actions.show_bookmarks_bar_action().set_checked(show_bookmarks_bar);
Browser::BookmarksBarWidget::the().set_visible(show_bookmarks_bar);
m_window_actions.on_vertical_tabs = [this](auto& action) {
m_tab_widget->set_tab_position(action.is_checked() ? GUI::TabWidget::TabPosition::Left : GUI::TabWidget::TabPosition::Top);
Config::write_bool("Browser", "Preferences", "VerticalTabs", action.is_checked());
Config::write_bool("Browser"sv, "Preferences"sv, "VerticalTabs"sv, action.is_checked());
};
bool vertical_tabs = Config::read_bool("Browser", "Preferences", "VerticalTabs", false);
bool vertical_tabs = Config::read_bool("Browser"sv, "Preferences"sv, "VerticalTabs"sv, false);
m_window_actions.vertical_tabs_action().set_checked(vertical_tabs);
m_tab_widget->set_tab_position(vertical_tabs ? GUI::TabWidget::TabPosition::Left : GUI::TabWidget::TabPosition::Top);
@ -258,13 +258,13 @@ void BrowserWindow::build_menus()
m_change_homepage_action = GUI::Action::create(
"Set Homepage URL...", g_icon_bag.go_home, [this](auto&) {
auto homepage_url = Config::read_string("Browser", "Preferences", "Home", "about:blank");
if (GUI::InputBox::show(this, homepage_url, "Enter URL", "Change homepage URL") == GUI::InputBox::ExecResult::OK) {
auto homepage_url = Config::read_string("Browser"sv, "Preferences"sv, "Home"sv, "about:blank"sv);
if (GUI::InputBox::show(this, homepage_url, "Enter URL"sv, "Change homepage URL"sv) == GUI::InputBox::ExecResult::OK) {
if (URL(homepage_url).is_valid()) {
Config::write_string("Browser", "Preferences", "Home", homepage_url);
Config::write_string("Browser"sv, "Preferences"sv, "Home"sv, homepage_url);
Browser::g_home_url = homepage_url;
} else {
GUI::MessageBox::show_error(this, "The URL you have entered is not valid");
GUI::MessageBox::show_error(this, "The URL you have entered is not valid"sv);
}
}
},
@ -280,13 +280,13 @@ void BrowserWindow::build_menus()
auto& color_scheme_menu = settings_menu.add_submenu("&Color Scheme");
color_scheme_menu.set_icon(g_icon_bag.color_chooser);
{
auto current_setting = Web::CSS::preferred_color_scheme_from_string(Config::read_string("Browser", "Preferences", "ColorScheme", "auto"));
auto current_setting = Web::CSS::preferred_color_scheme_from_string(Config::read_string("Browser"sv, "Preferences"sv, "ColorScheme"sv, "auto"sv));
m_color_scheme_actions.set_exclusive(true);
auto add_color_scheme_action = [&](auto& name, Web::CSS::PreferredColorScheme preference_value) {
auto action = GUI::Action::create_checkable(
name, [=, this](auto&) {
Config::write_string("Browser", "Preferences", "ColorScheme", Web::CSS::preferred_color_scheme_to_string(preference_value));
Config::write_string("Browser"sv, "Preferences"sv, "ColorScheme"sv, Web::CSS::preferred_color_scheme_to_string(preference_value));
active_tab().view().set_preferred_color_scheme(preference_value);
},
this);
@ -302,9 +302,9 @@ void BrowserWindow::build_menus()
}
settings_menu.add_separator();
auto open_settings_action = GUI::Action::create("&Settings", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/settings.png").release_value_but_fixme_should_propagate_errors(),
auto open_settings_action = GUI::Action::create("&Settings", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/settings.png"sv).release_value_but_fixme_should_propagate_errors(),
[this](auto&) {
GUI::Process::spawn_or_show_error(this, "/bin/BrowserSettings");
GUI::Process::spawn_or_show_error(this, "/bin/BrowserSettings"sv);
});
settings_menu.add_action(move(open_settings_action));
@ -385,7 +385,7 @@ void BrowserWindow::build_menus()
auto custom_user_agent = GUI::Action::create_checkable("Custom...", [this](auto& action) {
String user_agent;
if (GUI::InputBox::show(this, user_agent, "Enter User Agent:", "Custom User Agent") != GUI::InputBox::ExecResult::OK || user_agent.is_empty() || user_agent.is_null()) {
if (GUI::InputBox::show(this, user_agent, "Enter User Agent:"sv, "Custom User Agent"sv) != GUI::InputBox::ExecResult::OK || user_agent.is_empty() || user_agent.is_null()) {
m_disable_user_agent_spoofing->activate();
return;
}
@ -426,7 +426,7 @@ ErrorOr<void> BrowserWindow::load_search_engines(GUI::Menu& settings_menu)
m_disable_search_engine_action = GUI::Action::create_checkable(
"Disable", [](auto&) {
g_search_engine = {};
Config::write_string("Browser", "Preferences", "SearchEngine", g_search_engine);
Config::write_string("Browser"sv, "Preferences"sv, "SearchEngine"sv, g_search_engine);
},
this);
search_engine_menu.add_action(*m_disable_search_engine_action);
@ -444,13 +444,13 @@ ErrorOr<void> BrowserWindow::load_search_engines(GUI::Menu& settings_menu)
if (!json_item.is_object())
continue;
auto search_engine = json_item.as_object();
auto name = search_engine.get("title").to_string();
auto url_format = search_engine.get("url_format").to_string();
auto name = search_engine.get("title"sv).to_string();
auto url_format = search_engine.get("url_format"sv).to_string();
auto action = GUI::Action::create_checkable(
name, [&, url_format](auto&) {
g_search_engine = url_format;
Config::write_string("Browser", "Preferences", "SearchEngine", g_search_engine);
Config::write_string("Browser"sv, "Preferences"sv, "SearchEngine"sv, g_search_engine);
},
this);
search_engine_menu.add_action(action);
@ -467,20 +467,20 @@ ErrorOr<void> BrowserWindow::load_search_engines(GUI::Menu& settings_menu)
auto custom_search_engine_action = GUI::Action::create_checkable("Custom...", [&](auto& action) {
String search_engine;
if (GUI::InputBox::show(this, search_engine, "Enter URL template:", "Custom Search Engine", "https://host/search?q={}") != GUI::InputBox::ExecResult::OK || search_engine.is_empty()) {
if (GUI::InputBox::show(this, search_engine, "Enter URL template:"sv, "Custom Search Engine"sv, "https://host/search?q={}"sv) != GUI::InputBox::ExecResult::OK || search_engine.is_empty()) {
m_disable_search_engine_action->activate();
return;
}
auto argument_count = search_engine.count("{}"sv);
if (argument_count != 1) {
GUI::MessageBox::show(this, "Invalid format, must contain '{}' once!", "Error", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(this, "Invalid format, must contain '{}' once!"sv, "Error"sv, GUI::MessageBox::Type::Error);
m_disable_search_engine_action->activate();
return;
}
g_search_engine = search_engine;
Config::write_string("Browser", "Preferences", "SearchEngine", g_search_engine);
Config::write_string("Browser"sv, "Preferences"sv, "SearchEngine"sv, g_search_engine);
action.set_status_tip(search_engine);
});
search_engine_menu.add_action(custom_search_engine_action);
@ -608,7 +608,7 @@ void BrowserWindow::config_string_did_change(String const& domain, String const&
Browser::g_home_url = value;
else if (key == "NewTab")
Browser::g_new_tab_url = value;
} else if (group.starts_with("Proxy:")) {
} else if (group.starts_with("Proxy:"sv)) {
dbgln("Proxy mapping changed: {}/{} = {}", group, key, value);
auto proxy_spec = group.substring_view(6);
auto existing_proxy = Browser::g_proxies.find(proxy_spec);

View file

@ -25,7 +25,7 @@ ConsoleWidget::ConsoleWidget()
set_fill_with_background_color(true);
m_output_view = add<WebView::OutOfProcessWebView>();
m_output_view->load("data:text/html,<html></html>");
m_output_view->load("data:text/html,<html></html>"sv);
// Wait until our output WebView is loaded, and then request any messages that occurred before we existed
m_output_view->on_load_finish = [this](auto&) {
if (on_request_messages)
@ -130,9 +130,9 @@ void ConsoleWidget::handle_console_messages(i32 start_index, Vector<String> cons
void ConsoleWidget::print_source_line(StringView source)
{
StringBuilder html;
html.append("<span class=\"repl-indicator\">");
html.append("&gt; ");
html.append("</span>");
html.append("<span class=\"repl-indicator\">"sv);
html.append("&gt; "sv);
html.append("</span>"sv);
html.append(JS::MarkupGenerator::html_from_source(source));
@ -147,7 +147,7 @@ void ConsoleWidget::print_html(StringView line)
if (parent_id == 0) {
builder.append(R"~~~(
var parentGroup = document.body;
)~~~");
)~~~"sv);
} else {
builder.appendff(R"~~~(
var parentGroup = document.getElementById("group_{}");
@ -157,11 +157,11 @@ void ConsoleWidget::print_html(StringView line)
builder.append(R"~~~(
var p = document.createElement("p");
p.innerHTML = ")~~~");
p.innerHTML = ")~~~"sv);
builder.append_escaped_for_json(line);
builder.append(R"~~~("
parentGroup.appendChild(p);
)~~~");
)~~~"sv);
m_output_view->run_javascript(builder.string_view());
// FIXME: Make it scroll to the bottom, using `window.scrollTo()` in the JS above.
// We used to call `m_output_view->scroll_to_bottom();` here, but that does not work because
@ -174,7 +174,7 @@ void ConsoleWidget::clear_output()
m_group_stack.clear();
m_output_view->run_javascript(R"~~~(
document.body.innerHTML = "";
)~~~");
)~~~"sv);
}
void ConsoleWidget::begin_group(StringView label, bool start_expanded)
@ -184,7 +184,7 @@ void ConsoleWidget::begin_group(StringView label, bool start_expanded)
if (parent_id == 0) {
builder.append(R"~~~(
var parentGroup = document.body;
)~~~");
)~~~"sv);
} else {
builder.appendff(R"~~~(
var parentGroup = document.getElementById("group_{}");
@ -206,10 +206,10 @@ void ConsoleWidget::begin_group(StringView label, bool start_expanded)
builder.append(R"~~~(";
group.appendChild(label);
parentGroup.appendChild(group);
)~~~");
)~~~"sv);
if (start_expanded)
builder.append("group.open = true;");
builder.append("group.open = true;"sv);
m_output_view->run_javascript(builder.string_view());
// FIXME: Scroll console to bottom - see note in print_html()

View file

@ -29,7 +29,7 @@ String CookieJar::get_cookie(const URL& url, Web::Cookie::Source source)
for (auto const& cookie : cookie_list) {
// If there is an unprocessed cookie in the cookie-list, output the characters %x3B and %x20 ("; ")
if (!builder.is_empty())
builder.append("; ");
builder.append("; "sv);
// Output the cookie's name, the %x3D ("=") character, and the cookie's value.
builder.appendff("{}={}", cookie.name, cookie.value);
@ -50,9 +50,9 @@ void CookieJar::set_cookie(const URL& url, Web::Cookie::ParsedCookie const& pars
void CookieJar::dump_cookies() const
{
constexpr StringView key_color = "\033[34;1m";
constexpr StringView attribute_color = "\033[33m";
constexpr StringView no_color = "\033[0m";
constexpr auto key_color = "\033[34;1m"sv;
constexpr auto attribute_color = "\033[33m"sv;
constexpr auto no_color = "\033[0m"sv;
StringBuilder builder;
builder.appendff("{} cookies stored\n", m_cookies.size());

View file

@ -37,7 +37,7 @@ DownloadWidget::DownloadWidget(const URL& url)
m_destination_path = builder.to_string();
}
auto close_on_finish = Config::read_bool("Browser", "Preferences", "CloseDownloadWidgetOnFinish", false);
auto close_on_finish = Config::read_bool("Browser"sv, "Preferences"sv, "CloseDownloadWidgetOnFinish"sv, false);
m_elapsed_timer.start();
m_download = Web::ResourceLoader::the().connector().start_request("GET", url);
@ -49,7 +49,7 @@ DownloadWidget::DownloadWidget(const URL& url)
{
auto file_or_error = Core::Stream::File::open(m_destination_path, Core::Stream::OpenMode::Write);
if (file_or_error.is_error()) {
GUI::MessageBox::show(window(), String::formatted("Cannot open {} for writing", m_destination_path), "Download failed", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), String::formatted("Cannot open {} for writing", m_destination_path), "Download failed"sv, GUI::MessageBox::Type::Error);
window()->close();
return;
}
@ -68,7 +68,7 @@ DownloadWidget::DownloadWidget(const URL& url)
auto& animation_layout = animation_container.set_layout<GUI::HorizontalBoxLayout>();
m_browser_image = animation_container.add<GUI::ImageWidget>();
m_browser_image->load_from_file("/res/graphics/download-animation.gif");
m_browser_image->load_from_file("/res/graphics/download-animation.gif"sv);
animation_layout.add_spacer();
auto& source_label = add<GUI::Label>(String::formatted("From: {}", url));
@ -90,7 +90,7 @@ DownloadWidget::DownloadWidget(const URL& url)
m_close_on_finish_checkbox->set_checked(close_on_finish);
m_close_on_finish_checkbox->on_checked = [&](bool checked) {
Config::write_bool("Browser", "Preferences", "CloseDownloadWidgetOnFinish", checked);
Config::write_bool("Browser"sv, "Preferences"sv, "CloseDownloadWidgetOnFinish"sv, checked);
};
auto& button_container = add<GUI::Widget>();
@ -126,7 +126,7 @@ void DownloadWidget::did_progress(Optional<u32> total_size, u32 downloaded_size)
{
StringBuilder builder;
builder.append("Downloaded ");
builder.append("Downloaded "sv);
builder.append(human_readable_size(downloaded_size));
builder.appendff(" in {} sec", m_elapsed_timer.elapsed() / 1000);
m_progress_label->set_text(builder.to_string());
@ -140,7 +140,7 @@ void DownloadWidget::did_progress(Optional<u32> total_size, u32 downloaded_size)
} else {
builder.append(human_readable_size(downloaded_size));
}
builder.append(" of ");
builder.append(" of "sv);
builder.append(m_url.basename());
window()->set_title(builder.to_string());
}
@ -150,7 +150,7 @@ void DownloadWidget::did_finish(bool success)
{
dbgln("did_finish, success={}", success);
m_browser_image->load_from_file("/res/graphics/download-finished.gif");
m_browser_image->load_from_file("/res/graphics/download-finished.gif"sv);
window()->set_title("Download finished!");
m_close_button->set_enabled(true);
m_cancel_button->set_text("Open in Folder");
@ -161,7 +161,7 @@ void DownloadWidget::did_finish(bool success)
m_cancel_button->update();
if (!success) {
GUI::MessageBox::show(window(), String::formatted("Download failed for some reason"), "Download failed", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), String::formatted("Download failed for some reason"), "Download failed"sv, GUI::MessageBox::Type::Error);
window()->close();
return;
}

View file

@ -83,7 +83,7 @@ void ElementSizePreviewWidget::paint_event(GUI::PaintEvent& event)
draw_borders(margin_rect, Color::Black);
margin_rect.shrink(1, 1, 1, 1);
margin_rect.shrink(text_height_padding, text_width_padding, text_height_padding, text_width_padding);
painter.draw_text(margin_rect, "margin", font(), Gfx::TextAlignment::TopLeft, Color::Black);
painter.draw_text(margin_rect, "margin"sv, font(), Gfx::TextAlignment::TopLeft, Color::Black);
draw_size_texts(margin_rect, Color::Black, m_node_box_sizing.margin);
// paint border box
@ -91,7 +91,7 @@ void ElementSizePreviewWidget::paint_event(GUI::PaintEvent& event)
draw_borders(border_rect, Color::Black);
border_rect.shrink(1, 1, 1, 1);
border_rect.shrink(text_height_padding, text_width_padding, text_height_padding, text_width_padding);
painter.draw_text(border_rect, "border", font(), Gfx::TextAlignment::TopLeft, Color::Black);
painter.draw_text(border_rect, "border"sv, font(), Gfx::TextAlignment::TopLeft, Color::Black);
draw_size_texts(border_rect, Color::Black, m_node_box_sizing.border);
// paint padding box
@ -99,7 +99,7 @@ void ElementSizePreviewWidget::paint_event(GUI::PaintEvent& event)
draw_borders(padding_rect, Color::Black);
padding_rect.shrink(1, 1, 1, 1);
padding_rect.shrink(text_height_padding, text_width_padding, text_height_padding, text_width_padding);
painter.draw_text(padding_rect, "padding", font(), Gfx::TextAlignment::TopLeft, Color::Black);
painter.draw_text(padding_rect, "padding"sv, font(), Gfx::TextAlignment::TopLeft, Color::Black);
draw_size_texts(padding_rect, Color::Black, m_node_box_sizing.padding);
// paint content box

View file

@ -12,30 +12,30 @@ ErrorOr<IconBag> IconBag::try_create()
{
IconBag icon_bag;
icon_bag.filetype_html = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-html.png"));
icon_bag.filetype_text = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-text.png"));
icon_bag.filetype_javascript = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-javascript.png"));
icon_bag.bookmark_contour = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bookmark-contour.png"));
icon_bag.bookmark_filled = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bookmark-filled.png"));
icon_bag.inspector_object = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png"));
icon_bag.go_home = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-home.png"));
icon_bag.find = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"));
icon_bag.color_chooser = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/color-chooser.png"));
icon_bag.delete_icon = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png"));
icon_bag.new_tab = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-tab.png"));
icon_bag.duplicate_tab = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/duplicate-tab.png"));
icon_bag.code = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/code.png"));
icon_bag.dom_tree = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/browser/dom-tree.png"));
icon_bag.layout = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/layout.png"));
icon_bag.layers = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/layers.png"));
icon_bag.filetype_css = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-css.png"));
icon_bag.inspect = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspect.png"));
icon_bag.history = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/history.png"));
icon_bag.cookie = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/browser/cookie.png"));
icon_bag.local_storage = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/browser/local-storage.png"));
icon_bag.trash_can = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/trash-can.png"));
icon_bag.clear_cache = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/browser/clear-cache.png"));
icon_bag.spoof = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/spoof.png"));
icon_bag.filetype_html = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-html.png"sv));
icon_bag.filetype_text = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-text.png"sv));
icon_bag.filetype_javascript = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-javascript.png"sv));
icon_bag.bookmark_contour = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bookmark-contour.png"sv));
icon_bag.bookmark_filled = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bookmark-filled.png"sv));
icon_bag.inspector_object = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png"sv));
icon_bag.go_home = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-home.png"sv));
icon_bag.find = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"sv));
icon_bag.color_chooser = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/color-chooser.png"sv));
icon_bag.delete_icon = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png"sv));
icon_bag.new_tab = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-tab.png"sv));
icon_bag.duplicate_tab = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/duplicate-tab.png"sv));
icon_bag.code = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/code.png"sv));
icon_bag.dom_tree = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/browser/dom-tree.png"sv));
icon_bag.layout = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/layout.png"sv));
icon_bag.layers = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/layers.png"sv));
icon_bag.filetype_css = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-css.png"sv));
icon_bag.inspect = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspect.png"sv));
icon_bag.history = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/history.png"sv));
icon_bag.cookie = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/browser/cookie.png"sv));
icon_bag.local_storage = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/browser/local-storage.png"sv));
icon_bag.trash_can = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/trash-can.png"sv));
icon_bag.clear_cache = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/browser/clear-cache.png"sv));
icon_bag.spoof = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/spoof.png"sv));
return icon_bag;
}

View file

@ -50,11 +50,11 @@ void InspectorWidget::set_selection(GUI::ModelIndex const index)
VERIFY(json);
Selection selection {};
if (json->has_u32("pseudo-element")) {
selection.dom_node_id = json->get("parent-id").to_i32();
selection.pseudo_element = static_cast<Web::CSS::Selector::PseudoElement>(json->get("pseudo-element").to_u32());
if (json->has_u32("pseudo-element"sv)) {
selection.dom_node_id = json->get("parent-id"sv).to_i32();
selection.pseudo_element = static_cast<Web::CSS::Selector::PseudoElement>(json->get("pseudo-element"sv).to_u32());
} else {
selection.dom_node_id = json->get("id").to_i32();
selection.dom_node_id = json->get("id"sv).to_i32();
}
if (selection == m_selection)
@ -186,21 +186,21 @@ void InspectorWidget::update_node_box_model(Optional<String> node_box_sizing_jso
auto json_value = json_or_error.release_value();
auto const& json_object = json_value.as_object();
m_node_box_sizing.margin.top = json_object.get("margin_top").to_float();
m_node_box_sizing.margin.right = json_object.get("margin_right").to_float();
m_node_box_sizing.margin.bottom = json_object.get("margin_bottom").to_float();
m_node_box_sizing.margin.left = json_object.get("margin_left").to_float();
m_node_box_sizing.padding.top = json_object.get("padding_top").to_float();
m_node_box_sizing.padding.right = json_object.get("padding_right").to_float();
m_node_box_sizing.padding.bottom = json_object.get("padding_bottom").to_float();
m_node_box_sizing.padding.left = json_object.get("padding_left").to_float();
m_node_box_sizing.border.top = json_object.get("border_top").to_float();
m_node_box_sizing.border.right = json_object.get("border_right").to_float();
m_node_box_sizing.border.bottom = json_object.get("border_bottom").to_float();
m_node_box_sizing.border.left = json_object.get("border_left").to_float();
m_node_box_sizing.margin.top = json_object.get("margin_top"sv).to_float();
m_node_box_sizing.margin.right = json_object.get("margin_right"sv).to_float();
m_node_box_sizing.margin.bottom = json_object.get("margin_bottom"sv).to_float();
m_node_box_sizing.margin.left = json_object.get("margin_left"sv).to_float();
m_node_box_sizing.padding.top = json_object.get("padding_top"sv).to_float();
m_node_box_sizing.padding.right = json_object.get("padding_right"sv).to_float();
m_node_box_sizing.padding.bottom = json_object.get("padding_bottom"sv).to_float();
m_node_box_sizing.padding.left = json_object.get("padding_left"sv).to_float();
m_node_box_sizing.border.top = json_object.get("border_top"sv).to_float();
m_node_box_sizing.border.right = json_object.get("border_right"sv).to_float();
m_node_box_sizing.border.bottom = json_object.get("border_bottom"sv).to_float();
m_node_box_sizing.border.left = json_object.get("border_left"sv).to_float();
m_element_size_view->set_node_content_width(json_object.get("content_width").to_float());
m_element_size_view->set_node_content_height(json_object.get("content_height").to_float());
m_element_size_view->set_node_content_width(json_object.get("content_width"sv).to_float());
m_element_size_view->set_node_content_height(json_object.get("content_height"sv).to_float());
m_element_size_view->set_box_model(m_node_box_sizing);
}

View file

@ -25,7 +25,7 @@ StorageWidget::StorageWidget()
m_cookies_model = adopt_ref(*new CookiesModel());
m_cookies_filtering_model = MUST(GUI::FilteringProxyModel::create(*m_cookies_model));
m_cookies_filtering_model->set_filter_term("");
m_cookies_filtering_model->set_filter_term(""sv);
m_cookies_textbox->on_change = [this] {
m_cookies_filtering_model->set_filter_term(m_cookies_textbox->text());
@ -42,7 +42,7 @@ StorageWidget::StorageWidget()
m_local_storage_model = adopt_ref(*new StorageModel());
m_local_storage_filtering_model = MUST(GUI::FilteringProxyModel::create(*m_local_storage_model));
m_local_storage_filtering_model->set_filter_term("");
m_local_storage_filtering_model->set_filter_term(""sv);
m_local_storage_textbox->on_change = [this] {
m_local_storage_filtering_model->set_filter_term(m_local_storage_textbox->text());
@ -59,7 +59,7 @@ StorageWidget::StorageWidget()
m_session_storage_model = adopt_ref(*new StorageModel());
m_session_storage_filtering_model = MUST(GUI::FilteringProxyModel::create(*m_session_storage_model));
m_session_storage_filtering_model->set_filter_term("");
m_session_storage_filtering_model->set_filter_term(""sv);
m_session_storage_textbox->on_change = [this] {
m_session_storage_filtering_model->set_filter_term(m_session_storage_textbox->text());

View file

@ -42,8 +42,8 @@ namespace Browser {
URL url_from_user_input(String const& input)
{
if (input.starts_with("?") && !g_search_engine.is_empty())
return URL(g_search_engine.replace("{}", URL::percent_encode(input.substring_view(1)), ReplaceMode::FirstOnly));
if (input.starts_with('?') && !g_search_engine.is_empty())
return URL(g_search_engine.replace("{}"sv, URL::percent_encode(input.substring_view(1)), ReplaceMode::FirstOnly));
URL url_with_http_schema = URL(String::formatted("http://{}", input));
if (url_with_http_schema.is_valid() && url_with_http_schema.port().has_value())
@ -150,7 +150,7 @@ Tab::Tab(BrowserWindow& window)
toolbar.add_action(window.reload_action());
m_location_box = toolbar.add<GUI::UrlBox>();
m_location_box->set_placeholder("Address");
m_location_box->set_placeholder("Address"sv);
m_location_box->on_return_pressed = [this] {
auto url = url_from_location_bar();
@ -166,7 +166,7 @@ Tab::Tab(BrowserWindow& window)
m_location_box->add_custom_context_menu_action(GUI::Action::create("Paste && Go", [this](auto&) {
auto [data, mime_type, _] = GUI::Clipboard::the().fetch_data_and_type();
if (!mime_type.starts_with("text/"))
if (!mime_type.starts_with("text/"sv))
return;
auto const& paste_text = data;
if (paste_text.is_empty())
@ -400,7 +400,7 @@ Tab::Tab(BrowserWindow& window)
Optional<URL> Tab::url_from_location_bar(MayAppendTLD may_append_tld)
{
if (m_location_box->text().starts_with('?') && g_search_engine.is_empty()) {
GUI::MessageBox::show(&this->window(), "Select a search engine in the Settings menu before searching.", "No search engine selected", GUI::MessageBox::Type::Information);
GUI::MessageBox::show(&this->window(), "Select a search engine in the Settings menu before searching."sv, "No search engine selected"sv, GUI::MessageBox::Type::Information);
return {};
}
@ -410,8 +410,8 @@ Optional<URL> Tab::url_from_location_bar(MayAppendTLD may_append_tld)
builder.append(text);
if (may_append_tld == MayAppendTLD::Yes) {
// FIXME: Expand the list of top level domains.
if (!(text.ends_with(".com") || text.ends_with(".net") || text.ends_with(".org"))) {
builder.append(".com");
if (!(text.ends_with(".com"sv) || text.ends_with(".net"sv) || text.ends_with(".org"sv))) {
builder.append(".com"sv);
}
}
String final_text = builder.to_string();

View file

@ -66,7 +66,7 @@ WindowActions::WindowActions(GUI::Window& window)
m_tab_actions.last().set_status_tip("Switch to last tab");
m_about_action = GUI::Action::create(
"&About Browser", GUI::Icon::default_icon("app-browser").bitmap_for_size(16), [this](const GUI::Action&) {
"&About Browser", GUI::Icon::default_icon("app-browser"sv).bitmap_for_size(16), [this](const GUI::Action&) {
if (on_about)
on_about();
},

View file

@ -93,22 +93,22 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
Web::ResourceLoader::initialize(TRY(WebView::RequestServerAdapter::try_create()));
auto app_icon = GUI::Icon::default_icon("app-browser");
auto app_icon = GUI::Icon::default_icon("app-browser"sv);
Browser::g_home_url = Config::read_string("Browser", "Preferences", "Home", "file:///res/html/misc/welcome.html");
Browser::g_new_tab_url = Config::read_string("Browser", "Preferences", "NewTab", "file:///res/html/misc/new-tab.html");
Browser::g_search_engine = Config::read_string("Browser", "Preferences", "SearchEngine", {});
Browser::g_content_filters_enabled = Config::read_bool("Browser", "Preferences", "EnableContentFilters", true);
Browser::g_home_url = Config::read_string("Browser"sv, "Preferences"sv, "Home"sv, "file:///res/html/misc/welcome.html"sv);
Browser::g_new_tab_url = Config::read_string("Browser"sv, "Preferences"sv, "NewTab"sv, "file:///res/html/misc/new-tab.html"sv);
Browser::g_search_engine = Config::read_string("Browser"sv, "Preferences"sv, "SearchEngine"sv, {});
Browser::g_content_filters_enabled = Config::read_bool("Browser"sv, "Preferences"sv, "EnableContentFilters"sv, true);
Browser::g_icon_bag = TRY(Browser::IconBag::try_create());
TRY(load_content_filters());
for (auto& group : Config::list_groups("Browser")) {
if (!group.starts_with("Proxy:"))
for (auto& group : Config::list_groups("Browser"sv)) {
if (!group.starts_with("Proxy:"sv))
continue;
for (auto& key : Config::list_keys("Browser", group)) {
for (auto& key : Config::list_keys("Browser"sv, group)) {
auto proxy_spec = group.substring_view(6);
auto existing_proxy = Browser::g_proxies.find(proxy_spec);
if (existing_proxy.is_end())

View file

@ -62,22 +62,22 @@ BrowserSettingsWidget::BrowserSettingsWidget()
load_from_gml(browser_settings_widget_gml);
m_homepage_url_textbox = find_descendant_of_type_named<GUI::TextBox>("homepage_url_textbox");
m_homepage_url_textbox->set_text(Config::read_string("Browser", "Preferences", "Home", default_homepage_url), GUI::AllowCallback::No);
m_homepage_url_textbox->set_text(Config::read_string("Browser"sv, "Preferences"sv, "Home"sv, default_homepage_url), GUI::AllowCallback::No);
m_homepage_url_textbox->on_change = [&]() { set_modified(true); };
m_new_tab_url_textbox = find_descendant_of_type_named<GUI::TextBox>("new_tab_url_textbox");
m_new_tab_url_textbox->set_text(Config::read_string("Browser", "Preferences", "NewTab", default_new_tab_url), GUI::AllowCallback::No);
m_new_tab_url_textbox->set_text(Config::read_string("Browser"sv, "Preferences"sv, "NewTab"sv, default_new_tab_url), GUI::AllowCallback::No);
m_new_tab_url_textbox->on_change = [&]() { set_modified(true); };
m_color_scheme_combobox = find_descendant_of_type_named<GUI::ComboBox>("color_scheme_combobox");
m_color_scheme_combobox->set_only_allow_values_from_model(true);
m_color_scheme_combobox->set_model(adopt_ref(*new ColorSchemeModel()));
m_color_scheme_combobox->set_selected_index(0, GUI::AllowCallback::No);
set_color_scheme(Config::read_string("Browser", "Preferences", "ColorScheme", default_color_scheme));
set_color_scheme(Config::read_string("Browser"sv, "Preferences"sv, "ColorScheme"sv, default_color_scheme));
m_color_scheme_combobox->on_change = [&](auto, auto) { set_modified(true); };
m_show_bookmarks_bar_checkbox = find_descendant_of_type_named<GUI::CheckBox>("show_bookmarks_bar_checkbox");
m_show_bookmarks_bar_checkbox->set_checked(Config::read_bool("Browser", "Preferences", "ShowBookmarksBar", default_show_bookmarks_bar), GUI::AllowCallback::No);
m_show_bookmarks_bar_checkbox->set_checked(Config::read_bool("Browser"sv, "Preferences"sv, "ShowBookmarksBar"sv, default_show_bookmarks_bar), GUI::AllowCallback::No);
m_show_bookmarks_bar_checkbox->on_checked = [&](auto) { set_modified(true); };
m_enable_search_engine_checkbox = find_descendant_of_type_named<GUI::CheckBox>("enable_search_engine_checkbox");
@ -111,10 +111,10 @@ BrowserSettingsWidget::BrowserSettingsWidget()
m_custom_search_engine_group->set_enabled(m_is_custom_search_engine);
set_modified(true);
};
set_search_engine_url(Config::read_string("Browser", "Preferences", "SearchEngine", default_search_engine));
set_search_engine_url(Config::read_string("Browser"sv, "Preferences"sv, "SearchEngine"sv, default_search_engine));
m_auto_close_download_windows_checkbox = find_descendant_of_type_named<GUI::CheckBox>("auto_close_download_windows_checkbox");
m_auto_close_download_windows_checkbox->set_checked(Config::read_bool("Browser", "Preferences", "CloseDownloadWidgetOnFinish", default_auto_close_download_windows), GUI::AllowCallback::No);
m_auto_close_download_windows_checkbox->set_checked(Config::read_bool("Browser"sv, "Preferences"sv, "CloseDownloadWidgetOnFinish"sv, default_auto_close_download_windows), GUI::AllowCallback::No);
m_auto_close_download_windows_checkbox->on_checked = [&](auto) { set_modified(true); };
}
@ -170,39 +170,39 @@ void BrowserSettingsWidget::apply_settings()
{
auto homepage_url = m_homepage_url_textbox->text();
if (!URL(homepage_url).is_valid()) {
GUI::MessageBox::show_error(this->window(), "The homepage URL you have entered is not valid");
GUI::MessageBox::show_error(this->window(), "The homepage URL you have entered is not valid"sv);
m_homepage_url_textbox->select_all();
m_homepage_url_textbox->set_focus(true);
return;
}
Config::write_string("Browser", "Preferences", "Home", homepage_url);
Config::write_string("Browser"sv, "Preferences"sv, "Home"sv, homepage_url);
auto new_tab_url = m_new_tab_url_textbox->text();
if (!URL(new_tab_url).is_valid()) {
GUI::MessageBox::show_error(this->window(), "The new tab URL you have entered is not valid");
GUI::MessageBox::show_error(this->window(), "The new tab URL you have entered is not valid"sv);
m_new_tab_url_textbox->select_all();
m_new_tab_url_textbox->set_focus(true);
return;
}
Config::write_string("Browser", "Preferences", "NewTab", new_tab_url);
Config::write_string("Browser"sv, "Preferences"sv, "NewTab"sv, new_tab_url);
Config::write_bool("Browser", "Preferences", "ShowBookmarksBar", m_show_bookmarks_bar_checkbox->is_checked());
Config::write_bool("Browser"sv, "Preferences"sv, "ShowBookmarksBar"sv, m_show_bookmarks_bar_checkbox->is_checked());
auto color_scheme_index = m_color_scheme_combobox->selected_index();
auto color_scheme = m_color_scheme_combobox->model()->index(color_scheme_index, 1).data().to_string();
Config::write_string("Browser", "Preferences", "ColorScheme", color_scheme);
Config::write_string("Browser"sv, "Preferences"sv, "ColorScheme"sv, color_scheme);
if (!m_enable_search_engine_checkbox->is_checked()) {
Config::write_string("Browser", "Preferences", "SearchEngine", {});
Config::write_string("Browser"sv, "Preferences"sv, "SearchEngine"sv, {});
} else if (m_is_custom_search_engine) {
Config::write_string("Browser", "Preferences", "SearchEngine", m_custom_search_engine_textbox->text());
Config::write_string("Browser"sv, "Preferences"sv, "SearchEngine"sv, m_custom_search_engine_textbox->text());
} else {
auto selected_index = m_search_engine_combobox->selected_index();
auto url = m_search_engine_combobox->model()->index(selected_index, 1).data().to_string();
Config::write_string("Browser", "Preferences", "SearchEngine", url);
Config::write_string("Browser"sv, "Preferences"sv, "SearchEngine"sv, url);
}
Config::write_bool("Browser", "Preferences", "CloseDownloadWidgetOnFinish", m_auto_close_download_windows_checkbox->is_checked());
Config::write_bool("Browser"sv, "Preferences"sv, "CloseDownloadWidgetOnFinish"sv, m_auto_close_download_windows_checkbox->is_checked());
}
void BrowserSettingsWidget::reset_default_values()

View file

@ -114,13 +114,13 @@ ContentFilterSettingsWidget::ContentFilterSettingsWidget()
m_domain_list_view = find_descendant_of_type_named<GUI::ListView>("domain_list_view");
m_add_new_domain_button = find_descendant_of_type_named<GUI::Button>("add_new_domain_button");
m_enable_content_filtering_checkbox->set_checked(Config::read_bool("Browser", "Preferences", "EnableContentFilters", s_default_enable_content_filtering), GUI::AllowCallback::No);
m_enable_content_filtering_checkbox->set_checked(Config::read_bool("Browser"sv, "Preferences"sv, "EnableContentFilters"sv, s_default_enable_content_filtering), GUI::AllowCallback::No);
m_enable_content_filtering_checkbox->on_checked = [&](auto) { set_modified(true); };
m_add_new_domain_button->on_click = [&](unsigned) {
String text;
if (GUI::InputBox::show(window(), text, "Enter domain name", "Add domain to Content Filter") == GUI::Dialog::ExecResult::OK
if (GUI::InputBox::show(window(), text, "Enter domain name"sv, "Add domain to Content Filter"sv) == GUI::Dialog::ExecResult::OK
&& !text.is_empty()) {
m_domain_list_model->add_domain(std::move(text));
set_modified(true);
@ -151,7 +151,7 @@ void ContentFilterSettingsWidget::apply_settings()
{
// FIXME: Propagate errors
MUST(m_domain_list_model->save());
Config::write_bool("Browser", "Preferences", "EnableContentFilters", m_enable_content_filtering_checkbox->is_checked());
Config::write_bool("Browser"sv, "Preferences"sv, "EnableContentFilters"sv, m_enable_content_filtering_checkbox->is_checked());
}
void ContentFilterSettingsWidget::reset_default_values()

View file

@ -30,12 +30,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::unveil("/home/anon/.config/BrowserContentFilters.txt", "rwc"));
TRY(Core::System::unveil(nullptr, nullptr));
auto app_icon = GUI::Icon::default_icon("app-browser");
auto app_icon = GUI::Icon::default_icon("app-browser"sv);
auto window = TRY(GUI::SettingsWindow::create("Browser Settings", GUI::SettingsWindow::ShowDefaultsButton::Yes));
window->set_icon(app_icon.bitmap_for_size(16));
(void)TRY(window->add_tab<BrowserSettingsWidget>("Browser", "browser"));
(void)TRY(window->add_tab<ContentFilterSettingsWidget>("Content Filtering", "content-filtering"));
(void)TRY(window->add_tab<BrowserSettingsWidget>("Browser"sv, "browser"sv));
(void)TRY(window->add_tab<ContentFilterSettingsWidget>("Content Filtering"sv, "content-filtering"sv));
window->set_active_tab(selected_tab);
window->show();

View file

@ -27,7 +27,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
auto app_icon = GUI::Icon::default_icon("app-calculator");
auto app_icon = GUI::Icon::default_icon("app-calculator"sv);
auto window = TRY(GUI::Window::try_create());
window->set_title("Calculator");
@ -57,13 +57,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}));
auto& constants_menu = window->add_menu("&Constants");
constants_menu.add_action(GUI::Action::create("&Pi", TRY(Gfx::Bitmap::try_load_from_file("/res/icons/calculator/pi.png")), [&](auto&) {
constants_menu.add_action(GUI::Action::create("&Pi", TRY(Gfx::Bitmap::try_load_from_file("/res/icons/calculator/pi.png"sv)), [&](auto&) {
widget->set_entry(KeypadValue { 31415926535, 10 });
}));
constants_menu.add_action(GUI::Action::create("&Euler's Number", TRY(Gfx::Bitmap::try_load_from_file("/res/icons/calculator/eulers_number.png")), [&](auto&) {
constants_menu.add_action(GUI::Action::create("&Euler's Number", TRY(Gfx::Bitmap::try_load_from_file("/res/icons/calculator/eulers_number.png"sv)), [&](auto&) {
widget->set_entry(KeypadValue { 27182818284, 10 });
}));
constants_menu.add_action(GUI::Action::create("&Phi", TRY(Gfx::Bitmap::try_load_from_file("/res/icons/calculator/phi.png")), [&](auto&) {
constants_menu.add_action(GUI::Action::create("&Phi", TRY(Gfx::Bitmap::try_load_from_file("/res/icons/calculator/phi.png"sv)), [&](auto&) {
widget->set_entry(KeypadValue { 16180339887, 10 });
}));

View file

@ -31,7 +31,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-calendar"));
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-calendar"sv));
auto window = TRY(GUI::Window::try_create());
window->set_title("Calendar");
window->resize(600, 480);
@ -44,7 +44,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto toolbar = main_widget->find_descendant_of_type_named<GUI::Toolbar>("toolbar");
auto calendar = main_widget->find_descendant_of_type_named<GUI::Calendar>("calendar");
auto prev_date_action = GUI::Action::create({}, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png")), [&](const GUI::Action&) {
auto prev_date_action = GUI::Action::create({}, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"sv)), [&](const GUI::Action&) {
unsigned view_month = calendar->view_month();
unsigned view_year = calendar->view_year();
if (calendar->mode() == GUI::Calendar::Month) {
@ -59,7 +59,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
calendar->update_tiles(view_year, view_month);
});
auto next_date_action = GUI::Action::create({}, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png")), [&](const GUI::Action&) {
auto next_date_action = GUI::Action::create({}, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"sv)), [&](const GUI::Action&) {
unsigned view_month = calendar->view_month();
unsigned view_year = calendar->view_year();
if (calendar->mode() == GUI::Calendar::Month) {
@ -74,22 +74,22 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
calendar->update_tiles(view_year, view_month);
});
auto add_event_action = GUI::Action::create("&Add Event", {}, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/add-event.png")), [&](const GUI::Action&) {
auto add_event_action = GUI::Action::create("&Add Event", {}, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/add-event.png"sv)), [&](const GUI::Action&) {
AddEventDialog::show(calendar->selected_date(), window);
});
auto jump_to_action = GUI::Action::create("Jump to &Today", {}, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/calendar-date.png")), [&](const GUI::Action&) {
auto jump_to_action = GUI::Action::create("Jump to &Today", {}, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/calendar-date.png"sv)), [&](const GUI::Action&) {
calendar->set_selected_date(Core::DateTime::now());
calendar->update_tiles(Core::DateTime::now().year(), Core::DateTime::now().month());
});
auto view_month_action = GUI::Action::create_checkable("&Month View", { Mod_Ctrl, KeyCode::Key_1 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/calendar-month-view.png")), [&](const GUI::Action&) {
auto view_month_action = GUI::Action::create_checkable("&Month View", { Mod_Ctrl, KeyCode::Key_1 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/calendar-month-view.png"sv)), [&](const GUI::Action&) {
if (calendar->mode() == GUI::Calendar::Year)
calendar->toggle_mode();
});
view_month_action->set_checked(true);
auto view_year_action = GUI::Action::create_checkable("&Year View", { Mod_Ctrl, KeyCode::Key_2 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/icon-view.png")), [&](const GUI::Action&) {
auto view_year_action = GUI::Action::create_checkable("&Year View", { Mod_Ctrl, KeyCode::Key_2 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/icon-view.png"sv)), [&](const GUI::Action&) {
if (calendar->mode() == GUI::Calendar::Month)
calendar->toggle_mode();
});
@ -117,7 +117,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
};
auto& file_menu = window->add_menu("&File");
file_menu.add_action(GUI::Action::create("&Add Event", { Mod_Ctrl | Mod_Shift, Key_E }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/add-event.png")),
file_menu.add_action(GUI::Action::create("&Add Event", { Mod_Ctrl | Mod_Shift, Key_E }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/add-event.png"sv)),
[&](const GUI::Action&) {
AddEventDialog::show(calendar->selected_date(), window);
}));

View file

@ -37,11 +37,11 @@ CharacterMapWidget::CharacterMapWidget()
m_statusbar = find_descendant_of_type_named<GUI::Statusbar>("statusbar");
m_unicode_block_listview = find_descendant_of_type_named<GUI::ListView>("unicode_block_listview");
m_choose_font_action = GUI::Action::create("Choose Font...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
m_choose_font_action = GUI::Action::create("Choose Font...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
auto font_picker = GUI::FontPicker::construct(window(), &font(), false);
if (font_picker->exec() == GUI::Dialog::ExecResult::OK) {
auto& font = *font_picker->font();
Config::write_string("CharacterMap", "History", "Font", font.qualified_name());
Config::write_string("CharacterMap"sv, "History"sv, "Font"sv, font.qualified_name());
set_font(font);
}
});
@ -58,19 +58,19 @@ CharacterMapWidget::CharacterMapWidget()
});
m_copy_selection_action->set_status_tip("Copy the highlighted characters to the clipboard");
m_previous_glyph_action = GUI::Action::create("Previous character", { Mod_Alt, Key_Left }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
m_previous_glyph_action = GUI::Action::create("Previous character", { Mod_Alt, Key_Left }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
m_glyph_map->select_previous_existing_glyph();
});
m_previous_glyph_action->set_status_tip("Seek the previous visible glyph");
m_next_glyph_action = GUI::Action::create("&Next Glyph", { Mod_Alt, Key_Right }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
m_next_glyph_action = GUI::Action::create("&Next Glyph", { Mod_Alt, Key_Right }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
m_glyph_map->select_next_existing_glyph();
});
m_next_glyph_action->set_status_tip("Seek the next visible glyph");
m_go_to_glyph_action = GUI::Action::create("Go to glyph...", { Mod_Ctrl, Key_G }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-to.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
m_go_to_glyph_action = GUI::Action::create("Go to glyph...", { Mod_Ctrl, Key_G }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-to.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
String input;
if (GUI::InputBox::show(window(), input, "Hexadecimal:", "Go to glyph") == GUI::InputBox::ExecResult::OK && !input.is_empty()) {
if (GUI::InputBox::show(window(), input, "Hexadecimal:"sv, "Go to glyph"sv) == GUI::InputBox::ExecResult::OK && !input.is_empty()) {
auto maybe_code_point = AK::StringUtils::convert_to_uint_from_hex(input);
if (!maybe_code_point.has_value())
return;
@ -83,7 +83,7 @@ CharacterMapWidget::CharacterMapWidget()
});
m_go_to_glyph_action->set_status_tip("Go to the specified code point");
m_find_glyphs_action = GUI::Action::create("&Find glyphs...", { Mod_Ctrl, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
m_find_glyphs_action = GUI::Action::create("&Find glyphs...", { Mod_Ctrl, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
if (m_find_window.is_null()) {
m_find_window = GUI::Window::construct(window());
auto& search_widget = m_find_window->set_main_widget<CharacterSearchWidget>();
@ -91,7 +91,7 @@ CharacterMapWidget::CharacterMapWidget()
m_glyph_map->set_active_glyph(code_point);
m_glyph_map->scroll_to_glyph(code_point);
};
m_find_window->set_icon(GUI::Icon::try_create_default_icon("find").value().bitmap_for_size(16));
m_find_window->set_icon(GUI::Icon::try_create_default_icon("find"sv).value().bitmap_for_size(16));
m_find_window->set_title("Find a character");
m_find_window->resize(300, 400);
}
@ -159,7 +159,7 @@ void CharacterMapWidget::initialize_menubar(GUI::Window& window)
help_menu.add_action(GUI::CommonActions::make_help_action([&](auto&) {
Desktop::Launcher::open(URL::create_with_file_protocol("/usr/share/man/man1/CharacterMap.md"), "/bin/Help");
}));
help_menu.add_action(GUI::CommonActions::make_about_action("Character Map", GUI::Icon::default_icon("app-character-map"), &window));
help_menu.add_action(GUI::CommonActions::make_about_action("Character Map", GUI::Icon::default_icon("app-character-map"sv), &window));
}
void CharacterMapWidget::did_change_font()

View file

@ -24,7 +24,7 @@ static void search_and_print_results(String const& query)
for_each_character_containing(query, [&](auto code_point, auto display_name) {
StringBuilder builder;
builder.append_code_point(code_point);
builder.append(" - ");
builder.append(" - "sv);
builder.append(display_name);
outln(builder.string_view());
result_count++;
@ -62,7 +62,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return 0;
}
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-character-map"));
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-character-map"sv));
auto window = TRY(GUI::Window::try_create());
window->set_title("Character Map");
window->set_icon(app_icon.bitmap_for_size(16));
@ -71,7 +71,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto character_map_widget = TRY(window->try_set_main_widget<CharacterMapWidget>());
character_map_widget->initialize_menubar(*window);
auto font_query = Config::read_string("CharacterMap", "History", "Font", Gfx::FontDatabase::the().default_font_query());
auto font_query = Config::read_string("CharacterMap"sv, "History"sv, "Font"sv, Gfx::FontDatabase::the().default_font_query());
character_map_widget->set_font(Gfx::FontDatabase::the().get_by_name(font_query));
window->show();

View file

@ -14,10 +14,10 @@
#include <LibGUI/RadioButton.h>
#include <LibGUI/TextBox.h>
constexpr StringView time_format_12h = "%I:%M %p";
constexpr StringView time_format_12h_seconds = "%r";
constexpr StringView time_format_24h = "%R";
constexpr StringView time_format_24h_seconds = "%T";
constexpr auto time_format_12h = "%I:%M %p"sv;
constexpr auto time_format_12h_seconds = "%r"sv;
constexpr auto time_format_24h = "%R"sv;
constexpr auto time_format_24h_seconds = "%T"sv;
ClockSettingsWidget::ClockSettingsWidget()
{
@ -29,7 +29,7 @@ ClockSettingsWidget::ClockSettingsWidget()
auto& custom_radio = *find_descendant_of_type_named<GUI::RadioButton>("custom_radio");
m_clock_preview = *find_descendant_of_type_named<GUI::Label>("clock_preview");
m_time_format = Config::read_string("Taskbar", "Clock", "TimeFormat");
m_time_format = Config::read_string("Taskbar"sv, "Clock"sv, "TimeFormat"sv);
m_custom_format_input = *find_descendant_of_type_named<GUI::TextBox>("custom_format_input");
m_custom_format_input->set_text(m_time_format);
m_custom_format_input->set_enabled(false);
@ -96,14 +96,14 @@ ClockSettingsWidget::ClockSettingsWidget()
void ClockSettingsWidget::apply_settings()
{
Config::write_string("Taskbar", "Clock", "TimeFormat", m_custom_format_input->text());
Config::write_string("Taskbar"sv, "Clock"sv, "TimeFormat"sv, m_custom_format_input->text());
}
void ClockSettingsWidget::reset_default_values()
{
m_24_hour_radio->set_checked(true);
m_show_seconds_checkbox->set_checked(true);
Config::write_string("Taskbar", "Clock", "TimeFormat", time_format_24h_seconds);
Config::write_string("Taskbar"sv, "Clock"sv, "TimeFormat"sv, time_format_24h_seconds);
}
void ClockSettingsWidget::update_time_format_string()

View file

@ -62,7 +62,7 @@ TimeZoneSettingsWidget::TimeZoneSettingsWidget()
m_time_zone_map = *find_descendant_of_type_named<GUI::ImageWidget>("time_zone_map");
m_time_zone_map->set_bitmap(time_zone_map_bitmap);
auto time_zone_marker = Gfx::Bitmap::try_load_from_file("/res/icons/32x32/ladyball.png").release_value_but_fixme_should_propagate_errors();
auto time_zone_marker = Gfx::Bitmap::try_load_from_file("/res/icons/32x32/ladyball.png"sv).release_value_but_fixme_should_propagate_errors();
m_time_zone_marker = time_zone_marker->scaled(0.75f, 0.75f).release_value_but_fixme_should_propagate_errors();
set_time_zone_location();
@ -159,5 +159,5 @@ Optional<Gfx::FloatPoint> TimeZoneSettingsWidget::compute_time_zone_location() c
void TimeZoneSettingsWidget::set_time_zone()
{
GUI::Process::spawn_or_show_error(window(), "/bin/timezone", Array { m_time_zone.characters() });
GUI::Process::spawn_or_show_error(window(), "/bin/timezone"sv, Array { m_time_zone.characters() });
}

View file

@ -33,11 +33,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::unveil("/etc/timezone", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
auto app_icon = GUI::Icon::default_icon("app-analog-clock"); // FIXME: Create a ClockSettings icon.
auto app_icon = GUI::Icon::default_icon("app-analog-clock"sv); // FIXME: Create a ClockSettings icon.
auto window = TRY(GUI::SettingsWindow::create("Clock Settings", GUI::SettingsWindow::ShowDefaultsButton::Yes));
(void)TRY(window->add_tab<ClockSettingsWidget>("Clock", "clock"));
(void)TRY(window->add_tab<TimeZoneSettingsWidget>("Time Zone", "time-zone"));
(void)TRY(window->add_tab<ClockSettingsWidget>("Clock"sv, "clock"sv));
(void)TRY(window->add_tab<TimeZoneSettingsWidget>("Time Zone"sv, "time-zone"sv));
window->set_icon(app_icon.bitmap_for_size(16));
window->resize(540, 570);
window->set_active_tab(selected_tab);

View file

@ -73,9 +73,9 @@ static TitleAndText build_backtrace(Coredump::Reader const& coredump, ELF::Core:
};
if (metadata.contains("assertion"))
prepend_metadata("assertion", "ASSERTION FAILED: {}");
prepend_metadata("assertion", "ASSERTION FAILED: {}"sv);
else if (metadata.contains("pledge_violation"))
prepend_metadata("pledge_violation", "Has not pledged {}");
prepend_metadata("pledge_violation", "Has not pledged {}"sv);
auto fault_address = metadata.get("fault_address");
auto fault_type = metadata.get("fault_type");
@ -168,7 +168,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto pid = coredump->process_pid();
auto termination_signal = coredump->process_termination_signal();
auto app_icon = GUI::Icon::default_icon("app-crash-reporter");
auto app_icon = GUI::Icon::default_icon("app-crash-reporter"sv);
auto window = TRY(GUI::Window::try_create());
window->set_title("Crash Reporter");
@ -263,16 +263,16 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
};
auto& debug_button = *widget->find_descendant_of_type_named<GUI::Button>("debug_button");
debug_button.set_icon(TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-hack-studio.png")));
debug_button.set_icon(TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-hack-studio.png"sv)));
debug_button.on_click = [&](int) {
GUI::Process::spawn_or_show_error(window, "/bin/HackStudio", Array { "-c", coredump_path.characters() });
GUI::Process::spawn_or_show_error(window, "/bin/HackStudio"sv, Array { "-c", coredump_path.characters() });
};
auto& save_backtrace_button = *widget->find_descendant_of_type_named<GUI::Button>("save_backtrace_button");
save_backtrace_button.set_icon(TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/save.png")));
save_backtrace_button.set_icon(TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/save.png"sv)));
save_backtrace_button.on_click = [&](auto) {
if (full_backtrace.is_empty()) {
GUI::MessageBox::show(window, "Backtrace has not been generated yet. Please wait...", "Empty Backtrace", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window, "Backtrace has not been generated yet. Please wait..."sv, "Empty Backtrace"sv, GUI::MessageBox::Type::Error);
return;
}
@ -283,7 +283,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto file = file_or_error.value();
if (!file->write(full_backtrace.to_string()))
GUI::MessageBox::show(window, String::formatted("Couldn't save file: {}.", file_or_error.error()), "Saving backtrace failed", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window, String::formatted("Couldn't save file: {}.", file_or_error.error()), "Saving backtrace failed"sv, GUI::MessageBox::Type::Error);
};
(void)Threading::BackgroundAction<ThreadBacktracesAndCpuRegisters>::construct(

View file

@ -154,7 +154,7 @@ static bool handle_breakpoint_command(String const& command)
if (argument.is_empty())
return false;
if (argument.contains(":")) {
if (argument.contains(":"sv)) {
auto source_arguments = argument.split(':');
if (source_arguments.size() != 2)
return false;
@ -164,7 +164,7 @@ static bool handle_breakpoint_command(String const& command)
auto file = source_arguments[0];
return insert_breakpoint_at_source_position(file, line.value());
}
if ((argument.starts_with("0x"))) {
if ((argument.starts_with("0x"sv))) {
return insert_breakpoint_at_address(strtoul(argument.characters() + 2, nullptr, 16));
}
@ -181,7 +181,7 @@ static bool handle_examine_command(String const& command)
if (argument.is_empty())
return false;
if (!(argument.starts_with("0x"))) {
if (!(argument.starts_with("0x"sv))) {
return false;
}
FlatPtr address = strtoul(argument.characters() + 2, nullptr, 16);
@ -309,14 +309,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
handle_print_registers(regs);
success = true;
} else if (command.starts_with("dis")) {
} else if (command.starts_with("dis"sv)) {
success = handle_disassemble_command(command, ip);
} else if (command.starts_with("bp")) {
} else if (command.starts_with("bp"sv)) {
success = handle_breakpoint_command(command);
} else if (command.starts_with("x")) {
} else if (command.starts_with("x"sv)) {
success = handle_examine_command(command);
} else if (command.starts_with("bt")) {
} else if (command.starts_with("bt"sv)) {
success = handle_backtrace_command(regs);
}

View file

@ -65,7 +65,7 @@ void BackgroundSettingsWidget::create_frame()
};
m_context_menu = GUI::Menu::construct();
m_show_in_file_manager_action = GUI::Action::create("Show in File Manager", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png").release_value_but_fixme_should_propagate_errors(), [this](GUI::Action const&) {
m_show_in_file_manager_action = GUI::Action::create("Show in File Manager", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png"sv).release_value_but_fixme_should_propagate_errors(), [this](GUI::Action const&) {
LexicalPath path { m_monitor_widget->wallpaper() };
Desktop::Launcher::open(URL::create_with_file_protocol(path.dirname(), path.basename()));
});
@ -88,7 +88,7 @@ void BackgroundSettingsWidget::create_frame()
auto& button = *find_descendant_of_type_named<GUI::Button>("wallpaper_open_button");
button.on_click = [this](auto) {
auto path = GUI::FilePicker::get_open_filepath(window(), "Select wallpaper from file system", "/res/wallpapers");
auto path = GUI::FilePicker::get_open_filepath(window(), "Select wallpaper from file system", "/res/wallpapers"sv);
if (!path.has_value())
return;
m_wallpaper_view->selection().clear();
@ -124,7 +124,7 @@ void BackgroundSettingsWidget::load_current_settings()
{
auto ws_config = Core::ConfigFile::open("/etc/WindowServer.ini").release_value_but_fixme_should_propagate_errors();
auto selected_wallpaper = Config::read_string("WindowManager", "Background", "Wallpaper", "");
auto selected_wallpaper = Config::read_string("WindowManager"sv, "Background"sv, "Wallpaper"sv, ""sv);
if (!selected_wallpaper.is_empty()) {
auto index = static_cast<GUI::FileSystemModel*>(m_wallpaper_view->model())->index(selected_wallpaper, m_wallpaper_view->model_column());
m_wallpaper_view->set_cursor(index, GUI::AbstractView::SelectionUpdate::Set);

View file

@ -50,7 +50,7 @@ void DesktopSettingsWidget::apply_settings()
if (workspace_rows != desktop.workspace_rows() || workspace_columns != desktop.workspace_columns()) {
if (!GUI::ConnectionToWindowServer::the().apply_workspace_settings(workspace_rows, workspace_columns, true)) {
GUI::MessageBox::show(window(), String::formatted("Error applying workspace settings"),
"Workspace settings", GUI::MessageBox::Type::Error);
"Workspace settings"sv, GUI::MessageBox::Type::Error);
}
}
}

View file

@ -239,7 +239,7 @@ void MonitorSettingsWidget::apply_settings()
seconds_until_revert, seconds_until_revert == 1 ? "second" : "seconds");
};
auto box = GUI::MessageBox::construct(window(), box_text(), "Apply new screen layout",
auto box = GUI::MessageBox::construct(window(), box_text(), "Apply new screen layout"sv,
GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo);
box->set_icon(window()->icon());
@ -258,20 +258,20 @@ void MonitorSettingsWidget::apply_settings()
auto save_result = GUI::ConnectionToWindowServer::the().save_screen_layout();
if (!save_result.success()) {
GUI::MessageBox::show(window(), String::formatted("Error saving settings: {}", save_result.error_msg()),
"Unable to save setting", GUI::MessageBox::Type::Error);
"Unable to save setting"sv, GUI::MessageBox::Type::Error);
}
} else {
auto restore_result = GUI::ConnectionToWindowServer::the().set_screen_layout(current_layout, false);
if (!restore_result.success()) {
GUI::MessageBox::show(window(), String::formatted("Error restoring settings: {}", restore_result.error_msg()),
"Unable to restore setting", GUI::MessageBox::Type::Error);
"Unable to restore setting"sv, GUI::MessageBox::Type::Error);
} else {
load_current_settings();
}
}
} else {
GUI::MessageBox::show(window(), String::formatted("Error setting screen layout: {}", result.error_msg()),
"Unable to apply changes", GUI::MessageBox::Type::Error);
"Unable to apply changes"sv, GUI::MessageBox::Type::Error);
}
}
}

View file

@ -19,7 +19,7 @@ namespace DisplaySettings {
MonitorWidget::MonitorWidget()
{
m_desktop_resolution = GUI::Desktop::the().rect().size();
m_monitor_bitmap = Gfx::Bitmap::try_load_from_file("/res/graphics/monitor.png").release_value_but_fixme_should_propagate_errors();
m_monitor_bitmap = Gfx::Bitmap::try_load_from_file("/res/graphics/monitor.png"sv).release_value_but_fixme_should_propagate_errors();
m_desktop_bitmap = Gfx::Bitmap::try_create(m_monitor_bitmap->format(), { 280, 158 }).release_value_but_fixme_should_propagate_errors();
m_monitor_rect = { { 12, 13 }, m_desktop_bitmap->size() };
set_fixed_size(304, 201);

View file

@ -39,9 +39,9 @@ void ThemePreviewWidget::paint_preview(GUI::PaintEvent&)
};
center_window_group_within(window_group, frame_inner_rect());
paint_window("Inactive Window", inactive_window_rect, Gfx::WindowTheme::WindowState::Inactive, inactive_window_icon());
paint_window("Active Window", active_window_rect, Gfx::WindowTheme::WindowState::Active, active_window_icon());
paint_window("Alert", message_box, Gfx::WindowTheme::WindowState::Highlighted, active_window_icon(), 1);
paint_window("Inactive Window"sv, inactive_window_rect, Gfx::WindowTheme::WindowState::Inactive, inactive_window_icon());
paint_window("Active Window"sv, active_window_rect, Gfx::WindowTheme::WindowState::Active, active_window_icon());
paint_window("Alert"sv, message_box, Gfx::WindowTheme::WindowState::Highlighted, active_window_icon(), 1);
auto draw_centered_button = [&](auto window_rect, auto text, int button_width, int button_height) {
Gfx::IntRect button_rect { 0, 0, button_width, button_height };
@ -50,7 +50,7 @@ void ThemePreviewWidget::paint_preview(GUI::PaintEvent&)
painter.draw_text(button_rect, text, Gfx::TextAlignment::Center, preview_palette().color(foreground_role()), Gfx::TextElision::Right, Gfx::TextWrapping::DontWrap);
};
draw_centered_button(message_box, "Ok", 32, 16);
draw_centered_button(message_box, "Ok"sv, 32, 16);
}
}

View file

@ -45,11 +45,11 @@ ThemesSettingsWidget::ThemesSettingsWidget(bool& background_settings_changed)
};
m_themes_combo->set_selected_index(current_theme_index, GUI::AllowCallback::No);
auto mouse_settings_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-mouse.png").release_value_but_fixme_should_propagate_errors();
auto mouse_settings_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-mouse.png"sv).release_value_but_fixme_should_propagate_errors();
m_cursor_themes_button = *find_descendant_of_type_named<GUI::Button>("cursor_themes_button");
m_cursor_themes_button->set_icon(mouse_settings_icon);
m_cursor_themes_button->on_click = [&](auto) {
GUI::Process::spawn_or_show_error(window(), "/bin/MouseSettings", Array { "-t", "cursor-theme" });
GUI::Process::spawn_or_show_error(window(), "/bin/MouseSettings"sv, Array { "-t", "cursor-theme" });
};
GUI::Application::the()->on_theme_change = [&]() {

View file

@ -31,16 +31,16 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.add_option(selected_tab, "Tab, one of 'background', 'fonts', 'monitor', 'themes', or 'workspaces'", "open-tab", 't', "tab");
args_parser.parse(arguments);
auto app_icon = GUI::Icon::default_icon("app-display-settings");
auto app_icon = GUI::Icon::default_icon("app-display-settings"sv);
bool background_settings_changed = false;
auto window = TRY(GUI::SettingsWindow::create("Display Settings"));
(void)TRY(window->add_tab<DisplaySettings::BackgroundSettingsWidget>("Background", "background", background_settings_changed));
(void)TRY(window->add_tab<DisplaySettings::ThemesSettingsWidget>("Themes", "themes", background_settings_changed));
(void)TRY(window->add_tab<DisplaySettings::FontSettingsWidget>("Fonts", "fonts"));
(void)TRY(window->add_tab<DisplaySettings::MonitorSettingsWidget>("Monitor", "monitor"));
(void)TRY(window->add_tab<DisplaySettings::DesktopSettingsWidget>("Workspaces", "workspaces"));
(void)TRY(window->add_tab<DisplaySettings::BackgroundSettingsWidget>("Background"sv, "background"sv, background_settings_changed));
(void)TRY(window->add_tab<DisplaySettings::ThemesSettingsWidget>("Themes"sv, "themes"sv, background_settings_changed));
(void)TRY(window->add_tab<DisplaySettings::FontSettingsWidget>("Fonts"sv, "fonts"sv));
(void)TRY(window->add_tab<DisplaySettings::MonitorSettingsWidget>("Monitor"sv, "monitor"sv));
(void)TRY(window->add_tab<DisplaySettings::DesktopSettingsWidget>("Workspaces"sv, "workspaces"sv));
window->set_active_tab(selected_tab);
window->set_icon(app_icon.bitmap_for_size(16));

View file

@ -125,7 +125,7 @@ void DirectoryView::handle_activation(GUI::ModelIndex const& index)
unsetenv("__libgui_launch_origin_rect");
} else {
auto error_message = String::formatted("Could not open {}", path);
GUI::MessageBox::show(window(), error_message, "File Manager", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), error_message, "File Manager"sv, GUI::MessageBox::Type::Error);
}
}
@ -332,10 +332,10 @@ void DirectoryView::set_view_mode_from_string(String const& mode)
if (m_mode == Mode::Desktop)
return;
if (mode.contains("Table")) {
if (mode.contains("Table"sv)) {
set_view_mode(DirectoryView::ViewMode::Table);
m_view_as_table_action->set_checked(true);
} else if (mode.contains("Columns")) {
} else if (mode.contains("Columns"sv)) {
set_view_mode(DirectoryView::ViewMode::Columns);
m_view_as_columns_action->set_checked(true);
} else {
@ -462,7 +462,7 @@ void DirectoryView::update_statusbar()
if (selected_item_count == 1) {
auto& node = this->node(current_view().selection().first());
if (!node.symlink_target.is_empty()) {
builder.append("");
builder.append(""sv);
builder.append(node.symlink_target);
}
}
@ -550,37 +550,37 @@ void DirectoryView::handle_selection_change()
void DirectoryView::setup_actions()
{
m_mkdir_action = GUI::Action::create("&New Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
m_mkdir_action = GUI::Action::create("&New Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
String value;
if (GUI::InputBox::show(window(), value, "Enter name:", "New directory") == GUI::InputBox::ExecResult::OK && !value.is_empty()) {
if (GUI::InputBox::show(window(), value, "Enter name:"sv, "New directory"sv) == GUI::InputBox::ExecResult::OK && !value.is_empty()) {
auto new_dir_path = LexicalPath::canonicalized_path(String::formatted("{}/{}", path(), value));
int rc = mkdir(new_dir_path.characters(), 0777);
if (rc < 0) {
auto saved_errno = errno;
GUI::MessageBox::show(window(), String::formatted("mkdir(\"{}\") failed: {}", new_dir_path, strerror(saved_errno)), "Error", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), String::formatted("mkdir(\"{}\") failed: {}", new_dir_path, strerror(saved_errno)), "Error"sv, GUI::MessageBox::Type::Error);
}
}
});
m_touch_action = GUI::Action::create("New &File...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
m_touch_action = GUI::Action::create("New &File...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
String value;
if (GUI::InputBox::show(window(), value, "Enter name:", "New file") == GUI::InputBox::ExecResult::OK && !value.is_empty()) {
if (GUI::InputBox::show(window(), value, "Enter name:"sv, "New file"sv) == GUI::InputBox::ExecResult::OK && !value.is_empty()) {
auto new_file_path = LexicalPath::canonicalized_path(String::formatted("{}/{}", path(), value));
struct stat st;
int rc = stat(new_file_path.characters(), &st);
if ((rc < 0 && errno != ENOENT)) {
auto saved_errno = errno;
GUI::MessageBox::show(window(), String::formatted("stat(\"{}\") failed: {}", new_file_path, strerror(saved_errno)), "Error", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), String::formatted("stat(\"{}\") failed: {}", new_file_path, strerror(saved_errno)), "Error"sv, GUI::MessageBox::Type::Error);
return;
}
if (rc == 0) {
GUI::MessageBox::show(window(), String::formatted("{}: Already exists", new_file_path), "Error", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), String::formatted("{}: Already exists", new_file_path), "Error"sv, GUI::MessageBox::Type::Error);
return;
}
int fd = creat(new_file_path.characters(), 0666);
if (fd < 0) {
auto saved_errno = errno;
GUI::MessageBox::show(window(), String::formatted("creat(\"{}\") failed: {}", new_file_path, strerror(saved_errno)), "Error", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), String::formatted("creat(\"{}\") failed: {}", new_file_path, strerror(saved_errno)), "Error"sv, GUI::MessageBox::Type::Error);
return;
}
rc = close(fd);
@ -588,7 +588,7 @@ void DirectoryView::setup_actions()
}
});
m_open_terminal_action = GUI::Action::create("Open &Terminal Here", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
m_open_terminal_action = GUI::Action::create("Open &Terminal Here", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
spawn_terminal(path());
});
@ -605,23 +605,23 @@ void DirectoryView::setup_actions()
window());
m_view_as_icons_action = GUI::Action::create_checkable(
"View as &Icons", { Mod_Ctrl, KeyCode::Key_1 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/icon-view.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
"View as &Icons", { Mod_Ctrl, KeyCode::Key_1 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/icon-view.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
set_view_mode(DirectoryView::ViewMode::Icon);
Config::write_string("FileManager", "DirectoryView", "ViewMode", "Icon");
Config::write_string("FileManager"sv, "DirectoryView"sv, "ViewMode"sv, "Icon"sv);
},
window());
m_view_as_table_action = GUI::Action::create_checkable(
"View as &Table", { Mod_Ctrl, KeyCode::Key_2 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/table-view.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
"View as &Table", { Mod_Ctrl, KeyCode::Key_2 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/table-view.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
set_view_mode(DirectoryView::ViewMode::Table);
Config::write_string("FileManager", "DirectoryView", "ViewMode", "Table");
Config::write_string("FileManager"sv, "DirectoryView"sv, "ViewMode"sv, "Table"sv);
},
window());
m_view_as_columns_action = GUI::Action::create_checkable(
"View as &Columns", { Mod_Ctrl, KeyCode::Key_3 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/columns-view.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
"View as &Columns", { Mod_Ctrl, KeyCode::Key_3 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/columns-view.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
set_view_mode(DirectoryView::ViewMode::Columns);
Config::write_string("FileManager", "DirectoryView", "ViewMode", "Columns");
Config::write_string("FileManager"sv, "DirectoryView"sv, "ViewMode"sv, "Columns"sv);
},
window());

View file

@ -27,20 +27,20 @@ FileOperationProgressWidget::FileOperationProgressWidget(FileOperation operation
auto& button = *find_descendant_of_type_named<GUI::Button>("button");
auto& file_copy_animation = *find_descendant_of_type_named<GUI::ImageWidget>("file_copy_animation");
file_copy_animation.load_from_file("/res/graphics/file-flying-animation.gif");
file_copy_animation.load_from_file("/res/graphics/file-flying-animation.gif"sv);
file_copy_animation.animate();
auto& source_folder_icon = *find_descendant_of_type_named<GUI::ImageWidget>("source_folder_icon");
source_folder_icon.load_from_file("/res/icons/32x32/filetype-folder-open.png");
source_folder_icon.load_from_file("/res/icons/32x32/filetype-folder-open.png"sv);
auto& destination_folder_icon = *find_descendant_of_type_named<GUI::ImageWidget>("destination_folder_icon");
switch (m_operation) {
case FileOperation::Delete:
destination_folder_icon.load_from_file("/res/icons/32x32/recycle-bin.png");
destination_folder_icon.load_from_file("/res/icons/32x32/recycle-bin.png"sv);
break;
default:
destination_folder_icon.load_from_file("/res/icons/32x32/filetype-folder-open.png");
destination_folder_icon.load_from_file("/res/icons/32x32/filetype-folder-open.png"sv);
break;
}
@ -129,7 +129,7 @@ void FileOperationProgressWidget::did_error(StringView message)
{
// FIXME: Communicate more with the user about errors.
close_pipe();
GUI::MessageBox::show(window(), String::formatted("An error occurred: {}", message), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK);
GUI::MessageBox::show(window(), String::formatted("An error occurred: {}", message), "Error"sv, GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK);
window()->close();
}

View file

@ -29,7 +29,7 @@ void delete_paths(Vector<String> const& paths, bool should_confirm, GUI::Window*
if (should_confirm) {
auto result = GUI::MessageBox::show(parent_window,
message,
"Confirm deletion",
"Confirm deletion"sv,
GUI::MessageBox::Type::Warning,
GUI::MessageBox::InputType::OKCancel);
if (result == GUI::MessageBox::ExecResult::Cancel)
@ -51,17 +51,17 @@ ErrorOr<void> run_file_operation(FileOperation operation, Vector<String> const&
TRY(Core::System::dup2(pipe_fds[1], STDOUT_FILENO));
Vector<StringView> file_operation_args;
file_operation_args.append("/bin/FileOperation");
file_operation_args.append("/bin/FileOperation"sv);
switch (operation) {
case FileOperation::Copy:
file_operation_args.append("Copy");
file_operation_args.append("Copy"sv);
break;
case FileOperation::Move:
file_operation_args.append("Move");
file_operation_args.append("Move"sv);
break;
case FileOperation::Delete:
file_operation_args.append("Delete");
file_operation_args.append("Delete"sv);
break;
default:
VERIFY_NOT_REACHED();

View file

@ -40,7 +40,7 @@ PropertiesWindow::PropertiesWindow(String const& path, bool disable_rename, Wind
set_rect({ 0, 0, 360, 420 });
set_resizable(false);
set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/properties.png").release_value_but_fixme_should_propagate_errors());
set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/properties.png"sv).release_value_but_fixme_should_propagate_errors());
auto& tab_widget = main_widget.add<GUI::TabWidget>();
@ -194,12 +194,12 @@ bool PropertiesWindow::apply_changes()
String new_file = make_full_path(new_name).characters();
if (Core::File::exists(new_file)) {
GUI::MessageBox::show(this, String::formatted("A file \"{}\" already exists!", new_name), "Error", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(this, String::formatted("A file \"{}\" already exists!", new_name), "Error"sv, GUI::MessageBox::Type::Error);
return false;
}
if (rename(make_full_path(m_name).characters(), new_file.characters())) {
GUI::MessageBox::show(this, String::formatted("Could not rename file: {}!", strerror(errno)), "Error", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(this, String::formatted("Could not rename file: {}!", strerror(errno)), "Error"sv, GUI::MessageBox::Type::Error);
return false;
}
@ -210,7 +210,7 @@ bool PropertiesWindow::apply_changes()
if (m_permissions_dirty) {
if (chmod(make_full_path(m_name).characters(), m_mode)) {
GUI::MessageBox::show(this, String::formatted("Could not update permissions: {}!", strerror(errno)), "Error", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(this, String::formatted("Could not update permissions: {}!", strerror(errno)), "Error"sv, GUI::MessageBox::Type::Error);
return false;
}

View file

@ -135,7 +135,7 @@ void do_copy(Vector<String> const& selected_file_paths, FileOperation file_opera
StringBuilder copy_text;
if (file_operation == FileOperation::Move) {
copy_text.append("#cut\n"); // This exploits the comment lines in the text/uri-list specification, which might be a bit hackish
copy_text.append("#cut\n"sv); // This exploits the comment lines in the text/uri-list specification, which might be a bit hackish
}
for (auto& path : selected_file_paths) {
auto url = URL::create_with_file_protocol(path);
@ -186,7 +186,7 @@ void do_create_link(Vector<String> const& selected_file_paths, GUI::Window* wind
auto path = selected_file_paths.first();
auto destination = String::formatted("{}/{}", Core::StandardPaths::desktop_directory(), LexicalPath::basename(path));
if (auto result = Core::File::link_file(destination, path); result.is_error()) {
GUI::MessageBox::show(window, String::formatted("Could not create desktop shortcut:\n{}", result.error()), "File Manager",
GUI::MessageBox::show(window, String::formatted("Could not create desktop shortcut:\n{}", result.error()), "File Manager"sv,
GUI::MessageBox::Type::Error);
}
}
@ -194,7 +194,7 @@ void do_create_link(Vector<String> const& selected_file_paths, GUI::Window* wind
void do_create_archive(Vector<String> const& selected_file_paths, GUI::Window* window)
{
String archive_name;
if (GUI::InputBox::show(window, archive_name, "Enter name:", "Create Archive") != GUI::InputBox::ExecResult::OK)
if (GUI::InputBox::show(window, archive_name, "Enter name:"sv, "Create Archive"sv) != GUI::InputBox::ExecResult::OK)
return;
auto output_directory_path = LexicalPath(selected_file_paths.first());
@ -204,11 +204,11 @@ void do_create_archive(Vector<String> const& selected_file_paths, GUI::Window* w
path_builder.append("/");
if (archive_name.is_empty()) {
path_builder.append(output_directory_path.parent().basename());
path_builder.append(".zip");
path_builder.append(".zip"sv);
} else {
path_builder.append(archive_name);
if (!archive_name.ends_with(".zip"))
path_builder.append(".zip");
if (!archive_name.ends_with(".zip"sv))
path_builder.append(".zip"sv);
}
auto output_path = path_builder.build();
@ -239,7 +239,7 @@ void do_create_archive(Vector<String> const& selected_file_paths, GUI::Window* w
int status;
int rc = waitpid(zip_pid, &status, 0);
if (rc < 0 || !WIFEXITED(status) || WEXITSTATUS(status) != 0)
GUI::MessageBox::show(window, "Could not create archive", "Archive Error", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window, "Could not create archive"sv, "Archive Error"sv, GUI::MessageBox::Type::Error);
}
}
@ -265,7 +265,7 @@ void do_unzip_archive(Vector<String> const& selected_file_paths, GUI::Window* wi
int status;
int rc = waitpid(unzip_pid, &status, 0);
if (rc < 0 || !WIFEXITED(status) || WEXITSTATUS(status) != 0)
GUI::MessageBox::show(window, "Could not extract archive", "Extract Archive Error", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window, "Could not extract archive"sv, "Extract Archive Error"sv, GUI::MessageBox::Type::Error);
}
}
@ -362,7 +362,7 @@ ErrorOr<int> run_in_desktop_mode()
auto create_archive_action
= GUI::Action::create(
"Create &Archive",
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-archive.png").release_value_but_fixme_should_propagate_errors(),
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-archive.png"sv).release_value_but_fixme_should_propagate_errors(),
[&](GUI::Action const&) {
auto paths = directory_view->selected_file_paths();
if (paths.is_empty())
@ -411,7 +411,7 @@ ErrorOr<int> run_in_desktop_mode()
auto desktop_view_context_menu = TRY(GUI::Menu::try_create("Directory View"));
auto file_manager_action = GUI::Action::create("Open in File &Manager", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
auto file_manager_action = GUI::Action::create("Open in File &Manager", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
auto paths = directory_view->selected_file_paths();
if (paths.is_empty()) {
Desktop::Launcher::open(URL::create_with_file_protocol(directory_view->path()));
@ -424,7 +424,7 @@ ErrorOr<int> run_in_desktop_mode()
}
});
auto open_terminal_action = GUI::Action::create("Open in &Terminal", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
auto open_terminal_action = GUI::Action::create("Open in &Terminal", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
auto paths = directory_view->selected_file_paths();
if (paths.is_empty()) {
spawn_terminal(directory_view->path());
@ -438,7 +438,7 @@ ErrorOr<int> run_in_desktop_mode()
}
});
auto display_properties_action = GUI::Action::create("&Display Settings", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-display-settings.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
auto display_properties_action = GUI::Action::create("&Display Settings", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-display-settings.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
Desktop::Launcher::open(URL::create_with_file_protocol("/bin/DisplaySettings"));
});
@ -488,7 +488,7 @@ ErrorOr<int> run_in_desktop_mode()
file_context_menu->add_action(create_archive_action);
file_context_menu->add_separator();
if (node.full_path().ends_with(".zip", AK::CaseSensitivity::CaseInsensitive)) {
if (node.full_path().ends_with(".zip"sv, AK::CaseSensitivity::CaseInsensitive)) {
file_context_menu->add_action(unzip_archive_action);
file_context_menu->add_separator();
}
@ -514,7 +514,7 @@ ErrorOr<int> run_in_desktop_mode()
}
} wallpaper_listener;
auto selected_wallpaper = Config::read_string("WindowManager", "Background", "Wallpaper", "");
auto selected_wallpaper = Config::read_string("WindowManager"sv, "Background"sv, "Wallpaper"sv, ""sv);
if (!selected_wallpaper.is_empty()) {
auto wallpaper_bitmap = TRY(Gfx::Bitmap::try_load_from_file(selected_wallpaper));
GUI::Desktop::the().set_wallpaper(wallpaper_bitmap, {});
@ -529,11 +529,11 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
auto window = TRY(GUI::Window::try_create());
window->set_title("File Manager");
auto left = Config::read_i32("FileManager", "Window", "Left", 150);
auto top = Config::read_i32("FileManager", "Window", "Top", 75);
auto width = Config::read_i32("FileManager", "Window", "Width", 640);
auto height = Config::read_i32("FileManager", "Window", "Height", 480);
auto was_maximized = Config::read_bool("FileManager", "Window", "Maximized", false);
auto left = Config::read_i32("FileManager"sv, "Window"sv, "Left"sv, 150);
auto top = Config::read_i32("FileManager"sv, "Window"sv, "Top"sv, 75);
auto width = Config::read_i32("FileManager"sv, "Window"sv, "Width"sv, 640);
auto height = Config::read_i32("FileManager"sv, "Window"sv, "Height"sv, 480);
auto was_maximized = Config::read_bool("FileManager"sv, "Window"sv, "Maximized"sv, false);
auto widget = TRY(window->try_set_main_widget<GUI::Widget>());
@ -628,7 +628,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
auto directory_view_context_menu = TRY(GUI::Menu::try_create("Directory View"));
auto tree_view_directory_context_menu = TRY(GUI::Menu::try_create("Tree View Directory"));
auto open_parent_directory_action = GUI::Action::create("Open &Parent Directory", { Mod_Alt, Key_Up }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open-parent-directory.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
auto open_parent_directory_action = GUI::Action::create("Open &Parent Directory", { Mod_Alt, Key_Up }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open-parent-directory.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
directory_view->open_parent_directory();
});
@ -637,7 +637,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
RefPtr<GUI::Action> layout_statusbar_action;
RefPtr<GUI::Action> layout_folderpane_action;
auto show_toolbar = Config::read_bool("FileManager", "Layout", "ShowToolbar", true);
auto show_toolbar = Config::read_bool("FileManager"sv, "Layout"sv, "ShowToolbar"sv, true);
layout_toolbar_action = GUI::Action::create_checkable("&Toolbar", [&](auto& action) {
if (action.is_checked()) {
main_toolbar.set_visible(true);
@ -648,12 +648,12 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
toolbar_container.set_visible(false);
}
show_toolbar = action.is_checked();
Config::write_bool("FileManager", "Layout", "ShowToolbar", action.is_checked());
Config::write_bool("FileManager"sv, "Layout"sv, "ShowToolbar"sv, action.is_checked());
});
layout_toolbar_action->set_checked(show_toolbar);
main_toolbar.set_visible(show_toolbar);
auto show_location = Config::read_bool("FileManager", "Layout", "ShowLocationBar", true);
auto show_location = Config::read_bool("FileManager"sv, "Layout"sv, "ShowLocationBar"sv, true);
layout_location_action = GUI::Action::create_checkable("&Location Bar", [&](auto& action) {
if (action.is_checked()) {
breadcrumb_toolbar.set_visible(true);
@ -666,7 +666,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
toolbar_container.set_visible(false);
}
show_location = action.is_checked();
Config::write_bool("FileManager", "Layout", "ShowLocationBar", action.is_checked());
Config::write_bool("FileManager"sv, "Layout"sv, "ShowLocationBar"sv, action.is_checked());
});
layout_location_action->set_checked(show_location);
breadcrumb_toolbar.set_visible(show_location);
@ -675,19 +675,19 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
layout_statusbar_action = GUI::Action::create_checkable("&Status Bar", [&](auto& action) {
action.is_checked() ? statusbar.set_visible(true) : statusbar.set_visible(false);
Config::write_bool("FileManager", "Layout", "ShowStatusbar", action.is_checked());
Config::write_bool("FileManager"sv, "Layout"sv, "ShowStatusbar"sv, action.is_checked());
});
auto show_statusbar = Config::read_bool("FileManager", "Layout", "ShowStatusbar", true);
auto show_statusbar = Config::read_bool("FileManager"sv, "Layout"sv, "ShowStatusbar"sv, true);
layout_statusbar_action->set_checked(show_statusbar);
statusbar.set_visible(show_statusbar);
layout_folderpane_action = GUI::Action::create_checkable("&Folder Pane", { Mod_Ctrl, Key_P }, [&](auto& action) {
action.is_checked() ? tree_view.set_visible(true) : tree_view.set_visible(false);
Config::write_bool("FileManager", "Layout", "ShowFolderPane", action.is_checked());
Config::write_bool("FileManager"sv, "Layout"sv, "ShowFolderPane"sv, action.is_checked());
});
auto show_folderpane = Config::read_bool("FileManager", "Layout", "ShowFolderPane", true);
auto show_folderpane = Config::read_bool("FileManager"sv, "Layout"sv, "ShowFolderPane"sv, true);
layout_folderpane_action->set_checked(show_folderpane);
tree_view.set_visible(show_folderpane);
@ -749,7 +749,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
= GUI::Action::create(
"Open in New &Window",
{},
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png").release_value_but_fixme_should_propagate_errors(),
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png"sv).release_value_but_fixme_should_propagate_errors(),
[&](GUI::Action const& action) {
Vector<String> paths;
if (action.activator() == tree_view_directory_context_menu)
@ -768,7 +768,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
= GUI::Action::create(
"Open in &Terminal",
{},
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png").release_value_but_fixme_should_propagate_errors(),
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png"sv).release_value_but_fixme_should_propagate_errors(),
[&](GUI::Action const& action) {
Vector<String> paths;
if (action.activator() == tree_view_directory_context_menu)
@ -788,7 +788,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
= GUI::Action::create(
"Create Desktop &Shortcut",
{},
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-symlink.png").release_value_but_fixme_should_propagate_errors(),
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-symlink.png"sv).release_value_but_fixme_should_propagate_errors(),
[&](GUI::Action const&) {
auto paths = directory_view->selected_file_paths();
if (paths.is_empty()) {
@ -801,7 +801,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
auto create_archive_action
= GUI::Action::create(
"Create &Archive",
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-archive.png").release_value_but_fixme_should_propagate_errors(),
Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-archive.png"sv).release_value_but_fixme_should_propagate_errors(),
[&](GUI::Action const&) {
auto paths = directory_view->selected_file_paths();
if (paths.is_empty())
@ -909,12 +909,12 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
});
focus_dependent_delete_action->set_enabled(false);
auto mkdir_action = GUI::Action::create("&New Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
auto mkdir_action = GUI::Action::create("&New Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
directory_view->mkdir_action().activate();
refresh_tree_view();
});
auto touch_action = GUI::Action::create("New &File...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
auto touch_action = GUI::Action::create("New &File...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) {
directory_view->touch_action().activate();
refresh_tree_view();
});
@ -942,10 +942,10 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
directory_view->set_should_show_dotfiles(action.is_checked());
directories_model->set_should_show_dotfiles(action.is_checked());
refresh_tree_view();
Config::write_bool("FileManager", "DirectoryView", "ShowDotFiles", action.is_checked());
Config::write_bool("FileManager"sv, "DirectoryView"sv, "ShowDotFiles"sv, action.is_checked());
});
auto show_dotfiles = Config::read_bool("FileManager", "DirectoryView", "ShowDotFiles", false);
auto show_dotfiles = Config::read_bool("FileManager"sv, "DirectoryView"sv, "ShowDotFiles"sv, false);
directory_view->set_should_show_dotfiles(show_dotfiles);
show_dotfiles_action->set_checked(show_dotfiles);
@ -968,7 +968,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
TRY(view_menu->try_add_separator());
TRY(view_menu->try_add_action(show_dotfiles_action));
auto go_to_location_action = GUI::Action::create("Go to &Location...", { Mod_Ctrl, Key_L }, Key_F6, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-to.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
auto go_to_location_action = GUI::Action::create("Go to &Location...", { Mod_Ctrl, Key_L }, Key_F6, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-to.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
toolbar_container.set_visible(true);
location_toolbar.set_visible(true);
breadcrumb_toolbar.set_visible(false);
@ -986,7 +986,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
TRY(go_menu->try_add_action(directory_view->open_terminal_action()));
auto help_menu = TRY(window->try_add_menu("&Help"));
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("File Manager", GUI::Icon::default_icon("app-file-manager"), window)));
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("File Manager"sv, GUI::Icon::default_icon("app-file-manager"sv), window)));
(void)TRY(main_toolbar.try_add_action(go_back_action));
(void)TRY(main_toolbar.try_add_action(go_forward_action));
@ -1113,7 +1113,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
|| (!directory_view->current_view().selection().is_empty() && access(directory_view->path().characters(), W_OK) == 0));
};
auto directory_open_action = GUI::Action::create("Open", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
auto directory_open_action = GUI::Action::create("Open", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
directory_view->open(directory_view->selected_file_paths().first());
});
@ -1180,7 +1180,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
file_context_menu->add_action(create_archive_action);
file_context_menu->add_separator();
if (node.full_path().ends_with(".zip", AK::CaseSensitivity::CaseInsensitive)) {
if (node.full_path().ends_with(".zip"sv, AK::CaseSensitivity::CaseInsensitive)) {
file_context_menu->add_action(unzip_archive_action);
file_context_menu->add_separator();
}
@ -1243,7 +1243,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
if (auto result = Core::File::copy_file_or_directory(url_to_copy.path(), new_path); result.is_error()) {
auto error_message = String::formatted("Could not copy {} into {}:\n {}", url_to_copy.to_string(), new_path, static_cast<Error const&>(result.error()));
GUI::MessageBox::show(window, error_message, "File Manager", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window, error_message, "File Manager"sv, GUI::MessageBox::Type::Error);
} else {
had_accepted_copy = true;
}
@ -1288,7 +1288,7 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
window->show();
directory_view->set_view_mode_from_string(Config::read_string("FileManager", "DirectoryView", "ViewMode", "Icon"));
directory_view->set_view_mode_from_string(Config::read_string("FileManager"sv, "DirectoryView"sv, "ViewMode"sv, "Icon"sv));
if (!entry_focused_on_init.is_empty()) {
auto matches = directory_view->current_view().model()->matches(entry_focused_on_init, GUI::Model::MatchesFlag::MatchFull | GUI::Model::MatchesFlag::FirstMatchOnly);
@ -1298,12 +1298,12 @@ ErrorOr<int> run_in_windowed_mode(String const& initial_location, String const&
// Write window position to config file on close request.
window->on_close_request = [&] {
Config::write_bool("FileManager", "Window", "Maximized", window->is_maximized());
Config::write_bool("FileManager"sv, "Window"sv, "Maximized"sv, window->is_maximized());
if (!window->is_maximized()) {
Config::write_i32("FileManager", "Window", "Left", window->x());
Config::write_i32("FileManager", "Window", "Top", window->y());
Config::write_i32("FileManager", "Window", "Width", window->width());
Config::write_i32("FileManager", "Window", "Height", window->height());
Config::write_i32("FileManager"sv, "Window"sv, "Left"sv, window->x());
Config::write_i32("FileManager"sv, "Window"sv, "Top"sv, window->y());
Config::write_i32("FileManager"sv, "Window"sv, "Width"sv, window->width());
Config::write_i32("FileManager"sv, "Window"sv, "Height"sv, window->height());
}
return GUI::Window::CloseRequestDecision::Close;
};

View file

@ -45,16 +45,16 @@
namespace FontEditor {
static constexpr Array pangrams = {
"quick fox jumps nightly above wizard",
"five quacking zephyrs jolt my wax bed",
"pack my box with five dozen liquor jugs",
"quick brown fox jumps over the lazy dog",
"waxy and quivering jocks fumble the pizza",
"~#:[@_1%]*{$2.3}/4^(5'6\")-&|7+8!=<9,0\\>?;",
"byxfjärmat föl gick på duvshowen",
"         ",
"float Fox.quick(h){ is_brown && it_jumps_over(doges.lazy) }",
"<fox color=\"brown\" speed=\"quick\" jumps=\"over\">lazy dog</fox>"
"quick fox jumps nightly above wizard"sv,
"five quacking zephyrs jolt my wax bed"sv,
"pack my box with five dozen liquor jugs"sv,
"quick brown fox jumps over the lazy dog"sv,
"waxy and quivering jocks fumble the pizza"sv,
"~#:[@_1%]*{$2.3}/4^(5'6\"sv)-&|7+8!=<9,0\\>?;"sv,
"byxfjärmat föl gick på duvshowen"sv,
"         "sv,
"float Fox.quick(h){ is_brown && it_jumps_over(doges.lazy) }"sv,
"<fox color=\"brown\" speed=\"quick\" jumps=\"over\">lazy dog</fox>"sv
};
ErrorOr<RefPtr<GUI::Window>> MainWidget::create_preview_window()
@ -92,7 +92,7 @@ ErrorOr<RefPtr<GUI::Window>> MainWidget::create_preview_window()
ErrorOr<void> MainWidget::create_actions()
{
m_new_action = GUI::Action::create("&New Font...", { Mod_Ctrl, Key_N }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-font.png")), [&](auto&) {
m_new_action = GUI::Action::create("&New Font...", { Mod_Ctrl, Key_N }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-font.png"sv)), [&](auto&) {
if (!request_close())
return;
auto new_font_wizard = NewFontDialog::construct(window());
@ -115,7 +115,7 @@ ErrorOr<void> MainWidget::create_actions()
m_open_action = GUI::CommonActions::make_open_action([&](auto&) {
if (!request_close())
return;
Optional<String> open_path = GUI::FilePicker::get_open_filepath(window(), {}, "/res/fonts/");
Optional<String> open_path = GUI::FilePicker::get_open_filepath(window(), {}, "/res/fonts/"sv);
if (!open_path.has_value())
return;
open_file(open_path.value());
@ -175,7 +175,7 @@ ErrorOr<void> MainWidget::create_actions()
m_undo_selection->set_size(selection.size());
});
m_open_preview_action = GUI::Action::create("&Preview Font", { Mod_Ctrl, Key_P }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png")), [&](auto&) {
m_open_preview_action = GUI::Action::create("&Preview Font", { Mod_Ctrl, Key_P }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"sv)), [&](auto&) {
if (!m_font_preview_window) {
if (auto maybe_window = create_preview_window(); maybe_window.is_error())
warnln("Failed to create preview window: {}", maybe_window.error());
@ -187,27 +187,27 @@ ErrorOr<void> MainWidget::create_actions()
});
m_open_preview_action->set_status_tip("Preview the current font");
bool show_metadata = Config::read_bool("FontEditor", "Layout", "ShowMetadata", true);
bool show_metadata = Config::read_bool("FontEditor"sv, "Layout"sv, "ShowMetadata"sv, true);
set_show_font_metadata(show_metadata);
m_show_metadata_action = GUI::Action::create_checkable("Font &Metadata", { Mod_Ctrl, Key_M }, [&](auto& action) {
set_show_font_metadata(action.is_checked());
Config::write_bool("FontEditor", "Layout", "ShowMetadata", action.is_checked());
Config::write_bool("FontEditor"sv, "Layout"sv, "ShowMetadata"sv, action.is_checked());
});
m_show_metadata_action->set_checked(show_metadata);
m_show_metadata_action->set_status_tip("Show or hide metadata about the current font");
bool show_unicode_blocks = Config::read_bool("FontEditor", "Layout", "ShowUnicodeBlocks", true);
bool show_unicode_blocks = Config::read_bool("FontEditor"sv, "Layout"sv, "ShowUnicodeBlocks"sv, true);
set_show_unicode_blocks(show_unicode_blocks);
m_show_unicode_blocks_action = GUI::Action::create_checkable("&Unicode Blocks", { Mod_Ctrl, Key_U }, [&](auto& action) {
set_show_unicode_blocks(action.is_checked());
Config::write_bool("FontEditor", "Layout", "ShowUnicodeBlocks", action.is_checked());
Config::write_bool("FontEditor"sv, "Layout"sv, "ShowUnicodeBlocks"sv, action.is_checked());
});
m_show_unicode_blocks_action->set_checked(show_unicode_blocks);
m_show_unicode_blocks_action->set_status_tip("Show or hide the Unicode block list");
m_go_to_glyph_action = GUI::Action::create("&Go to Glyph...", { Mod_Ctrl, Key_G }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-to.png")), [&](auto&) {
m_go_to_glyph_action = GUI::Action::create("&Go to Glyph...", { Mod_Ctrl, Key_G }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-to.png"sv)), [&](auto&) {
String input;
if (GUI::InputBox::show(window(), input, "Hexadecimal:", "Go to glyph") == GUI::InputBox::ExecResult::OK && !input.is_empty()) {
if (GUI::InputBox::show(window(), input, "Hexadecimal:"sv, "Go to glyph"sv) == GUI::InputBox::ExecResult::OK && !input.is_empty()) {
auto maybe_code_point = AK::StringUtils::convert_to_uint_from_hex(input);
if (!maybe_code_point.has_value())
return;
@ -220,17 +220,17 @@ ErrorOr<void> MainWidget::create_actions()
});
m_go_to_glyph_action->set_status_tip("Go to the specified code point");
m_previous_glyph_action = GUI::Action::create("Pre&vious Glyph", { Mod_Alt, Key_Left }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png")), [&](auto&) {
m_previous_glyph_action = GUI::Action::create("Pre&vious Glyph", { Mod_Alt, Key_Left }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"sv)), [&](auto&) {
m_glyph_map_widget->select_previous_existing_glyph();
});
m_previous_glyph_action->set_status_tip("Seek the previous visible glyph");
m_next_glyph_action = GUI::Action::create("&Next Glyph", { Mod_Alt, Key_Right }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png")), [&](auto&) {
m_next_glyph_action = GUI::Action::create("&Next Glyph", { Mod_Alt, Key_Right }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"sv)), [&](auto&) {
m_glyph_map_widget->select_next_existing_glyph();
});
m_next_glyph_action->set_status_tip("Seek the next visible glyph");
i32 scale = Config::read_i32("FontEditor", "GlyphEditor", "Scale", 10);
i32 scale = Config::read_i32("FontEditor"sv, "GlyphEditor"sv, "Scale"sv, 10);
set_scale(scale);
m_scale_five_action = GUI::Action::create_checkable("500%", { Mod_Ctrl, Key_1 }, [this](auto&) {
set_scale_and_save(5);
@ -253,12 +253,12 @@ ErrorOr<void> MainWidget::create_actions()
m_glyph_editor_scale_actions.add_action(*m_scale_fifteen_action);
m_glyph_editor_scale_actions.set_exclusive(true);
m_paint_glyph_action = GUI::Action::create_checkable("Paint Glyph", { Mod_Ctrl, KeyCode::Key_J }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/pen.png")), [&](auto&) {
m_paint_glyph_action = GUI::Action::create_checkable("Paint Glyph", { Mod_Ctrl, KeyCode::Key_J }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/pen.png"sv)), [&](auto&) {
m_glyph_editor_widget->set_mode(GlyphEditorWidget::Paint);
});
m_paint_glyph_action->set_checked(true);
m_move_glyph_action = GUI::Action::create_checkable("Move Glyph", { Mod_Ctrl, KeyCode::Key_K }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/selection-move.png")), [&](auto&) {
m_move_glyph_action = GUI::Action::create_checkable("Move Glyph", { Mod_Ctrl, KeyCode::Key_K }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/selection-move.png"sv)), [&](auto&) {
m_glyph_editor_widget->set_mode(GlyphEditorWidget::Move);
});
@ -274,15 +274,15 @@ ErrorOr<void> MainWidget::create_actions()
m_glyph_editor_widget->rotate_90(GlyphEditorWidget::Clockwise);
});
m_flip_horizontal_action = GUI::Action::create("Flip Horizontally", { Mod_Ctrl | Mod_Shift, Key_Q }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-horizontal.png")), [&](auto&) {
m_flip_horizontal_action = GUI::Action::create("Flip Horizontally", { Mod_Ctrl | Mod_Shift, Key_Q }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-horizontal.png"sv)), [&](auto&) {
m_glyph_editor_widget->flip_horizontally();
});
m_flip_vertical_action = GUI::Action::create("Flip Vertically", { Mod_Ctrl | Mod_Shift, Key_W }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-vertical.png")), [&](auto&) {
m_flip_vertical_action = GUI::Action::create("Flip Vertically", { Mod_Ctrl | Mod_Shift, Key_W }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-vertical.png"sv)), [&](auto&) {
m_glyph_editor_widget->flip_vertically();
});
m_copy_text_action = GUI::Action::create("Copy as Te&xt", { Mod_Ctrl, Key_T }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png")), [&](auto&) {
m_copy_text_action = GUI::Action::create("Copy as Te&xt", { Mod_Ctrl, Key_T }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png"sv)), [&](auto&) {
StringBuilder builder;
auto selection = m_glyph_map_widget->selection().normalized();
for (auto code_point = selection.start(); code_point < selection.start() + selection.size(); ++code_point) {
@ -348,7 +348,7 @@ ErrorOr<void> MainWidget::create_models()
m_unicode_block_model = GUI::ItemListModel<String>::create(m_unicode_block_list);
m_filter_model = TRY(GUI::FilteringProxyModel::create(*m_unicode_block_model));
m_filter_model->set_filter_term("");
m_filter_model->set_filter_term(""sv);
m_unicode_block_listview = find_descendant_of_type_named<GUI::ListView>("unicode_block_listview");
m_unicode_block_listview->on_selection_change = [this, unicode_blocks] {
@ -658,7 +658,7 @@ ErrorOr<void> MainWidget::initialize_menubar(GUI::Window& window)
TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([](auto&) {
Desktop::Launcher::open(URL::create_with_file_protocol("/usr/share/man/man1/FontEditor.md"), "/bin/Help");
})));
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Font Editor", TRY(GUI::Icon::try_create_default_icon("app-font-editor")), &window)));
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Font Editor", TRY(GUI::Icon::try_create_default_icon("app-font-editor"sv)), &window)));
return {};
}
@ -668,7 +668,7 @@ bool MainWidget::save_file(String const& path)
auto saved_font = m_edited_font->masked_character_set();
auto ret_val = saved_font->write_to_file(path);
if (!ret_val) {
GUI::MessageBox::show(window(), "The font file could not be saved.", "Save failed", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), "The font file could not be saved."sv, "Save failed"sv, GUI::MessageBox::Type::Error);
return false;
}
m_path = path;
@ -699,7 +699,7 @@ bool MainWidget::open_file(String const& path)
auto bitmap_font = Gfx::BitmapFont::load_from_file(path);
if (!bitmap_font) {
String message = String::formatted("Couldn't load font: {}\n", path);
GUI::MessageBox::show(window(), message, "Font Editor", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), message, "Font Editor"sv, GUI::MessageBox::Type::Error);
return false;
}
auto new_font = bitmap_font->unmasked_character_set();
@ -748,7 +748,7 @@ void MainWidget::undo()
auto glyph = m_undo_selection->restored_active_glyph();
auto glyph_width = edited_font().raw_glyph_width(glyph);
if (glyph < m_range.first || glyph > m_range.last)
m_search_textbox->set_text("");
m_search_textbox->set_text(""sv);
deferred_invoke([this, glyph] {
auto start = m_undo_selection->restored_start();
@ -778,7 +778,7 @@ void MainWidget::redo()
auto glyph = m_undo_selection->restored_active_glyph();
auto glyph_width = edited_font().raw_glyph_width(glyph);
if (glyph < m_range.first || glyph > m_range.last)
m_search_textbox->set_text("");
m_search_textbox->set_text(""sv);
deferred_invoke([this, glyph] {
auto start = m_undo_selection->restored_start();
@ -818,10 +818,10 @@ void MainWidget::update_title()
{
StringBuilder title;
if (m_path.is_empty())
title.append("Untitled");
title.append("Untitled"sv);
else
title.append(m_path);
title.append("[*] - Font Editor");
title.append("[*] - Font Editor"sv);
window()->set_title(title.to_string());
}
@ -894,7 +894,7 @@ void MainWidget::set_scale(i32 scale)
void MainWidget::set_scale_and_save(i32 scale)
{
set_scale(scale);
Config::write_i32("FontEditor", "GlyphEditor", "Scale", scale);
Config::write_i32("FontEditor"sv, "GlyphEditor"sv, "Scale"sv, scale);
m_glyph_editor_widget->set_fixed_size(m_glyph_editor_widget->preferred_width(), m_glyph_editor_widget->preferred_height());
}
@ -926,7 +926,7 @@ void MainWidget::cut_selected_glyphs()
void MainWidget::paste_glyphs()
{
auto [data, mime_type, metadata] = GUI::Clipboard::the().fetch_data_and_type();
if (!mime_type.starts_with("glyph/"))
if (!mime_type.starts_with("glyph/"sv))
return;
auto glyph_count = metadata.get("count").value().to_uint().value_or(0);

View file

@ -36,7 +36,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.add_positional_argument(path, "The font file for editing.", "file", Core::ArgsParser::Required::No);
args_parser.parse(arguments);
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-font-editor"));
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-font-editor"sv));
auto window = TRY(GUI::Window::try_create());
window->set_icon(app_icon.bitmap_for_size(16));

View file

@ -94,7 +94,7 @@ MainWidget::MainWidget()
m_web_view->on_link_click = [this](auto& url, auto&, unsigned) {
if (url.protocol() == "file") {
auto path = url.path();
if (!path.starts_with("/usr/share/man/")) {
if (!path.starts_with("/usr/share/man/"sv)) {
open_external(url);
return;
}
@ -181,7 +181,7 @@ void MainWidget::set_start_page(StringView start_page, u32 section)
m_history.push(path);
open_page(path);
set_start_page = true;
} else if (URL url = URL::create_with_url_or_path(start_page); url.is_valid() && url.path().ends_with(".md")) {
} else if (URL url = URL::create_with_url_or_path(start_page); url.is_valid() && url.path().ends_with(".md"sv)) {
// > Help [/path/to/documentation/file.md]
m_history.push(url.path());
open_page(url.path());
@ -241,11 +241,11 @@ ErrorOr<void> MainWidget::initialize_fallibles(GUI::Window& window)
TRY(go_menu->try_add_action(*m_go_home_action));
auto help_menu = TRY(window.try_add_menu("&Help"));
TRY(help_menu->try_add_action(GUI::Action::create("&Contents", { Key_F1 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-unknown.png")), [&](auto&) {
TRY(help_menu->try_add_action(GUI::Action::create("&Contents", { Key_F1 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-unknown.png"sv)), [&](auto&) {
String path = "/usr/share/man/man1/Help.md";
open_page(path);
})));
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Help", TRY(GUI::Icon::try_create_default_icon("app-help")), &window)));
TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Help", TRY(GUI::Icon::try_create_default_icon("app-help"sv)), &window)));
m_context_menu = TRY(GUI::Menu::try_create());
TRY(m_context_menu->try_add_action(*m_go_back_action));
@ -259,7 +259,7 @@ ErrorOr<void> MainWidget::initialize_fallibles(GUI::Window& window)
m_browse_view->set_model(*m_manual_model);
m_filter_model = TRY(GUI::FilteringProxyModel::create(*m_manual_model));
m_search_view->set_model(*m_filter_model);
m_filter_model->set_filter_term("");
m_filter_model->set_filter_term(""sv);
return {};
}
@ -287,7 +287,7 @@ void MainWidget::open_url(URL const& url)
void MainWidget::open_external(URL const& url)
{
if (!Desktop::Launcher::open(url))
GUI::MessageBox::show(window(), String::formatted("The link to '{}' could not be opened.", url), "Failed to open link", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), String::formatted("The link to '{}' could not be opened.", url), "Failed to open link"sv, GUI::MessageBox::Type::Error);
}
void MainWidget::open_page(String const& path)

View file

@ -23,9 +23,9 @@ static ManualSectionNode s_sections[] = {
ManualModel::ManualModel()
{
m_section_open_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book-open.png").release_value_but_fixme_should_propagate_errors());
m_section_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book.png").release_value_but_fixme_should_propagate_errors());
m_page_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-unknown.png").release_value_but_fixme_should_propagate_errors());
m_section_open_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book-open.png"sv).release_value_but_fixme_should_propagate_errors());
m_section_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book.png"sv).release_value_but_fixme_should_propagate_errors());
m_page_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-unknown.png"sv).release_value_but_fixme_should_propagate_errors());
}
Optional<GUI::ModelIndex> ManualModel::index_from_path(StringView path) const

View file

@ -77,7 +77,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
} });
args_parser.parse(arguments);
auto app_icon = GUI::Icon::default_icon("app-help");
auto app_icon = GUI::Icon::default_icon("app-help"sv);
auto window = TRY(GUI::Window::try_create());
window->set_icon(app_icon.bitmap_for_size(16));

View file

@ -26,8 +26,8 @@ struct Option {
static constexpr Array<Option, 2> options = {
{
{ "ASCII String", OPTION_ASCII_STRING, true, true },
{ "Hex value", OPTION_HEX_VALUE, true, false },
{ "ASCII String"sv, OPTION_ASCII_STRING, true, true },
{ "Hex value"sv, OPTION_HEX_VALUE, true, false },
}
};
@ -79,7 +79,7 @@ Result<ByteBuffer, String> FindDialog::process_input(String text_value, OptionId
}
case OPTION_HEX_VALUE: {
auto decoded = decode_hex(text_value.replace(" ", "", ReplaceMode::All));
auto decoded = decode_hex(text_value.replace(" "sv, ""sv, ReplaceMode::All));
if (decoded.is_error())
return String::formatted("Input is invalid: {}", decoded.error().string_literal());

View file

@ -126,9 +126,9 @@ GoToOffsetDialog::GoToOffsetDialog()
m_text_editor->on_change = [this]() {
auto text = m_text_editor->text();
if (text.starts_with("0x")) {
if (text.starts_with("0x"sv)) {
m_offset_type_box->set_selected_index(1);
m_text_editor->set_text(text.replace("0x", "", ReplaceMode::FirstOnly));
m_text_editor->set_text(text.replace("0x"sv, ""sv, ReplaceMode::FirstOnly));
}
update_statusbar();
};

View file

@ -194,17 +194,17 @@ bool HexEditor::copy_selected_hex_to_clipboard_as_c_code()
StringBuilder output_string_builder;
output_string_builder.appendff("unsigned char raw_data[{}] = {{\n", m_selection_end - m_selection_start);
output_string_builder.append(" ");
output_string_builder.append(" "sv);
for (size_t i = m_selection_start, j = 1; i < m_selection_end; i++, j++) {
output_string_builder.appendff("{:#02X}", m_document->get(i).value);
if (i >= m_selection_end - 1)
continue;
if ((j % 12) == 0)
output_string_builder.append(",\n ");
output_string_builder.append(",\n "sv);
else
output_string_builder.append(", ");
output_string_builder.append(", "sv);
}
output_string_builder.append("\n};\n");
output_string_builder.append("\n};\n"sv);
GUI::Clipboard::the().set_plain_text(output_string_builder.to_string());
return true;

View file

@ -92,19 +92,19 @@ HexEditorWidget::HexEditorWidget()
m_editor->update();
};
m_new_action = GUI::Action::create("New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png").release_value_but_fixme_should_propagate_errors(), [this](const GUI::Action&) {
m_new_action = GUI::Action::create("New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"sv).release_value_but_fixme_should_propagate_errors(), [this](const GUI::Action&) {
String value;
if (request_close() && GUI::InputBox::show(window(), value, "Enter new file size:", "New file size") == GUI::InputBox::ExecResult::OK && !value.is_empty()) {
if (request_close() && GUI::InputBox::show(window(), value, "Enter new file size:"sv, "New file size"sv) == GUI::InputBox::ExecResult::OK && !value.is_empty()) {
auto file_size = value.to_int();
if (file_size.has_value() && file_size.value() > 0) {
window()->set_modified(false);
if (!m_editor->open_new_file(file_size.value())) {
GUI::MessageBox::show(window(), "Entered file size is too large.", "Error", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), "Entered file size is too large."sv, "Error"sv, GUI::MessageBox::Type::Error);
return;
}
set_path({});
} else {
GUI::MessageBox::show(window(), "Invalid file size entered.", "Error", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), "Invalid file size entered."sv, "Error"sv, GUI::MessageBox::Type::Error);
}
}
});
@ -125,7 +125,7 @@ HexEditorWidget::HexEditorWidget()
return m_save_as_action->activate();
if (!m_editor->save()) {
GUI::MessageBox::show(window(), "Unable to save file.\n", "Error", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), "Unable to save file.\n"sv, "Error"sv, GUI::MessageBox::Type::Error);
} else {
window()->set_modified(false);
m_editor->update();
@ -139,7 +139,7 @@ HexEditorWidget::HexEditorWidget()
return;
auto file = response.release_value();
if (!m_editor->save_as(file)) {
GUI::MessageBox::show(window(), "Unable to save file.\n", "Error", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), "Unable to save file.\n"sv, "Error"sv, GUI::MessageBox::Type::Error);
return;
}
@ -148,7 +148,7 @@ HexEditorWidget::HexEditorWidget()
dbgln("Wrote document to {}", file->filename());
});
m_find_action = GUI::Action::create("&Find", { Mod_Ctrl, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
m_find_action = GUI::Action::create("&Find", { Mod_Ctrl, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"sv).release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
auto old_buffer = m_search_buffer;
bool find_all = false;
if (FindDialog::show(window(), m_search_text, m_search_buffer, find_all) == GUI::InputBox::ExecResult::OK) {
@ -158,7 +158,7 @@ HexEditorWidget::HexEditorWidget()
m_search_results->update();
if (matches.is_empty()) {
GUI::MessageBox::show(window(), String::formatted("Pattern \"{}\" not found in this file", m_search_text), "Not found", GUI::MessageBox::Type::Warning);
GUI::MessageBox::show(window(), String::formatted("Pattern \"{}\" not found in this file", m_search_text), "Not found"sv, GUI::MessageBox::Type::Warning);
return;
}
@ -174,7 +174,7 @@ HexEditorWidget::HexEditorWidget()
auto result = m_editor->find_and_highlight(m_search_buffer, same_buffers ? last_found_index() : 0);
if (!result.has_value()) {
GUI::MessageBox::show(window(), String::formatted("Pattern \"{}\" not found in this file", m_search_text), "Not found", GUI::MessageBox::Type::Warning);
GUI::MessageBox::show(window(), String::formatted("Pattern \"{}\" not found in this file", m_search_text), "Not found"sv, GUI::MessageBox::Type::Warning);
return;
}
@ -185,7 +185,7 @@ HexEditorWidget::HexEditorWidget()
}
});
m_goto_offset_action = GUI::Action::create("&Go to Offset ...", { Mod_Ctrl, Key_G }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-to.png").release_value_but_fixme_should_propagate_errors(), [this](const GUI::Action&) {
m_goto_offset_action = GUI::Action::create("&Go to Offset ...", { Mod_Ctrl, Key_G }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-to.png"sv).release_value_but_fixme_should_propagate_errors(), [this](const GUI::Action&) {
int new_offset;
auto result = GoToOffsetDialog::show(
window(),
@ -201,31 +201,31 @@ HexEditorWidget::HexEditorWidget()
m_layout_toolbar_action = GUI::Action::create_checkable("&Toolbar", [&](auto& action) {
m_toolbar_container->set_visible(action.is_checked());
Config::write_bool("HexEditor", "Layout", "ShowToolbar", action.is_checked());
Config::write_bool("HexEditor"sv, "Layout"sv, "ShowToolbar"sv, action.is_checked());
});
m_layout_search_results_action = GUI::Action::create_checkable("&Search Results", [&](auto& action) {
set_search_results_visible(action.is_checked());
});
m_copy_hex_action = GUI::Action::create("Copy &Hex", { Mod_Ctrl, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/hex.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
m_copy_hex_action = GUI::Action::create("Copy &Hex", { Mod_Ctrl, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/hex.png"sv).release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
m_editor->copy_selected_hex_to_clipboard();
});
m_copy_hex_action->set_enabled(false);
m_copy_text_action = GUI::Action::create("Copy &Text", { Mod_Ctrl | Mod_Shift, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
m_copy_text_action = GUI::Action::create("Copy &Text", { Mod_Ctrl | Mod_Shift, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png"sv).release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
m_editor->copy_selected_text_to_clipboard();
});
m_copy_text_action->set_enabled(false);
m_copy_as_c_code_action = GUI::Action::create("Copy as &C Code", { Mod_Alt | Mod_Shift, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/c.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
m_copy_as_c_code_action = GUI::Action::create("Copy as &C Code", { Mod_Alt | Mod_Shift, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/c.png"sv).release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
m_editor->copy_selected_hex_to_clipboard_as_c_code();
});
m_copy_as_c_code_action->set_enabled(false);
m_fill_selection_action = GUI::Action::create("Fill &Selection...", { Mod_Ctrl, Key_B }, [&](const GUI::Action&) {
String value;
if (GUI::InputBox::show(window(), value, "Fill byte (hex):", "Fill Selection") == GUI::InputBox::ExecResult::OK && !value.is_empty()) {
if (GUI::InputBox::show(window(), value, "Fill byte (hex):"sv, "Fill Selection"sv) == GUI::InputBox::ExecResult::OK && !value.is_empty()) {
auto fill_byte = strtol(value.characters(), nullptr, 16);
m_editor->fill_selection(fill_byte);
}
@ -386,29 +386,29 @@ void HexEditorWidget::initialize_menubar(GUI::Window& window)
edit_menu.add_action(*m_copy_as_c_code_action);
edit_menu.add_separator();
edit_menu.add_action(*m_find_action);
edit_menu.add_action(GUI::Action::create("Find &Next", { Mod_None, Key_F3 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find-next.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
edit_menu.add_action(GUI::Action::create("Find &Next", { Mod_None, Key_F3 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find-next.png"sv).release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
if (m_search_text.is_empty() || m_search_buffer.is_empty()) {
GUI::MessageBox::show(&window, "Nothing to search for", "Not found", GUI::MessageBox::Type::Warning);
GUI::MessageBox::show(&window, "Nothing to search for"sv, "Not found"sv, GUI::MessageBox::Type::Warning);
return;
}
auto result = m_editor->find_and_highlight(m_search_buffer, last_found_index());
if (!result.has_value()) {
GUI::MessageBox::show(&window, String::formatted("No more matches for \"{}\" found in this file", m_search_text), "Not found", GUI::MessageBox::Type::Warning);
GUI::MessageBox::show(&window, String::formatted("No more matches for \"{}\" found in this file", m_search_text), "Not found"sv, GUI::MessageBox::Type::Warning);
return;
}
m_editor->update();
m_last_found_index = result.value();
}));
edit_menu.add_action(GUI::Action::create("Find All &Strings", { Mod_Ctrl | Mod_Shift, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
edit_menu.add_action(GUI::Action::create("Find All &Strings", { Mod_Ctrl | Mod_Shift, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"sv).release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) {
int min_length = 4;
auto matches = m_editor->find_all_strings(min_length);
m_search_results->set_model(*new SearchResultsModel(move(matches)));
m_search_results->update();
if (matches.is_empty()) {
GUI::MessageBox::show(&window, "No strings found in this file", "Not found", GUI::MessageBox::Type::Warning);
GUI::MessageBox::show(&window, "No strings found in this file"sv, "Not found"sv, GUI::MessageBox::Type::Warning);
return;
}
@ -420,7 +420,7 @@ void HexEditorWidget::initialize_menubar(GUI::Window& window)
auto& view_menu = window.add_menu("&View");
auto show_toolbar = Config::read_bool("HexEditor", "Layout", "ShowToolbar", true);
auto show_toolbar = Config::read_bool("HexEditor"sv, "Layout"sv, "ShowToolbar"sv, true);
m_layout_toolbar_action->set_checked(show_toolbar);
m_toolbar_container->set_visible(show_toolbar);
view_menu.add_action(*m_layout_toolbar_action);
@ -428,7 +428,7 @@ void HexEditorWidget::initialize_menubar(GUI::Window& window)
view_menu.add_action(*m_layout_value_inspector_action);
view_menu.add_separator();
auto bytes_per_row = Config::read_i32("HexEditor", "Layout", "BytesPerRow", 16);
auto bytes_per_row = Config::read_i32("HexEditor"sv, "Layout"sv, "BytesPerRow"sv, 16);
m_editor->set_bytes_per_row(bytes_per_row);
m_editor->update();
@ -438,7 +438,7 @@ void HexEditorWidget::initialize_menubar(GUI::Window& window)
auto action = GUI::Action::create_checkable(String::number(i), [this, i](auto&) {
m_editor->set_bytes_per_row(i);
m_editor->update();
Config::write_i32("HexEditor", "Layout", "BytesPerRow", i);
Config::write_i32("HexEditor"sv, "Layout"sv, "BytesPerRow"sv, i);
});
m_bytes_per_row_actions.add_action(action);
bytes_per_row_menu.add_action(action);
@ -466,7 +466,7 @@ void HexEditorWidget::initialize_menubar(GUI::Window& window)
little_endian_mode->set_checked(true);
auto& help_menu = window.add_menu("&Help");
help_menu.add_action(GUI::CommonActions::make_about_action("Hex Editor", GUI::Icon::default_icon("app-hex-editor"), &window));
help_menu.add_action(GUI::CommonActions::make_about_action("Hex Editor", GUI::Icon::default_icon("app-hex-editor"sv), &window));
}
void HexEditorWidget::set_path(StringView path)
@ -488,10 +488,10 @@ void HexEditorWidget::update_title()
{
StringBuilder builder;
if (m_path.is_empty())
builder.append("Untitled");
builder.append("Untitled"sv);
else
builder.append(m_path);
builder.append("[*] - Hex Editor");
builder.append("[*] - Hex Editor"sv);
window()->set_title(builder.to_string());
}

View file

@ -25,7 +25,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
Config::pledge_domain("HexEditor");
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-hex-editor"));
auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-hex-editor"sv));
auto window = TRY(GUI::Window::try_create());
window->set_title("Hex Editor");

View file

@ -154,7 +154,7 @@ void ViewWidget::mouseup_event(GUI::MouseEvent& event)
void ViewWidget::load_from_file(String const& path)
{
auto show_error = [&] {
GUI::MessageBox::show(window(), String::formatted("Failed to open {}", path), "Cannot open image", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window(), String::formatted("Failed to open {}", path), "Cannot open image"sv, GUI::MessageBox::Type::Error);
};
auto file_or_error = Core::MappedFile::map(path);

View file

@ -43,7 +43,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Desktop::Launcher::add_allowed_handler_with_only_specific_urls("/bin/Help", { URL::create_with_file_protocol("/usr/share/man/man1/ImageViewer.md") }));
TRY(Desktop::Launcher::seal_allowlist());
auto app_icon = GUI::Icon::default_icon("filetype-image");
auto app_icon = GUI::Icon::default_icon("filetype-image"sv);
char const* path = nullptr;
Core::ArgsParser args_parser;
@ -124,7 +124,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto msgbox_result = GUI::MessageBox::show(window,
String::formatted("Are you sure you want to delete {}?", path),
"Confirm deletion",
"Confirm deletion"sv,
GUI::MessageBox::Type::Warning,
GUI::MessageBox::InputType::OKCancel);
@ -135,7 +135,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (unlinked_or_error.is_error()) {
GUI::MessageBox::show(window,
String::formatted("unlink({}) failed: {}", path, unlinked_or_error.error()),
"Delete failed",
"Delete failed"sv,
GUI::MessageBox::Type::Error);
return;
@ -157,42 +157,42 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
widget->rotate(Gfx::RotationDirection::Clockwise);
});
auto vertical_flip_action = GUI::Action::create("Flip &Vertically", { Mod_None, Key_V }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-vertical.png")),
auto vertical_flip_action = GUI::Action::create("Flip &Vertically", { Mod_None, Key_V }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-vertical.png"sv)),
[&](auto&) {
widget->flip(Gfx::Orientation::Vertical);
});
auto horizontal_flip_action = GUI::Action::create("Flip &Horizontally", { Mod_None, Key_H }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-horizontal.png")),
auto horizontal_flip_action = GUI::Action::create("Flip &Horizontally", { Mod_None, Key_H }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-horizontal.png"sv)),
[&](auto&) {
widget->flip(Gfx::Orientation::Horizontal);
});
auto desktop_wallpaper_action = GUI::Action::create("Set as Desktop &Wallpaper", TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-display-settings.png")),
auto desktop_wallpaper_action = GUI::Action::create("Set as Desktop &Wallpaper", TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-display-settings.png"sv)),
[&](auto&) {
if (!GUI::Desktop::the().set_wallpaper(widget->bitmap(), widget->path())) {
GUI::MessageBox::show(window,
String::formatted("set_wallpaper({}) failed", widget->path()),
"Could not set wallpaper",
"Could not set wallpaper"sv,
GUI::MessageBox::Type::Error);
}
});
auto go_first_action = GUI::Action::create("&Go to First", { Mod_None, Key_Home }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-first.png")),
auto go_first_action = GUI::Action::create("&Go to First", { Mod_None, Key_Home }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-first.png"sv)),
[&](auto&) {
widget->navigate(ViewWidget::Directions::First);
});
auto go_back_action = GUI::Action::create("Go &Back", { Mod_None, Key_Left }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png")),
auto go_back_action = GUI::Action::create("Go &Back", { Mod_None, Key_Left }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"sv)),
[&](auto&) {
widget->navigate(ViewWidget::Directions::Back);
});
auto go_forward_action = GUI::Action::create("Go &Forward", { Mod_None, Key_Right }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png")),
auto go_forward_action = GUI::Action::create("Go &Forward", { Mod_None, Key_Right }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"sv)),
[&](auto&) {
widget->navigate(ViewWidget::Directions::Forward);
});
auto go_last_action = GUI::Action::create("Go to &Last", { Mod_None, Key_End }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-last.png")),
auto go_last_action = GUI::Action::create("Go to &Last", { Mod_None, Key_End }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-last.png"sv)),
[&](auto&) {
widget->navigate(ViewWidget::Directions::Last);
});

View file

@ -58,7 +58,7 @@ void KeyboardMapperWidget::create_frame()
tmp_button.on_click = [this, &tmp_button]() {
String value;
if (GUI::InputBox::show(window(), value, "New Character:", "Select Character") == GUI::InputBox::ExecResult::OK) {
if (GUI::InputBox::show(window(), value, "New Character:"sv, "Select Character"sv) == GUI::InputBox::ExecResult::OK) {
int i = m_keys.find_first_index(&tmp_button).value_or(0);
VERIFY(i > 0);
@ -90,11 +90,11 @@ void KeyboardMapperWidget::create_frame()
m_map_group->set_layout<GUI::HorizontalBoxLayout>();
m_map_group->set_fixed_width(450);
add_map_radio_button("map", "Default");
add_map_radio_button("shift_map", "Shift");
add_map_radio_button("altgr_map", "AltGr");
add_map_radio_button("alt_map", "Alt");
add_map_radio_button("shift_altgr_map", "Shift+AltGr");
add_map_radio_button("map"sv, "Default"sv);
add_map_radio_button("shift_map"sv, "Shift"sv);
add_map_radio_button("altgr_map"sv, "AltGr"sv);
add_map_radio_button("alt_map"sv, "Alt"sv);
add_map_radio_button("shift_altgr_map"sv, "Shift+AltGr"sv);
bottom_widget.layout()->add_spacer();
}
@ -257,7 +257,7 @@ void KeyboardMapperWidget::update_window_title()
{
StringBuilder sb;
sb.append(m_filename);
sb.append("[*] - Keyboard Mapper");
sb.append("[*] - Keyboard Mapper"sv);
window()->set_title(sb.to_string());
}

View file

@ -29,7 +29,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::pledge("stdio getkeymap thread rpath cpath wpath recvfd sendfd"));
auto app_icon = GUI::Icon::default_icon("app-keyboard-mapper");
auto app_icon = GUI::Icon::default_icon("app-keyboard-mapper"sv);
auto window = GUI::Window::construct();
window->set_title("Keyboard Mapper");
@ -50,7 +50,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (!keyboard_mapper_widget->request_close())
return;
Optional<String> path = GUI::FilePicker::get_open_filepath(window, "Open", "/res/keymaps/");
Optional<String> path = GUI::FilePicker::get_open_filepath(window, "Open"sv, "/res/keymaps/"sv);
if (!path.has_value())
return;

View file

@ -62,13 +62,13 @@ private:
Core::DirIterator iterator("/res/keymaps/", Core::DirIterator::Flags::SkipDots);
if (iterator.has_error()) {
GUI::MessageBox::show(nullptr, String::formatted("Error on reading mapping file list: {}", iterator.error_string()), "Keyboard settings", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(nullptr, String::formatted("Error on reading mapping file list: {}", iterator.error_string()), "Keyboard settings"sv, GUI::MessageBox::Type::Error);
GUI::Application::the()->quit(-1);
}
while (iterator.has_next()) {
auto name = iterator.next_path();
auto basename = name.replace(".json", "", ReplaceMode::FirstOnly);
auto basename = name.replace(".json"sv, ""sv, ReplaceMode::FirstOnly);
if (!selected_keymaps.find(basename).is_end())
continue;
m_character_map_files.append(basename);
@ -160,8 +160,8 @@ KeyboardSettingsWidget::KeyboardSettingsWidget()
auto json = JsonValue::from_string(proc_keymap->read_all()).release_value_but_fixme_should_propagate_errors();
auto const& keymap_object = json.as_object();
VERIFY(keymap_object.has("keymap"));
m_initial_active_keymap = keymap_object.get("keymap").to_string();
VERIFY(keymap_object.has("keymap"sv));
m_initial_active_keymap = keymap_object.get("keymap"sv).to_string();
dbgln("KeyboardSettings thinks the current keymap is: {}", m_initial_active_keymap);
auto mapper_config(Core::ConfigFile::open("/etc/Keyboard.ini").release_value_but_fixme_should_propagate_errors());
@ -247,7 +247,7 @@ KeyboardSettingsWidget::KeyboardSettingsWidget()
};
m_num_lock_checkbox = find_descendant_of_type_named<GUI::CheckBox>("num_lock_checkbox");
m_num_lock_checkbox->set_checked(Config::read_bool("KeyboardSettings", "StartupEnable", "NumLock", true));
m_num_lock_checkbox->set_checked(Config::read_bool("KeyboardSettings"sv, "StartupEnable"sv, "NumLock"sv, true));
m_num_lock_checkbox->on_checked = [&](auto) {
set_modified(true);
};
@ -277,11 +277,11 @@ void KeyboardSettingsWidget::apply_settings()
m_initial_keymap_list.append(keymap);
}
m_initial_active_keymap = m_keymaps_list_model.active_keymap();
Config::write_bool("KeyboardSettings", "StartupEnable", "NumLock", m_num_lock_checkbox->is_checked());
Config::write_bool("KeyboardSettings"sv, "StartupEnable"sv, "NumLock"sv, m_num_lock_checkbox->is_checked());
}
void KeyboardSettingsWidget::set_keymaps(Vector<String> const& keymaps, String const& active_keymap)
{
auto keymaps_string = String::join(',', keymaps);
GUI::Process::spawn_or_show_error(window(), "/bin/keymap", Array { "-s", keymaps_string.characters(), "-m", active_keymap.characters() });
GUI::Process::spawn_or_show_error(window(), "/bin/keymap"sv, Array { "-s", keymaps_string.characters(), "-m", active_keymap.characters() });
}

View file

@ -33,11 +33,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::unveil("/etc/Keyboard.ini", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
auto app_icon = GUI::Icon::default_icon("app-keyboard-settings");
auto app_icon = GUI::Icon::default_icon("app-keyboard-settings"sv);
auto window = TRY(GUI::SettingsWindow::create("Keyboard Settings"));
window->set_icon(app_icon.bitmap_for_size(16));
auto keyboard_settings_widget = TRY(window->add_tab<KeyboardSettingsWidget>("Keyboard", "keyboard"));
auto keyboard_settings_widget = TRY(window->add_tab<KeyboardSettingsWidget>("Keyboard"sv, "keyboard"sv));
window->set_active_tab(selected_tab);
window->on_active_window_change = [&](bool is_active_window) {

View file

@ -24,7 +24,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
auto app_icon = GUI::Icon::default_icon("app-magnifier");
auto app_icon = GUI::Icon::default_icon("app-magnifier"sv);
// 4px on each side for padding
constexpr int window_dimensions = 200 + 4 + 4;
@ -78,13 +78,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto timeline_menu = TRY(window->try_add_menu("&Timeline"));
auto previous_frame_action = GUI::Action::create(
"&Previous frame", { Key_Left }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png")), [&](auto&) {
"&Previous frame", { Key_Left }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"sv)), [&](auto&) {
pause_action->set_checked(true);
magnifier->pause_capture(true);
magnifier->display_previous_frame();
});
auto next_frame_action = GUI::Action::create(
"&Next frame", { Key_Right }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png")), [&](auto&) {
"&Next frame", { Key_Right }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"sv)), [&](auto&) {
pause_action->set_checked(true);
magnifier->pause_capture(true);
magnifier->display_next_frame();

View file

@ -44,7 +44,7 @@ MailWidget::MailWidget()
GUI::MessageBox::show(
window(),
String::formatted("The link to '{}' could not be opened.", url),
"Failed to open link",
"Failed to open link"sv,
GUI::MessageBox::Type::Error);
}
};
@ -98,28 +98,28 @@ MailWidget::MailWidget()
bool MailWidget::connect_and_login()
{
auto server = Config::read_string("Mail", "Connection", "Server", {});
auto server = Config::read_string("Mail"sv, "Connection"sv, "Server"sv, {});
if (server.is_empty()) {
auto result = GUI::MessageBox::show(window(), "Mail has no servers configured. Do you want configure them now?", "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::YesNo);
auto result = GUI::MessageBox::show(window(), "Mail has no servers configured. Do you want configure them now?"sv, "Error"sv, GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::YesNo);
if (result == GUI::MessageBox::ExecResult::Yes)
Desktop::Launcher::open(URL::create_with_file_protocol("/bin/MailSettings"));
return false;
}
// Assume TLS by default, which is on port 993.
auto port = Config::read_i32("Mail", "Connection", "Port", 993);
auto tls = Config::read_bool("Mail", "Connection", "TLS", true);
auto port = Config::read_i32("Mail"sv, "Connection"sv, "Port"sv, 993);
auto tls = Config::read_bool("Mail"sv, "Connection"sv, "TLS"sv, true);
auto username = Config::read_string("Mail", "User", "Username", {});
auto username = Config::read_string("Mail"sv, "User"sv, "Username"sv, {});
if (username.is_empty()) {
GUI::MessageBox::show_error(window(), "Mail has no username configured. Refer to the Mail(1) man page for more information.");
GUI::MessageBox::show_error(window(), "Mail has no username configured. Refer to the Mail(1) man page for more information."sv);
return false;
}
auto password = Config::read_string("Mail", "User", "Password", {});
auto password = Config::read_string("Mail"sv, "User"sv, "Password"sv, {});
while (password.is_empty()) {
if (GUI::PasswordInputDialog::show(window(), password, "Login", server, username) != GUI::Dialog::ExecResult::OK)
if (GUI::PasswordInputDialog::show(window(), password, "Login"sv, server, username) != GUI::Dialog::ExecResult::OK)
return false;
}
@ -142,7 +142,7 @@ bool MailWidget::connect_and_login()
return false;
}
response = m_imap_client->list("", "*")->await().release_value();
response = m_imap_client->list(""sv, "*"sv)->await().release_value();
if (response.status() != IMAP::ResponseStatus::OK) {
dbgln("Failed to retrieve mailboxes. The server says: '{}'", response.response_text());
@ -171,7 +171,7 @@ void MailWidget::on_window_close()
IMAP::MultiPartBodyStructureData const* MailWidget::look_for_alternative_body_structure(IMAP::MultiPartBodyStructureData const& current_body_structure, Vector<u32>& position_stack) const
{
if (current_body_structure.media_type.equals_ignoring_case("ALTERNATIVE"))
if (current_body_structure.media_type.equals_ignoring_case("ALTERNATIVE"sv))
return &current_body_structure;
u32 structure_index = 1;
@ -227,7 +227,7 @@ Vector<MailWidget::Alternative> MailWidget::get_alternatives(IMAP::MultiPartBody
bool MailWidget::is_supported_alternative(Alternative const& alternative) const
{
return alternative.body_structure.type.equals_ignoring_case("text") && (alternative.body_structure.subtype.equals_ignoring_case("plain") || alternative.body_structure.subtype.equals_ignoring_case("html"));
return alternative.body_structure.type.equals_ignoring_case("text"sv) && (alternative.body_structure.subtype.equals_ignoring_case("plain"sv) || alternative.body_structure.subtype.equals_ignoring_case("html"sv));
}
void MailWidget::selected_mailbox()
@ -351,7 +351,7 @@ void MailWidget::selected_mailbox()
};
auto& subject_iterator_value = subject_iterator->get<1>().value();
auto subject_index = subject_iterator_value.find("Subject:");
auto subject_index = subject_iterator_value.find("Subject:"sv);
String subject;
if (subject_index.has_value()) {
auto potential_subject = subject_iterator_value.substring(subject_index.value());
@ -363,7 +363,7 @@ void MailWidget::selected_mailbox()
subject = "(no subject)";
auto& from_iterator_value = from_iterator->get<1>().value();
auto from_index = from_iterator_value.find("From:");
auto from_index = from_iterator_value.find("From:"sv);
VERIFY(from_index.has_value());
auto potential_from = from_iterator_value.substring(from_index.value());
auto from_parts = potential_from.split_limit(':', 2);
@ -419,7 +419,7 @@ void MailWidget::selected_email_to_load()
auto alternatives = get_alternatives(data);
if (alternatives.is_empty()) {
dbgln("No alternatives. The server said: '{}'", fetch_response.response_text());
GUI::MessageBox::show_error(window(), "The server sent no message to display.");
GUI::MessageBox::show_error(window(), "The server sent no message to display."sv);
return;
}
@ -430,7 +430,7 @@ void MailWidget::selected_email_to_load()
});
if (!chosen_alternative.has_value()) {
GUI::MessageBox::show(window(), "Displaying this type of e-mail is currently unsupported.", "Unsupported", GUI::MessageBox::Type::Information);
GUI::MessageBox::show(window(), "Displaying this type of e-mail is currently unsupported."sv, "Unsupported"sv, GUI::MessageBox::Type::Information);
return;
}
@ -469,14 +469,14 @@ void MailWidget::selected_email_to_load()
if (fetch_data.is_empty()) {
dbgln("The server sent no fetch data.");
GUI::MessageBox::show_error(window(), "The server sent no data.");
GUI::MessageBox::show_error(window(), "The server sent no data."sv);
return;
}
auto& fetch_response_data = fetch_data.last().get<IMAP::FetchResponseData>();
if (!fetch_response_data.contains_response_type(IMAP::FetchResponseType::Body)) {
GUI::MessageBox::show_error(window(), "The server sent no body.");
GUI::MessageBox::show_error(window(), "The server sent no body."sv);
return;
}
@ -493,21 +493,21 @@ void MailWidget::selected_email_to_load()
// FIXME: String uses char internally, so 8bit shouldn't be stored in it.
// However, it works for now.
if (selected_alternative_encoding.equals_ignoring_case("7bit") || selected_alternative_encoding.equals_ignoring_case("8bit")) {
if (selected_alternative_encoding.equals_ignoring_case("7bit"sv) || selected_alternative_encoding.equals_ignoring_case("8bit"sv)) {
decoded_data = encoded_data;
} else if (selected_alternative_encoding.equals_ignoring_case("base64")) {
} else if (selected_alternative_encoding.equals_ignoring_case("base64"sv)) {
auto decoded_base64 = decode_base64(encoded_data);
if (!decoded_base64.is_error())
decoded_data = decoded_base64.release_value();
} else if (selected_alternative_encoding.equals_ignoring_case("quoted-printable")) {
} else if (selected_alternative_encoding.equals_ignoring_case("quoted-printable"sv)) {
decoded_data = IMAP::decode_quoted_printable(encoded_data);
} else {
dbgln("Mail: Unimplemented decoder for encoding: {}", selected_alternative_encoding);
GUI::MessageBox::show(window(), String::formatted("The e-mail encoding '{}' is currently unsupported.", selected_alternative_encoding), "Unsupported", GUI::MessageBox::Type::Information);
GUI::MessageBox::show(window(), String::formatted("The e-mail encoding '{}' is currently unsupported.", selected_alternative_encoding), "Unsupported"sv, GUI::MessageBox::Type::Information);
return;
}
// FIXME: I'm not sure what the URL should be. Just use the default URL "about:blank".
// FIXME: It would be nice if we could pass over the charset.
m_web_view->load_html(decoded_data, "about:blank");
m_web_view->load_html(decoded_data, "about:blank"sv);
}

View file

@ -11,9 +11,9 @@
MailboxTreeModel::MailboxTreeModel(AccountHolder const& account_holder)
: m_account_holder(account_holder)
{
m_mail_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-mail.png").release_value_but_fixme_should_propagate_errors());
m_folder_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-folder.png").release_value_but_fixme_should_propagate_errors());
m_account_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/home-directory.png").release_value_but_fixme_should_propagate_errors());
m_mail_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-mail.png"sv).release_value_but_fixme_should_propagate_errors());
m_folder_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-folder.png"sv).release_value_but_fixme_should_propagate_errors());
m_account_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/home-directory.png"sv).release_value_but_fixme_should_propagate_errors());
}
GUI::ModelIndex MailboxTreeModel::index(int row, int column, GUI::ModelIndex const& parent) const

View file

@ -37,7 +37,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto window = GUI::Window::construct();
auto app_icon = GUI::Icon::default_icon("app-mail");
auto app_icon = GUI::Icon::default_icon("app-mail"sv);
window->set_icon(app_icon.bitmap_for_size(16));
auto mail_widget = TRY(window->try_set_main_widget<MailWidget>());

View file

@ -17,10 +17,10 @@
void MailSettingsWidget::reset_default_values()
{
m_server_inputbox->set_text("");
m_port_combobox->set_text("993");
m_server_inputbox->set_text(""sv);
m_port_combobox->set_text("993"sv);
m_tls_checkbox->set_checked(false);
m_email_inputbox->set_text("");
m_email_inputbox->set_text(""sv);
}
void MailSettingsWidget::apply_settings()
@ -30,10 +30,10 @@ void MailSettingsWidget::apply_settings()
m_tls = m_tls_checkbox->is_checked();
m_email = m_email_inputbox->get_text();
Config::write_string("Mail", "Connection", "Server", m_server);
Config::write_string("Mail", "Connection", "Port", m_port);
Config::write_bool("Mail", "Connection", "TLS", m_tls);
Config::write_string("Mail", "User", "Username", m_email);
Config::write_string("Mail"sv, "Connection"sv, "Server"sv, m_server);
Config::write_string("Mail"sv, "Connection"sv, "Port"sv, m_port);
Config::write_bool("Mail"sv, "Connection"sv, "TLS"sv, m_tls);
Config::write_string("Mail"sv, "User"sv, "Username"sv, m_email);
}
MailSettingsWidget::MailSettingsWidget()
@ -45,13 +45,13 @@ MailSettingsWidget::MailSettingsWidget()
load_from_gml(mail_settings_widget_gml);
m_server_inputbox = *find_descendant_of_type_named<GUI::TextBox>("server_input");
m_server_inputbox->set_text(Config::read_string("Mail", "Connection", "Server", ""));
m_server_inputbox->set_text(Config::read_string("Mail"sv, "Connection"sv, "Server"sv, ""sv));
m_server_inputbox->on_change = [&]() {
set_modified(true);
};
m_port_combobox = *find_descendant_of_type_named<GUI::ComboBox>("port_input");
m_port_combobox->set_text(Config::read_string("Mail", "Connection", "Port", "993"));
m_port_combobox->set_text(Config::read_string("Mail"sv, "Connection"sv, "Port"sv, "993"sv));
m_port_combobox->set_only_allow_values_from_model(false);
m_port_combobox->set_model(*GUI::ItemListModel<String>::create(m_common_ports));
m_port_combobox->on_change = [&](auto, auto) {
@ -59,13 +59,13 @@ MailSettingsWidget::MailSettingsWidget()
};
m_tls_checkbox = *find_descendant_of_type_named<GUI::CheckBox>("tls_input");
m_tls_checkbox->set_checked(Config::read_bool("Mail", "Connection", "TLS", false));
m_tls_checkbox->set_checked(Config::read_bool("Mail"sv, "Connection"sv, "TLS"sv, false));
m_tls_checkbox->on_checked = [&](auto) {
set_modified(true);
};
m_email_inputbox = *find_descendant_of_type_named<GUI::TextBox>("email_input");
m_email_inputbox->set_text(Config::read_string("Mail", "User", "Username", ""));
m_email_inputbox->set_text(Config::read_string("Mail"sv, "User"sv, "Username"sv, ""sv));
m_email_inputbox->on_change = [&]() {
set_modified(true);
};

View file

@ -31,10 +31,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::unveil("/res", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
auto app_icon = GUI::Icon::default_icon("app-mail");
auto app_icon = GUI::Icon::default_icon("app-mail"sv);
auto window = TRY(GUI::SettingsWindow::create("Mail Settings", GUI::SettingsWindow::ShowDefaultsButton::Yes));
(void)TRY(window->add_tab<MailSettingsWidget>("Mail", "mail"));
(void)TRY(window->add_tab<MailSettingsWidget>("Mail"sv, "mail"sv));
window->set_icon(app_icon.bitmap_for_size(16));
window->set_active_tab(selected_tab);

View file

@ -24,7 +24,7 @@ void DoubleClickArrowWidget::set_double_click_speed(int speed)
DoubleClickArrowWidget::DoubleClickArrowWidget()
{
m_arrow_bitmap = Gfx::Bitmap::try_load_from_file("/res/graphics/double-click-down-arrow.png").release_value_but_fixme_should_propagate_errors();
m_arrow_bitmap = Gfx::Bitmap::try_load_from_file("/res/graphics/double-click-down-arrow.png"sv).release_value_but_fixme_should_propagate_errors();
}
void DoubleClickArrowWidget::paint_event(GUI::PaintEvent& event)

View file

@ -30,7 +30,7 @@ ErrorOr<void> HighlightPreviewWidget::reload_cursor()
return maybe_bitmap;
return Gfx::Bitmap::try_load_from_file(default_path);
};
constexpr auto default_cursor_path = "/res/cursor-themes/Default/arrow.x2y2.png";
constexpr auto default_cursor_path = "/res/cursor-themes/Default/arrow.x2y2.png"sv;
auto cursor_path = String::formatted("/res/cursor-themes/{}/{}",
cursor_theme, cursor_theme_config->read_entry("Cursor", "Arrow"));
m_cursor_bitmap = TRY(load_bitmap(cursor_path, default_cursor_path));

View file

@ -54,9 +54,9 @@ void MouseCursorModel::invalidate()
while (iterator.has_next()) {
auto path = iterator.next_full_path();
if (path.ends_with(".ini"))
if (path.ends_with(".ini"sv))
continue;
if (path.contains("2x"))
if (path.contains("2x"sv))
continue;
Cursor cursor;

View file

@ -31,12 +31,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.add_option(selected_tab, "Tab, one of 'cursor-theme', 'cursor-highlight', or 'mouse'", "open-tab", 't', "tab");
args_parser.parse(arguments);
auto app_icon = GUI::Icon::default_icon("app-mouse");
auto app_icon = GUI::Icon::default_icon("app-mouse"sv);
auto window = TRY(GUI::SettingsWindow::create("Mouse Settings", GUI::SettingsWindow::ShowDefaultsButton::Yes));
(void)TRY(window->add_tab<MouseWidget>("Mouse", "mouse"));
(void)TRY(window->add_tab<ThemeWidget>("Cursor Theme", "cursor-theme"));
(void)TRY(window->add_tab<HighlightWidget>("Cursor Highlight", "cursor-highlight"));
(void)TRY(window->add_tab<MouseWidget>("Mouse"sv, "mouse"sv));
(void)TRY(window->add_tab<ThemeWidget>("Cursor Theme"sv, "cursor-theme"sv));
(void)TRY(window->add_tab<HighlightWidget>("Cursor Highlight"sv, "cursor-highlight"sv));
window->set_icon(app_icon.bitmap_for_size(16));
window->set_active_tab(selected_tab);

View file

@ -63,14 +63,14 @@ NetworkSettingsWidget::NetworkSettingsWidget()
auto config_file = Core::ConfigFile::open_for_system("Network").release_value_but_fixme_should_propagate_errors();
auto proc_net_adapters_file = Core::Stream::File::open("/proc/net/adapters", Core::Stream::OpenMode::Read).release_value_but_fixme_should_propagate_errors();
auto proc_net_adapters_file = Core::Stream::File::open("/proc/net/adapters"sv, Core::Stream::OpenMode::Read).release_value_but_fixme_should_propagate_errors();
auto data = proc_net_adapters_file->read_all().release_value_but_fixme_should_propagate_errors();
JsonParser parser(data);
JsonValue proc_net_adapters_json = parser.parse().release_value_but_fixme_should_propagate_errors();
// FIXME: This should be done before creating a window.
if (proc_net_adapters_json.as_array().is_empty()) {
GUI::MessageBox::show_error(window(), "No network adapters found!");
GUI::MessageBox::show_error(window(), "No network adapters found!"sv);
::exit(1);
}
@ -78,7 +78,7 @@ NetworkSettingsWidget::NetworkSettingsWidget()
size_t index = 0;
proc_net_adapters_json.as_array().for_each([&](auto& value) {
auto& if_object = value.as_object();
auto adapter_name = if_object.get("name").to_string();
auto adapter_name = if_object.get("name"sv).to_string();
if (adapter_name == "loop")
return;
@ -160,10 +160,10 @@ void NetworkSettingsWidget::apply_settings()
config_file->write_entry(adapter_data.key, "IPv4Gateway", adapter_data.value.default_gateway);
}
GUI::Process::spawn_or_show_error(window(), "/bin/NetworkServer");
GUI::Process::spawn_or_show_error(window(), "/bin/NetworkServer"sv);
if (may_need_to_reboot)
GUI::MessageBox::show(window(), "You may need to reboot for changes to take effect.", "Network Settings", GUI::MessageBox::Type::Warning);
GUI::MessageBox::show(window(), "You may need to reboot for changes to take effect."sv, "Network Settings"sv, GUI::MessageBox::Type::Warning);
}
}

View file

@ -30,15 +30,15 @@ ErrorOr<int> serenity_main(Main::Arguments args)
auto app = TRY(GUI::Application::try_create(args));
if (getuid() != 0) {
GUI::MessageBox::show_error(nullptr, "You need to be root to run Network Settings!");
GUI::MessageBox::show_error(nullptr, "You need to be root to run Network Settings!"sv);
return 1;
}
TRY(Core::System::pledge("stdio rpath wpath cpath recvfd sendfd proc exec"));
auto app_icon = GUI::Icon::default_icon("network");
auto app_icon = GUI::Icon::default_icon("network"sv);
auto window = TRY(GUI::SettingsWindow::create("Network Settings", GUI::SettingsWindow::ShowDefaultsButton::No));
(void)TRY(window->add_tab<NetworkSettings::NetworkSettingsWidget>("Network", "network"));
(void)TRY(window->add_tab<NetworkSettings::NetworkSettingsWidget>("Network"sv, "network"sv));
window->set_icon(app_icon.bitmap_for_size(16));
window->show();

View file

@ -9,7 +9,7 @@
NumericInput::NumericInput()
{
set_text("0");
set_text("0"sv);
on_change = [&] {
auto number_opt = text().to_int();

View file

@ -15,8 +15,8 @@ NonnullRefPtr<OutlineModel> OutlineModel::create(NonnullRefPtr<PDF::OutlineDict>
OutlineModel::OutlineModel(NonnullRefPtr<PDF::OutlineDict> const& outline)
: m_outline(outline)
{
m_closed_item_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book.png").release_value_but_fixme_should_propagate_errors());
m_open_item_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book-open.png").release_value_but_fixme_should_propagate_errors());
m_closed_item_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book.png"sv).release_value_but_fixme_should_propagate_errors());
m_open_item_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book-open.png"sv).release_value_but_fixme_should_propagate_errors());
}
void OutlineModel::set_index_open_state(const GUI::ModelIndex& index, bool is_open)

View file

@ -44,7 +44,7 @@ PDFViewer::PDFViewer()
start_timer(30'000);
m_page_view_mode = static_cast<PageViewMode>(Config::read_i32("PDFViewer", "Display", "PageMode", 0));
m_page_view_mode = static_cast<PageViewMode>(Config::read_i32("PDFViewer"sv, "Display"sv, "PageMode"sv, 0));
}
PDF::PDFErrorOr<void> PDFViewer::set_document(RefPtr<PDF::Document> document)
@ -289,7 +289,7 @@ void PDFViewer::rotate(int degrees)
void PDFViewer::set_page_view_mode(PageViewMode mode)
{
m_page_view_mode = mode;
Config::write_i32("PDFViewer", "Display", "PageMode", static_cast<i32>(mode));
Config::write_i32("PDFViewer"sv, "Display"sv, "PageMode"sv, static_cast<i32>(mode));
update();
}

View file

@ -65,13 +65,13 @@ void PDFViewerWidget::initialize_menubar(GUI::Window& window)
view_menu.add_action(*m_reset_zoom_action);
auto& help_menu = window.add_menu("&Help");
help_menu.add_action(GUI::CommonActions::make_about_action("PDF Viewer", GUI::Icon::default_icon("app-pdf-viewer"), &window));
help_menu.add_action(GUI::CommonActions::make_about_action("PDF Viewer", GUI::Icon::default_icon("app-pdf-viewer"sv), &window));
}
void PDFViewerWidget::initialize_toolbar(GUI::Toolbar& toolbar)
{
auto open_outline_action = GUI::Action::create(
"Toggle &Sidebar", { Mod_Ctrl, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/sidebar.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
"Toggle &Sidebar", { Mod_Ctrl, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/sidebar.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
m_sidebar_open = !m_sidebar_open;
m_sidebar->set_fixed_width(m_sidebar_open ? 200 : 0);
},
@ -82,13 +82,13 @@ void PDFViewerWidget::initialize_toolbar(GUI::Toolbar& toolbar)
toolbar.add_action(*open_outline_action);
toolbar.add_separator();
m_go_to_prev_page_action = GUI::Action::create("Go to &Previous Page", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-up.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
m_go_to_prev_page_action = GUI::Action::create("Go to &Previous Page", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-up.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
VERIFY(m_viewer->current_page() > 0);
m_page_text_box->set_current_number(m_viewer->current_page());
});
m_go_to_prev_page_action->set_enabled(false);
m_go_to_next_page_action = GUI::Action::create("Go to &Next Page", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-down.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
m_go_to_next_page_action = GUI::Action::create("Go to &Next Page", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-down.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
VERIFY(m_viewer->current_page() < m_viewer->document()->get_page_count() - 1);
m_page_text_box->set_current_number(m_viewer->current_page() + 2);
});

View file

@ -24,7 +24,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.parse(arguments);
auto app = TRY(GUI::Application::try_create(arguments));
auto app_icon = GUI::Icon::default_icon("app-pdf-viewer");
auto app_icon = GUI::Icon::default_icon("app-pdf-viewer"sv);
Config::pledge_domain("PDFViewer");

View file

@ -87,30 +87,30 @@ constexpr int black_key_height = 60;
constexpr int white_key_labels_count = 12;
constexpr Array<StringView, white_key_labels_count> white_key_labels = {
"A",
"S",
"D",
"F",
"G",
"H",
"J",
"K",
"L",
";",
"\'",
"\u23CE", // Return key symbol
"A"sv,
"S"sv,
"D"sv,
"F"sv,
"G"sv,
"H"sv,
"J"sv,
"K"sv,
"L"sv,
";"sv,
"\'"sv,
"\u23CE"sv, // Return key symbol
};
constexpr int black_key_labels_count = 8;
constexpr Array<StringView, black_key_labels_count> black_key_labels = {
"W",
"E",
"T",
"Y",
"U",
"O",
"P",
"]",
"W"sv,
"E"sv,
"T"sv,
"Y"sv,
"U"sv,
"O"sv,
"P"sv,
"]"sv,
};
constexpr int black_key_offsets[] = {

View file

@ -55,11 +55,11 @@ MainWidget::MainWidget(TrackManager& track_manager, AudioPlayerLoop& loop)
void MainWidget::add_track_actions(GUI::Menu& menu)
{
menu.add_action(GUI::Action::create("&Add Track", { Mod_Ctrl, Key_T }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/plus.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
menu.add_action(GUI::Action::create("&Add Track", { Mod_Ctrl, Key_T }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/plus.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
m_player_widget->add_track();
}));
menu.add_action(GUI::Action::create("&Next Track", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-last.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
menu.add_action(GUI::Action::create("&Next Track", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-last.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
turn_off_pressed_keys();
m_player_widget->next_track();
turn_on_pressed_keys();

View file

@ -155,19 +155,19 @@ constexpr int beats_per_bar = 4;
constexpr int notes_per_beat = 4;
constexpr int roll_length = (sample_rate / (beats_per_minute / 60)) * beats_per_bar;
constexpr char const* note_names[] = {
"C",
"C#",
"D",
"D#",
"E",
"F",
"F#",
"G",
"G#",
"A",
"A#",
"B",
constexpr StringView note_names[] = {
"C"sv,
"C#"sv,
"D"sv,
"D#"sv,
"E"sv,
"F"sv,
"F#"sv,
"G"sv,
"G#"sv,
"A"sv,
"A#"sv,
"B"sv,
};
// Equal temperament, A = 440Hz

View file

@ -24,12 +24,12 @@ PlayerWidget::PlayerWidget(TrackManager& manager, AudioPlayerLoop& loop)
set_fill_with_background_color(true);
m_track_number_choices.append("1");
m_play_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/play.png").release_value_but_fixme_should_propagate_errors();
m_pause_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/pause.png").release_value_but_fixme_should_propagate_errors();
m_back_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png").release_value_but_fixme_should_propagate_errors(); // Go back a note
m_next_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors(); // Advance a note
m_add_track_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/plus.png").release_value_but_fixme_should_propagate_errors();
m_next_track_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-last.png").release_value_but_fixme_should_propagate_errors();
m_play_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/play.png"sv).release_value_but_fixme_should_propagate_errors();
m_pause_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/pause.png"sv).release_value_but_fixme_should_propagate_errors();
m_back_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"sv).release_value_but_fixme_should_propagate_errors(); // Go back a note
m_next_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"sv).release_value_but_fixme_should_propagate_errors(); // Advance a note
m_add_track_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/plus.png"sv).release_value_but_fixme_should_propagate_errors();
m_next_track_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-last.png"sv).release_value_but_fixme_should_propagate_errors();
RefPtr<GUI::Label> label = add<GUI::Label>("Track");
label->set_max_width(75);

View file

@ -152,7 +152,7 @@ void RollWidget::paint_event(GUI::PaintEvent& event)
}
Gfx::IntRect note_name_rect(3, y, 1, note_height);
char const* note_name = note_names[note % notes_per_octave];
auto note_name = note_names[note % notes_per_octave];
painter.draw_text(note_name_rect, note_name, Gfx::TextAlignment::CenterLeft);
note_name_rect.translate_by(Gfx::FontDatabase::default_font().width(note_name) + 2, 0);

View file

@ -81,7 +81,7 @@ SamplerWidget::SamplerWidget(TrackManager& track_manager)
m_open_button = m_open_button_and_recorded_sample_name_container->add<GUI::Button>();
m_open_button->set_fixed_size(24, 24);
m_open_button->set_focus_policy(GUI::FocusPolicy::TabFocus);
m_open_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png").release_value_but_fixme_should_propagate_errors());
m_open_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png"sv).release_value_but_fixme_should_propagate_errors());
m_open_button->on_click = [this](auto) {
Optional<String> open_path = GUI::FilePicker::get_open_filepath(window());
if (!open_path.has_value())

View file

@ -38,7 +38,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto audio_loop = AudioPlayerLoop::construct(track_manager, need_to_write_wav, wav_writer);
auto app_icon = GUI::Icon::default_icon("app-piano");
auto app_icon = GUI::Icon::default_icon("app-piano"sv);
auto window = GUI::Window::construct();
auto main_widget = TRY(window->try_set_main_widget<MainWidget>(track_manager, audio_loop));
window->set_title("Piano");
@ -51,13 +51,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
main_widget_updater->start();
auto& file_menu = window->add_menu("&File");
file_menu.add_action(GUI::Action::create("Export", { Mod_Ctrl, Key_E }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/file-export.png")), [&](const GUI::Action&) {
file_menu.add_action(GUI::Action::create("Export", { Mod_Ctrl, Key_E }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/file-export.png"sv)), [&](const GUI::Action&) {
save_path = GUI::FilePicker::get_save_filepath(window, "Untitled", "wav");
if (!save_path.has_value())
return;
wav_writer.set_file(save_path.value());
if (wav_writer.has_error()) {
GUI::MessageBox::show(window, String::formatted("Failed to export WAV file: {}", wav_writer.error_string()), "Error", GUI::MessageBox::Type::Error);
GUI::MessageBox::show(window, String::formatted("Failed to export WAV file: {}", wav_writer.error_string()), "Error"sv, GUI::MessageBox::Type::Error);
wav_writer.clear_error();
return;
}

View file

@ -34,7 +34,7 @@ CreateNewImageDialog::CreateNewImageDialog(GUI::Window* parent_window)
m_name_textbox->on_change = [this] {
m_image_name = m_name_textbox->text();
};
auto default_name = Config::read_string("PixelPaint", "NewImage", "Name");
auto default_name = Config::read_string("PixelPaint"sv, "NewImage"sv, "Name"sv);
m_name_textbox->set_text(default_name);
auto& width_label = main_widget.add<GUI::Label>("Width:");
@ -72,8 +72,8 @@ CreateNewImageDialog::CreateNewImageDialog(GUI::Window* parent_window)
width_spinbox.set_range(1, 16384);
height_spinbox.set_range(1, 16384);
auto default_width = Config::read_i32("PixelPaint", "NewImage", "Width", 510);
auto default_height = Config::read_i32("PixelPaint", "NewImage", "Height", 356);
auto default_width = Config::read_i32("PixelPaint"sv, "NewImage"sv, "Width"sv, 510);
auto default_height = Config::read_i32("PixelPaint"sv, "NewImage"sv, "Height"sv, 356);
width_spinbox.set_value(default_width);
height_spinbox.set_value(default_height);
}

View file

@ -30,7 +30,7 @@ CreateNewLayerDialog::CreateNewLayerDialog(Gfx::IntSize const& suggested_size, G
name_label.set_text_alignment(Gfx::TextAlignment::CenterLeft);
m_name_textbox = main_widget.add<GUI::TextBox>();
m_name_textbox->set_text("Layer");
m_name_textbox->set_text("Layer"sv);
m_name_textbox->select_all();
m_name_textbox->on_change = [this] {
m_layer_name = m_name_textbox->text();

View file

@ -44,7 +44,7 @@ private:
// FIXME: Help! Make this GUI less ugly.
StringBuilder builder;
builder.appendff("{}x{}", N, N);
builder.append(" Convolution");
builder.append(" Convolution"sv);
set_title(builder.string_view());
resize(200, 250);
@ -73,7 +73,7 @@ private:
if (endptr != nullptr)
element = value;
else
textbox.set_text("");
textbox.set_text(""sv);
};
} else {
horizontal_container.template add<GUI::Widget>();

View file

@ -26,7 +26,7 @@ namespace PixelPaint {
ErrorOr<NonnullRefPtr<GUI::TreeViewModel>> create_filter_tree_model(ImageEditor* editor)
{
auto directory_icon = GUI::FileIconProvider::directory_icon();
auto filter_icon = GUI::Icon(TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/filter.png")));
auto filter_icon = GUI::Icon(TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/filter.png"sv)));
auto filter_tree_model = GUI::TreeViewModel::create();

View file

@ -12,35 +12,35 @@ ErrorOr<IconBag> IconBag::try_create()
{
IconBag icon_bag;
icon_bag.filetype_pixelpaint = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-pixelpaint.png"));
icon_bag.new_clipboard = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/new-clipboard.png"));
icon_bag.file_export = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/file-export.png"));
icon_bag.close_image = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/close-tab.png"));
icon_bag.edit_copy = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png"));
icon_bag.clear_selection = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/clear-selection.png"));
icon_bag.swap_colors = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/swap-colors.png"));
icon_bag.default_colors = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/default-colors.png"));
icon_bag.load_color_palette = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/load-color-palette.png"));
icon_bag.save_color_palette = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/save-color-palette.png"));
icon_bag.add_guide = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/add-guide.png"));
icon_bag.clear_guides = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/clear-guides.png"));
icon_bag.edit_flip_vertical = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-vertical.png"));
icon_bag.edit_flip_horizontal = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-horizontal.png"));
icon_bag.resize_image = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/selection-move.png"));
icon_bag.crop = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/crop.png"));
icon_bag.new_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-layer.png"));
icon_bag.previous_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/previous-layer.png"));
icon_bag.next_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/next-layer.png"));
icon_bag.top_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/top-layer.png"));
icon_bag.bottom_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bottom-layer.png"));
icon_bag.active_layer_up = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/active-layer-up.png"));
icon_bag.active_layer_down = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/active-layer-down.png"));
icon_bag.delete_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png"));
icon_bag.merge_visible = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/merge-visible.png"));
icon_bag.merge_active_layer_up = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/merge-active-layer-up.png"));
icon_bag.merge_active_layer_down = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/merge-active-layer-down.png"));
icon_bag.filter = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/filter.png"));
icon_bag.levels = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/levels.png"));
icon_bag.filetype_pixelpaint = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-pixelpaint.png"sv));
icon_bag.new_clipboard = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/new-clipboard.png"sv));
icon_bag.file_export = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/file-export.png"sv));
icon_bag.close_image = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/close-tab.png"sv));
icon_bag.edit_copy = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png"sv));
icon_bag.clear_selection = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/clear-selection.png"sv));
icon_bag.swap_colors = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/swap-colors.png"sv));
icon_bag.default_colors = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/default-colors.png"sv));
icon_bag.load_color_palette = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/load-color-palette.png"sv));
icon_bag.save_color_palette = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/save-color-palette.png"sv));
icon_bag.add_guide = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/add-guide.png"sv));
icon_bag.clear_guides = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/clear-guides.png"sv));
icon_bag.edit_flip_vertical = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-vertical.png"sv));
icon_bag.edit_flip_horizontal = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-horizontal.png"sv));
icon_bag.resize_image = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/selection-move.png"sv));
icon_bag.crop = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/crop.png"sv));
icon_bag.new_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-layer.png"sv));
icon_bag.previous_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/previous-layer.png"sv));
icon_bag.next_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/next-layer.png"sv));
icon_bag.top_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/top-layer.png"sv));
icon_bag.bottom_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bottom-layer.png"sv));
icon_bag.active_layer_up = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/active-layer-up.png"sv));
icon_bag.active_layer_down = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/active-layer-down.png"sv));
icon_bag.delete_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png"sv));
icon_bag.merge_visible = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/merge-visible.png"sv));
icon_bag.merge_active_layer_up = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/merge-active-layer-up.png"sv));
icon_bag.merge_active_layer_down = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/merge-active-layer-down.png"sv));
icon_bag.filter = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/filter.png"sv));
icon_bag.levels = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/levels.png"sv));
return icon_bag;
}

View file

@ -85,37 +85,37 @@ ErrorOr<NonnullRefPtr<Image>> Image::try_create_from_bitmap(NonnullRefPtr<Gfx::B
ErrorOr<NonnullRefPtr<Image>> Image::try_create_from_pixel_paint_json(JsonObject const& json)
{
auto image = TRY(try_create_with_size({ json.get("width").to_i32(), json.get("height").to_i32() }));
auto image = TRY(try_create_with_size({ json.get("width"sv).to_i32(), json.get("height"sv).to_i32() }));
auto layers_value = json.get("layers");
auto layers_value = json.get("layers"sv);
for (auto& layer_value : layers_value.as_array().values()) {
auto& layer_object = layer_value.as_object();
auto name = layer_object.get("name").as_string();
auto name = layer_object.get("name"sv).as_string();
auto bitmap_base64_encoded = layer_object.get("bitmap").as_string();
auto bitmap_base64_encoded = layer_object.get("bitmap"sv).as_string();
auto bitmap_data = TRY(decode_base64(bitmap_base64_encoded));
auto bitmap = TRY(try_decode_bitmap(bitmap_data));
auto layer = TRY(Layer::try_create_with_bitmap(*image, move(bitmap), name));
if (auto mask_object = layer_object.get("mask"); !mask_object.is_null()) {
if (auto mask_object = layer_object.get("mask"sv); !mask_object.is_null()) {
auto mask_base64_encoded = mask_object.as_string();
auto mask_data = TRY(decode_base64(mask_base64_encoded));
auto mask = TRY(try_decode_bitmap(mask_data));
TRY(layer->try_set_bitmaps(layer->content_bitmap(), mask));
}
auto width = layer_object.get("width").to_i32();
auto height = layer_object.get("height").to_i32();
auto width = layer_object.get("width"sv).to_i32();
auto height = layer_object.get("height"sv).to_i32();
if (width != layer->size().width() || height != layer->size().height())
return Error::from_string_literal("Decoded layer bitmap has wrong size");
image->add_layer(*layer);
layer->set_location({ layer_object.get("locationx").to_i32(), layer_object.get("locationy").to_i32() });
layer->set_opacity_percent(layer_object.get("opacity_percent").to_i32());
layer->set_visible(layer_object.get("visible").as_bool());
layer->set_selected(layer_object.get("selected").as_bool());
layer->set_location({ layer_object.get("locationx"sv).to_i32(), layer_object.get("locationy"sv).to_i32() });
layer->set_opacity_percent(layer_object.get("opacity_percent"sv).to_i32());
layer->set_visible(layer_object.get("visible"sv).as_bool());
layer->set_selected(layer_object.get("selected"sv).as_bool());
}
return image;
@ -123,24 +123,24 @@ ErrorOr<NonnullRefPtr<Image>> Image::try_create_from_pixel_paint_json(JsonObject
void Image::serialize_as_json(JsonObjectSerializer<StringBuilder>& json) const
{
MUST(json.add("width", m_size.width()));
MUST(json.add("height", m_size.height()));
MUST(json.add("width"sv, m_size.width()));
MUST(json.add("height"sv, m_size.height()));
{
auto json_layers = MUST(json.add_array("layers"));
auto json_layers = MUST(json.add_array("layers"sv));
for (auto const& layer : m_layers) {
Gfx::BMPWriter bmp_writer;
auto json_layer = MUST(json_layers.add_object());
MUST(json_layer.add("width", layer.size().width()));
MUST(json_layer.add("height", layer.size().height()));
MUST(json_layer.add("name", layer.name()));
MUST(json_layer.add("locationx", layer.location().x()));
MUST(json_layer.add("locationy", layer.location().y()));
MUST(json_layer.add("opacity_percent", layer.opacity_percent()));
MUST(json_layer.add("visible", layer.is_visible()));
MUST(json_layer.add("selected", layer.is_selected()));
MUST(json_layer.add("bitmap", encode_base64(bmp_writer.dump(layer.content_bitmap()))));
MUST(json_layer.add("width"sv, layer.size().width()));
MUST(json_layer.add("height"sv, layer.size().height()));
MUST(json_layer.add("name"sv, layer.name()));
MUST(json_layer.add("locationx"sv, layer.location().x()));
MUST(json_layer.add("locationy"sv, layer.location().y()));
MUST(json_layer.add("opacity_percent"sv, layer.opacity_percent()));
MUST(json_layer.add("visible"sv, layer.is_visible()));
MUST(json_layer.add("selected"sv, layer.is_selected()));
MUST(json_layer.add("bitmap"sv, encode_base64(bmp_writer.dump(layer.content_bitmap()))));
if (layer.is_masked())
MUST(json_layer.add("mask", encode_base64(bmp_writer.dump(*layer.mask_bitmap()))));
MUST(json_layer.add("mask"sv, encode_base64(bmp_writer.dump(*layer.mask_bitmap()))));
MUST(json_layer.finish());
}

View file

@ -36,11 +36,11 @@ ImageEditor::ImageEditor(NonnullRefPtr<Image> image)
set_original_rect(m_image->rect());
set_scale_bounds(0.1f, 100.0f);
m_pixel_grid_threshold = (float)Config::read_i32("PixelPaint", "PixelGrid", "Threshold", 15);
m_show_pixel_grid = Config::read_bool("PixelPaint", "PixelGrid", "Show", true);
m_pixel_grid_threshold = (float)Config::read_i32("PixelPaint"sv, "PixelGrid"sv, "Threshold"sv, 15);
m_show_pixel_grid = Config::read_bool("PixelPaint"sv, "PixelGrid"sv, "Show"sv, true);
m_show_rulers = Config::read_bool("PixelPaint", "Rulers", "Show", true);
m_show_guides = Config::read_bool("PixelPaint", "Guides", "Show", true);
m_show_rulers = Config::read_bool("PixelPaint"sv, "Rulers"sv, "Show"sv, true);
m_show_guides = Config::read_bool("PixelPaint"sv, "Guides"sv, "Show"sv, true);
}
ImageEditor::~ImageEditor()
@ -618,14 +618,14 @@ Result<void, String> ImageEditor::save_project_to_file(Core::File& file) const
StringBuilder builder;
auto json = MUST(JsonObjectSerializer<>::try_create(builder));
m_image->serialize_as_json(json);
auto json_guides = MUST(json.add_array("guides"));
auto json_guides = MUST(json.add_array("guides"sv));
for (auto const& guide : m_guides) {
auto json_guide = MUST(json_guides.add_object());
MUST(json_guide.add("offset"sv, (double)guide.offset()));
if (guide.orientation() == Guide::Orientation::Vertical)
MUST(json_guide.add("orientation", "vertical"));
MUST(json_guide.add("orientation"sv, "vertical"));
else if (guide.orientation() == Guide::Orientation::Horizontal)
MUST(json_guide.add("orientation", "horizontal"));
MUST(json_guide.add("orientation"sv, "horizontal"));
MUST(json_guide.finish());
}
MUST(json_guides.finish());

View file

@ -23,7 +23,7 @@ LayerPropertiesWidget::LayerPropertiesWidget()
{
set_layout<GUI::VerticalBoxLayout>();
auto& group_box = add<GUI::GroupBox>("Layer properties");
auto& group_box = add<GUI::GroupBox>("Layer properties"sv);
auto& layout = group_box.set_layout<GUI::VerticalBoxLayout>();
layout.set_margins({ 8 });

View file

@ -174,7 +174,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
auto response = FileSystemAccessClient::Client::the().try_save_file(&window, "untitled", "bmp");
if (response.is_error())
return;
auto preserve_alpha_channel = GUI::MessageBox::show(&window, "Do you wish to preserve transparency?", "Preserve transparency?", GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo);
auto preserve_alpha_channel = GUI::MessageBox::show(&window, "Do you wish to preserve transparency?"sv, "Preserve transparency?"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo);
auto result = editor->image().export_bmp_to_file(response.value(), preserve_alpha_channel == GUI::MessageBox::ExecResult::Yes);
if (result.is_error())
GUI::MessageBox::show_error(&window, String::formatted("Export to BMP failed: {}", result.error()));
@ -189,7 +189,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
auto response = FileSystemAccessClient::Client::the().try_save_file(&window, "untitled", "png");
if (response.is_error())
return;
auto preserve_alpha_channel = GUI::MessageBox::show(&window, "Do you wish to preserve transparency?", "Preserve transparency?", GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo);
auto preserve_alpha_channel = GUI::MessageBox::show(&window, "Do you wish to preserve transparency?"sv, "Preserve transparency?"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo);
auto result = editor->image().export_png_to_file(response.value(), preserve_alpha_channel == GUI::MessageBox::ExecResult::Yes);
if (result.is_error())
GUI::MessageBox::show_error(&window, String::formatted("Export to PNG failed: {}", result.error()));
@ -407,12 +407,12 @@ void MainWidget::initialize_menubar(GUI::Window& window)
// Save this so other methods can use it
m_show_guides_action = GUI::Action::create_checkable(
"Show &Guides", [&](auto& action) {
Config::write_bool("PixelPaint", "Guides", "Show", action.is_checked());
Config::write_bool("PixelPaint"sv, "Guides"sv, "Show"sv, action.is_checked());
auto* editor = current_image_editor();
VERIFY(editor);
editor->set_guide_visibility(action.is_checked());
});
m_show_guides_action->set_checked(Config::read_bool("PixelPaint", "Guides", "Show", true));
m_show_guides_action->set_checked(Config::read_bool("PixelPaint"sv, "Guides"sv, "Show"sv, true));
m_view_menu->add_action(*m_zoom_in_action);
m_view_menu->add_action(*m_zoom_out_action);
@ -437,32 +437,32 @@ void MainWidget::initialize_menubar(GUI::Window& window)
auto show_pixel_grid_action = GUI::Action::create_checkable(
"Show &Pixel Grid", [&](auto& action) {
Config::write_bool("PixelPaint", "PixelGrid", "Show", action.is_checked());
Config::write_bool("PixelPaint"sv, "PixelGrid"sv, "Show"sv, action.is_checked());
auto* editor = current_image_editor();
VERIFY(editor);
editor->set_pixel_grid_visibility(action.is_checked());
});
show_pixel_grid_action->set_checked(Config::read_bool("PixelPaint", "PixelGrid", "Show", true));
show_pixel_grid_action->set_checked(Config::read_bool("PixelPaint"sv, "PixelGrid"sv, "Show"sv, true));
m_view_menu->add_action(*show_pixel_grid_action);
m_show_rulers_action = GUI::Action::create_checkable(
"Show R&ulers", { Mod_Ctrl, Key_R }, [&](auto& action) {
Config::write_bool("PixelPaint", "Rulers", "Show", action.is_checked());
Config::write_bool("PixelPaint"sv, "Rulers"sv, "Show"sv, action.is_checked());
auto* editor = current_image_editor();
VERIFY(editor);
editor->set_ruler_visibility(action.is_checked());
});
m_show_rulers_action->set_checked(Config::read_bool("PixelPaint", "Rulers", "Show", true));
m_show_rulers_action->set_checked(Config::read_bool("PixelPaint"sv, "Rulers"sv, "Show"sv, true));
m_view_menu->add_action(*m_show_rulers_action);
m_show_active_layer_boundary_action = GUI::Action::create_checkable(
"Show Active Layer &Boundary", [&](auto& action) {
Config::write_bool("PixelPaint", "ImageEditor", "ShowActiveLayerBoundary", action.is_checked());
Config::write_bool("PixelPaint"sv, "ImageEditor"sv, "ShowActiveLayerBoundary"sv, action.is_checked());
auto* editor = current_image_editor();
VERIFY(editor);
editor->set_show_active_layer_boundary(action.is_checked());
});
m_show_active_layer_boundary_action->set_checked(Config::read_bool("PixelPaint", "ImageEditor", "ShowActiveLayerBoundary", true));
m_show_active_layer_boundary_action->set_checked(Config::read_bool("PixelPaint"sv, "ImageEditor"sv, "ShowActiveLayerBoundary"sv, true));
m_view_menu->add_action(*m_show_active_layer_boundary_action);
m_tool_menu = window.add_menu("&Tool");
@ -700,7 +700,7 @@ void MainWidget::initialize_menubar(GUI::Window& window)
}));
auto& help_menu = window.add_menu("&Help");
help_menu.add_action(GUI::CommonActions::make_about_action("Pixel Paint", GUI::Icon::default_icon("app-pixel-paint"), &window));
help_menu.add_action(GUI::CommonActions::make_about_action("Pixel Paint", GUI::Icon::default_icon("app-pixel-paint"sv), &window));
m_levels_dialog_action = GUI::Action::create(
"Change &Levels...", { Mod_Ctrl, Key_L }, g_icon_bag.levels, [&](auto&) {
@ -825,7 +825,7 @@ void MainWidget::create_image_from_clipboard()
{
auto bitmap = GUI::Clipboard::the().fetch_data_and_type().as_bitmap();
if (!bitmap) {
GUI::MessageBox::show(window(), "There is no image in a clipboard to paste.", "PixelPaint", GUI::MessageBox::Type::Warning);
GUI::MessageBox::show(window(), "There is no image in a clipboard to paste."sv, "PixelPaint"sv, GUI::MessageBox::Type::Warning);
return;
}

View file

@ -264,7 +264,7 @@ Result<void, String> PaletteWidget::save_palette_file(Vector<Color> palette, Cor
{
for (auto& color : palette) {
file.write(color.to_string_without_alpha());
file.write("\n");
file.write("\n"sv);
}
return {};
}

View file

@ -35,8 +35,8 @@ ErrorOr<void> ProjectLoader::try_load_from_file(Core::File& file)
auto& json = json_or_error.value().as_object();
auto image = TRY(Image::try_create_from_pixel_paint_json(json));
if (json.has("guides"))
m_json_metadata = json.get("guides").as_array();
if (json.has("guides"sv))
m_json_metadata = json.get("guides"sv).as_array();
m_image = image;
return {};

View file

@ -18,7 +18,7 @@ ToolPropertiesWidget::ToolPropertiesWidget()
{
set_layout<GUI::VerticalBoxLayout>();
m_group_box = add<GUI::GroupBox>("Tool properties");
m_group_box = add<GUI::GroupBox>("Tool properties"sv);
auto& layout = m_group_box->set_layout<GUI::VerticalBoxLayout>();
layout.set_margins({ 8 });
m_tool_widget_stack = m_group_box->add<GUI::StackWidget>();

View file

@ -68,20 +68,20 @@ void ToolboxWidget::setup_tools()
m_tools.append(move(tool));
};
add_tool("Move", "move", { 0, Key_M }, make<MoveTool>());
add_tool("Pen", "pen", { 0, Key_N }, make<PenTool>());
add_tool("Brush", "brush", { 0, Key_P }, make<BrushTool>());
add_tool("Bucket Fill", "bucket", { Mod_Shift, Key_B }, make<BucketTool>());
add_tool("Spray", "spray", { Mod_Shift, Key_S }, make<SprayTool>());
add_tool("Color Picker", "picker", { 0, Key_O }, make<PickerTool>());
add_tool("Erase", "eraser", { Mod_Shift, Key_E }, make<EraseTool>());
add_tool("Line", "line", { Mod_Ctrl | Mod_Shift, Key_L }, make<LineTool>());
add_tool("Rectangle", "rectangle", { Mod_Ctrl | Mod_Shift, Key_R }, make<RectangleTool>());
add_tool("Ellipse", "circle", { Mod_Ctrl | Mod_Shift, Key_E }, make<EllipseTool>());
add_tool("Zoom", "zoom", { 0, Key_Z }, make<ZoomTool>());
add_tool("Rectangle Select", "rectangle-select", { 0, Key_R }, make<RectangleSelectTool>());
add_tool("Guides", "guides", { 0, Key_G }, make<GuideTool>());
add_tool("Clone Tool", "clone", { 0, Key_C }, make<CloneTool>());
add_tool("Move", "move"sv, { 0, Key_M }, make<MoveTool>());
add_tool("Pen", "pen"sv, { 0, Key_N }, make<PenTool>());
add_tool("Brush", "brush"sv, { 0, Key_P }, make<BrushTool>());
add_tool("Bucket Fill", "bucket"sv, { Mod_Shift, Key_B }, make<BucketTool>());
add_tool("Spray", "spray"sv, { Mod_Shift, Key_S }, make<SprayTool>());
add_tool("Color Picker", "picker"sv, { 0, Key_O }, make<PickerTool>());
add_tool("Erase", "eraser"sv, { Mod_Shift, Key_E }, make<EraseTool>());
add_tool("Line", "line"sv, { Mod_Ctrl | Mod_Shift, Key_L }, make<LineTool>());
add_tool("Rectangle", "rectangle"sv, { Mod_Ctrl | Mod_Shift, Key_R }, make<RectangleTool>());
add_tool("Ellipse", "circle"sv, { Mod_Ctrl | Mod_Shift, Key_E }, make<EllipseTool>());
add_tool("Zoom", "zoom"sv, { 0, Key_Z }, make<ZoomTool>());
add_tool("Rectangle Select", "rectangle-select"sv, { 0, Key_R }, make<RectangleSelectTool>());
add_tool("Guides", "guides"sv, { 0, Key_G }, make<GuideTool>());
add_tool("Clone Tool", "clone"sv, { 0, Key_C }, make<CloneTool>());
}
}

View file

@ -22,7 +22,7 @@ namespace PixelPaint {
BucketTool::BucketTool()
{
m_cursor = Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/bucket.png").release_value_but_fixme_should_propagate_errors();
m_cursor = Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/bucket.png"sv).release_value_but_fixme_should_propagate_errors();
}
static float color_distance_squared(Gfx::Color const& lhs, Gfx::Color const& rhs)

View file

@ -135,7 +135,7 @@ void GuideTool::on_context_menu(Layer*, GUI::ContextMenuEvent& event)
if (!m_context_menu) {
m_context_menu = GUI::Menu::construct();
m_context_menu->add_action(GUI::Action::create(
"Set &Offset", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/gear.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
"Set &Offset", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/gear.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) {
if (!m_context_menu_guide)
return;
auto dialog = EditGuideDialog::construct(
@ -153,7 +153,7 @@ void GuideTool::on_context_menu(Layer*, GUI::ContextMenuEvent& event)
},
editor()));
m_context_menu->add_action(GUI::Action::create(
"&Delete Guide", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) {
"&Delete Guide", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) {
if (!m_context_menu_guide)
return;
editor()->remove_guide(*m_context_menu_guide);

View file

@ -38,7 +38,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::unveil("/etc/FileIconProvider.ini", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
auto app_icon = GUI::Icon::default_icon("app-pixel-paint");
auto app_icon = GUI::Icon::default_icon("app-pixel-paint"sv);
PixelPaint::g_icon_bag = TRY(PixelPaint::IconBag::try_create());

View file

@ -31,7 +31,7 @@ RunWindow::RunWindow()
{
load_history();
auto app_icon = GUI::Icon::default_icon("app-run");
auto app_icon = GUI::Icon::default_icon("app-run"sv);
set_title("Run");
set_icon(app_icon.bitmap_for_size(16));
@ -101,7 +101,7 @@ void RunWindow::do_run()
return;
}
GUI::MessageBox::show_error(this, "Failed to run. Please check your command, path, or address, and try again.");
GUI::MessageBox::show_error(this, "Failed to run. Please check your command, path, or address, and try again."sv);
show();
}

View file

@ -76,7 +76,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::pledge("stdio thread recvfd sendfd rpath cpath wpath proc exec"));
auto app_icon = GUI::Icon::default_icon("app-settings");
auto app_icon = GUI::Icon::default_icon("app-settings"sv);
auto window = TRY(GUI::Window::try_create());
window->set_title("Settings");

Some files were not shown because too many files have changed in this diff Show more