!44 英文版日历中农历信息不应该存在

From: @pei-jiankang 
Reviewed-by: @dou33 
Signed-off-by: @dou33
This commit is contained in:
openeuler-ci-bot 2022-03-28 09:15:53 +00:00 committed by Gitee
commit a60a00a8e6
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 356 additions and 1 deletions

View File

@ -0,0 +1,350 @@
From 1b4f782534346e5360e05e78d9e3a1885b36a18f Mon Sep 17 00:00:00 2001
From: pei-jiankang <peijiankang@kylinos.cn>
Date: Mon, 28 Mar 2022 15:58:21 +0800
Subject: [PATCH] modify lunarcalendar display error
---
plugin-calendar/CMakeLists.txt | 3 +
plugin-calendar/html/hlnew/hl2021.js | 4 +-
plugin-calendar/html/hlnew/hl2022.js | 2 +-
plugin-calendar/html/jiejiari.js | 13 ++-
.../lunarcalendarwidget/lunarcalendaritem.cpp | 95 +++++++++++--------
.../lunarcalendarmonthitem.cpp | 2 +-
.../lunarcalendarwidget.cpp | 55 +++++++----
.../lunarcalendaryearitem.cpp | 4 +-
8 files changed, 109 insertions(+), 69 deletions(-)
diff --git a/plugin-calendar/CMakeLists.txt b/plugin-calendar/CMakeLists.txt
index f6cb668..bfe257a 100644
--- a/plugin-calendar/CMakeLists.txt
+++ b/plugin-calendar/CMakeLists.txt
@@ -48,4 +48,7 @@ link_libraries(glib-2.0.so)
include(../cmake/UkuiPluginTranslationTs.cmake)
ukui_plugin_translate_ts(${PLUGIN})
+install(DIRECTORY html/
+ DESTINATION ${PACKAGE_DATA_DIR}/plugin-calendar/html)
+
BUILD_UKUI_PLUGIN(${PLUGIN})
diff --git a/plugin-calendar/html/hlnew/hl2021.js b/plugin-calendar/html/hlnew/hl2021.js
index 3dc5a2e..86c62f3 100644
--- a/plugin-calendar/html/hlnew/hl2021.js
+++ b/plugin-calendar/html/hlnew/hl2021.js
@@ -1742,7 +1742,7 @@
},
"d1020": {
"y": "搬家.装修.开业.结婚.领证.开工.动土.出行.",
- "j": "入宅.安床.订婚.安葬.上梁.破土.祈福.祭祀.kylin@UK:~入宅.安床.订婚.安葬.上梁.破土.祈福.祭祀..",
+ "j": "入宅.安床.订婚.安葬.上梁.破土.祈福.祭祀.",
"c": "生肖冲虎",
"s": "煞南",
"ch": "开",
@@ -2021,7 +2021,7 @@
},
"d1120": {
"y": "搬家.装修.结婚.领证.动土.订婚.入学.求嗣.",
- "j": "开业.开工.安床.出行.安葬.上梁.开张.旅游.kylin@UK:~.",
+ "j": "开业.开工.安床.出行.安葬.上梁.开张.旅游.",
"c": "生肖冲鸡",
"s": "煞西",
"ch": "定",
diff --git a/plugin-calendar/html/hlnew/hl2022.js b/plugin-calendar/html/hlnew/hl2022.js
index 69d1f36..3d08118 100644
--- a/plugin-calendar/html/hlnew/hl2022.js
+++ b/plugin-calendar/html/hlnew/hl2022.js
@@ -76,7 +76,7 @@
"j": "伐木."
},
"d0120": {
-"y": "搬家.装修.结婚.入宅.",
+"y": "搬家.装修.结婚.",
"j": "入宅."
},
"d0121": {
diff --git a/plugin-calendar/html/jiejiari.js b/plugin-calendar/html/jiejiari.js
index 79a4b59..ca2569b 100644
--- a/plugin-calendar/html/jiejiari.js
+++ b/plugin-calendar/html/jiejiari.js
@@ -25,7 +25,16 @@
"d1001":"2","d1002":"2","d1003":"2","d1004":"2","d1005":"2","d1006":"2","d1007":"2","d1009":"1"
},
"worktime.y2022":{
- "d0101":"2","d0102":"2",
- "d0131":"2","d0201":"2","d0202":"2","d0203":"2","d0204":"2","d0205":"2"
+ "d0101":"2","d0102":"2","d0103":"2","d0129":"1","d0130":"1","d0131":"2",
+ "d0201":"2","d0202":"2","d0203":"2","d0204":"2","d0205":"2","d0206":"2",
+ "d0402":"1","d0403":"2","d0404":"2","d0405":"2","d0424":"1","d0430":"2",
+ "d0501":"2","d0502":"2","d0503":"2","d0504":"2","d0507":"1",
+ "d0603":"2","d0604":"2","d0605":"2",
+ "d0910":"2","d0911":"2","d0912":"2",
+ "d1001":"2","d1002":"2","d1003":"2","d1004":"2","d1005":"2","d1006":"2","d1007":"2","d1008":"1","d1009":"1"
+
+ },
+"worktime.y2023":{
+ "d0101":"2","d0102":"2","d0103":"2"
}
}
diff --git a/plugin-calendar/lunarcalendarwidget/lunarcalendaritem.cpp b/plugin-calendar/lunarcalendarwidget/lunarcalendaritem.cpp
index 6df1d1f..ea34cd8 100644
--- a/plugin-calendar/lunarcalendarwidget/lunarcalendaritem.cpp
+++ b/plugin-calendar/lunarcalendarwidget/lunarcalendaritem.cpp
@@ -78,7 +78,7 @@ LunarCalendarItem::LunarCalendarItem(QWidget *parent) : QWidget(parent)
currentBgColor = QColor(255, 255, 255);
otherBgColor = QColor(240, 240, 240);
- selectBgColor = QColor(55,143,250);
+ selectBgColor = QColor(55,144,250);
hoverBgColor = QColor(204, 183, 180);
}
@@ -239,28 +239,37 @@ void LunarCalendarItem::drawDay(QPainter *painter)
font.setBold(true);
painter->setFont(font);
+ QLocale locale = (QLocale::system().name() == "zh_CN" ? (QLocale::Chinese) : (QLocale::English));
//代码复用率待优化
if (showLunar) {
QRect dayRect = QRect(0, 0, width, height / 1.7);
painter->drawText(dayRect, Qt::AlignHCenter | Qt::AlignBottom, QString::number(date.day()));
if (handleJsMap(date.toString("yyyy"),date.toString("MMdd")) == "2") {
painter->setPen(Qt::NoPen);
- painter->setBrush(QColor(244,78,80));
+ if(locale == QLocale::Chinese){
+ painter->setBrush(QColor(244,78,80));
+ }
QRect dayRect1 = QRect(0, 0, width/3.5,height/3.5);
painter->drawRoundedRect(dayRect1,1,1);
font.setPixelSize(side / 5);
painter->setFont(font);
painter->setPen(Qt::white);
- painter->drawText(dayRect1, Qt::AlignHCenter | Qt::AlignBottom,"休");
+ if(locale == QLocale::Chinese){
+ painter->drawText(dayRect1, Qt::AlignHCenter | Qt::AlignBottom,"休");
+ }
} else if (handleJsMap(date.toString("yyyy"),date.toString("MMdd")) == "1") {
painter->setPen(Qt::NoPen);
- painter->setBrush(QColor(251,170,42));
+ if(locale == QLocale::Chinese){
+ painter->setBrush(QColor(251,170,42));
+ }
QRect dayRect1 = QRect(0, 0, width/3.5,height/3.5);
painter->drawRoundedRect(dayRect1,1,1);
font.setPixelSize(side / 5);
painter->setFont(font);
painter->setPen(Qt::white);
- painter->drawText(dayRect1, Qt::AlignHCenter | Qt::AlignBottom,"班");
+ if(locale == QLocale::Chinese){
+ painter->drawText(dayRect1, Qt::AlignHCenter | Qt::AlignBottom,"班");
+ }
}
}
else {
@@ -300,6 +309,8 @@ void LunarCalendarItem::drawLunar(QPainter *painter)
int day;
QString strHoliday;
+ QLocale locale = (QLocale::system().name() == "zh_CN" ? (QLocale::Chinese) : (QLocale::English));
+ qDebug()<<"LunarCalendarItem语言模式:"<<locale;
painter->save();
if (!showLunar) {
@@ -324,44 +335,44 @@ void LunarCalendarItem::drawLunar(QPainter *painter)
// painter->drawText(lunarRect, Qt::AlignCenter, strHoliday);
}
else {
-
- QStringList listDayName;
- listDayName << "*" << "初一" << "初二" << "初三" << "初四" << "初五" << "初六" << "初七" << "初八" << "初九" << "初十"
- << "十一" << "十二" << "十三" << "十四" << "十五" << "十六" << "十七" << "十八" << "十九" << "二十"
- << "廿一" << "廿二" << "廿三" << "廿四" << "廿五" << "廿六" << "廿七" << "廿八" << "廿九" << "三十";
-
- //判断当前农历文字是否节日,是节日且是当月则用农历节日颜色显示
- bool exist = (!listDayName.contains(lunar) && dayType != DayType_MonthPre && dayType != DayType_MonthNext);
-
- //根据当前类型选择对应的颜色
- QColor color = currentLunarColor;
- if (dayType == DayType_MonthPre || dayType == DayType_MonthNext) {
- color = otherLunarColor;
- }
-
-// if (select) {
-// color = selectTextColor;
-// } /*else if (hover) {
-// color = hoverTextColor;
-// }*/ else if (exist) {
-// color = lunarColor;
-// }
-
- if (exist) {
- color = lunarColor;
- }
-
- painter->setPen(color);
-
- QFont font;
- font.setPixelSize(side * 0.27);
- painter->setFont(font);
-
- QRect lunarRect(0, height / 2, width, height / 2);
- painter->drawText(lunarRect, Qt::AlignCenter, lunar);
+ if(locale == QLocale::Chinese){
+ QStringList listDayName;
+ listDayName << "*" << "初一" << "初二" << "初三" << "初四" << "初五" << "初六" << "初七" << "初八" << "初九" << "初十"
+ << "十一" << "十二" << "十三" << "十四" << "十五" << "十六" << "十七" << "十八" << "十九" << "二十"
+ << "廿一" << "廿二" << "廿三" << "廿四" << "廿五" << "廿六" << "廿七" << "廿八" << "廿九" << "三十";
+
+ //判断当前农历文字是否节日,是节日且是当月则用农历节日颜色显示
+ bool exist = (!listDayName.contains(lunar) && dayType != DayType_MonthPre && dayType != DayType_MonthNext);
+
+ //根据当前类型选择对应的颜色
+ QColor color = currentLunarColor;
+ if (dayType == DayType_MonthPre || dayType == DayType_MonthNext) {
+ color = otherLunarColor;
+ }
+
+ // if (select) {
+ // color = selectTextColor;
+ // } /*else if (hover) {
+ // color = hoverTextColor;
+ // }*/ else if (exist) {
+ // color = lunarColor;
+ // }
+
+ if (exist) {
+ color = lunarColor;
+ }
+
+ painter->setPen(color);
+
+ QFont font;
+ font.setPixelSize(side * 0.27);
+ painter->setFont(font);
+
+ QRect lunarRect(0, height / 2, width, height / 2);
+ painter->drawText(lunarRect, Qt::AlignCenter, lunar);
+ }
+ painter->restore();
}
- painter->restore();
-
}
diff --git a/plugin-calendar/lunarcalendarwidget/lunarcalendarmonthitem.cpp b/plugin-calendar/lunarcalendarwidget/lunarcalendarmonthitem.cpp
index 6cfe449..e7a046b 100644
--- a/plugin-calendar/lunarcalendarwidget/lunarcalendarmonthitem.cpp
+++ b/plugin-calendar/lunarcalendarwidget/lunarcalendarmonthitem.cpp
@@ -200,7 +200,7 @@ void LunarCalendarMonthItem::drawMonth(QPainter *painter)
painter->setFont(font);
QRect dayRect = QRect(0, 0, width, height / 1.7);
- QString arg = QString::number(date.month()) +"月";
+ QString arg = QString::number(date.month()) /*+"月"*/;
painter->drawText(dayRect, Qt::AlignHCenter | Qt::AlignBottom, arg);
painter->restore();
}
diff --git a/plugin-calendar/lunarcalendarwidget/lunarcalendarwidget.cpp b/plugin-calendar/lunarcalendarwidget/lunarcalendarwidget.cpp
index ddfd1db..ca6cb02 100644
--- a/plugin-calendar/lunarcalendarwidget/lunarcalendarwidget.cpp
+++ b/plugin-calendar/lunarcalendarwidget/lunarcalendarwidget.cpp
@@ -32,10 +32,18 @@ LunarCalendarWidget::LunarCalendarWidget(QWidget *parent) : QWidget(parent)
connect(calendar_gsettings, &QGSettings::changed, this, [=] (const QString &key){
if(key == LUNAR_KEY){
if(calendar_gsettings->get("calendar").toString() == "lunar") {
- //农历
- lunarstate = true;
- labWidget->setVisible(true);
- yijiWidget->setVisible(true);
+ QLocale locale = (QLocale::system().name() == "zh_CN" ? (QLocale::Chinese) : (QLocale::English));
+ if(locale == QLocale::Chinese){
+ //农历模式且是中文模式
+ lunarstate = true;
+ labWidget->setVisible(true);
+ yijiWidget->setVisible(true);
+ }else{
+ qDebug()<<"农历模式但非中文模式则不能显示农历相关";
+ lunarstate = false;
+ labWidget->setVisible(false);
+ yijiWidget->setVisible(false);
+ }
} else {
//公历
lunarstate = false;
@@ -43,7 +51,7 @@ LunarCalendarWidget::LunarCalendarWidget(QWidget *parent) : QWidget(parent)
yijiWidget->setVisible(false);
}
_timeUpdate();
- }
+ }
if(key == "date") {
if(calendar_gsettings->get("date").toString() == "cn"){
dateShowMode = "yyyy/MM/dd dddd";
@@ -110,20 +118,29 @@ LunarCalendarWidget::LunarCalendarWidget(QWidget *parent) : QWidget(parent)
timeShow->setContentsMargins(0, 0, 0, 0);
initWidget();
- if(QGSettings::isSchemaInstalled(calendar_id)){
- //初始化农历/公历显示方式
- if(calendar_gsettings->get("calendar").toString() == "lunar") {
- //农历
- lunarstate = true;
- labWidget->setVisible(true);
- yijiWidget->setVisible(true);
- } else {
- //公历
- lunarstate = false;
- labWidget->setVisible(false);
- yijiWidget->setVisible(false);
- }
- }
+ if(QGSettings::isSchemaInstalled(calendar_id)){
+ //初始化农历/公历显示方式
+ if(calendar_gsettings->get("calendar").toString() == "lunar") {
+ QLocale locale = (QLocale::system().name() == "zh_CN" ? (QLocale::Chinese) : (QLocale::English));
+ qDebug()<<"语言模式2:"<<locale;
+ if(locale == QLocale::Chinese){
+ //农历模式且是中文模式
+ lunarstate = true;
+ labWidget->setVisible(true);
+ yijiWidget->setVisible(true);
+ }else{
+ qDebug()<<"农历模式但非中文模式则不能显示农历相关";
+ lunarstate = false;
+ labWidget->setVisible(false);
+ yijiWidget->setVisible(false);
+ }
+ } else {
+ //公历
+ lunarstate = false;
+ labWidget->setVisible(false);
+ yijiWidget->setVisible(false);
+ }
+ }
//切换主题
diff --git a/plugin-calendar/lunarcalendarwidget/lunarcalendaryearitem.cpp b/plugin-calendar/lunarcalendarwidget/lunarcalendaryearitem.cpp
index ca3d6a2..150f27e 100644
--- a/plugin-calendar/lunarcalendarwidget/lunarcalendaryearitem.cpp
+++ b/plugin-calendar/lunarcalendarwidget/lunarcalendaryearitem.cpp
@@ -76,7 +76,7 @@ LunarCalendarYearItem::LunarCalendarYearItem(QWidget *parent) : QWidget(parent)
currentBgColor = QColor(255, 255, 255);
otherBgColor = QColor(240, 240, 240);
- selectBgColor = QColor(55,143,250);
+ selectBgColor = QColor(55,144,250);
hoverBgColor = QColor(204, 183, 180);
}
@@ -199,7 +199,7 @@ void LunarCalendarYearItem::drawYear(QPainter *painter)
painter->setFont(font);
QRect dayRect = QRect(0, 0, width, height / 1.7);
- QString arg = QString::number(date.year()) + "年";
+ QString arg = QString::number(date.year()) /*+ "年"*/;
painter->drawText(dayRect, Qt::AlignHCenter | Qt::AlignBottom, arg);
painter->restore();
}
--
2.33.0

View File

@ -2,7 +2,7 @@
Name: ukui-panel
Version: 3.0.6
Release: 6
Release: 7
Summary: ukui desktop panel
License: LGPL-2.1+ GPL-2+ LGPL-3
URL: http://www.ukui.org
@ -12,6 +12,7 @@ Patch0: fix-panel-translation.patch
Patch1: 0001-modify-show-taskview-not-translation.patch
Patch2: 0002-tran-to-zh_cn.patch
Patch3: 0003-modify-close-ShowTaskview-no-replay.patch
Patch4: 0004-modify-lunarcalendar-display-error.patch
BuildRequires: cmake
BuildRequires: alsa-lib-devel
@ -64,6 +65,7 @@ Provides: ukui-indicators
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
cp -rf %{SOURCE1} %{_builddir}/%{name}-%{version}/panel/resources
%build
@ -87,6 +89,9 @@ rm -rf $RPM_BUILD_ROOT
%{_datadir}/*
%changelog
* Mon Mar 28 2022 pei-jiankang <peijiankang@kylinos.cn> - 3.0.6-7
- modify lunarcalendar display error
* Mon Mar 28 2022 pei-jiankang <peijiankang@kylinos.cn> - 3.0.6-6
- modify close ShowTaskview no replay