From 761f67f02ca3a2b0673d0810368a0b179e2685be Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=B1=90=E5=85=89?= <3285778581@qq.com>
Date: Sun, 26 Jan 2025 04:49:16 +0000
Subject: [PATCH] =?UTF-8?q?!316=20=E5=B0=86=E9=87=8D=E6=96=B0=E5=AE=89?=
 =?UTF-8?q?=E8=A3=85=E6=94=B9=E4=B8=BA=E5=90=AF=E5=8A=A8=E8=BD=AF=E4=BB=B6?=
 =?UTF-8?q?=20*=20=E5=B0=86=E5=8F=AF=E5=90=AF=E5=8A=A8=E5=BA=94=E7=94=A8?=
 =?UTF-8?q?=E7=9A=84=E9=87=8D=E6=96=B0=E5=AE=89=E8=A3=85=E6=94=B9=E4=B8=BA?=
 =?UTF-8?q?=E5=90=AF=E5=8A=A8=E5=BA=94=E7=94=A8=20*=20=E5=B0=86=E9=87=8D?=
 =?UTF-8?q?=E6=96=B0=E5=AE=89=E8=A3=85=E6=94=B9=E4=B8=BA=E5=90=AF=E5=8A=A8?=
 =?UTF-8?q?=E8=BD=AF=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/pages/appintopage.cpp | 39 +++++++++++++++++++++++++++++++++++----
 1 file changed, 35 insertions(+), 4 deletions(-)

diff --git a/src/pages/appintopage.cpp b/src/pages/appintopage.cpp
index 63b0235..9ef148c 100644
--- a/src/pages/appintopage.cpp
+++ b/src/pages/appintopage.cpp
@@ -180,7 +180,19 @@ void AppIntoPage::openUrl(const QUrl &url)
             {
                 if (isUpdated)
                 {
-                    ui->downloadButton->setText(tr("Reinstall"));
+                    QProcess process;
+                    QStringList arguments;
+                    arguments << "check" << info["Pkgname"].toString();
+                    process.start("/opt/durapps/spark-store/bin/store-helper/ss-launcher", arguments);
+                    if (process.waitForFinished()) {
+                            exitCode = process.exitCode();
+                            exitStatus = process.exitStatus();
+                            if (exitCode != 0){
+                                ui->downloadButton->setText(tr("Reinstall"));
+                            }else{
+                                ui->downloadButton->setText(tr("Launch"));
+                            }
+                    }
                     ui->downloadButton->setEnabled(true);
                     ui->downloadButton->show();
                     ui->pushButton_3->show();
@@ -357,14 +369,25 @@ void AppIntoPage::isDownloading(const QUrl &url)
 
         int exitCode = process.exitCode();
         QProcess::ExitStatus exitStatus = process.exitStatus();
-        process.close();
 
         if (exitCode == 0 && exitStatus == QProcess::NormalExit)
         {
+            QStringList arguments;
+            arguments << "check" << info["Pkgname"].toString();
+            process.start("/opt/durapps/spark-store/bin/store-helper/ss-launcher", arguments);
+            if (process.waitForFinished()) {
+                    exitCode = process.exitCode();
+                    exitStatus = process.exitStatus();
+                    if (exitCode != 0){
+                        ui->downloadButton->setText(tr("Reinstall"));
+                    }else{
+                        ui->downloadButton->setText(tr("Launch"));
+                    }
+            }
             ui->downloadButton->setEnabled(true);
-            ui->downloadButton->setText(tr("Reinstall"));
             ui->downloadButton->show();
             ui->pushButton_3->show();
+            process.close();
         }
         else
         {
@@ -498,6 +521,15 @@ void AppIntoPage::on_downloadButton_clicked()
 
         return;
     }
+    else if (ui->downloadButton->text() == tr("Launch"))
+    {
+        QString scriptPath = "/opt/durapps/spark-store/bin/store-helper/ss-launcher";
+        QStringList arguments;
+        arguments << "launch" << info["Pkgname"].toString();
+        QProcess process;
+        process.startDetached(scriptPath, arguments);
+        return;
+    }
 
     emit clickedDownloadBtn();
 
@@ -506,7 +538,6 @@ void AppIntoPage::on_downloadButton_clicked()
     {
         return;
     }
-
     if (ui->downloadButton->text() == tr("Reinstall"))
     {
         item->reinstall = true;