95 lines
3.3 KiB
Diff
95 lines
3.3 KiB
Diff
From 4208da6c0f07a645b2cfe3b53c5ce28412639af9 Mon Sep 17 00:00:00 2001
|
|
From: peijiankang <peijiankang@kylinos.cn>
|
|
Date: Fri, 13 Jan 2023 15:14:11 +0800
|
|
Subject: [PATCH] fix get Weather error
|
|
|
|
---
|
|
src/gsettingmanager.cpp | 6 +++---
|
|
src/platforminfo.cpp | 21 +++++++++++++++++++++
|
|
src/platforminfo.h | 6 ++++--
|
|
3 files changed, 28 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/src/gsettingmanager.cpp b/src/gsettingmanager.cpp
|
|
index fad7961..5869fa2 100644
|
|
--- a/src/gsettingmanager.cpp
|
|
+++ b/src/gsettingmanager.cpp
|
|
@@ -677,7 +677,7 @@ Q_GLOBAL_STATIC(WeatherGsetting, weatherGsetting)
|
|
WeatherGsetting::WeatherGsetting()
|
|
{
|
|
//获取系统
|
|
- if (PLATFORM::Intel.compare(PLATFORM::g_platformType,Qt::CaseInsensitive) == 0) {
|
|
+ if (PLATFORM::Weathername.compare(PLATFORM::g_weathername,Qt::CaseInsensitive) == 0) {
|
|
const QByteArray id(WEATHER_GSETTING_OLD);
|
|
if (QGSettings::isSchemaInstalled(id)) {
|
|
m_pWeatherSetting = new QGSettings(id);
|
|
@@ -712,7 +712,7 @@ WeatherGsetting *WeatherGsetting::getInstance()
|
|
QString WeatherGsetting::getWeather()
|
|
{
|
|
//获取系统
|
|
- if (PLATFORM::Intel.compare(PLATFORM::g_platformType,Qt::CaseInsensitive) == 0) {
|
|
+ if (PLATFORM::Weathername.compare(PLATFORM::g_weathername,Qt::CaseInsensitive) == 0) {
|
|
const QByteArray id(WEATHER_GSETTING_OLD);
|
|
if (QGSettings::isSchemaInstalled(id) && m_pWeatherSetting != nullptr \
|
|
&& m_pWeatherSetting->keys().contains(WEATHER_GSETTING_KEY)) {
|
|
@@ -740,7 +740,7 @@ QString WeatherGsetting::getWeather()
|
|
QString WeatherGsetting::getIcon()
|
|
{
|
|
//获取系统
|
|
- if (PLATFORM::Intel.compare(PLATFORM::g_platformType,Qt::CaseInsensitive) == 0) {
|
|
+ if (PLATFORM::Weathername.compare(PLATFORM::g_weathername,Qt::CaseInsensitive) == 0) {
|
|
const QByteArray id(WEATHER_GSETTING_OLD);
|
|
if (QGSettings::isSchemaInstalled(id) && m_pWeatherSetting != nullptr \
|
|
&& m_pWeatherSetting->keys().contains(WEATHER_GSETTING_KEY)) {
|
|
diff --git a/src/platforminfo.cpp b/src/platforminfo.cpp
|
|
index 8a16c2b..58f0792 100644
|
|
--- a/src/platforminfo.cpp
|
|
+++ b/src/platforminfo.cpp
|
|
@@ -1,5 +1,26 @@
|
|
#include "platforminfo.h"
|
|
|
|
+QString getweathername() {
|
|
+ FILE *pp = NULL;
|
|
+ char *line = NULL;
|
|
+ size_t len = 0;
|
|
+ QString weathername = "none";
|
|
+
|
|
+ pp = popen("rpm -q indicator-china-weather", "r");
|
|
+ if(NULL == pp)
|
|
+ return weathername;
|
|
+
|
|
+ if(getline(&line, &len, pp) != -1){
|
|
+ weathername = "indicator-china-weather";
|
|
+ }
|
|
+
|
|
+ free(line);
|
|
+ line = NULL;
|
|
+ pclose(pp);
|
|
+ return weathername;
|
|
+}
|
|
+
|
|
namespace PLATFORM {
|
|
QString g_platformType = KDKGetPrjCodeName().c_str();
|
|
+ QString g_weathername = getweathername();
|
|
}
|
|
diff --git a/src/platforminfo.h b/src/platforminfo.h
|
|
index 1e331d9..17e6ca2 100644
|
|
--- a/src/platforminfo.h
|
|
+++ b/src/platforminfo.h
|
|
@@ -6,9 +6,11 @@
|
|
#include <ukuisdk/kylin-com4cxx.h>
|
|
|
|
namespace PLATFORM {
|
|
- const QString V101 = "V10SP1";
|
|
- const QString Intel = "V10SP1-edu";
|
|
+ const QString V101 = "V10SP1";
|
|
+ const QString Intel = "V10SP1-edu";
|
|
+ const QString Weathername = "indicator-china-weather";
|
|
extern QString g_platformType ;
|
|
+ extern QString g_weathername ;
|
|
}
|
|
|
|
#endif // PLATFORMINFO_H
|
|
--
|
|
2.33.0
|
|
|