mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 16:17:34 +00:00
FileManager: Allow deleting without confirmation via Shift+Delete
A powerful command for powerful users. :^)
This commit is contained in:
parent
33b8c807a6
commit
482d5295f1
1 changed files with 22 additions and 10 deletions
|
@ -201,7 +201,9 @@ int main(int argc, char** argv)
|
||||||
auto properties_action
|
auto properties_action
|
||||||
= GAction::create("Properties...", { Mod_Alt, Key_Return }, GraphicsBitmap::load_from_file("/res/icons/16x16/properties.png"), [](auto&) {});
|
= GAction::create("Properties...", { Mod_Alt, Key_Return }, GraphicsBitmap::load_from_file("/res/icons/16x16/properties.png"), [](auto&) {});
|
||||||
|
|
||||||
auto delete_action = GCommonActions::make_delete_action([&](const GAction&) {
|
enum class ConfirmBeforeDelete { No, Yes };
|
||||||
|
|
||||||
|
auto do_delete = [&](ConfirmBeforeDelete confirm) {
|
||||||
auto paths = selected_file_paths();
|
auto paths = selected_file_paths();
|
||||||
if (paths.is_empty())
|
if (paths.is_empty())
|
||||||
return;
|
return;
|
||||||
|
@ -213,15 +215,17 @@ int main(int argc, char** argv)
|
||||||
message = String::format("Really delete %d files?", paths.size());
|
message = String::format("Really delete %d files?", paths.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
GMessageBox box(
|
if (confirm == ConfirmBeforeDelete::Yes) {
|
||||||
message,
|
GMessageBox box(
|
||||||
"Confirm deletion",
|
message,
|
||||||
GMessageBox::Type::Warning,
|
"Confirm deletion",
|
||||||
GMessageBox::InputType::OKCancel,
|
GMessageBox::Type::Warning,
|
||||||
window);
|
GMessageBox::InputType::OKCancel,
|
||||||
auto result = box.exec();
|
window);
|
||||||
if (result == GMessageBox::ExecCancel)
|
auto result = box.exec();
|
||||||
return;
|
if (result == GMessageBox::ExecCancel)
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (auto& path : paths) {
|
for (auto& path : paths) {
|
||||||
if (unlink(path.characters()) < 0) {
|
if (unlink(path.characters()) < 0) {
|
||||||
|
@ -235,6 +239,14 @@ int main(int argc, char** argv)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
auto force_delete_action = GAction::create("Delete without confirmation", { Mod_Shift, Key_Delete }, [&](const GAction&) {
|
||||||
|
do_delete(ConfirmBeforeDelete::No);
|
||||||
|
});
|
||||||
|
|
||||||
|
auto delete_action = GCommonActions::make_delete_action([&](const GAction&) {
|
||||||
|
do_delete(ConfirmBeforeDelete::Yes);
|
||||||
});
|
});
|
||||||
delete_action->set_enabled(false);
|
delete_action->set_enabled(false);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue