mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 21:47:45 +00:00
LibGUI: Simplify GCommonActions a bit
Use the same callback signature as GAction so we can just forward it to GAction instead of chaining callbacks.
This commit is contained in:
parent
b7bedab28a
commit
e83390387c
14 changed files with 45 additions and 65 deletions
|
@ -131,7 +131,7 @@ int main(int argc, char** argv)
|
|||
|
||||
view_as_icons_action->set_checked(true);
|
||||
|
||||
auto copy_action = GAction::create("Copy", { Mod_Ctrl, Key_C }, GraphicsBitmap::load_from_file("/res/icons/16x16/edit-copy.png"), [&](const GAction&) {
|
||||
auto copy_action = GCommonActions::make_copy_action([&](const GAction&) {
|
||||
if (!selected_file_paths.has_value()) {
|
||||
return;
|
||||
}
|
||||
|
@ -143,7 +143,7 @@ int main(int argc, char** argv)
|
|||
});
|
||||
copy_action->set_enabled(false);
|
||||
|
||||
auto paste_action = GAction::create("Paste", { Mod_Ctrl, Key_V }, GraphicsBitmap::load_from_file("/res/icons/paste16.png"), [&](const GAction&) {
|
||||
auto paste_action = GCommonActions::make_paste_action([&](const GAction&) {
|
||||
auto data_and_type = GClipboard::the().data_and_type();
|
||||
if (data_and_type.type != "file-list") {
|
||||
dbg() << "Cannot paste clipboard type " << data_and_type.type;
|
||||
|
@ -177,7 +177,7 @@ int main(int argc, char** argv)
|
|||
auto properties_action
|
||||
= GAction::create("Properties...", { Mod_Alt, Key_Return }, GraphicsBitmap::load_from_file("/res/icons/16x16/properties.png"), [](auto&) {});
|
||||
|
||||
auto delete_action = GAction::create("Delete", { Mod_None, Key_Delete }, GraphicsBitmap::load_from_file("/res/icons/16x16/delete.png"), [](const GAction&) {
|
||||
auto delete_action = GCommonActions::make_delete_action([](const GAction&) {
|
||||
dbgprintf("'Delete' action activated!\n");
|
||||
});
|
||||
delete_action->set_enabled(false);
|
||||
|
@ -204,7 +204,7 @@ int main(int argc, char** argv)
|
|||
app_menu->add_action(paste_action);
|
||||
app_menu->add_action(delete_action);
|
||||
app_menu->add_separator();
|
||||
app_menu->add_action(GCommonActions::make_quit_action([] {
|
||||
app_menu->add_action(GCommonActions::make_quit_action([](auto&) {
|
||||
GApplication::the().quit(0);
|
||||
}));
|
||||
menubar->add_menu(move(app_menu));
|
||||
|
|
|
@ -124,7 +124,7 @@ void IRCAppWindow::setup_menus()
|
|||
{
|
||||
auto menubar = make<GMenuBar>();
|
||||
auto app_menu = make<GMenu>("IRC Client");
|
||||
app_menu->add_action(GCommonActions::make_quit_action([] {
|
||||
app_menu->add_action(GCommonActions::make_quit_action([](auto&) {
|
||||
dbgprintf("Terminal: Quit menu activated!\n");
|
||||
GApplication::the().quit(0);
|
||||
return;
|
||||
|
|
|
@ -37,7 +37,7 @@ int main(int argc, char** argv)
|
|||
|
||||
auto menubar = make<GMenuBar>();
|
||||
auto app_menu = make<GMenu>("PaintBrush");
|
||||
app_menu->add_action(GCommonActions::make_quit_action([] {
|
||||
app_menu->add_action(GCommonActions::make_quit_action([](auto&) {
|
||||
GApplication::the().quit(0);
|
||||
return;
|
||||
}));
|
||||
|
|
|
@ -46,7 +46,7 @@ int main(int argc, char** argv)
|
|||
auto menubar = make<GMenuBar>();
|
||||
|
||||
auto app_menu = make<GMenu>("Piano");
|
||||
app_menu->add_action(GCommonActions::make_quit_action([] {
|
||||
app_menu->add_action(GCommonActions::make_quit_action([](auto&) {
|
||||
GApplication::the().quit(0);
|
||||
return;
|
||||
}));
|
||||
|
|
|
@ -16,7 +16,7 @@ int main(int argc, char** argv)
|
|||
auto menubar = make<GMenuBar>();
|
||||
|
||||
auto app_menu = make<GMenu>("QuickShow");
|
||||
app_menu->add_action(GCommonActions::make_quit_action([] {
|
||||
app_menu->add_action(GCommonActions::make_quit_action([](auto&) {
|
||||
GApplication::the().quit(0);
|
||||
return;
|
||||
}));
|
||||
|
|
|
@ -139,7 +139,7 @@ int main(int argc, char** argv)
|
|||
|
||||
auto menubar = make<GMenuBar>();
|
||||
auto app_menu = make<GMenu>("System Monitor");
|
||||
app_menu->add_action(GCommonActions::make_quit_action([] {
|
||||
app_menu->add_action(GCommonActions::make_quit_action([](auto&) {
|
||||
GApplication::the().quit(0);
|
||||
return;
|
||||
}));
|
||||
|
|
|
@ -187,7 +187,7 @@ int main(int argc, char** argv)
|
|||
settings_window->move_to_front();
|
||||
}));
|
||||
app_menu->add_separator();
|
||||
app_menu->add_action(GCommonActions::make_quit_action([] {
|
||||
app_menu->add_action(GCommonActions::make_quit_action([](auto&) {
|
||||
dbgprintf("Terminal: Quit menu activated!\n");
|
||||
GApplication::the().quit(0);
|
||||
}));
|
||||
|
|
|
@ -118,14 +118,14 @@ TextEditorWidget::TextEditorWidget()
|
|||
|
||||
m_new_action = GAction::create("New", { Mod_Ctrl, Key_N }, GraphicsBitmap::load_from_file("/res/icons/16x16/new.png"), [this](const GAction&) {
|
||||
if (m_document_dirty) {
|
||||
GMessageBox save_document_first_box("Save Document First?", "Warning", GMessageBox::Type::Warning, GMessageBox::InputType::OKCancel, window());
|
||||
GMessageBox save_document_first_box("Save Document First?", "Warning", GMessageBox::Type::Warning, GMessageBox::InputType::OKCancel, window());
|
||||
auto save_document_first_result = save_document_first_box.exec();
|
||||
|
||||
if (save_document_first_result != GDialog::ExecResult::ExecOK)
|
||||
return;
|
||||
return;
|
||||
m_save_action->activate();
|
||||
}
|
||||
|
||||
|
||||
m_document_dirty = false;
|
||||
m_editor->set_text(StringView());
|
||||
set_path(FileSystemPath());
|
||||
|
@ -184,7 +184,7 @@ TextEditorWidget::TextEditorWidget()
|
|||
app_menu->add_action(*m_save_action);
|
||||
app_menu->add_action(*m_save_as_action);
|
||||
app_menu->add_separator();
|
||||
app_menu->add_action(GCommonActions::make_quit_action([this] {
|
||||
app_menu->add_action(GCommonActions::make_quit_action([this](auto&) {
|
||||
if (!request_close())
|
||||
return;
|
||||
GApplication::the().quit(0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue