| 75 | } |
| 76 | |
| 77 | bool frmProgress::download() { |
| 78 | if (summary.isVisible()) { |
| 79 | summary.close(); |
| 80 | } |
| 81 | |
| 82 | auto config = LibQNapi::loadConfig(); |
| 83 | auto config1 = config; |
| 84 | if (!targetFormatOverride.isEmpty()) { |
| 85 | config1 = config1.setPostProcessingConfig( |
| 86 | config1.postProcessingConfig().setSubFormat(targetFormatOverride)); |
| 87 | } |
| 88 | auto config2 = config1; |
| 89 | if (!targetExtOverride.isEmpty()) { |
| 90 | config2 = config2.setPostProcessingConfig( |
| 91 | config2.postProcessingConfig().setSubExtension(targetExtOverride)); |
| 92 | } |
| 93 | |
| 94 | QNapi napi(config2); |
| 95 | |
| 96 | // TODO: perform these checks earlier |
| 97 | if (!napi.checkP7ZipPath()) { |
| 98 | QMessageBox::warning(0, tr("Can not find p7zip!"), |
| 99 | tr("The path to the program p7zip is incorrect!")); |
| 100 | return false; |
| 101 | } |
| 102 | |
| 103 | if (!napi.checkTmpPath()) { |
| 104 | QMessageBox::warning( |
| 105 | 0, tr("Invalid temporary directory!"), |
| 106 | tr("Unable to write to the temporary directory! Check your settings.")); |
| 107 | return false; |
| 108 | } |
| 109 | |
| 110 | if (getThread.queue.isEmpty()) { |
| 111 | QMessageBox::warning( |
| 112 | 0, tr("No files!"), |
| 113 | tr("Can't download subtitles as no movie files specified!")); |
| 114 | return false; |
| 115 | } |
| 116 | |
| 117 | if (!isVisible()) { |
| 118 | QRect position = frameGeometry(); |
| 119 | position.moveCenter(QDesktopWidget().availableGeometry().center()); |
| 120 | move(position.topLeft()); |
| 121 | show(); |
| 122 | } |
| 123 | |
| 124 | showSummary = true; |
| 125 | closeRequested = false; |
| 126 | ui.pbCancel->setEnabled(true); |
| 127 | |
| 128 | getThread.setConfig(config2); |
| 129 | getThread.start(); |
| 130 | return true; |
| 131 | } |
| 132 | |
| 133 | void frmProgress::updateProgress(int current, int all, float stageProgress) { |
| 134 | static int lastCurrent, lastAll; |
no test coverage detected