From 49152d8a2f77e1d18396924bf895b9b3b7a3c3ab Mon Sep 17 00:00:00 2001 From: houchengqiu Date: Tue, 29 Aug 2023 21:06:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0accessible=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加accessible标签名称 Log: 添加accessible标签名称 --- application/CMakeLists.txt | 1 + application/accessible.h | 270 +++++++++++++++++++++++++++++++ application/displaycontent.cpp | 32 ++-- application/displaycontent.h | 6 + application/filtercontent.cpp | 13 +- application/logcollectormain.cpp | 6 + application/loglistview.cpp | 15 -- application/main.cpp | 4 + 8 files changed, 314 insertions(+), 33 deletions(-) create mode 100644 application/accessible.h diff --git a/application/CMakeLists.txt b/application/CMakeLists.txt index 7960a7c0..520d0227 100755 --- a/application/CMakeLists.txt +++ b/application/CMakeLists.txt @@ -235,6 +235,7 @@ set (APP_HEADERS_FILES logallexportthread.h eventlogutils.h logbackend.h + accessible.h ) # 5. 头文件 diff --git a/application/accessible.h b/application/accessible.h new file mode 100644 index 00000000..f6339d69 --- /dev/null +++ b/application/accessible.h @@ -0,0 +1,270 @@ +// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#ifndef ACCESSIBLE_H +#define ACCESSIBLE_H + +// 为了方便使用,把相关定义独立出来,如有需要,直接包含这个头文件,然后使用SET_*的宏去设置,USE_*宏开启即可 +/* 宏参数说明 +* classname:类名,例如DLineEdit +* accessiblename:accessible唯一标识,需保证唯一性[getAccessibleName函数处理],优先使用QObject::setAccessibleName值 +* accessibletype:即QAccessible::Role,表示标识控件的类型 +* classobj:QObject指针 +* accessdescription:accessible描述内容,考虑到暂时用不到,目前都默认为空,有需要可自行设计接口 +* +* 部分创建宏说明 +* FUNC_CREATE:创建构造函数 +* FUNC_PRESS:创建Press接口 +* FUNC_SHOWMENU:创建右键菜单接口 +* FUNC_PRESS_SHOWMENU:上两者的综合 +* FUNC_RECT:实现rect接口 +* FUNC_TEXT:实现text接口 +* USE_ACCESSIBLE:对传入的类型设置其accessible功能 +* USE_ACCESSIBLE_BY_OBJECTNAME:同上,[指定objectname]---适用同一个类,但objectname不同的情况 +* +* 设置为指定类型的Accessible控件宏 +* SET_BUTTON_ACCESSIBLE_PRESS_SHOWMENU:button类型,添加press和showmenu功能 +* SET_BUTTON_ACCESSIBLE_SHOWMENU:button类型,添加showmenu功能 +* SET_BUTTON_ACCESSIBLE:button类型,添加press功能 +* SET_LABEL_ACCESSIBLE:label类型,用于标签控件 +* SET_FORM_ACCESSIBLE:form类型,用于widget控件 +* SET_SLIDER_ACCESSIBLE:slider类型,用于滑块控件 +* SET_SEPARATOR_ACCESSIBLE:separator类型,用于分隔符控件 +*/ + +#include +#include +#include +#include +#include +#include + +inline constexpr char kSeparator[] { "_" }; + +inline QString getObjPrefix(QAccessible::Role r) +{ + // 按照类型添加固定前缀 + QMetaEnum metaEnum = QMetaEnum::fromType(); + QByteArray prefix = metaEnum.valueToKeys(r); + switch (r) { + case QAccessible::Button: prefix = "Btn"; break; + case QAccessible::StaticText: prefix = "Label"; break; + default: break; + } + return QString::fromLatin1(prefix); +} + +inline QString getIntelAccessibleName(QWidget *w, QAccessible::Role r, QString fallback) +{ + // 避免重复生成 + static QMap< QObject *, QString > objnameMap; + if (!objnameMap[w].isEmpty()) + return objnameMap[w]; + + static QMap< QAccessible::Role, QList< QString > > accessibleMap; + QString oldAccessName = w->accessibleName(); + oldAccessName.replace(kSeparator, ""); + + // 再加上标识 + QString accessibleName = "";//getObjPrefix(r) + kSeparator; + accessibleName += oldAccessName.isEmpty() ? fallback : oldAccessName; + // 检查名称是否唯一 + if (accessibleMap[r].contains(accessibleName)) { + if (objnameMap.key(accessibleName)) { + objnameMap.remove(objnameMap.key(accessibleName)); + objnameMap.insert(w, accessibleName); + return accessibleName; + } + // 获取编号,然后+1 + int pos = accessibleName.indexOf(kSeparator); + int id = accessibleName.mid(pos + 1).toInt(); + + QString newAccessibleName; + do { + // 一直找到一个不重复的名字 + newAccessibleName = accessibleName + kSeparator + QString::number(++id); + } while (accessibleMap[r].contains(newAccessibleName)); + + accessibleMap[r].append(newAccessibleName); + objnameMap.insert(w, newAccessibleName); + + return newAccessibleName; + } else { + accessibleMap[r].append(accessibleName); + objnameMap.insert(w, accessibleName); + + return accessibleName; + } +} + +inline QString getAccessibleName(QWidget *w, QAccessible::Role r, QString fallback) +{ + QString accessibleName = getIntelAccessibleName(w, r, fallback); + if(accessibleName.isEmpty()) + { + return getObjPrefix(r) + kSeparator; + } + + return accessibleName; +} + +#define FUNC_CREATE(classname,accessibletype,accessdescription) Accessible##classname(classname *w) \ + : QAccessibleWidget(w,accessibletype,#classname)\ + , m_w(w)\ + , m_description(accessdescription)\ +{}\ + private:\ + classname *m_w;\ + QString m_description;\ + +#define FUNC_PRESS(classobj) QStringList actionNames() const override{\ + if(!classobj->isEnabled())\ + return QStringList();\ + return QStringList() << pressAction();}\ + void doAction(const QString &actionName) override{\ + if(actionName == pressAction())\ +{\ + QPointF localPos = classobj->geometry().center();\ + QMouseEvent event(QEvent::MouseButtonPress,localPos,Qt::LeftButton,Qt::LeftButton,Qt::NoModifier);\ + QMouseEvent event2(QEvent::MouseButtonRelease,localPos,Qt::LeftButton,Qt::LeftButton,Qt::NoModifier);\ + qApp->sendEvent(classobj,&event);\ + qApp->sendEvent(classobj,&event2);\ + }\ + }\ + +#define FUNC_SHOWMENU(classobj) QStringList actionNames() const override{\ + if(!classobj->isEnabled())\ + return QStringList();\ + return QStringList() << showMenuAction();}\ + void doAction(const QString &actionName) override{\ + if(actionName == showMenuAction())\ +{\ + QPointF localPos = classobj->geometry().center();\ + QMouseEvent event(QEvent::MouseButtonPress,localPos,Qt::RightButton,Qt::RightButton,Qt::NoModifier);\ + QMouseEvent event2(QEvent::MouseButtonRelease,localPos,Qt::RightButton,Qt::RightButton,Qt::NoModifier);\ + qApp->sendEvent(classobj,&event);\ + qApp->sendEvent(classobj,&event2);\ + }\ + }\ + +#define FUNC_PRESS_SHOWMENU(classobj) QStringList actionNames() const override{\ + if(!classobj->isEnabled())\ + return QStringList();\ + return QStringList() << pressAction() << showMenuAction();}\ + void doAction(const QString &actionName) override{\ + if(actionName == pressAction())\ +{\ + QPointF localPos = classobj->geometry().center();\ + QMouseEvent event(QEvent::MouseButtonPress,localPos,Qt::LeftButton,Qt::LeftButton,Qt::NoModifier);\ + QMouseEvent event2(QEvent::MouseButtonRelease,localPos,Qt::LeftButton,Qt::LeftButton,Qt::NoModifier);\ + qApp->sendEvent(classobj,&event);\ + qApp->sendEvent(classobj,&event2);\ + }\ + else if(actionName == showMenuAction())\ +{\ + QPointF localPos = classobj->geometry().center();\ + QMouseEvent event(QEvent::MouseButtonPress,localPos,Qt::RightButton,Qt::RightButton,Qt::NoModifier);\ + QMouseEvent event2(QEvent::MouseButtonRelease,localPos,Qt::RightButton,Qt::RightButton,Qt::NoModifier);\ + qApp->sendEvent(classobj,&event);\ + qApp->sendEvent(classobj,&event2);\ + }\ + }\ + +#define FUNC_RECT(classobj) QRect rect() const override{\ + if (!classobj->isVisible())\ + return QRect();\ + return classobj->geometry();\ + }\ + +#define FUNC_TEXT(classname,accessiblename) QString Accessible##classname::text(QAccessible::Text t) const{\ + switch (t) {\ + case QAccessible::Name:\ + return getAccessibleName(m_w, this->role(), accessiblename);\ + case QAccessible::Description:\ + return m_description;\ + default:\ + return QString();\ + }\ + }\ + +#define USE_ACCESSIBLE(classnamestring,classname) if (classnamestring == QLatin1String(#classname) && object && object->isWidgetType())\ +{\ + interface = new Accessible##classname(static_cast(object));\ + }\ + +// [指定objectname]---适用同一个类,但objectname不同的情况 +#define USE_ACCESSIBLE_BY_OBJECTNAME(classnamestring,classname,objectname) if (classnamestring == QLatin1String(#classname) && object && (object->objectName() == objectname) && object->isWidgetType())\ +{\ + interface = new Accessible##classname(static_cast(object));\ + }\ + +#define SET_BUTTON_ACCESSIBLE_PRESS_DESCRIPTION(classname,accessiblename,accessdescription) class Accessible##classname : public QAccessibleWidget\ +{\ + public:\ + FUNC_CREATE(classname,QAccessible::Button,accessdescription)\ + QString text(QAccessible::Text t) const override;\ + FUNC_PRESS(m_w)\ + };\ + +#define SET_BUTTON_ACCESSIBLE_SHOWMENU_DESCRIPTION(classname,accessiblename,accessdescription) class Accessible##classname : public QAccessibleWidget\ +{\ + public:\ + FUNC_CREATE(classname,QAccessible::Button,accessdescription)\ + QString text(QAccessible::Text t) const override;\ + FUNC_SHOWMENU(m_w)\ + };\ + +#define SET_BUTTON_ACCESSIBLE_PRESS_SHOEMENU_DESCRIPTION(classname,accessiblename,accessdescription) class Accessible##classname : public QAccessibleWidget\ +{\ + public:\ + FUNC_CREATE(classname,QAccessible::Button,accessdescription)\ + QString text(QAccessible::Text t) const override;\ + FUNC_PRESS_SHOWMENU(m_w)\ + };\ + +#define SET_LABEL_ACCESSIBLE_WITH_DESCRIPTION(classname,aaccessibletype,accessiblename,accessdescription) class Accessible##classname : public QAccessibleWidget\ +{\ + public:\ + FUNC_CREATE(classname,aaccessibletype,accessdescription)\ + QString text(QAccessible::Text t) const override;\ + FUNC_RECT(m_w)\ + };\ + +// /*******************************************简化使用*******************************************/ +#define SET_BUTTON_ACCESSIBLE_PRESS_SHOWMENU(classname,accessiblename) SET_BUTTON_ACCESSIBLE_PRESS_SHOEMENU_DESCRIPTION(classname,accessiblename,"")\ + FUNC_TEXT(classname,accessiblename) + +#define SET_BUTTON_ACCESSIBLE_SHOWMENU(classname,accessiblename) SET_BUTTON_ACCESSIBLE_SHOWMENU_DESCRIPTION(classname,accessiblename,"")\ + FUNC_TEXT(classname,accessiblename) + +#define SET_BUTTON_ACCESSIBLE(classname,accessiblename) SET_BUTTON_ACCESSIBLE_PRESS_DESCRIPTION(classname,accessiblename,"")\ + FUNC_TEXT(classname,accessiblename) + +#define SET_LABEL_ACCESSIBLE(classname,accessiblename) SET_LABEL_ACCESSIBLE_WITH_DESCRIPTION(classname,QAccessible::StaticText,accessiblename,"")\ + FUNC_TEXT(classname,accessiblename) + +#define SET_FORM_ACCESSIBLE(classname,accessiblename) SET_LABEL_ACCESSIBLE_WITH_DESCRIPTION(classname,QAccessible::Form,accessiblename,"");\ + FUNC_TEXT(classname,accessiblename) + +#define SET_SLIDER_ACCESSIBLE(classname,accessiblename) SET_LABEL_ACCESSIBLE_WITH_DESCRIPTION(classname,QAccessible::Slider,accessiblename,"")\ + FUNC_TEXT(classname,accessiblename) + +#define SET_SEPARATOR_ACCESSIBLE(classname,accessiblename) SET_LABEL_ACCESSIBLE_WITH_DESCRIPTION(classname,QAccessible::Separator,accessiblename,"")\ + FUNC_TEXT(classname,accessiblename) +/************************************************************************************************/ + + +/********************** 添加accessible ***********************/ +SET_FORM_ACCESSIBLE(QWidget,m_w->objectName()) + +QAccessibleInterface *accessibleFactory(const QString &classname, QObject *object) +{ + QAccessibleInterface *interface = nullptr; + USE_ACCESSIBLE(classname, QWidget); + + return interface; +} +/*************************************************************/ + +#endif // ACCESSIBLE_H diff --git a/application/displaycontent.cpp b/application/displaycontent.cpp index 7ab13708..6fa70346 100644 --- a/application/displaycontent.cpp +++ b/application/displaycontent.cpp @@ -113,17 +113,21 @@ void DisplayContent::initUI() //m_spinnerWgt,m_spinnerWgt_K m_spinnerWgt = new LogSpinnerWidget(this); + m_spinnerWgt->setAccessibleName("spinnerWidget"); m_spinnerWgt->setMinimumHeight(300); m_spinnerWgt_K = new LogSpinnerWidget(this); + m_spinnerWgt_K->setAccessibleName("spinnerWidget_K"); m_spinnerWgt_K->setMinimumHeight(300); //m_detailWgt m_detailWgt = new logDetailInfoWidget(this); + m_detailWgt->setAccessibleName("detailInfoWidget"); m_detailWgt->setMinimumHeight(70); m_detailWgt->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); //m_splitter m_splitter = new Dtk::Widget::DSplitter( this); + m_splitter->setAccessibleName("splitterFrame"); m_splitter->setOrientation(Qt::Vertical); m_splitter->setChildrenCollapsible(false); m_splitter->addWidget(m_treeView); @@ -146,8 +150,15 @@ void DisplayContent::initUI() //m_exportDlg m_exportDlg = new ExportProgressDlg(this); + m_exportDlg->setAccessibleName("ExportProgressDlg"); m_exportDlg->hide(); + + m_menu = new QMenu(m_treeView); + m_menu->setAccessibleName("table_menu"); + m_act_openForder = m_menu->addAction(/*tr("在文件管理器中显示")*/ DApplication::translate("Action", "Display in file manager")); + m_act_refresh = m_menu->addAction(/*tr("刷新")*/ DApplication::translate("Action", "Refresh")); + //setLoadState setLoadState(DATA_COMPLETE); } @@ -193,6 +204,7 @@ void DisplayContent::initTableView() { m_treeView = new LogTreeView(this); m_treeView->setObjectName("mainLogTable"); + m_treeView->setAccessibleName("mainLogTable"); m_pModel = new QStandardItemModel(this); m_treeView->setModel(m_pModel); m_treeView->setContextMenuPolicy(Qt::CustomContextMenu); @@ -3952,23 +3964,17 @@ void DisplayContent::slot_requestShowRightMenu(const QPoint &pos) if (m_treeView->indexAt(pos).isValid()) { QModelIndex index = m_treeView->currentIndex(); if (!m_treeView->selectionModel()->selectedIndexes().empty()) { - QMenu *menu = new QMenu(m_treeView); - QAction *act_openForder = new QAction(/*tr("在文件管理器中显示")*/ DApplication::translate("Action", "Display in file manager"), this); - QAction *act_refresh = new QAction(/*tr("刷新")*/ DApplication::translate("Action", "Refresh"), this); - - menu->addAction(act_openForder); - menu->addAction(act_refresh); QString path; if (m_flag == COREDUMP) { if (index.siblingAtColumn(2).data().toString() == "missing") { // 文件状态为missing,不能在文管中打开 - act_openForder->setEnabled(false); + m_act_openForder->setEnabled(false); } else { - act_openForder->setEnabled(true); + m_act_openForder->setEnabled(true); } //coredump文件不需要刷新 - act_refresh->setEnabled(false); + m_act_refresh->setEnabled(false); path = m_pModel->item(index.row(), 4)->data(Qt::UserRole + 2).toString(); } else { @@ -3976,17 +3982,19 @@ void DisplayContent::slot_requestShowRightMenu(const QPoint &pos) } //显示当前日志目录 - connect(act_openForder, &QAction::triggered, this, [ = ] { + m_act_openForder->disconnect(); + connect(m_act_openForder, &QAction::triggered, this, [ = ] { DDesktopServices::showFileItem(path); }); //刷新逻辑 - connect(act_refresh, &QAction::triggered, this, [ = ]() { + m_act_refresh->disconnect(); + connect(m_act_refresh, &QAction::triggered, this, [ = ]() { generateOOCFile(path); }); m_treeView->setContextMenuPolicy(Qt::CustomContextMenu); - menu->exec(QCursor::pos()); + m_menu->exec(QCursor::pos()); } } } diff --git a/application/displaycontent.h b/application/displaycontent.h index 809fc3ac..29fc60a5 100644 --- a/application/displaycontent.h +++ b/application/displaycontent.h @@ -275,6 +275,12 @@ public slots: * @brief m_spinnerWgt_K 加载内核日志数据时转轮控件 */ LogSpinnerWidget *m_spinnerWgt_K; // add by Airy + + // 列表右键菜单 + QMenu *m_menu{ nullptr }; + QAction *m_act_openForder{ nullptr }; + QAction *m_act_refresh{ nullptr }; + /** * @brief m_curAppLog 当前选中的应用的日志文件路径 */ diff --git a/application/filtercontent.cpp b/application/filtercontent.cpp index 21af9003..10bb624d 100644 --- a/application/filtercontent.cpp +++ b/application/filtercontent.cpp @@ -93,20 +93,16 @@ void FilterContent::initUI() hLayout_period->addWidget(m_lastMonthBtn); hLayout_period->addWidget(m_threeMonthBtn); hLayout_period->addStretch(1); - - DSuggestButton *cmdLinkBtn = new DSuggestButton(("Reset"), this); - cmdLinkBtn->setFlat(true); - cmdLinkBtn->hide(); - m_btnGroup->addButton(cmdLinkBtn, 6); - hLayout_period->addWidget(cmdLinkBtn); hLayout_period->setSpacing(10); // set level info hLayout_all = new QHBoxLayout; QHBoxLayout *hLayout_lvl = new QHBoxLayout; lvTxt = new DLabel(DApplication::translate("Label", "Level: "), this); + lvTxt->setAccessibleName(DApplication::translate("Label", "Level: ")); lvTxt->setAlignment(Qt::AlignRight | Qt::AlignVCenter); cbx_lv = new LogCombox(this); + cbx_lv->view()->setAccessibleName("combobox_level_view"); cbx_lv->setMinimumSize(QSize(198, BUTTON_HEIGHT_MIN)); cbx_lv->addItems(QStringList() << DApplication::translate("ComboBox", "All") << DApplication::translate("ComboBox", "Emergency") @@ -124,8 +120,10 @@ void FilterContent::initUI() hLayout_all->addLayout(hLayout_lvl); QHBoxLayout *hLayout_dnf_lvl = new QHBoxLayout; dnflvTxt = new DLabel(DApplication::translate("Label", "Level: "), this); + dnflvTxt->setAccessibleName("dnf" + DApplication::translate("Label", "Level: ")); dnflvTxt->setAlignment(Qt::AlignRight | Qt::AlignVCenter); cbx_dnf_lv = new LogCombox(this); + cbx_dnf_lv->view()->setAccessibleName("combobox_dnflevel_view"); cbx_dnf_lv->setMinimumSize(QSize(198, BUTTON_HEIGHT_MIN)); cbx_dnf_lv->addItem(DApplication::translate("ComboBox", "All"), DNFLVALL); cbx_dnf_lv->addItem(DApplication::translate("ComboBox", "Super critical"), SUPERCRITICAL); @@ -143,6 +141,7 @@ void FilterContent::initUI() QHBoxLayout *hLayout_app = new QHBoxLayout; appTxt = new DLabel(DApplication::translate("Label", "Application list:"), this); cbx_app = new LogCombox(this); + cbx_app->view()->setAccessibleName("combobox_app_view"); cbx_app->setMinimumSize(QSize(180, BUTTON_HEIGHT_MIN)); hLayout_app->addWidget(appTxt); @@ -154,6 +153,7 @@ void FilterContent::initUI() QHBoxLayout *hLayout_status = new QHBoxLayout; statusTxt = new DLabel(DApplication::translate("Label", "Status:"), this); cbx_status = new LogCombox(this); + cbx_status->view()->setAccessibleName("combobox_status_view"); cbx_status->setMinimumWidth(120); cbx_status->setMinimumSize(QSize(120, BUTTON_HEIGHT_MIN)); cbx_status->addItems(QStringList() << DApplication::translate("ComboBox", "All") << "OK" @@ -167,6 +167,7 @@ void FilterContent::initUI() QHBoxLayout *hLayout_type = new QHBoxLayout; typeTxt = new DLabel(DApplication::translate("Label", "Event Type:"), this); typeCbx = new LogCombox(this); + typeCbx->view()->setAccessibleName("combobox_eventtype_view"); typeCbx->setMinimumWidth(120); typeCbx->setMinimumSize(QSize(120, BUTTON_HEIGHT_MIN)); typeCbx->addItems(QStringList() << DApplication::translate("ComboBox", "All") diff --git a/application/logcollectormain.cpp b/application/logcollectormain.cpp index 9f3f4951..1e2a34ec 100644 --- a/application/logcollectormain.cpp +++ b/application/logcollectormain.cpp @@ -143,11 +143,13 @@ void LogCollectorMain::initUI() /** left frame */ m_logCatelogue = new LogListView(); m_logCatelogue->setObjectName("logTypeSelectList"); + m_logCatelogue->setAccessibleName("left_side_bar"); m_hLayout->addWidget(m_logCatelogue, 1); m_logCatelogue->setFixedWidth(160); m_vLayout = new QVBoxLayout; /** topRight frame */ m_topRightWgt = new FilterContent(); + m_topRightWgt->setAccessibleName("filterWidget"); m_vLayout->addWidget(m_topRightWgt); /** midRight frame */ m_midRightWgt = new DisplayContent(); @@ -160,6 +162,7 @@ void LogCollectorMain::initUI() m_hLayout->setContentsMargins(0, 0, 10, 0); m_hLayout->setSpacing(10); + this->centralWidget()->setAccessibleName("centralWidget"); this->centralWidget()->setLayout(m_hLayout); m_searchEdt->setObjectName("searchEdt"); m_searchEdt->lineEdit()->setObjectName("searchChildEdt"); @@ -177,6 +180,7 @@ void LogCollectorMain::initTitlebarExtensions() { DMenu *refreshMenu = new DMenu(this); DMenu *menu = new DMenu(DApplication::translate("titlebar", "Refresh interval"), refreshMenu); + menu->setAccessibleName("refresh_interval_menu"); m_refreshActions.push_back(menu->addAction(qApp->translate("titlebar", "10 sec"))); m_refreshActions.push_back(menu->addAction(qApp->translate("titlebar", "1 min"))); m_refreshActions.push_back(menu->addAction(qApp->translate("titlebar", "5 min"))); @@ -208,11 +212,13 @@ void LogCollectorMain::initTitlebarExtensions() m_exportAllBtn->setIcon(QIcon::fromTheme("export")); m_exportAllBtn->setIconSize(QSize(36, 36)); m_exportAllBtn->setToolTip(qApp->translate("titlebar", "Export All")); + m_exportAllBtn->setAccessibleName(qApp->translate("titlebar", "Export All")); m_refreshBtn = new DIconButton(widget); m_refreshBtn->setIcon(QIcon::fromTheme("refresh")); m_refreshBtn->setFixedSize(QSize(36, 36)); m_refreshBtn->setIconSize(QSize(36, 36)); m_refreshBtn->setToolTip(qApp->translate("titlebar", "Refresh Now")); + m_refreshBtn->setAccessibleName(qApp->translate("titlebar", "Refresh Now")); layout->addSpacing(115); layout->addWidget(m_exportAllBtn); layout->addSpacing(2); diff --git a/application/loglistview.cpp b/application/loglistview.cpp index ab63bef6..5131c579 100644 --- a/application/loglistview.cpp +++ b/application/loglistview.cpp @@ -159,7 +159,6 @@ void LogListView::initUI() item->setData(JOUR_TREE_DATA, ITEM_DATE_ROLE); item->setSizeHint(QSize(ITEM_WIDTH, ITEM_HEIGHT)); item->setData(VListViewItemMargin, Dtk::MarginsRole); - item->setAccessibleText("System Log"); m_pModel->appendRow(item); m_logTypes.push_back(JOUR_TREE_DATA); } @@ -171,7 +170,6 @@ void LogListView::initUI() item->setData(DMESG_TREE_DATA, ITEM_DATE_ROLE); item->setSizeHint(QSize(ITEM_WIDTH, ITEM_HEIGHT)); item->setData(VListViewItemMargin, Dtk::MarginsRole); - item->setAccessibleText("dmesg Log"); m_pModel->appendRow(item); m_logTypes.push_back(DMESG_TREE_DATA); } else { @@ -182,7 +180,6 @@ void LogListView::initUI() item->setData(KERN_TREE_DATA, ITEM_DATE_ROLE); item->setSizeHint(QSize(ITEM_WIDTH, ITEM_HEIGHT)); item->setData(VListViewItemMargin, Dtk::MarginsRole); - item->setAccessibleText("Kernel Log"); m_pModel->appendRow(item); m_logTypes.push_back(KERN_TREE_DATA); } @@ -194,7 +191,6 @@ void LogListView::initUI() item->setData(BOOT_KLU_TREE_DATA, ITEM_DATE_ROLE); item->setSizeHint(QSize(ITEM_WIDTH, ITEM_HEIGHT)); item->setData(VListViewItemMargin, Dtk::MarginsRole); - item->setAccessibleText("Boot Klu Log"); m_pModel->appendRow(item); m_logTypes.push_back(BOOT_KLU_TREE_DATA); } else { @@ -204,7 +200,6 @@ void LogListView::initUI() item->setData(BOOT_TREE_DATA, ITEM_DATE_ROLE); item->setSizeHint(QSize(ITEM_WIDTH, ITEM_HEIGHT)); item->setData(VListViewItemMargin, Dtk::MarginsRole); - item->setAccessibleText("Boot Log"); m_pModel->appendRow(item); m_logTypes.push_back(BOOT_TREE_DATA); } @@ -215,7 +210,6 @@ void LogListView::initUI() item->setData(DNF_TREE_DATA, ITEM_DATE_ROLE); item->setSizeHint(QSize(ITEM_WIDTH, ITEM_HEIGHT)); item->setData(VListViewItemMargin, Dtk::MarginsRole); - item->setAccessibleText("dnf Log"); m_pModel->appendRow(item); m_logTypes.push_back(DNF_TREE_DATA); } else { @@ -226,7 +220,6 @@ void LogListView::initUI() item->setData(DPKG_TREE_DATA, ITEM_DATE_ROLE); item->setSizeHint(QSize(ITEM_WIDTH, ITEM_HEIGHT)); item->setData(VListViewItemMargin, Dtk::MarginsRole); - item->setAccessibleText("dpkg Log"); m_pModel->appendRow(item); m_logTypes.push_back(DPKG_TREE_DATA); } @@ -239,7 +232,6 @@ void LogListView::initUI() item->setData(KWIN_TREE_DATA, ITEM_DATE_ROLE); item->setSizeHint(QSize(ITEM_WIDTH, ITEM_HEIGHT)); item->setData(VListViewItemMargin, Dtk::MarginsRole); - item->setAccessibleText("dpkg Log"); m_pModel->appendRow(item); m_logTypes.push_back(KWIN_TREE_DATA); } else { @@ -249,7 +241,6 @@ void LogListView::initUI() item->setData(XORG_TREE_DATA, ITEM_DATE_ROLE); item->setSizeHint(QSize(ITEM_WIDTH, ITEM_HEIGHT)); item->setData(VListViewItemMargin, Dtk::MarginsRole); - item->setAccessibleText("Xorg Log"); m_pModel->appendRow(item); m_logTypes.push_back(XORG_TREE_DATA); } @@ -263,7 +254,6 @@ void LogListView::initUI() item->setData(APP_TREE_DATA, ITEM_DATE_ROLE); item->setSizeHint(QSize(ITEM_WIDTH, ITEM_HEIGHT)); item->setData(VListViewItemMargin, Dtk::MarginsRole); - item->setAccessibleText("Application Log"); m_pModel->appendRow(item); this->setModel(m_pModel); m_logTypes.push_back(APP_TREE_DATA); @@ -276,7 +266,6 @@ void LogListView::initUI() item->setData(COREDUMP_TREE_DATA, ITEM_DATE_ROLE); item->setSizeHint(QSize(ITEM_WIDTH, ITEM_HEIGHT)); item->setData(VListViewItemMargin, Dtk::MarginsRole); - item->setAccessibleText("Coredump Log"); m_pModel->appendRow(item); m_logTypes.push_back(COREDUMP_TREE_DATA); @@ -290,7 +279,6 @@ void LogListView::initUI() DApplication::translate("Tree", "Boot-Shutdown Event")); // add by Airy for bug 16245 item->setSizeHint(QSize(ITEM_WIDTH, ITEM_HEIGHT)); item->setData(VListViewItemMargin, Dtk::MarginsRole); - item->setAccessibleText("Boot-Shutdown Event"); m_pModel->appendRow(item); this->setModel(m_pModel); m_logTypes.push_back(LAST_TREE_DATA); @@ -303,7 +291,6 @@ void LogListView::initUI() item->setData(OTHER_TREE_DATA, ITEM_DATE_ROLE); item->setSizeHint(QSize(ITEM_WIDTH, ITEM_HEIGHT)); item->setData(VListViewItemMargin, Dtk::MarginsRole); - item->setAccessibleText("Other Log"); m_pModel->appendRow(item); m_logTypes.push_back(OTHER_TREE_DATA); @@ -321,7 +308,6 @@ void LogListView::initUI() item->setData(AUDIT_TREE_DATA, ITEM_DATE_ROLE); item->setSizeHint(QSize(ITEM_WIDTH, ITEM_HEIGHT)); item->setData(VListViewItemMargin, Dtk::MarginsRole); - item->setAccessibleText("Auidt Log"); m_pModel->appendRow(item); m_logTypes.push_back(AUDIT_TREE_DATA); } @@ -343,7 +329,6 @@ void LogListView::initCustomLogItem() m_customLogItem->setData(CUSTOM_TREE_DATA, ITEM_DATE_ROLE); m_customLogItem->setSizeHint(QSize(ITEM_WIDTH, ITEM_HEIGHT)); m_customLogItem->setData(VListViewItemMargin, Dtk::MarginsRole); - m_customLogItem->setAccessibleText("Custom Log"); m_pModel->appendRow(m_customLogItem); } diff --git a/application/main.cpp b/application/main.cpp index d212e81d..c14db5d8 100644 --- a/application/main.cpp +++ b/application/main.cpp @@ -12,6 +12,7 @@ #include "DebugTimeManager.h" #include "logbackend.h" #include "cliapplicationhelper.h" +#include "accessible.h" #include #include @@ -128,6 +129,9 @@ int main(int argc, char *argv[]) LogCollectorMain w; a.setMainWindow(&w); + // 自动化标记由此开始 + QAccessible::installFactory(accessibleFactory); + //埋点记录启动数据 QJsonObject objStartEvent{ {"tid", Eventlogutils::StartUp},