| 25 | : ppConfig(ppConfig), subtitleConverter(subtitleConverter) {} |
| 26 | |
| 27 | void SubtitlePostProcessor::perform(const QString& movieFilePath, |
| 28 | const QString& subtitleFilePath) const { |
| 29 | if (ppConfig.removeWordsEnabled()) { |
| 30 | ppRemoveLinesContainingWords(subtitleFilePath, ppConfig.removeWords()); |
| 31 | } |
| 32 | |
| 33 | switch (ppConfig.encodingChangeMethod()) { |
| 34 | case ECM_REPLACE_DIACRITICS: |
| 35 | ppReplaceDiacriticsWithASCII(subtitleFilePath); |
| 36 | break; |
| 37 | case ECM_CHANGE: |
| 38 | if (!ppConfig.encodingAutoDetectFrom() || |
| 39 | !ppChangeSubtitlesEncoding(subtitleFilePath, ppConfig.encodingTo())) { |
| 40 | ppChangeSubtitlesEncoding(subtitleFilePath, ppConfig.encodingFrom(), |
| 41 | ppConfig.encodingTo()); |
| 42 | } |
| 43 | break; |
| 44 | case ECM_ORIGINAL: |
| 45 | // Nie ruszaj pobranych napisów! |
| 46 | break; |
| 47 | } |
| 48 | |
| 49 | if (!ppConfig.subFormat().isEmpty()) { |
| 50 | QString targetFormat = ppConfig.subFormat(); |
| 51 | subtitleConverter->convertSubtitles(subtitleFilePath, targetFormat, |
| 52 | subtitleFilePath, movieFilePath); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | bool SubtitlePostProcessor::ppReplaceDiacriticsWithASCII( |
| 57 | const QString& subtitleFilePath) const { |
no test coverage detected