MCPcopy Create free account
hub / github.com/SpartanJ/eepp / deleteFileDialog

Method deleteFileDialog

src/tools/ecode/settingsmenu.cpp:2941–2971  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2939}
2940
2941void SettingsMenu::deleteFileDialog( const FileInfo& file ) {
2942 UIMessageBox* msgBox = UIMessageBox::New(
2943 UIMessageBox::OK_CANCEL,
2944 String::format(
2945 i18n( "confirm_remove_file", "Do you really want to remove \"%s\"?" ).toUtf8().c_str(),
2946 file.getFileName().c_str() ) );
2947 msgBox->on( Event::OnConfirm, [this, file, msgBox]( const Event* ) {
2948 auto errFn = [this, file] {
2949 mApp->errorMsgBox( String::format(
2950 std::string( i18n( "couldnt_remove", "Couldn't remove" ).toUtf8() + "%s." ).c_str(),
2951 file.isDirectory() ? i18n( "directory", "directory" ).toUtf8().c_str()
2952 : i18n( "file", "file" ).toUtf8().c_str() ) );
2953 };
2954
2955 if ( file.isDirectory() ) {
2956 try {
2957 std::string fpath( file.getFilepath() );
2958 FileSystem::dirRemoveSlashAtEnd( fpath );
2959 fsRemoveAll( fpath );
2960 } catch ( const fs::filesystem_error& ) {
2961 errFn();
2962 }
2963 } else if ( !FileSystem::fileRemove( file.getFilepath() ) ) {
2964 errFn();
2965 }
2966 msgBox->closeWindow();
2967 } );
2968 msgBox->setTitle( i18n( "remove_file_question", "Remove file?" ) );
2969 msgBox->center();
2970 msgBox->showWhenReady();
2971}
2972
2973void SettingsMenu::createProjectMenu() {
2974 auto* owner = mProjectMenu->addSubMenu( i18n( "documents_settings", "Documents Settings" ),

Callers 1

initProjectTreeViewUIMethod · 0.80

Calls 12

formatFunction · 0.85
c_strMethod · 0.80
toUtf8Method · 0.80
errorMsgBoxMethod · 0.80
closeWindowMethod · 0.80
centerMethod · 0.80
showWhenReadyMethod · 0.80
fsRemoveAllFunction · 0.70
NewFunction · 0.50
onMethod · 0.45
isDirectoryMethod · 0.45
setTitleMethod · 0.45

Tested by

no test coverage detected