From 749a7b4cb7fceba82b8a715bbabdac6fa104591a Mon Sep 17 00:00:00 2001
From: peijiankang <peijiankang@kylinos.cn>
Date: Mon, 22 Aug 2022 14:44:23 +0800
Subject: [PATCH] modify version is error

---
 src/aboutdialog.cpp | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/src/aboutdialog.cpp b/src/aboutdialog.cpp
index 1df8335..e6b9f0f 100644
--- a/src/aboutdialog.cpp
+++ b/src/aboutdialog.cpp
@@ -34,8 +34,30 @@ AboutDialog::AboutDialog(QWidget *parent) :
     ui->label_2->setFont(f);
 
     connect(ui->btn_close, &QPushButton::clicked, [&](){close();});
+    
+    QString appVersion;
+    FILE *pp = NULL;
+    char *line = NULL;
+    char *q = NULL;
+    size_t len = 0;
+
+    pp = popen("rpm -q kylin-video", "r");
+    if(pp) { while(getline(&line, &len, pp) != -1){
+        q = strrchr(line, '\n');
+        *q = '\0';
+        QString content = line;
+        QStringList list = content.split("-");
+        if (list.size() >= 3)
+            appVersion = list.at(2);
+        }
+    }
+    if(line){
+        free(line);
+        line = NULL;
+    }
+    pclose(pp);
 
-    ui->label_3->setText(QString("<html><head/><body><p align=\"center\">%0</p></body></html>").arg(tr("version: ").append("3.1.1")));
+    ui->label_3->setText(QString("<html><head/><body><p align=\"center\">%0</p></body></html>").arg(tr("version: ").append(appVersion)));
     ui->label_4->setText(tr("service and support: ").append("<a href=\"mailto://support@kylinos.cn\">support@kylinos.cn</a>"));
     connect(ui->label_4, SIGNAL(linkActivated(QString)), this, SLOT(slotOpenUrl(QString)));
     initStyle();
-- 
2.33.0

