| 79 | } |
| 80 | |
| 81 | void MainWindow::OnInstallClicked(QObject *window) { |
| 82 | if(m_LoadingThread.joinable()) |
| 83 | m_LoadingThread.join(); |
| 84 | m_LoadingThread = std::thread([window]() { |
| 85 | QMetaObject::invokeMethod(window, "showLoadingScreen", Q_ARG(QVariant, QString::fromUtf8(I18n::Get("please_wait")))); |
| 86 | auto logCallback = [window](const std::string &str) { |
| 87 | spdlog::info(str); |
| 88 | QMetaObject::invokeMethod(window, "appendLoadingOutput", Q_ARG(QVariant, QString::fromUtf8(str))); |
| 89 | }; |
| 90 | auto installer = ServiceInstaller(logCallback); |
| 91 | try { |
| 92 | if(ServiceInstaller::IsInstalled()) { |
| 93 | installer.Uninstall(); |
| 94 | installer.ClearSettings(); |
| 95 | } else { |
| 96 | installer.Install(); |
| 97 | installer.ApplySettings(installer.GetSettings(), true); |
| 98 | } |
| 99 | AppSettings::SetInstalledVersion(ServiceInstaller::IsInstalled()); |
| 100 | QMetaObject::invokeMethod(window, "finishLoadingScreen", Q_ARG(QVariant, QString::fromUtf8(I18n::Get("success")))); |
| 101 | } catch(const std::exception &ex) { |
| 102 | logCallback(ex.what()); |
| 103 | QMetaObject::invokeMethod(window, "finishLoadingScreen", Q_ARG(QVariant, QString::fromUtf8(I18n::Get("error")))); |
| 104 | } |
| 105 | }); |
| 106 | } |
| 107 | |
| 108 | void MainWindow::OnReinstallClicked(QObject *window) { |
| 109 | if(m_LoadingThread.joinable()) |
nothing calls this directly
no test coverage detected