mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibGUI: Add back/forward actions to GCommonActions
This commit is contained in:
parent
ee64d99a96
commit
7dd03b7846
Notes:
sideshowbarker
2024-07-19 11:49:05 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/7dd03b7846b
4 changed files with 16 additions and 6 deletions
|
@ -249,13 +249,11 @@ int main(int argc, char** argv)
|
|||
});
|
||||
delete_action->set_enabled(false);
|
||||
|
||||
auto go_back_action = GAction::create("Go Back", { Mod_Alt, Key_Left }, GraphicsBitmap::load_from_file("/res/icons/16x16/go-back.png"), [&](const GAction&) {
|
||||
dbgprintf("'Go Back' action activated!\n");
|
||||
auto go_back_action = GCommonActions::make_go_back_action([&](auto&) {
|
||||
directory_view->open_previous_directory();
|
||||
});
|
||||
|
||||
auto go_forward_action = GAction::create("Go Forward", { Mod_Alt, Key_Right }, GraphicsBitmap::load_from_file("/res/icons/16x16/go-forward.png"), [&](const GAction&) {
|
||||
dbgprintf("'Go Forward' action activated!\n");
|
||||
auto go_forward_action = GCommonActions::make_go_forward_action([&](auto&) {
|
||||
directory_view->open_next_directory();
|
||||
});
|
||||
|
||||
|
|
|
@ -110,13 +110,13 @@ int main(int argc, char* argv[])
|
|||
free(path);
|
||||
};
|
||||
|
||||
go_back_action = GAction::create("Go Back", { Mod_Alt, Key_Left }, GraphicsBitmap::load_from_file("/res/icons/16x16/go-back.png"), [&](const GAction&) {
|
||||
go_back_action = GCommonActions::make_go_back_action([&](auto&) {
|
||||
history.go_back();
|
||||
update_actions();
|
||||
open_page(history.current());
|
||||
});
|
||||
|
||||
go_forward_action = GAction::create("Go Forward", { Mod_Alt, Key_Right }, GraphicsBitmap::load_from_file("/res/icons/16x16/go-forward.png"), [&](const GAction&) {
|
||||
go_forward_action = GCommonActions::make_go_forward_action([&](auto&) {
|
||||
history.go_forward();
|
||||
update_actions();
|
||||
open_page(history.current());
|
||||
|
|
|
@ -61,6 +61,16 @@ NonnullRefPtr<GAction> make_quit_action(Function<void(GAction&)> callback)
|
|||
return GAction::create("Quit", { Mod_Alt, Key_F4 }, move(callback));
|
||||
}
|
||||
|
||||
NonnullRefPtr<GAction> make_go_back_action(Function<void(GAction&)> callback, GWidget* widget)
|
||||
{
|
||||
return GAction::create("Go back", { Mod_Alt, Key_Left }, GraphicsBitmap::load_from_file("/res/icons/16x16/go-back.png"), move(callback), widget);
|
||||
}
|
||||
|
||||
NonnullRefPtr<GAction> make_go_forward_action(Function<void(GAction&)> callback, GWidget* widget)
|
||||
{
|
||||
return GAction::create("Go forward", { Mod_Alt, Key_Right }, GraphicsBitmap::load_from_file("/res/icons/16x16/go-forward.png"), move(callback), widget);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GAction::GAction(const StringView& text, Function<void(GAction&)> on_activation_callback, GWidget* widget)
|
||||
|
|
|
@ -30,6 +30,8 @@ NonnullRefPtr<GAction> make_move_to_front_action(Function<void(GAction&)>, GWidg
|
|||
NonnullRefPtr<GAction> make_move_to_back_action(Function<void(GAction&)>, GWidget* widget = nullptr);
|
||||
NonnullRefPtr<GAction> make_fullscreen_action(Function<void(GAction&)>, GWidget* widget = nullptr);
|
||||
NonnullRefPtr<GAction> make_quit_action(Function<void(GAction&)>);
|
||||
NonnullRefPtr<GAction> make_go_back_action(Function<void(GAction&)>, GWidget* widget = nullptr);
|
||||
NonnullRefPtr<GAction> make_go_forward_action(Function<void(GAction&)>, GWidget* widget = nullptr);
|
||||
};
|
||||
|
||||
class GAction : public RefCounted<GAction>
|
||||
|
|
Loading…
Add table
Reference in a new issue