From 6433e34bc3e113a11aa2d56b8eec8607f43a1927 Mon Sep 17 00:00:00 2001
From: peijiankang <peijiankang@kylinos.cn>
Date: Thu, 9 Jun 2022 14:12:37 +0800
Subject: [PATCH] Fix kylin-user-guide version is empty

---
 src/main.cpp | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/src/main.cpp b/src/main.cpp
index 68e5c11..2d3b270 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -78,16 +78,25 @@ static void crashHandler(int sig)
 }
 
 QString getAppVersion(){
+    QString m_appVersion;
+    QStringList options;
     QProcess process;
-    QString cmd = "dpkg-parsechangelog";
-    QStringList arg;
-    arg.clear();
-    arg << "-l" << CHANGELOG_PATH << "--show-field" << "Version";
-    process.start(cmd,arg);
+    options << "-q" << "kylin-user-guide";
+    process.start("rpm", options);
     process.waitForFinished();
-    QByteArray result = process.readAllStandardOutput();
-    result = result.left(result.length()-1);
-    return result;
+    QString dpkgInfo = process.readAll();
+    QStringList infoList = dpkgInfo.split("\n");
+    for (int n = 0; n < infoList.size(); n++) {
+    	QString strInfoLine = infoList[n];
+    	if (strInfoLine.contains("kylin-user-guide")) {
+            QStringList lineInfoList = strInfoLine.split(QRegExp("-"));
+            if (lineInfoList.size() >= 3) {
+            	m_appVersion = lineInfoList[3];
+       	    }
+   	    break;
+	}
+    }
+    return m_appVersion;
 }
 
 int main(int argc, char *argv[])
-- 
2.33.0

