]> git.sur5r.net Git - minitube/blobdiff - lib/updater/src/impl/runinstaller.cpp
New upstream version 3.5
[minitube] / lib / updater / src / impl / runinstaller.cpp
diff --git a/lib/updater/src/impl/runinstaller.cpp b/lib/updater/src/impl/runinstaller.cpp
new file mode 100644 (file)
index 0000000..67aa7f2
--- /dev/null
@@ -0,0 +1,22 @@
+#include "runinstaller.h"
+
+#include <QDesktopServices>
+
+namespace updater {
+
+RunInstaller::RunInstaller() : Installer() {}
+
+void RunInstaller::start(const QString &filename) {
+    if (arguments.isEmpty()) {
+        if (!QDesktopServices::openUrl(QUrl("file:///" + filename)))
+            emit error("Cannot start update");
+    } else {
+        QProcess *process = new QProcess(this);
+        QObject::connect(process, &QProcess::errorOccurred, this, [this](auto error) {
+            this->emit error("Update error: " + QVariant::fromValue(error).toString());
+        });
+        process->startDetached(filename, arguments);
+    }
+}
+
+} // namespace updater