| 2762 | } |
| 2763 | |
| 2764 | void App::openFileFromPath( const std::string& path ) { |
| 2765 | std::string ext = FileSystem::fileExtension( path ); |
| 2766 | if ( !Image::isImageExtension( path ) && !SoundFileFactory::isKnownFileExtension( path ) && |
| 2767 | !PathHelper::isOpenExternalExtension( ext ) && TextDocument::fileMightBeBinary( path ) ) { |
| 2768 | auto msgBox = UIMessageBox::New( |
| 2769 | UIMessageBox::YES_NO, |
| 2770 | i18n( "open_binary_file_warning", |
| 2771 | "File looks like a binary file. Are you sure " |
| 2772 | "you want to open it as a document?\nOtherwise it will try to open the " |
| 2773 | "file with an external application." ) ); |
| 2774 | msgBox->getButtonOK()->setText( i18n( "open_as_document", "Open as document" ) ); |
| 2775 | msgBox->getButtonOK()->getIcon()->setVisible( false ); |
| 2776 | msgBox->getButtonCancel()->setText( i18n( "open_externally", "Open externally" ) ); |
| 2777 | msgBox->getButtonCancel()->getIcon()->setVisible( false ); |
| 2778 | msgBox->setCloseShortcut( { KEY_ESCAPE } ); |
| 2779 | msgBox->on( Event::OnConfirm, [this, path]( auto ) { loadFileFromPath( path ); } ); |
| 2780 | msgBox->on( Event::OnCancel, [path]( auto ) { |
| 2781 | FileInfo f( path ); |
| 2782 | if ( f.isExecutable() ) |
| 2783 | Sys::execute( path ); |
| 2784 | else |
| 2785 | Engine::instance()->openURI( path ); |
| 2786 | } ); |
| 2787 | msgBox->showWhenReady(); |
| 2788 | } else { |
| 2789 | loadFileFromPath( path ); |
| 2790 | } |
| 2791 | } |
| 2792 | |
| 2793 | bool App::loadFileFromPath( |
| 2794 | std::string path, bool inNewTab, UICodeEditor* codeEditor, |
no test coverage detected