From 6cbbee2bb18efc0c77dfc892f3758e6da9b3e86f Mon Sep 17 00:00:00 2001 From: sundagao Date: Mon, 20 Jul 2026 17:29:58 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20accessible=20n?= =?UTF-8?q?ame=20=EF=BC=8C=E6=96=B9=E4=BE=BF=E5=B1=8F=E5=B9=95=E9=98=85?= =?UTF-8?q?=E8=AF=BB=E5=99=A8=E9=98=85=E8=AF=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加 accessible name Task: #648639 From: kylin Severity: Moderate Changelog-Other: 添加 accessible name Changelog-Break: 屏幕阅读 Change-Id: I45721d73b218f682b0aa79c83ffdeede3f41344f --- notification-ukcc-plugin/notice-menu.cpp | 18 ++--- .../notification-settings-item.cpp | 8 ++- .../notification-ukcc-plugin.cpp | 71 +++++++++++++------ .../notification-ukcc-plugin.h | 1 + 4 files changed, 66 insertions(+), 32 deletions(-) diff --git a/notification-ukcc-plugin/notice-menu.cpp b/notification-ukcc-plugin/notice-menu.cpp index 4579267..0febc40 100644 --- a/notification-ukcc-plugin/notice-menu.cpp +++ b/notification-ukcc-plugin/notice-menu.cpp @@ -75,29 +75,32 @@ void NoticeMenu::initUi() menuLyt->setSpacing(0); menuLyt->setContentsMargins(8, 0, 8, 0); - const QString baseAccessibleName = m_parent ? m_parent->accessibleName() : QStringLiteral("notification_ukcc_plugin"); + const QString baseAccessibleName = m_parent->property("localName").toString(); QFrame *voiceFrame = new QFrame(this); m_voiceBtn = new KSwitchButton; + const QString voiceBtnText = tr("Beep sound when notified"); m_voiceBtn->setTranslucent(true); - m_voiceBtn->setAccessibleName(baseAccessibleName + "_sound_button"); - setFrame(voiceFrame, tr("Beep sound when notified"), m_voiceBtn); + m_voiceBtn->setAccessibleName(baseAccessibleName + tr("allow") + voiceBtnText); + setFrame(voiceFrame, voiceBtnText, m_voiceBtn); QFrame *line_1 = setLine(); QFrame *detailFrame = new QFrame(this); + const QString detailBtnText = tr("Show message on screenlock"); m_detailBtn = new KSwitchButton; m_detailBtn->setTranslucent(true); - m_detailBtn->setAccessibleName(baseAccessibleName + "_detail_button"); + m_detailBtn->setAccessibleName(baseAccessibleName + tr("allow") + detailBtnText); - setFrame(detailFrame, tr("Show message on screenlock"), m_detailBtn); + setFrame(detailFrame, detailBtnText, m_detailBtn); QFrame *line_2 = setLine(); QFrame *showFrame = new QFrame(this); m_showBtn = new KSwitchButton; + const QString showBtnText = tr("Show noticfication on screenlock"); m_showBtn->setTranslucent(true); - m_showBtn->setAccessibleName(baseAccessibleName + "_show_button"); - setFrame(showFrame, tr("Show noticfication on screenlock"), m_showBtn); + m_showBtn->setAccessibleName(baseAccessibleName + tr("allow") + showBtnText); + setFrame(showFrame, showBtnText, m_showBtn); menuLyt->addWidget(voiceFrame); menuLyt->addWidget(line_1); @@ -169,5 +172,4 @@ void NoticeMenu::showEvent(QShowEvent *event) QPoint pos = QPoint(menuXPos - menuWidth + buttonWidth, this->pos().y()); this->move(pos); - QMenu::showEvent(event); } diff --git a/notification-ukcc-plugin/notification-settings-item.cpp b/notification-ukcc-plugin/notification-settings-item.cpp index b0018fd..814047c 100644 --- a/notification-ukcc-plugin/notification-settings-item.cpp +++ b/notification-ukcc-plugin/notification-settings-item.cpp @@ -46,13 +46,15 @@ NotificationSettingsItem::NotificationSettingsItem(const QString &localName, con m_menuButton->setAutoRaise(true); m_menuButton->setFixedSize(QSize(36, 36)); m_menuButton->setIcon(QIcon::fromTheme("view-more-horizontal-symbolic")); - m_menuButton->setAccessibleName("notification_ukcc_plugin_" + nameEn + "_set_button"); - + m_menuButton->setAccessibleName(localName + tr("notification menu")); + m_menuButton->setProperty("localName", localName); m_menu = new NoticeMenu(settings, m_menuButton); m_menuButton->setMenu(m_menu); m_notificationSwitch = new KSwitchButton(this); - m_notificationSwitch->setAccessibleName("notification_ukcc_plugin_" + nameEn + "_app_button"); + m_notificationSwitch->setAccessibleName(localName + tr("allow notification")); + + m_horLayout = new QHBoxLayout(this); m_horLayout->setSpacing(8); diff --git a/notification-ukcc-plugin/notification-ukcc-plugin.cpp b/notification-ukcc-plugin/notification-ukcc-plugin.cpp index 4a63dd5..3b28d7a 100644 --- a/notification-ukcc-plugin/notification-ukcc-plugin.cpp +++ b/notification-ukcc-plugin/notification-ukcc-plugin.cpp @@ -115,6 +115,11 @@ bool Notice::isEnable() const return true; } +QString Notice::baseAccessibleName() +{ + return tr("Do not disturb mode"); +} + void Notice::initUi(QWidget *widget) { QVBoxLayout *mverticalLayout = new QVBoxLayout(widget); @@ -135,7 +140,7 @@ void Notice::initUi(QWidget *widget) m_noticeLabel = new TitleLabel(Noticewidget); m_notFazeLabel = new TitleLabel(); //~ contents_path /Notice/Do not disturb mode Mode - m_notFazeLabel->setText(tr("Do not disturb mode")); + m_notFazeLabel->setText(baseAccessibleName()); LightLabel *notFazeLabel = new LightLabel(tr("(Notification banners, prompts will be hidden, and notification sounds will be muted)")); QFrame *distrubFrame = new QFrame(widget); @@ -158,9 +163,10 @@ void Notice::initUi(QWidget *widget) m_getNoticeLabel = new QLabel(m_getNoticeFrame); m_getNoticeLabel->setFixedWidth(550); + m_getNoticeLabel->setText(tr("Get notifications from the app")); m_enableSwitchBtn = new KSwitchButton(m_getNoticeFrame); m_enableSwitchBtn->setObjectName("getnoticeinfo"); - m_enableSwitchBtn->setAccessibleName("notification_ukcc_plugin_enable_notifications_switch"); + m_enableSwitchBtn->setAccessibleName(m_getNoticeLabel->text() + tr("switch")); mGetNoticeLayout->addWidget(m_getNoticeLabel,Qt::AlignLeft); mGetNoticeLayout->addStretch(); @@ -214,73 +220,96 @@ void Notice::initNotFaze(QFrame *frame) autoLyt->setContentsMargins(16, 0, 16, 0); //~ contents_path /Notice/Do not disturb mode Mode/Automatically turn on QLabel *autoOpenLabel = new QLabel(tr("Automatically turn on"), autoOpenFrame); + autoOpenLabel->setAccessibleName(baseAccessibleName() + tr("auto open time hour")); + m_openTimeHComboBox = new QComboBox(autoOpenFrame); m_openTimeHComboBox->setObjectName("opentimehour"); m_openTimeHComboBox->setFixedWidth(64); + autoOpenLabel->setBuddy(m_openTimeHComboBox); m_openTimeMComboBox = new QComboBox(autoOpenFrame); m_openTimeMComboBox->setObjectName("opentimeminute"); m_openTimeMComboBox->setFixedWidth(64); + m_closeTimeHComboBox = new QComboBox(autoOpenFrame); m_closeTimeHComboBox->setObjectName("closetimehour"); m_closeTimeHComboBox->setFixedWidth(64); m_closeTimeMComboBox = new QComboBox(autoOpenFrame); m_closeTimeMComboBox->setObjectName("closetimeminute"); m_closeTimeMComboBox->setFixedWidth(64); + for (int i = 0; i < 24; i++) { m_openTimeHComboBox->addItem(QStringLiteral("%1").arg(i, 2, 10, QLatin1Char('0'))); + m_openTimeHComboBox->setItemData(i, tr("%1 o'clock").arg(i), Qt::AccessibleTextRole); m_closeTimeHComboBox->addItem(QStringLiteral("%1").arg(i, 2, 10, QLatin1Char('0'))); + m_closeTimeHComboBox->setItemData(i, tr("%1 o'clock").arg(i), Qt::AccessibleTextRole); } + for (int i = 0; i < 60; i++) { m_openTimeMComboBox->addItem(QStringLiteral("%1").arg(i, 2, 10, QLatin1Char('0'))); + m_openTimeMComboBox->setItemData(i, tr("%1 minute").arg(i), Qt::AccessibleTextRole); m_closeTimeMComboBox->addItem(QStringLiteral("%1").arg(i, 2, 10, QLatin1Char('0'))); + m_closeTimeMComboBox->setItemData(i, tr("%1 minute").arg(i), Qt::AccessibleTextRole); } - QLabel * label_1 = new QLabel(autoOpenFrame); - label_1->setFixedWidth(20); - label_1->setText(tr("to")); - QLabel *label_2 = new QLabel(autoOpenFrame); - label_2->setFixedWidth(4); - label_2->setText(":"); - QLabel *label_3 = new QLabel(autoOpenFrame); - label_3->setFixedWidth(4); - label_3->setText(":"); + // hh:mm to hh:mm + QLabel *openMinuteSeparatorLabel = new QLabel(autoOpenFrame); + openMinuteSeparatorLabel->setFixedWidth(4); + openMinuteSeparatorLabel->setText(":"); + openMinuteSeparatorLabel->setAccessibleName(baseAccessibleName() + tr("auto open time minute")); + openMinuteSeparatorLabel->setBuddy(m_openTimeMComboBox); + + QLabel * timeRangeLabel = new QLabel(autoOpenFrame); + timeRangeLabel->setFixedWidth(20); + timeRangeLabel->setText(tr("to")); + timeRangeLabel->setAccessibleName(baseAccessibleName() + tr("auto close time hour")); + timeRangeLabel->setBuddy(m_closeTimeHComboBox); + + QLabel *closeMinuteSeparatorLabel = new QLabel(autoOpenFrame); + closeMinuteSeparatorLabel->setFixedWidth(4); + closeMinuteSeparatorLabel->setText(":"); + closeMinuteSeparatorLabel->setAccessibleName(baseAccessibleName() + tr("auto close time minute")); + closeMinuteSeparatorLabel->setBuddy(m_closeTimeMComboBox); + m_autoOpenSwitchBtn = new KSwitchButton(autoOpenFrame); m_autoOpenSwitchBtn->setObjectName("autoopen"); - m_autoOpenSwitchBtn->setAccessibleName("notification_ukcc_plugin_auto_open_dnd_switch"); + m_autoOpenSwitchBtn->setAccessibleName(baseAccessibleName() + autoOpenLabel->text() + tr("switch")); autoLyt->addWidget(autoOpenLabel); autoLyt->addStretch(); autoLyt->addWidget(m_openTimeHComboBox); - autoLyt->addWidget(label_2); + autoLyt->addWidget(openMinuteSeparatorLabel); autoLyt->addWidget(m_openTimeMComboBox); - autoLyt->addWidget(label_1); + autoLyt->addWidget(timeRangeLabel); autoLyt->addWidget(m_closeTimeHComboBox); - autoLyt->addWidget(label_3); + autoLyt->addWidget(closeMinuteSeparatorLabel); autoLyt->addWidget(m_closeTimeMComboBox); autoLyt->addSpacing(24); autoLyt->addWidget(m_autoOpenSwitchBtn); QFrame *multiScreenFrame = new QFrame(frame); + const QString multiScreenText = tr("Automatically turn on when multiple screens are connected"); m_multiScreenSwitchBtn= new KSwitchButton(); m_multiScreenSwitchBtn->setObjectName("multiscreen"); - m_multiScreenSwitchBtn->setAccessibleName("notification_ukcc_plugin_multi_screen_dnd_switch"); + m_multiScreenSwitchBtn->setAccessibleName(baseAccessibleName() + multiScreenText); //~ contents_path /Notice/Do not disturb mode/Automatically turn on when multiple screens are connected - setFrame(multiScreenFrame, m_multiScreenSwitchBtn, tr("Automatically turn on when multiple screens are connected")); + setFrame(multiScreenFrame, m_multiScreenSwitchBtn, multiScreenText); QFrame *fullScreenFrame = new QFrame(frame); + const QString fullScreenText = tr("Automatically open in full screen mode"); m_fullScreenSwitchBtn= new KSwitchButton(); m_fullScreenSwitchBtn->setObjectName("fullscreen"); - m_fullScreenSwitchBtn->setAccessibleName("notification_ukcc_plugin_full_screen_dnd_switch"); + m_fullScreenSwitchBtn->setAccessibleName(baseAccessibleName() + fullScreenText); //~ contents_path /Notice/Do not disturb mode/Automatically open in full screen mode - setFrame(fullScreenFrame, m_fullScreenSwitchBtn, tr("Automatically open in full screen mode")); + setFrame(fullScreenFrame, m_fullScreenSwitchBtn, fullScreenText); QFrame *allowAlarmrRemindersFrame = new QFrame(frame); + const QString allowAlarmText = tr("Allow automatic alarm reminders in Do Not Disturb mode"); m_allowAlarmSwitchBtn= new KSwitchButton(); m_allowAlarmSwitchBtn->setObjectName("allowAlarmr"); - m_allowAlarmSwitchBtn->setAccessibleName("notification_ukcc_plugin_allow_alarm_dnd_switch"); + m_allowAlarmSwitchBtn->setAccessibleName(allowAlarmText); //~ contents_path /Notice/Do not disturb mode/Allow automatic alarm reminders in Do Not Disturb mode - setFrame(allowAlarmrRemindersFrame, m_allowAlarmSwitchBtn, tr("Allow automatic alarm reminders in Do Not Disturb mode")); + setFrame(allowAlarmrRemindersFrame, m_allowAlarmSwitchBtn, allowAlarmText); notFazeLyt->addWidget(autoOpenFrame); notFazeLyt->addWidget(line_1); diff --git a/notification-ukcc-plugin/notification-ukcc-plugin.h b/notification-ukcc-plugin/notification-ukcc-plugin.h index a060b33..b75c1b3 100644 --- a/notification-ukcc-plugin/notification-ukcc-plugin.h +++ b/notification-ukcc-plugin/notification-ukcc-plugin.h @@ -52,6 +52,7 @@ public: bool isShowOnHomePage() const Q_DECL_OVERRIDE; QIcon icon() const Q_DECL_OVERRIDE; bool isEnable() const Q_DECL_OVERRIDE; + static QString baseAccessibleName(); void initUi(QWidget *widget); void initNotFaze(QFrame *frame); -- Gitee From 6521b1c8be87c8c24a376fbc27da5b47d16227c4 Mon Sep 17 00:00:00 2001 From: sundagao Date: Tue, 21 Jul 2026 09:42:32 +0800 Subject: [PATCH 2/2] =?UTF-8?q?chore:=20=E6=B7=BB=E5=8A=A0=E4=B8=AD?= =?UTF-8?q?=E6=96=87=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加翻译文件 Task: #648639 From: kylin Severity: Moderate Change-Id: Ib4ab0329040e3973e4df2c22b8bb3405f420db70 --- .../translations/zh_CN.ts | 91 +++++++++++++++---- 1 file changed, 75 insertions(+), 16 deletions(-) diff --git a/notification-ukcc-plugin/translations/zh_CN.ts b/notification-ukcc-plugin/translations/zh_CN.ts index 2deb9cf..bc298d9 100644 --- a/notification-ukcc-plugin/translations/zh_CN.ts +++ b/notification-ukcc-plugin/translations/zh_CN.ts @@ -4,7 +4,7 @@ Notice - + Notice 通知 @@ -13,52 +13,91 @@ 勿扰模式 - + Do not disturb mode 勿扰模式 - /Notice/Do not disturb mode Mode - + (Notification banners, prompts will be hidden, and notification sounds will be muted) (通知横幅、提示将会隐藏,通知声音将会静音) - + + + switch + 开关 + + + Automatically turn on 自动开启 /Notice/Do not disturb mode Mode/Automatically turn on + + auto open time hour + 自动开启时间小时 + + + + auto close time hour + 自动关闭时间小时 + + + + auto close time minute + 自动关闭时间分钟 + + + + + %1 o'clock + %1点 + + + + %1 minute + %1分钟 + + + + auto open time minute + 自动开启时间分钟 + + + to - + auto close time + 自动关闭时间 + + + Automatically turn on when multiple screens are connected 多屏连接时自动开启 - /Notice/Do not disturb mode/Automatically turn on when multiple screens are connected - + Automatically open in full screen mode 全屏模式下自动开启 - /Notice/Do not disturb mode/Automatically open in full screen mode - + Allow automatic alarm reminders in Do Not Disturb mode 勿扰模式下允许闹钟提示 - /Notice/Do not disturb mode/Allow automatic alarm reminders in Do Not Disturb mode - + Notice Settings 通知 - + + Get notifications from the app 获取来自应用的通知 /notice/Get notifications from the app @@ -67,17 +106,24 @@ NoticeMenu - + Beep sound when notified 通知时提示声音 - + + + + allow + 允许 + + + Show message on screenlock 在锁屏界面显示消息内容 - + Show noticfication on screenlock 在锁屏界面显示通知 @@ -98,4 +144,17 @@ 无:通知不会显示在屏幕上,但会进入通知中心 + + NotificationSettingsItem + + + notification menu + 通知菜单 + + + + allow notification + 允许通知 + + -- Gitee