| 1573 | } |
| 1574 | |
| 1575 | void MainWindow::downloadUpdates(GoUpdate::Status status) |
| 1576 | { |
| 1577 | if(!APPLICATION->updatesAreAllowed()) |
| 1578 | { |
| 1579 | return; |
| 1580 | } |
| 1581 | qDebug() << "Downloading updates."; |
| 1582 | ProgressDialog updateDlg(this); |
| 1583 | status.rootPath = APPLICATION->root(); |
| 1584 | |
| 1585 | auto dlPath = FS::PathCombine(APPLICATION->root(), "update", "XXXXXX"); |
| 1586 | if (!FS::ensureFilePathExists(dlPath)) |
| 1587 | { |
| 1588 | CustomMessageBox::selectable(this, tr("Error"), tr("Couldn't create folder for update downloads:\n%1").arg(dlPath), QMessageBox::Warning)->show(); |
| 1589 | } |
| 1590 | GoUpdate::DownloadTask updateTask(APPLICATION->network(), status, dlPath, &updateDlg); |
| 1591 | // If the task succeeds, install the updates. |
| 1592 | if (updateDlg.execWithTask(&updateTask)) |
| 1593 | { |
| 1594 | /** |
| 1595 | * NOTE: This disables launching instances until the update either succeeds (and this process exits) |
| 1596 | * or the update fails (and the control leaves this scope). |
| 1597 | */ |
| 1598 | APPLICATION->updateIsRunning(true); |
| 1599 | UpdateController update(this, APPLICATION->root(), updateTask.updateFilesDir(), updateTask.operations()); |
| 1600 | update.installUpdates(); |
| 1601 | APPLICATION->updateIsRunning(false); |
| 1602 | } |
| 1603 | else |
| 1604 | { |
| 1605 | CustomMessageBox::selectable(this, tr("Error"), updateTask.failReason(), QMessageBox::Warning)->show(); |
| 1606 | } |
| 1607 | } |
| 1608 | |
| 1609 | void MainWindow::onCatToggled(bool state) |
| 1610 | { |
nothing calls this directly
no test coverage detected