Projects
Eulaceura:Mainline
ukui-control-center
_service:obs_scm:0001-Fix-the-version-number-sh...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:0001-Fix-the-version-number-showing-none-problem.patch of Package ukui-control-center
From 3fa9efa1ec6ae9853b023279934177e1b8f0e3f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BE=AF=E7=BA=A2=E5=8B=8B?= <houhongxun@kylinos.cn> Date: Mon, 27 May 2024 17:17:27 +0800 Subject: [PATCH] Fix the version number showing "none" problem MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 侯红勋 <houhongxun@kylinos.cn> --- libukcc/interface/common.cpp | 33 +++++++++------------------- libukcc/interface/ukcccommon.cpp | 33 +++++++++------------------- shell/ukccabout.cpp | 37 +++++++++++--------------------- shell/utils/utils.cpp | 33 +++++++++------------------- 4 files changed, 42 insertions(+), 94 deletions(-) diff --git a/libukcc/interface/common.cpp b/libukcc/interface/common.cpp index fcdf5aa..d56ebf2 100644 --- a/libukcc/interface/common.cpp +++ b/libukcc/interface/common.cpp @@ -331,34 +331,21 @@ QString Common::boolToString(bool b) QString Common::getUkccVersion() { - FILE *pp = NULL; - char *line = NULL; - size_t len = 0; - ssize_t read; - char *q = NULL; - QString version = "none"; + QProcess v_p; + v_p.start("rpm", QStringList() << "-q" << "ukui-control-center"); - pp = popen("dpkg -l ukui-control-center | grep ukui-control-center", "r"); - if(NULL == pp) - return version; + if (!v_p.waitForFinished()) + return "none"; - while((read = getline(&line, &len, pp)) != -1){ - q = strrchr(line, '\n'); - *q = '\0'; + QByteArray ba = v_p.readAllStandardOutput(); - QString content = line; - QStringList list = content.split(" "); + QRegularExpression qe("-([^-]+)-[^-]+\n$"); - list.removeAll(""); - - if (list.size() >= 3) - version = list.at(2); + QRegularExpressionMatch qem = qe.match(ba); + if (qem.hasMatch()) { + return qem.captured(1); } - - free(line); - line = NULL; - pclose(pp); - return version; + return "none"; } QString Common::getProductName() diff --git a/libukcc/interface/ukcccommon.cpp b/libukcc/interface/ukcccommon.cpp index 00d03ac..e299962 100644 --- a/libukcc/interface/ukcccommon.cpp +++ b/libukcc/interface/ukcccommon.cpp @@ -339,34 +339,21 @@ QString UkccCommon::boolToString(bool b) QString UkccCommon::getUkccVersion() { - FILE *pp = NULL; - char *line = NULL; - size_t len = 0; - ssize_t read; - char *q = NULL; - QString version = "none"; + QProcess v_p; + v_p.start("rpm", QStringList() << "-q" << "ukui-control-center"); - pp = popen("dpkg -l ukui-control-center | grep ukui-control-center", "r"); - if(NULL == pp) - return version; + if (!v_p.waitForFinished()) + return "none"; - while((read = getline(&line, &len, pp)) != -1){ - q = strrchr(line, '\n'); - *q = '\0'; + QByteArray ba = v_p.readAllStandardOutput(); - QString content = line; - QStringList list = content.split(" "); + QRegularExpression qe("-([^-]+)-[^-]+\n$"); - list.removeAll(""); - - if (list.size() >= 3) - version = list.at(2); + QRegularExpressionMatch qem = qe.match(ba); + if (qem.hasMatch()) { + return qem.captured(1); } - - free(line); - line = NULL; - pclose(pp); - return version; + return "none"; } QString UkccCommon::getProductName() diff --git a/shell/ukccabout.cpp b/shell/ukccabout.cpp index e9c5482..5a174a9 100644 --- a/shell/ukccabout.cpp +++ b/shell/ukccabout.cpp @@ -20,16 +20,16 @@ #include "ukccabout.h" #include "xatom-helper.h" #include "interface/ukcccommon.h" - #include <QVariant> #include <QDesktopServices> #include <QUrl> #include <QMouseEvent> #include <QDebug> +#include <QProcess> +#include <QRegularExpression> UkccAbout::UkccAbout(QWidget *parent) : QDialog(parent) { - setFixedSize(420, 344); setWindowTitle(tr("Settings")); initUI(); @@ -100,32 +100,19 @@ void UkccAbout::hideComponent() } QString UkccAbout::getUkccVersion() { - FILE *pp = NULL; - char *line = NULL; - size_t len = 0; - ssize_t read; - char *q = NULL; - QString version = "none"; + QProcess v_p; + v_p.start("rpm", QStringList() << "-q" << "ukui-control-center"); - pp = popen("dpkg -l ukui-control-center | grep ukui-control-center", "r"); - if(NULL == pp) - return version; + if (!v_p.waitForFinished()) + return "none"; - while((read = getline(&line, &len, pp)) != -1){ - q = strrchr(line, '\n'); - *q = '\0'; + QByteArray ba = v_p.readAllStandardOutput(); - QString content = line; - QStringList list = content.split(" "); + QRegularExpression qe("-([^-]+)-[^-]+\n$"); - list.removeAll(""); - - if (list.size() >= 3) - version = list.at(2); + QRegularExpressionMatch qem = qe.match(ba); + if (qem.hasMatch()) { + return qem.captured(1); } - - free(line); - line = NULL; - pclose(pp); - return version; + return "none"; } diff --git a/shell/utils/utils.cpp b/shell/utils/utils.cpp index 27d7fa1..33a5938 100644 --- a/shell/utils/utils.cpp +++ b/shell/utils/utils.cpp @@ -267,32 +267,19 @@ bool Utils::isZJY() QString Utils::getUkccVersion() { - FILE *pp = NULL; - char *line = NULL; - size_t len = 0; - ssize_t read; - char *q = NULL; - QString version = "none"; + QProcess v_p; + v_p.start("rpm", QStringList() << "-q" << "ukui-control-center"); - pp = popen("dpkg -l ukui-control-center | grep ukui-control-center", "r"); - if(NULL == pp) - return version; + if (!v_p.waitForFinished()) + return "none"; - while((read = getline(&line, &len, pp)) != -1){ - q = strrchr(line, '\n'); - *q = '\0'; + QByteArray ba = v_p.readAllStandardOutput(); - QString content = line; - QStringList list = content.split(" "); + QRegularExpression qe("-([^-]+)-[^-]+\n$"); - list.removeAll(""); - - if (list.size() >= 3) - version = list.at(2); + QRegularExpressionMatch qem = qe.match(ba); + if (qem.hasMatch()) { + return qem.captured(1); } - - free(line); - line = NULL; - pclose(pp); - return version; + return "none"; } -- 2.33.0
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.
浙ICP备2022010568号-2