| 2939 | } |
| 2940 | |
| 2941 | void 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 | |
| 2973 | void SettingsMenu::createProjectMenu() { |
| 2974 | auto* owner = mProjectMenu->addSubMenu( i18n( "documents_settings", "Documents Settings" ), |
no test coverage detected