| 1268 | } |
| 1269 | |
| 1270 | void MainWindow::downloadUpdates(GoUpdate::Status status) |
| 1271 | { |
| 1272 | if(!APPLICATION->updatesAreAllowed()) |
| 1273 | { |
| 1274 | return; |
| 1275 | } |
| 1276 | qDebug() << "Downloading updates."; |
| 1277 | ProgressDialog updateDlg(this); |
| 1278 | status.rootPath = APPLICATION->root(); |
| 1279 | |
| 1280 | auto dlPath = FS::PathCombine(APPLICATION->root(), "update", "XXXXXX"); |
| 1281 | if (!FS::ensureFilePathExists(dlPath)) |
| 1282 | { |
| 1283 | CustomMessageBox::selectable(this, tr("Error"), tr("Couldn't create folder for update downloads:\n%1").arg(dlPath), QMessageBox::Warning)->show(); |
| 1284 | } |
| 1285 | GoUpdate::DownloadTask updateTask(APPLICATION->network(), status, dlPath, &updateDlg); |
| 1286 | // If the task succeeds, install the updates. |
| 1287 | if (updateDlg.execWithTask(&updateTask)) |
| 1288 | { |
| 1289 | /** |
| 1290 | * NOTE: This disables launching instances until the update either succeeds (and this process exits) |
| 1291 | * or the update fails (and the control leaves this scope). |
| 1292 | */ |
| 1293 | APPLICATION->updateIsRunning(true); |
| 1294 | UpdateController update(this, APPLICATION->root(), updateTask.updateFilesDir(), updateTask.operations()); |
| 1295 | update.installUpdates(); |
| 1296 | APPLICATION->updateIsRunning(false); |
| 1297 | } |
| 1298 | else |
| 1299 | { |
| 1300 | CustomMessageBox::selectable(this, tr("Error"), updateTask.failReason(), QMessageBox::Warning)->show(); |
| 1301 | } |
| 1302 | } |
| 1303 | |
| 1304 | void MainWindow::onCatToggled(bool state) |
| 1305 | { |
nothing calls this directly
no test coverage detected