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

LibGUI+Userland: Port Action status tips to String

This commit is contained in:
Karol Kosek 2023-06-04 11:22:04 +02:00 committed by Sam Atkins
parent 4b169cf25f
commit 5234a30731
16 changed files with 86 additions and 85 deletions

View file

@ -23,7 +23,7 @@ ErrorOr<NonnullRefPtr<GUI::Action>> make_cards_settings_action(GUI::Window* pare
GUI::Process::spawn_or_show_error(parent, "/bin/GamesSettings"sv, Array { "--open-tab", "cards" });
},
parent);
action->set_status_tip("Open the Game Settings for Cards");
action->set_status_tip(TRY("Open the Game Settings for Cards"_string));
return action;
}

View file

@ -318,7 +318,7 @@ void Action::set_tooltip(DeprecatedString tooltip)
DeprecatedString Action::status_tip() const
{
if (!m_status_tip.is_empty())
return m_status_tip;
return m_status_tip.to_deprecated_string();
return Gfx::parse_ampersand_string(m_text);
}

View file

@ -12,6 +12,7 @@
#include <AK/HashTable.h>
#include <AK/NonnullRefPtr.h>
#include <AK/RefCounted.h>
#include <AK/String.h>
#include <AK/WeakPtr.h>
#include <AK/Weakable.h>
#include <LibCore/Object.h>
@ -89,7 +90,7 @@ public:
void set_tooltip(DeprecatedString);
DeprecatedString status_tip() const;
void set_status_tip(DeprecatedString status_tip) { m_status_tip = move(status_tip); }
void set_status_tip(String status_tip) { m_status_tip = move(status_tip); }
Shortcut const& shortcut() const { return m_shortcut; }
Shortcut const& alternate_shortcut() const { return m_alternate_shortcut; }
@ -150,7 +151,7 @@ private:
DeprecatedString m_text;
Optional<DeprecatedString> m_tooltip;
DeprecatedString m_status_tip;
String m_status_tip;
RefPtr<Gfx::Bitmap const> m_icon;
Shortcut m_shortcut;
Shortcut m_alternate_shortcut;

View file

@ -28,42 +28,42 @@ NonnullRefPtr<Action> make_about_action(DeprecatedString const& app_name, Icon c
weak_parent)
.release_value_but_fixme_should_propagate_errors();
});
action->set_status_tip("Show application about box");
action->set_status_tip("Show application about box"_string.release_value_but_fixme_should_propagate_errors());
return action;
}
NonnullRefPtr<Action> make_open_action(Function<void(Action&)> callback, Core::Object* parent)
{
auto action = Action::create("&Open...", { Mod_Ctrl, Key_O }, Gfx::Bitmap::load_from_file("/res/icons/16x16/open.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
action->set_status_tip("Open an existing file");
action->set_status_tip("Open an existing file"_string.release_value_but_fixme_should_propagate_errors());
return action;
}
NonnullRefPtr<Action> make_save_action(Function<void(Action&)> callback, Core::Object* parent)
{
auto action = Action::create("&Save", { Mod_Ctrl, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/16x16/save.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
action->set_status_tip("Save the current file");
action->set_status_tip("Save the current file"_string.release_value_but_fixme_should_propagate_errors());
return action;
}
NonnullRefPtr<Action> make_save_as_action(Function<void(Action&)> callback, Core::Object* parent)
{
auto action = Action::create("Save &As...", { Mod_Ctrl | Mod_Shift, Key_S }, Gfx::Bitmap::load_from_file("/res/icons/16x16/save-as.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
action->set_status_tip("Save the current file with a new name");
action->set_status_tip("Save the current file with a new name"_string.release_value_but_fixme_should_propagate_errors());
return action;
}
NonnullRefPtr<Action> make_move_to_front_action(Function<void(Action&)> callback, Core::Object* parent)
{
auto action = Action::create("Move to &Front", { Mod_Ctrl | Mod_Shift, Key_Up }, Gfx::Bitmap::load_from_file("/res/icons/16x16/move-to-front.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
action->set_status_tip("Move to the top of the stack");
action->set_status_tip("Move to the top of the stack"_string.release_value_but_fixme_should_propagate_errors());
return action;
}
NonnullRefPtr<Action> make_move_to_back_action(Function<void(Action&)> callback, Core::Object* parent)
{
auto action = Action::create("Move to &Back", { Mod_Ctrl | Mod_Shift, Key_Down }, Gfx::Bitmap::load_from_file("/res/icons/16x16/move-to-back.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
action->set_status_tip("Move to the bottom of the stack");
action->set_status_tip("Move to the bottom of the stack"_string.release_value_but_fixme_should_propagate_errors());
return action;
}
@ -85,35 +85,35 @@ NonnullRefPtr<Action> make_delete_action(Function<void(Action&)> callback, Core:
NonnullRefPtr<Action> make_cut_action(Function<void(Action&)> callback, Core::Object* parent)
{
auto action = Action::create("Cu&t", { Mod_Ctrl, Key_X }, Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-cut.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
action->set_status_tip("Cut to clipboard");
action->set_status_tip("Cut to clipboard"_string.release_value_but_fixme_should_propagate_errors());
return action;
}
NonnullRefPtr<Action> make_copy_action(Function<void(Action&)> callback, Core::Object* parent)
{
auto action = Action::create("&Copy", { Mod_Ctrl, Key_C }, Gfx::Bitmap::load_from_file("/res/icons/16x16/edit-copy.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
action->set_status_tip("Copy to clipboard");
action->set_status_tip("Copy to clipboard"_string.release_value_but_fixme_should_propagate_errors());
return action;
}
NonnullRefPtr<Action> make_paste_action(Function<void(Action&)> callback, Core::Object* parent)
{
auto action = Action::create("&Paste", { Mod_Ctrl, Key_V }, Gfx::Bitmap::load_from_file("/res/icons/16x16/paste.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
action->set_status_tip("Paste from clipboard");
action->set_status_tip("Paste from clipboard"_string.release_value_but_fixme_should_propagate_errors());
return action;
}
NonnullRefPtr<Action> make_insert_emoji_action(Function<void(Action&)> callback, Core::Object* parent)
{
auto action = Action::create("&Insert Emoji...", { Mod_Ctrl | Mod_Alt, Key_Space }, Gfx::Bitmap::load_from_file("/res/icons/16x16/emoji.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
action->set_status_tip("Open the Emoji Picker");
action->set_status_tip("Open the Emoji Picker"_string.release_value_but_fixme_should_propagate_errors());
return action;
}
NonnullRefPtr<Action> make_fullscreen_action(Function<void(Action&)> callback, Core::Object* parent)
{
auto action = Action::create("&Fullscreen", { Mod_None, Key_F11 }, move(callback), parent);
action->set_status_tip("Enter fullscreen mode");
action->set_status_tip("Enter fullscreen mode"_string.release_value_but_fixme_should_propagate_errors());
action->set_icon(Gfx::Bitmap::load_from_file("/res/icons/16x16/fullscreen.png"sv).release_value_but_fixme_should_propagate_errors());
return action;
}
@ -121,28 +121,28 @@ NonnullRefPtr<Action> make_fullscreen_action(Function<void(Action&)> callback, C
NonnullRefPtr<Action> make_quit_action(Function<void(Action&)> callback)
{
auto action = Action::create("&Quit", { Mod_Alt, Key_F4 }, move(callback));
action->set_status_tip("Quit the application");
action->set_status_tip("Quit the application"_string.release_value_but_fixme_should_propagate_errors());
return action;
}
NonnullRefPtr<Action> make_help_action(Function<void(Action&)> callback, Core::Object* parent)
{
auto action = Action::create("&Manual", { Mod_None, Key_F1 }, Gfx::Bitmap::load_from_file("/res/icons/16x16/app-help.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
action->set_status_tip("Show help contents");
action->set_status_tip("Show help contents"_string.release_value_but_fixme_should_propagate_errors());
return action;
}
NonnullRefPtr<Action> make_go_back_action(Function<void(Action&)> callback, Core::Object* parent)
{
auto action = Action::create("Go &Back", { Mod_Alt, Key_Left }, { MouseButton::Backward }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-back.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
action->set_status_tip("Move one step backward in history");
action->set_status_tip("Move one step backward in history"_string.release_value_but_fixme_should_propagate_errors());
return action;
}
NonnullRefPtr<Action> make_go_forward_action(Function<void(Action&)> callback, Core::Object* parent)
{
auto action = Action::create("Go &Forward", { Mod_Alt, Key_Right }, { MouseButton::Forward }, Gfx::Bitmap::load_from_file("/res/icons/16x16/go-forward.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
action->set_status_tip("Move one step forward in history");
action->set_status_tip("Move one step forward in history"_string.release_value_but_fixme_should_propagate_errors());
return action;
}
@ -154,7 +154,7 @@ NonnullRefPtr<Action> make_go_home_action(Function<void(Action&)> callback, Core
NonnullRefPtr<Action> make_close_tab_action(Function<void(Action&)> callback, Core::Object* parent)
{
auto action = Action::create("&Close Tab", { Mod_Ctrl, Key_W }, Gfx::Bitmap::load_from_file("/res/icons/16x16/close-tab.png"sv).release_value_but_fixme_should_propagate_errors(), move(callback), parent);
action->set_status_tip("Close current tab");
action->set_status_tip("Close current tab"_string.release_value_but_fixme_should_propagate_errors());
return action;
}
@ -214,7 +214,7 @@ NonnullRefPtr<Action> make_command_palette_action(Window* window)
action->flash_menubar_menu(*window);
action->activate();
});
action->set_status_tip("Open the command palette");
action->set_status_tip("Open the command palette"_string.release_value_but_fixme_should_propagate_errors());
return action;
}

View file

@ -171,7 +171,7 @@ ErrorOr<void> Toolbar::create_overflow_objects()
m_overflow_action = Action::create("Overflow Menu", { Mod_Ctrl | Mod_Shift, Key_O }, TRY(Gfx::Bitmap::load_from_file("/res/icons/16x16/overflow-menu.png"sv)), [&](auto&) {
m_overflow_menu->popup(m_overflow_button->screen_relative_rect().bottom_left().moved_up(1), {}, m_overflow_button->rect());
});
m_overflow_action->set_status_tip("Show hidden toolbar actions");
m_overflow_action->set_status_tip(TRY("Show hidden toolbar actions"_string));
m_overflow_action->set_enabled(false);
TRY(add_spacer());