Fix the problem that application version is not set

Signed-off-by: 侯红勋 <houhongxun@kylinos.cn>
This commit is contained in:
侯红勋 2024-05-28 14:59:24 +08:00
parent bc7b2a0a5b
commit 98aa26b101
2 changed files with 114 additions and 1 deletions

View File

@ -0,0 +1,105 @@
From cca34e2f88f6a2c2af752a39f665ce9fdc776464 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E4=BE=AF=E7=BA=A2=E5=8B=8B?= <houhongxun@kylinos.cn>
Date: Tue, 28 May 2024 14:47:33 +0800
Subject: [PATCH] fix the problem that the app version not set
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: 侯红勋 <houhongxun@kylinos.cn>
---
src/ukui-screensaver-command.cpp | 22 ++++++++++++++++++++++
src/ukui-screensaver-dialog.cpp | 21 +++++++++++++++++++++
2 files changed, 43 insertions(+)
diff --git a/src/ukui-screensaver-command.cpp b/src/ukui-screensaver-command.cpp
index 1ce2d54..97f1eb7 100644
--- a/src/ukui-screensaver-command.cpp
+++ b/src/ukui-screensaver-command.cpp
@@ -22,15 +22,37 @@
#include <QTranslator>
#include <QCommandLineParser>
#include <QDebug>
+#include <QProcess>
+#include <QRegularExpression>
#include "types.h"
#include <ukui-log4qt.h>
#define WORKING_DIRECTORY "/usr/share/ukui-screensaver"
+static QString getVersion()
+{
+ QProcess v_p;
+ v_p.start("rpm", QStringList() << "-q" << "ukui-screensaver");
+
+ if (!v_p.waitForFinished())
+ return "none";
+
+ QByteArray ba = v_p.readAllStandardOutput();
+
+ QRegularExpression qe("-([^-]+)-[^-]+\n$");
+
+ QRegularExpressionMatch qem = qe.match(ba);
+ if (qem.hasMatch()) {
+ return qem.captured(1);
+ }
+ return "none";
+}
+
int main(int argc, char **argv)
{
initUkuiLog4qt("ukui-screensaver-command");
QCoreApplication a(argc, argv);
+ a.setApplicationVersion(getVersion());
QString locale = QLocale::system().name();
QTranslator translator;
diff --git a/src/ukui-screensaver-dialog.cpp b/src/ukui-screensaver-dialog.cpp
index e05cd00..3ea7bad 100644
--- a/src/ukui-screensaver-dialog.cpp
+++ b/src/ukui-screensaver-dialog.cpp
@@ -28,6 +28,7 @@
#include <QDebug>
#include <QDesktopWidget>
#include <QDBusInterface>
+#include <QRegularExpression>
#include <signal.h>
#include <unistd.h>
#include <fcntl.h>
@@ -125,6 +126,25 @@ void handler(int signum)
window->closeScreensaver();
}
+static QString getVersion()
+{
+ QProcess v_p;
+ v_p.start("rpm", QStringList() << "-q" << "ukui-screensaver");
+
+ if (!v_p.waitForFinished())
+ return "none";
+
+ QByteArray ba = v_p.readAllStandardOutput();
+
+ QRegularExpression qe("-([^-]+)-[^-]+\n$");
+
+ QRegularExpressionMatch qem = qe.match(ba);
+ if (qem.hasMatch()) {
+ return qem.captured(1);
+ }
+ return "none";
+}
+
#define WORKING_DIRECTORY "/usr/share/ukui-screensaver"
int main(int argc, char *argv[])
{
@@ -169,6 +189,7 @@ int main(int argc, char *argv[])
//signal(SIGTERM,handler);
QApplication a(argc, argv);
QApplication::setSetuidAllowed(true);
+ a.setApplicationVersion(getVersion());
QDesktopWidget *desktop = QApplication::desktop();
if(desktop->geometry().width()<=0 || desktop->geometry().height()<=0)
--
2.33.0

View File

@ -1,6 +1,6 @@
Name: ukui-screensaver
Version: 3.1.1
Release: 6
Release: 7
Summary: Screensaver for UKUI desktop environment
License: GPL-3+ and GPL-2+
URL: http://www.ukui.org
@ -11,6 +11,7 @@ Patch02: 0002-fix-build-compile-error.patch
Patch03: disable-Suspend-and-Sleep-of-ukui-screensaver.patch
Patch04: add-switchuser-no-limits-in-ukui-screensaver.patch
%endif
Patch05: 0001-fix-the-problem-that-the-app-version-not-set.patch
BuildRequires: cmake
BuildRequires: qt5-qtbase-devel
BuildRequires: qt5-qtx11extras-devel
@ -48,6 +49,7 @@ fi
%patch03 -p1
%patch04 -p1
%endif
%patch05 -p1
%build
cmake .
@ -82,6 +84,12 @@ glib-compile-schemas /usr/share/glib-2.0/schemas/ &> /dev/null ||:
%{_prefix}/lib/ukui-screensaver/screensaver-focus-helper
%changelog
* Tue May 28 2024 houhongxun <houhongxun@kylinos.cn> - 3.1.1-7
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:add patch5:0001-fix-the-problem-that-the-app-version-not-set.patch
* Mon Sep 04 2023 peijiankang <peijiankang@kylinos.cn> - 3.1.1-6
- Type:bugfix
- ID:NA