Projects
Eulaceura:Factory
kylin-screenshot
_service:obs_scm:0001-Fix-wrong-app-version-num...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:obs_scm:0001-Fix-wrong-app-version-number.patch of Package kylin-screenshot
From eadb118a2947fc24ab2ab0b574655b653190cf35 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 15:59:36 +0800 Subject: [PATCH] Fix wrong app version number MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 侯红勋 <houhongxun@kylinos.cn> --- src/common/my_qt.h | 2 ++ src/main.cpp | 24 ++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/common/my_qt.h b/src/common/my_qt.h index bdfac71..ab3f40a 100644 --- a/src/common/my_qt.h +++ b/src/common/my_qt.h @@ -52,6 +52,8 @@ #include <QMenu> #include <QDesktopWidget> #include <QGSettings/qgsettings.h> +#include <QProcess> +#include <QRegularExpression> #include <set> diff --git a/src/main.cpp b/src/main.cpp index f6c966d..7114e57 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,7 +15,6 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ - #include "src/core/controller.h" #include "singleapplication.h" #include "src/utils/filenamehandler.h" @@ -39,6 +38,7 @@ #include "Logger.h" #include "my_x.h" +static QString getVersion(); int getScreenWidth() { @@ -67,7 +67,7 @@ int main(int argc, char *argv[]) #endif } qRegisterMetaTypeStreamOperators<QList<int> >("QList<int>"); - qApp->setApplicationVersion(static_cast<QString>(APP_VERSION)); + qApp->setApplicationVersion(getVersion()); if (qgetenv("QT_QPA_PLATFORMTHEME") != "ukui") qputenv("QT_QPA_PLATFORMTHEME", "ukui"); // no arguments, just launch kylin-screenshot @@ -552,3 +552,23 @@ finish: #endif return 0; } + +static QString getVersion() +{ + QProcess v_p; + v_p.start("rpm", QStringList() << "-q" << "kylin-screenshot"); + + 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"; +} + -- 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