添加重新安装按钮

This commit is contained in:
柚子 2022-12-11 18:41:09 +08:00
parent 2d3366990a
commit 60ed4c5aff

View File

@ -92,9 +92,9 @@ void AppIntoPage::openUrl(QUrl url)
bool isInstalled;
bool isUpdated;
QString packagename = info["Pkgname"].toString();
isInstall.start("dpkg -s " + info["Pkgname"].toString()); //todo
isInstall.waitForStarted();
isInstall.waitForFinished(-1);
isInstall.start("dpkg -s " + info["Pkgname"].toString());
qDebug()<<info["Pkgname"].toString();
isInstall.waitForFinished(180); // 默认超时 3 分钟
int error = QString::fromStdString(isInstall.readAllStandardError().toStdString()).length();
if(error == 0)
{
@ -102,12 +102,12 @@ void AppIntoPage::openUrl(QUrl url)
QProcess isUpdate;
isUpdate.start("dpkg-query --showformat='${Version}' --show " + info["Pkgname"].toString());
isUpdate.waitForFinished(10);
isUpdate.waitForFinished(180); // 默认超时 3 分钟
QString localVersion = isUpdate.readAllStandardOutput();
localVersion.replace("'", "");
isUpdate.start("dpkg --compare-versions " + localVersion + " ge " + info["Version"].toString());
isUpdate.waitForFinished(10);
isUpdate.waitForFinished(180); // 默认超时 3 分钟
if(!isUpdate.exitCode())
{
isUpdated = true;
@ -128,11 +128,13 @@ void AppIntoPage::openUrl(QUrl url)
if(isUpdated)
{
ui->downloadButton->setText(tr("Reinstall"));
ui->downloadButton->show();
ui->pushButton_3->show();
}
else
{
ui->downloadButton->setText(tr("Upgrade"));
ui->downloadButton->show();
ui->pushButton_3->show();
}
}