mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-25 05:55:13 +00:00
LibGUI: Add Undo/Redo to GCommonActions
This commit is contained in:
parent
e83390387c
commit
b41b5433f4
Notes:
sideshowbarker
2024-07-19 12:06:33 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/b41b5433f4c
3 changed files with 18 additions and 12 deletions
|
@ -6,6 +6,16 @@
|
|||
|
||||
namespace GCommonActions {
|
||||
|
||||
NonnullRefPtr<GAction> make_undo_action(Function<void(GAction&)> callback, GWidget* widget)
|
||||
{
|
||||
return GAction::create("Undo", { Mod_Ctrl, Key_Z }, GraphicsBitmap::load_from_file("/res/icons/16x16/undo.png"), move(callback), widget);
|
||||
}
|
||||
|
||||
NonnullRefPtr<GAction> make_redo_action(Function<void(GAction&)> callback, GWidget* widget)
|
||||
{
|
||||
return GAction::create("Redo", { Mod_Ctrl, Key_Y }, GraphicsBitmap::load_from_file("/res/icons/16x16/redo.png"), move(callback), widget);
|
||||
}
|
||||
|
||||
NonnullRefPtr<GAction> make_delete_action(Function<void(GAction&)> callback, GWidget* widget)
|
||||
{
|
||||
return GAction::create("Delete", { Mod_None, Key_Delete }, GraphicsBitmap::load_from_file("/res/icons/16x16/delete.png"), move(callback), widget);
|
||||
|
|
|
@ -19,6 +19,8 @@ class GMenuItem;
|
|||
class GWidget;
|
||||
|
||||
namespace GCommonActions {
|
||||
NonnullRefPtr<GAction> make_undo_action(Function<void(GAction&)>, GWidget* widget = nullptr);
|
||||
NonnullRefPtr<GAction> make_redo_action(Function<void(GAction&)>, GWidget* widget = nullptr);
|
||||
NonnullRefPtr<GAction> make_cut_action(Function<void(GAction&)>, GWidget* widget = nullptr);
|
||||
NonnullRefPtr<GAction> make_copy_action(Function<void(GAction&)>, GWidget* widget = nullptr);
|
||||
NonnullRefPtr<GAction> make_paste_action(Function<void(GAction&)>, GWidget* widget = nullptr);
|
||||
|
|
|
@ -35,18 +35,12 @@ GTextEditor::~GTextEditor()
|
|||
|
||||
void GTextEditor::create_actions()
|
||||
{
|
||||
m_undo_action = GAction::create(
|
||||
"Undo", { Mod_Ctrl, Key_Z }, GraphicsBitmap::load_from_file("/res/icons/16x16/undo.png"), [&](const GAction&) {
|
||||
m_undo_action = GCommonActions::make_undo_action([&](auto&) {
|
||||
// FIXME: Undo
|
||||
},
|
||||
this);
|
||||
|
||||
m_redo_action = GAction::create(
|
||||
"Redo", { Mod_Ctrl, Key_Y }, GraphicsBitmap::load_from_file("/res/icons/16x16/redo.png"), [&](const GAction&) {
|
||||
// FIXME: Redo
|
||||
},
|
||||
this);
|
||||
|
||||
});
|
||||
m_redo_action = GCommonActions::make_redo_action([&](auto&) {
|
||||
// FIXME: Undo
|
||||
});
|
||||
m_cut_action = GCommonActions::make_cut_action([&](auto&) { cut(); }, this);
|
||||
m_copy_action = GCommonActions::make_copy_action([&](auto&) { copy(); }, this);
|
||||
m_paste_action = GCommonActions::make_paste_action([&](auto&) { paste(); }, this);
|
||||
|
|
Loading…
Add table
Reference in a new issue