Mercurial > trustbridge
diff ui/mainwindow.cpp @ 810:ee75e236843c
Use sudo to install software in case of is_admin
author | Andre Heinecke <andre.heinecke@intevation.de> |
---|---|
date | Tue, 15 Jul 2014 16:31:24 +0200 |
parents | 1e18d4c1932a |
children | c4af7874250b |
line wrap: on
line diff
--- a/ui/mainwindow.cpp Tue Jul 15 16:30:55 2014 +0200 +++ b/ui/mainwindow.cpp Tue Jul 15 16:31:24 2014 +0200 @@ -297,15 +297,30 @@ } #else /* WIN32 */ QStringList parameters; - parameters << "/S" << "/UPDATE=1" - << QString::fromLatin1("/D=%1").arg(installDir.path()); + parameters << "--prefix" << installDir.path(); + bool sudo_started = false; + bool use_sudo = is_admin(); + if (use_sudo) { + QStringList sudoPrograms; + sudoPrograms << "gksudo" << "kdesudo" << "sudo"; + QStringList sudoParams; + sudoParams << filePath + " " + parameters.join(" "); - qDebug() << "Starting process " << filePath << " args: " << parameters; - - if (!QProcess::startDetached(filePath, parameters)) { + foreach (const QString &sProg, sudoPrograms) { + qDebug() << "Starting process " << sProg <<" params: " << sudoParams; + if (!QProcess::startDetached(sProg, sudoParams)) { + continue; + } else { + sudo_started = true; + break; + } + } + } + if (!sudo_started && !QProcess::startDetached(filePath, parameters)) { qDebug() << "Failed to start process."; return; } + #endif /* Installer process should now be running. We exit */