MCPcopy Create free account
hub / github.com/MeisApps/pcbu-desktop / OnInstallClicked

Method OnInstallClicked

desktop/src/ui/MainWindow.cpp:81–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81void 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
108void MainWindow::OnReinstallClicked(QObject *window) {
109 if(m_LoadingThread.joinable())

Callers

nothing calls this directly

Calls 6

ServiceInstallerClass · 0.85
ClearSettingsMethod · 0.80
UninstallMethod · 0.45
InstallMethod · 0.45
ApplySettingsMethod · 0.45
GetSettingsMethod · 0.45

Tested by

no test coverage detected