From 26c21cea61c43db986817d8be4a25642b46e0fc7 Mon Sep 17 00:00:00 2001
From: peijiankang <peijiankang@kylinos.cn>
Date: Tue, 2 Aug 2022 09:26:38 +0800
Subject: [PATCH] modify the error version of ukui-clock

---
 about.cpp | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/about.cpp b/about.cpp
index 08b081c..e699d2a 100644
--- a/about.cpp
+++ b/about.cpp
@@ -38,7 +38,31 @@ About::About(QWidget *parent) :
     ui->appnameLabel->setText(tr(KYLIN_CLOCK_APP_NAME));
     ui->appnameLabel->setStyleSheet("QLabel{ font-size: 18px; color: palette(windowText);}"
                                     "QLabel{font-family: NotoSansCJKsc-Medium, NotoSansCJKsc;}");
-    ui->versionLabel->setText(tr("Version: ")+"2021.2.0");
+   
+    QString appVersion = "2021.2.0"; 
+    FILE *pp = NULL;
+    char *line = NULL;
+    char *q = NULL;
+    size_t len = 0;
+    ssize_t read;
+
+    pp = popen("rpm -q ukui-clock", "r");
+    if(pp) { while((read = 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->versionLabel->setText(tr("Version: ")+ appVersion);
     settingsStyle();
     //中间大图标
     ui->appiconLabel->setPixmap(QIcon::fromTheme("kylin-alarm-clock").pixmap(96,96));
-- 
2.33.0

