mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 12:35:14 +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
Notes:
sideshowbarker
2024-07-19 12:03:10 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/482d5295f1a
1 changed files with 22 additions and 10 deletions
|
@ -201,7 +201,9 @@ 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 = GCommonActions::make_delete_action([&](const GAction&) {
|
||||
enum class ConfirmBeforeDelete { No, Yes };
|
||||
|
||||
auto do_delete = [&](ConfirmBeforeDelete confirm) {
|
||||
auto paths = selected_file_paths();
|
||||
if (paths.is_empty())
|
||||
return;
|
||||
|
@ -213,15 +215,17 @@ int main(int argc, char** argv)
|
|||
message = String::format("Really delete %d files?", paths.size());
|
||||
}
|
||||
|
||||
GMessageBox box(
|
||||
message,
|
||||
"Confirm deletion",
|
||||
GMessageBox::Type::Warning,
|
||||
GMessageBox::InputType::OKCancel,
|
||||
window);
|
||||
auto result = box.exec();
|
||||
if (result == GMessageBox::ExecCancel)
|
||||
return;
|
||||
if (confirm == ConfirmBeforeDelete::Yes) {
|
||||
GMessageBox box(
|
||||
message,
|
||||
"Confirm deletion",
|
||||
GMessageBox::Type::Warning,
|
||||
GMessageBox::InputType::OKCancel,
|
||||
window);
|
||||
auto result = box.exec();
|
||||
if (result == GMessageBox::ExecCancel)
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (auto& path : paths) {
|
||||
if (unlink(path.characters()) < 0) {
|
||||
|
@ -235,6 +239,14 @@ int main(int argc, char** argv)
|
|||
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);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue