91 lines
3.0 KiB
Diff
91 lines
3.0 KiB
Diff
From 9b05757e476316786e21a902982ed3befb9de443 Mon Sep 17 00:00:00 2001
|
|
From: peijiankang <peijiankang@kylinos.cn>
|
|
Date: Tue, 17 Jan 2023 13:42:01 +0800
|
|
Subject: [PATCH] fix get Weather error
|
|
|
|
---
|
|
src/gsettingmanager.cpp | 17 ++++++++++++++---
|
|
src/gsettingmanager.h | 3 +++
|
|
2 files changed, 17 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/gsettingmanager.cpp b/src/gsettingmanager.cpp
|
|
index fad7961..ff8630d 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 (isFileExist(WEATHER_DESKTOP_FILE)) {
|
|
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 (isFileExist(WEATHER_DESKTOP_FILE)) {
|
|
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 (isFileExist(WEATHER_DESKTOP_FILE)) {
|
|
const QByteArray id(WEATHER_GSETTING_OLD);
|
|
if (QGSettings::isSchemaInstalled(id) && m_pWeatherSetting != nullptr \
|
|
&& m_pWeatherSetting->keys().contains(WEATHER_GSETTING_KEY)) {
|
|
@@ -765,6 +765,17 @@ QString WeatherGsetting::getIcon()
|
|
}
|
|
}
|
|
|
|
+bool WeatherGsetting::isFileExist(QString FullFileName)
|
|
+{
|
|
+ QFileInfo fileInfo(FullFileName);
|
|
+ if(fileInfo.isFile())
|
|
+ {
|
|
+ return true;
|
|
+ }
|
|
+ return false;
|
|
+}
|
|
+
|
|
+
|
|
//! 护眼中心
|
|
Q_GLOBAL_STATIC(EyeprotectionGsetting, eyeprotectionGsetting)
|
|
|
|
diff --git a/src/gsettingmanager.h b/src/gsettingmanager.h
|
|
index 7319a27..9440598 100644
|
|
--- a/src/gsettingmanager.h
|
|
+++ b/src/gsettingmanager.h
|
|
@@ -5,6 +5,7 @@
|
|
#include <QGSettings>
|
|
#include <QGuiApplication>
|
|
#include <QDebug>
|
|
+#include <QFileInfo>
|
|
#include "../platforminfo.h"
|
|
|
|
//! 控制中心-个性化部分
|
|
@@ -293,6 +294,7 @@ private:
|
|
#define WEATHER_GSETTING_OLD "org.china-weather-data.settings"
|
|
#define WEATHER_GSETTING_NEW "org.kylin-weather.settings"
|
|
#define WEATHER_GSETTING_KEY "weather"
|
|
+#define WEATHER_DESKTOP_FILE "/etc/xdg/autostart/indicator-china-weather.desktop"
|
|
|
|
class WeatherGsetting : public QObject
|
|
{
|
|
@@ -305,6 +307,7 @@ public:
|
|
|
|
QString getWeather();
|
|
QString getIcon();
|
|
+ bool isFileExist(QString FullFileName);
|
|
|
|
private:
|
|
QGSettings *m_pWeatherSetting = nullptr;
|
|
--
|
|
2.33.0
|
|
|