mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-01 07:05:48 +00:00
chore: remove QAccessible
tests has been disabled, and QAccessible is not used in right ways log: as title
This commit is contained in:
parent
223a9df0d7
commit
f48785876e
@ -37,7 +37,6 @@ find_package(Threads REQUIRED)
|
||||
pkg_check_modules(XCB_EWMH REQUIRED IMPORTED_TARGET xcb-image xcb-ewmh xcb-composite xtst x11 dbusmenu-qt5 xext xcursor xkbcommon)
|
||||
pkg_check_modules(QGSettings REQUIRED IMPORTED_TARGET gsettings-qt)
|
||||
pkg_check_modules(WAYLAND REQUIRED IMPORTED_TARGET wayland-client wayland-cursor wayland-egl)
|
||||
pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0)
|
||||
|
||||
# driver-manager
|
||||
add_executable(${BIN_NAME}
|
||||
@ -86,7 +85,6 @@ target_link_libraries(${BIN_NAME} PRIVATE
|
||||
PkgConfig::QGSettings
|
||||
PkgConfig::XCB_EWMH
|
||||
PkgConfig::WAYLAND
|
||||
PkgConfig::GIO
|
||||
Dtk::Gui
|
||||
Qt5::Widgets
|
||||
Qt5::Gui
|
||||
|
@ -1,195 +0,0 @@
|
||||
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
#include "accessibledefine.h"
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "mainpanelcontrol.h"
|
||||
#include "desktop_widget.h"
|
||||
#include "tipswidget.h"
|
||||
#include "dockpopupwindow.h"
|
||||
#include "dragwidget.h"
|
||||
|
||||
#include "launcheritem.h"
|
||||
#include "appitem.h"
|
||||
#include "components/previewcontainer.h"
|
||||
#include "pluginsitem.h"
|
||||
#include "traypluginitem.h"
|
||||
#include "placeholderitem.h"
|
||||
#include "components/appdragwidget.h"
|
||||
#include "components/appsnapshot.h"
|
||||
#include "components/floatingpreview.h"
|
||||
|
||||
#include "snitraywidget.h"
|
||||
#include "abstracttraywidget.h"
|
||||
#include "indicatortraywidget.h"
|
||||
#include "xembedtraywidget.h"
|
||||
#include "system-trays/systemtrayitem.h"
|
||||
#include "fashiontray/fashiontrayitem.h"
|
||||
#include "fashiontray/fashiontraywidgetwrapper.h"
|
||||
#include "fashiontray/fashiontraycontrolwidget.h"
|
||||
#include "fashiontray/containers/attentioncontainer.h"
|
||||
#include "fashiontray/containers/holdcontainer.h"
|
||||
#include "fashiontray/containers/normalcontainer.h"
|
||||
#include "fashiontray/containers/spliteranimated.h"
|
||||
|
||||
// 这部分由sound插件单独维护,这样做是因为在标记volumeslider这个类时,需要用到其setValue的实现,
|
||||
// 但插件的源文件dock这边并没有包含,不想引入复杂的包含关系,其实最好的做法就是像sound插件这样,谁维护谁的
|
||||
//#include "../plugins/sound/sounditem.h"
|
||||
//#include "../plugins/sound/soundapplet.h"
|
||||
//#include "../plugins/sound/sinkinputwidget.h"
|
||||
//#include "../plugins/sound/componments/volumeslider.h"
|
||||
//#include "../plugins/sound/componments/horizontalseparator.h"
|
||||
|
||||
#include "showdesktopwidget.h"
|
||||
#include "datetimewidget.h"
|
||||
#include "onboarditem.h"
|
||||
#include "trashwidget.h"
|
||||
#include "popupcontrolwidget.h"
|
||||
#include "shutdownwidget.h"
|
||||
#include "multitaskingwidget.h"
|
||||
#include "overlaywarningwidget.h"
|
||||
#include "horizontalseperator.h"
|
||||
|
||||
#include <DIconButton>
|
||||
#include <DSwitchButton>
|
||||
#include <DPushButton>
|
||||
#include <DListView>
|
||||
#include <DSwitchButton>
|
||||
#include <DSpinner>
|
||||
#include <dloadingindicator.h>
|
||||
|
||||
#include <QScrollBar>
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
using namespace Dock;
|
||||
|
||||
// 添加accessible
|
||||
SET_FORM_ACCESSIBLE(MainWindow, "mainwindow")
|
||||
SET_BUTTON_ACCESSIBLE(MainPanelControl, "mainpanelcontrol")
|
||||
SET_LABEL_ACCESSIBLE(TipsWidget, "tips")
|
||||
SET_FORM_ACCESSIBLE(DockPopupWindow, "popupwindow")
|
||||
SET_BUTTON_ACCESSIBLE(LauncherItem, "launcheritem")
|
||||
SET_BUTTON_ACCESSIBLE(AppItem, "appitem")
|
||||
SET_BUTTON_ACCESSIBLE(PreviewContainer, "previewcontainer")
|
||||
SET_BUTTON_ACCESSIBLE(PluginsItem, m_w->pluginName())
|
||||
SET_BUTTON_ACCESSIBLE(TrayPluginItem, m_w->pluginName())
|
||||
SET_BUTTON_ACCESSIBLE(PlaceholderItem, "placeholderitem")
|
||||
SET_BUTTON_ACCESSIBLE(AppDragWidget, "appdragwidget")
|
||||
SET_BUTTON_ACCESSIBLE(AppSnapshot, "appsnapshot")
|
||||
SET_BUTTON_ACCESSIBLE(FloatingPreview, "floatingpreview")
|
||||
SET_BUTTON_ACCESSIBLE(XEmbedTrayWidget, m_w->itemKeyForConfig().replace("sni:", ""))
|
||||
SET_BUTTON_ACCESSIBLE(IndicatorTrayWidget, m_w->itemKeyForConfig().replace("sni:", ""))
|
||||
SET_BUTTON_ACCESSIBLE(SNITrayWidget, m_w->itemKeyForConfig().replace("sni:", ""))
|
||||
SET_BUTTON_ACCESSIBLE(AbstractTrayWidget, m_w->itemKeyForConfig().replace("sni:", ""))
|
||||
SET_BUTTON_ACCESSIBLE(SystemTrayItem, m_w->itemKeyForConfig().replace("sni:", ""))
|
||||
SET_FORM_ACCESSIBLE(FashionTrayItem, "fashiontrayitem")
|
||||
SET_FORM_ACCESSIBLE(FashionTrayWidgetWrapper, "fashiontraywrapper")
|
||||
SET_BUTTON_ACCESSIBLE(FashionTrayControlWidget, "fashiontraycontrolwidget")
|
||||
SET_FORM_ACCESSIBLE(AttentionContainer, "attentioncontainer")
|
||||
SET_FORM_ACCESSIBLE(HoldContainer, "holdcontainer")
|
||||
SET_FORM_ACCESSIBLE(NormalContainer, "normalcontainer")
|
||||
SET_FORM_ACCESSIBLE(SpliterAnimated, "spliteranimated")
|
||||
SET_FORM_ACCESSIBLE(DatetimeWidget, "plugin-datetime")
|
||||
SET_FORM_ACCESSIBLE(OnboardItem, "plugin-onboard")
|
||||
SET_FORM_ACCESSIBLE(TrashWidget, "plugin-trash")
|
||||
SET_BUTTON_ACCESSIBLE(PopupControlWidget, "popupcontrolwidget")
|
||||
SET_FORM_ACCESSIBLE(ShutdownWidget, "plugin-shutdown")
|
||||
SET_FORM_ACCESSIBLE(MultitaskingWidget, "plugin-multitasking")
|
||||
SET_FORM_ACCESSIBLE(ShowDesktopWidget, "plugin-showdesktop")
|
||||
SET_FORM_ACCESSIBLE(OverlayWarningWidget, "plugin-overlaywarningwidget")
|
||||
SET_FORM_ACCESSIBLE(QWidget, m_w->objectName().isEmpty() ? "widget" : m_w->objectName())
|
||||
SET_LABEL_ACCESSIBLE(QLabel, m_w->objectName() == "notifications" ? m_w->objectName() : m_w->text().isEmpty() ? m_w->objectName().isEmpty() ? "text" : m_w->objectName() : m_w->text())
|
||||
SET_BUTTON_ACCESSIBLE(DIconButton, m_w->objectName().isEmpty() ? "imagebutton" : m_w->objectName())
|
||||
SET_BUTTON_ACCESSIBLE(DSwitchButton, m_w->text().isEmpty() ? "switchbutton" : m_w->text())
|
||||
SET_BUTTON_ACCESSIBLE(DesktopWidget, "desktopWidget");
|
||||
SET_FORM_ACCESSIBLE(HorizontalSeperator, "HorizontalSeperator");
|
||||
// 几个没什么用的标记,但为了提醒大家不要遗漏标记控件,还是不要去掉
|
||||
SET_FORM_ACCESSIBLE(DBlurEffectWidget, "DBlurEffectWidget")
|
||||
SET_FORM_ACCESSIBLE(DListView, "DListView")
|
||||
SET_FORM_ACCESSIBLE(DLoadingIndicator, "DLoadingIndicator")
|
||||
SET_FORM_ACCESSIBLE(DSpinner, "DSpinner")
|
||||
SET_FORM_ACCESSIBLE(QMenu, "QMenu")
|
||||
SET_FORM_ACCESSIBLE(QPushButton, "QPushButton")
|
||||
SET_FORM_ACCESSIBLE(QSlider, "QSlider")
|
||||
SET_FORM_ACCESSIBLE(QScrollBar, "QScrollBar")
|
||||
SET_FORM_ACCESSIBLE(QScrollArea, "QScrollArea")
|
||||
SET_FORM_ACCESSIBLE(QFrame, "QFrame")
|
||||
SET_FORM_ACCESSIBLE(QGraphicsView, "QGraphicsView")
|
||||
SET_FORM_ACCESSIBLE(DragWidget, "DragWidget")
|
||||
|
||||
QAccessibleInterface *accessibleFactory(const QString &classname, QObject *object)
|
||||
{
|
||||
// 自动化标记确定不需要的控件,方可加入忽略列表
|
||||
const static QStringList ignoreLst = {"WirelessItem", "WiredItem", "SsidButton", "WirelessList", "AccessPointWidget"};
|
||||
|
||||
QAccessibleInterface *interface = nullptr;
|
||||
|
||||
USE_ACCESSIBLE(classname, MainWindow)
|
||||
ELSE_USE_ACCESSIBLE(classname, MainPanelControl)
|
||||
ELSE_USE_ACCESSIBLE(QString(classname).replace("Dock::", ""), TipsWidget)
|
||||
ELSE_USE_ACCESSIBLE(classname, DockPopupWindow)
|
||||
ELSE_USE_ACCESSIBLE(classname, LauncherItem)
|
||||
ELSE_USE_ACCESSIBLE(classname, AppItem)
|
||||
ELSE_USE_ACCESSIBLE(classname, PreviewContainer)
|
||||
ELSE_USE_ACCESSIBLE(classname, PluginsItem)
|
||||
ELSE_USE_ACCESSIBLE(classname, TrayPluginItem)
|
||||
ELSE_USE_ACCESSIBLE(classname, PlaceholderItem)
|
||||
ELSE_USE_ACCESSIBLE(classname, AppDragWidget)
|
||||
ELSE_USE_ACCESSIBLE(classname, AppSnapshot)
|
||||
ELSE_USE_ACCESSIBLE(classname, FloatingPreview)
|
||||
ELSE_USE_ACCESSIBLE(classname, SNITrayWidget)
|
||||
ELSE_USE_ACCESSIBLE(classname, AbstractTrayWidget)
|
||||
ELSE_USE_ACCESSIBLE(classname, SystemTrayItem)
|
||||
ELSE_USE_ACCESSIBLE(classname, FashionTrayItem)
|
||||
ELSE_USE_ACCESSIBLE(classname, FashionTrayWidgetWrapper)
|
||||
ELSE_USE_ACCESSIBLE(classname, FashionTrayControlWidget)
|
||||
ELSE_USE_ACCESSIBLE(classname, AttentionContainer)
|
||||
ELSE_USE_ACCESSIBLE(classname, HoldContainer)
|
||||
ELSE_USE_ACCESSIBLE(classname, NormalContainer)
|
||||
ELSE_USE_ACCESSIBLE(classname, SpliterAnimated)
|
||||
ELSE_USE_ACCESSIBLE(classname, IndicatorTrayWidget)
|
||||
ELSE_USE_ACCESSIBLE(classname, XEmbedTrayWidget)
|
||||
ELSE_USE_ACCESSIBLE(classname, DesktopWidget)
|
||||
ELSE_USE_ACCESSIBLE(classname, DatetimeWidget)
|
||||
ELSE_USE_ACCESSIBLE(classname, OnboardItem)
|
||||
ELSE_USE_ACCESSIBLE(classname, TrashWidget)
|
||||
ELSE_USE_ACCESSIBLE(classname, PopupControlWidget)
|
||||
ELSE_USE_ACCESSIBLE(classname, ShutdownWidget)
|
||||
ELSE_USE_ACCESSIBLE(classname, MultitaskingWidget)
|
||||
ELSE_USE_ACCESSIBLE(classname, ShowDesktopWidget)
|
||||
ELSE_USE_ACCESSIBLE(classname, OverlayWarningWidget)
|
||||
ELSE_USE_ACCESSIBLE(classname, QWidget)
|
||||
ELSE_USE_ACCESSIBLE_BY_OBJECTNAME(classname, QLabel, "spliter_fix")
|
||||
ELSE_USE_ACCESSIBLE_BY_OBJECTNAME(classname, QLabel, "spliter_app")
|
||||
ELSE_USE_ACCESSIBLE_BY_OBJECTNAME(classname, QLabel, "spliter_tray")
|
||||
ELSE_USE_ACCESSIBLE(classname, QLabel)
|
||||
ELSE_USE_ACCESSIBLE_BY_OBJECTNAME(QString(classname).replace("Dtk::Widget::", ""), DIconButton, "closebutton-2d")
|
||||
ELSE_USE_ACCESSIBLE_BY_OBJECTNAME(QString(classname).replace("Dtk::Widget::", ""), DIconButton, "closebutton-3d")
|
||||
ELSE_USE_ACCESSIBLE_BY_OBJECTNAME(QString(classname).replace("Dtk::Widget::", ""), DSwitchButton, "")
|
||||
ELSE_USE_ACCESSIBLE(QString(classname).replace("Dtk::Widget::", ""), DBlurEffectWidget)
|
||||
ELSE_USE_ACCESSIBLE(QString(classname).replace("Dtk::Widget::", ""), DListView)
|
||||
ELSE_USE_ACCESSIBLE(QString(classname).replace("Dtk::Widget::", ""), DLoadingIndicator)
|
||||
ELSE_USE_ACCESSIBLE(QString(classname).replace("Dtk::Widget::", ""), DSpinner)
|
||||
ELSE_USE_ACCESSIBLE(QString(classname).replace("Dtk::Widget::", ""), DSwitchButton)
|
||||
ELSE_USE_ACCESSIBLE(QString(classname).replace("Dtk::Widget::", ""), DIconButton)
|
||||
ELSE_USE_ACCESSIBLE(classname, QMenu)
|
||||
ELSE_USE_ACCESSIBLE(classname, QPushButton)
|
||||
ELSE_USE_ACCESSIBLE(classname, QSlider)
|
||||
ELSE_USE_ACCESSIBLE(classname, QScrollBar)
|
||||
ELSE_USE_ACCESSIBLE(classname, QScrollArea)
|
||||
ELSE_USE_ACCESSIBLE(classname, QFrame)
|
||||
ELSE_USE_ACCESSIBLE(classname, QGraphicsView)
|
||||
ELSE_USE_ACCESSIBLE(classname, DragWidget)
|
||||
ELSE_USE_ACCESSIBLE(classname, HorizontalSeperator);
|
||||
|
||||
if (!interface && object->inherits("QWidget") && !ignoreLst.contains(classname)) {
|
||||
QWidget *w = static_cast<QWidget *>(object);
|
||||
// 如果你看到这里的输出,说明代码中仍有控件未兼顾到accessible功能,请帮忙添加
|
||||
if (w->accessibleName().isEmpty())
|
||||
qWarning() << "accessibleFactory()" + QString("Class: " + classname + " cannot access");
|
||||
}
|
||||
|
||||
return interface;
|
||||
}
|
@ -1,405 +0,0 @@
|
||||
// Copyright (C) 2018 ~ 2020 Deepin Technology Co., Ltd.
|
||||
// SPDX-FileCopyrightText: 2018 - 2023 UnionTech Software Technology Co., Ltd.
|
||||
//
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
// 为了方便使用,把相关定义独立出来,如有需要,直接包含这个头文件,然后使用SET_*的宏去设置,USE_*宏开启即可
|
||||
// 注意:对项目中出现的所有的QWidget的派生类都要再启用一次accessiblity,包括qt的原生控件[qt未限制其标记名称为空的情况]
|
||||
// 注意:使用USE_ACCESSIBLE_BY_OBJECTNAME开启accessiblity的时候,一定要再对这个类用一下USE_ACCESSIBLE,否则标记可能会遗漏
|
||||
|
||||
#ifndef ACCESSIBLEINTERFACE_H
|
||||
#define ACCESSIBLEINTERFACE_H
|
||||
|
||||
#include <QAccessible>
|
||||
#include <QAccessibleWidget>
|
||||
#include <QEvent>
|
||||
#include <QMap>
|
||||
#include <QString>
|
||||
#include <QWidget>
|
||||
#include <QObject>
|
||||
#include <QMetaEnum>
|
||||
#include <QMouseEvent>
|
||||
#include <QApplication>
|
||||
|
||||
#define SEPARATOR "_"
|
||||
|
||||
inline QString getAccessibleName(QWidget *w, QAccessible::Role r, const QString &fallback)
|
||||
{
|
||||
const QString lowerFallback = fallback.toLower();
|
||||
// 避免重复生成
|
||||
static QMap< QObject *, QString > objnameMap;
|
||||
if (!objnameMap[w].isEmpty())
|
||||
return objnameMap[w];
|
||||
|
||||
static QMap< QAccessible::Role, QList< QString > > accessibleMap;
|
||||
QString oldAccessName = w->accessibleName().toLower();
|
||||
oldAccessName.replace(SEPARATOR, "");
|
||||
|
||||
// 按照类型添加固定前缀
|
||||
QMetaEnum metaEnum = QMetaEnum::fromType<QAccessible::Role>();
|
||||
QByteArray prefix = metaEnum.valueToKeys(r);
|
||||
switch (r) {
|
||||
case QAccessible::Button: prefix = "Btn"; break;
|
||||
case QAccessible::StaticText: prefix = "Label"; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
// 再加上标识
|
||||
QString accessibleName = QString::fromLatin1(prefix) + SEPARATOR;
|
||||
QString objectName = w->objectName().toLower();
|
||||
accessibleName += oldAccessName.isEmpty() ? (objectName.isEmpty() ?lowerFallback : objectName) : 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(SEPARATOR);
|
||||
int id = accessibleName.mid(pos + 1).toInt();
|
||||
|
||||
QString newAccessibleName;
|
||||
do {
|
||||
// 一直找到一个不重复的名字
|
||||
newAccessibleName = accessibleName + SEPARATOR + QString::number(++id);
|
||||
} while (accessibleMap[r].contains(newAccessibleName));
|
||||
|
||||
accessibleMap[r].append(newAccessibleName);
|
||||
objnameMap.insert(w, newAccessibleName);
|
||||
|
||||
// 对象销毁后移除占用名称
|
||||
QObject::connect(w, &QWidget::destroyed, [ = ] (QObject *obj) {
|
||||
objnameMap.remove(obj);
|
||||
accessibleMap[r].removeOne(newAccessibleName);
|
||||
});
|
||||
return newAccessibleName;
|
||||
} else {
|
||||
accessibleMap[r].append(accessibleName);
|
||||
objnameMap.insert(w, accessibleName);
|
||||
|
||||
// 对象销毁后移除占用名称
|
||||
QObject::connect(w, &QWidget::destroyed, [ = ] (QObject *obj) {
|
||||
objnameMap.remove(obj);
|
||||
accessibleMap[r].removeOne(accessibleName);
|
||||
});
|
||||
return accessibleName;
|
||||
}
|
||||
}
|
||||
|
||||
// 公共的功能
|
||||
#define FUNC_CREATE(classname,accessibletype,accessdescription) explicit Accessible##classname(classname *w) \
|
||||
: QAccessibleWidget(w,accessibletype,#classname)\
|
||||
, m_w(w)\
|
||||
, m_description(accessdescription)\
|
||||
{}\
|
||||
|
||||
#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();\
|
||||
}\
|
||||
}\
|
||||
|
||||
// button控件特有功能
|
||||
#define FUNC_ACTIONNAMES(classname) QStringList Accessible##classname::actionNames() const{\
|
||||
if(!m_w->isEnabled())\
|
||||
return QStringList();\
|
||||
return QStringList() << pressAction()<< showMenuAction();\
|
||||
}\
|
||||
|
||||
#define FUNC_DOACTION(classname) void Accessible##classname::doAction(const QString &actionName){\
|
||||
if(actionName == pressAction())\
|
||||
{\
|
||||
QPointF localPos = m_w->geometry().center();\
|
||||
QMouseEvent event(QEvent::MouseButtonPress,localPos,Qt::LeftButton,Qt::LeftButton,Qt::NoModifier);\
|
||||
qApp->sendEvent(m_w,&event);\
|
||||
}\
|
||||
else if(actionName == showMenuAction())\
|
||||
{\
|
||||
QPointF localPos = m_w->geometry().center();\
|
||||
QMouseEvent event(QEvent::MouseButtonPress,localPos,Qt::RightButton,Qt::RightButton,Qt::NoModifier);\
|
||||
qApp->sendEvent(m_w,&event);\
|
||||
}\
|
||||
}\
|
||||
|
||||
// Label控件特有功能
|
||||
#define FUNC_TEXT_(classname) QString Accessible##classname::text(int startOffset, int endOffset) const{\
|
||||
Q_UNUSED(startOffset)\
|
||||
Q_UNUSED(endOffset)\
|
||||
return m_w->text();\
|
||||
}\
|
||||
|
||||
// Slider控件特有功能
|
||||
#define FUNC_CURRENTVALUE(classname) QVariant Accessible##classname::currentValue() const{\
|
||||
return m_w->value();\
|
||||
}\
|
||||
|
||||
#define FUNC_SETCURRENTVALUE(classname) void Accessible##classname::setCurrentValue(const QVariant &value){\
|
||||
return m_w->setValue(value.toInt());\
|
||||
}\
|
||||
|
||||
#define FUNC_MAXMUMVALUE(classname) QVariant Accessible##classname::maximumValue() const{\
|
||||
return QVariant(m_w->maximum());\
|
||||
}\
|
||||
|
||||
#define FUNC_FUNC_MINIMUMVALUE(classname) QVariant Accessible##classname::minimumValue() const{\
|
||||
return QVariant(m_w->minimum());\
|
||||
}\
|
||||
|
||||
// DSlider控件特有功能函数
|
||||
#define FUNC_FUNC_MINIMUMSTEPSIZE(classname) QVariant Accessible##classname::minimumStepSize() const{\
|
||||
return QVariant(m_w->pageStep());\
|
||||
}\
|
||||
|
||||
#define SET_FORM_ACCESSIBLE_WITH_DESCRIPTION(classname,accessiblename,accessdescription) class Accessible##classname : public QAccessibleWidget\
|
||||
{\
|
||||
public:\
|
||||
FUNC_CREATE(classname,QAccessible::Form,accessdescription)\
|
||||
QString text(QAccessible::Text t) const override;\
|
||||
void *interface_cast(QAccessible::InterfaceType t) override{\
|
||||
switch (t) {\
|
||||
case QAccessible::ActionInterface:\
|
||||
return static_cast<QAccessibleActionInterface*>(this);\
|
||||
default:\
|
||||
return nullptr;\
|
||||
}\
|
||||
}\
|
||||
private:\
|
||||
classname *m_w;\
|
||||
QString m_description;\
|
||||
};\
|
||||
FUNC_TEXT(classname,accessiblename)\
|
||||
|
||||
#define SET_BUTTON_ACCESSIBLE_WITH_DESCRIPTION(classname,accessiblename,accessdescription) class Accessible##classname : public QAccessibleWidget\
|
||||
{\
|
||||
public:\
|
||||
FUNC_CREATE(classname,QAccessible::Button,accessdescription)\
|
||||
QString text(QAccessible::Text t) const override;\
|
||||
void *interface_cast(QAccessible::InterfaceType t) override{\
|
||||
switch (t) {\
|
||||
case QAccessible::ActionInterface:\
|
||||
return static_cast<QAccessibleActionInterface*>(this);\
|
||||
default:\
|
||||
return nullptr;\
|
||||
}\
|
||||
}\
|
||||
QStringList actionNames() const override;\
|
||||
void doAction(const QString &actionName) override;\
|
||||
private:\
|
||||
classname *m_w;\
|
||||
QString m_description;\
|
||||
};\
|
||||
FUNC_TEXT(classname,accessiblename)\
|
||||
FUNC_ACTIONNAMES(classname)\
|
||||
FUNC_DOACTION(classname)\
|
||||
|
||||
#define SET_LABEL_ACCESSIBLE_WITH_DESCRIPTION(classname,accessiblename,accessdescription) class Accessible##classname : public QAccessibleWidget, public QAccessibleTextInterface\
|
||||
{\
|
||||
public:\
|
||||
FUNC_CREATE(classname,QAccessible::StaticText,accessdescription)\
|
||||
QString text(QAccessible::Text t) const override;\
|
||||
void *interface_cast(QAccessible::InterfaceType t) override{\
|
||||
switch (t) {\
|
||||
case QAccessible::ActionInterface:\
|
||||
return static_cast<QAccessibleActionInterface*>(this);\
|
||||
case QAccessible::TextInterface:\
|
||||
return static_cast<QAccessibleTextInterface*>(this);\
|
||||
default:\
|
||||
return nullptr;\
|
||||
}\
|
||||
}\
|
||||
QString text(int startOffset, int endOffset) const override;\
|
||||
void selection(int selectionIndex, int *startOffset, int *endOffset) const override {\
|
||||
Q_UNUSED(selectionIndex)\
|
||||
Q_UNUSED(startOffset)\
|
||||
Q_UNUSED(endOffset)\
|
||||
}\
|
||||
int selectionCount() const override { return 0; }\
|
||||
void addSelection(int startOffset, int endOffset) override {\
|
||||
Q_UNUSED(startOffset)\
|
||||
Q_UNUSED(endOffset)\
|
||||
}\
|
||||
void removeSelection(int selectionIndex) override {\
|
||||
Q_UNUSED(selectionIndex)\
|
||||
}\
|
||||
void setSelection(int selectionIndex, int startOffset, int endOffset) override {\
|
||||
Q_UNUSED(selectionIndex)\
|
||||
Q_UNUSED(startOffset)\
|
||||
Q_UNUSED(endOffset)\
|
||||
}\
|
||||
int cursorPosition() const override { return 0; }\
|
||||
void setCursorPosition(int position) override {\
|
||||
Q_UNUSED(position)\
|
||||
}\
|
||||
int characterCount() const override { return 0; }\
|
||||
QRect characterRect(int offset) const override {\
|
||||
Q_UNUSED(offset)\
|
||||
return QRect();\
|
||||
}\
|
||||
int offsetAtPoint(const QPoint &point) const override {\
|
||||
Q_UNUSED(point)\
|
||||
return 0;\
|
||||
}\
|
||||
void scrollToSubstring(int startIndex, int endIndex) override {\
|
||||
Q_UNUSED(startIndex)\
|
||||
Q_UNUSED(endIndex)\
|
||||
}\
|
||||
QString attributes(int offset, int *startOffset, int *endOffset) const override {\
|
||||
Q_UNUSED(offset)\
|
||||
Q_UNUSED(startOffset)\
|
||||
Q_UNUSED(endOffset)\
|
||||
return QString();\
|
||||
}\
|
||||
private:\
|
||||
classname *m_w;\
|
||||
QString m_description;\
|
||||
};\
|
||||
FUNC_TEXT(classname,accessiblename)\
|
||||
FUNC_TEXT_(classname)\
|
||||
|
||||
#define SET_SLIDER_ACCESSIBLE_WITH_DESCRIPTION(classname,accessiblename,accessdescription) class Accessible##classname : public QAccessibleWidget, public QAccessibleValueInterface\
|
||||
{\
|
||||
public:\
|
||||
FUNC_CREATE(classname,QAccessible::Slider,accessdescription)\
|
||||
QString text(QAccessible::Text t) const override;\
|
||||
void *interface_cast(QAccessible::InterfaceType t) override{\
|
||||
switch (t) {\
|
||||
case QAccessible::ActionInterface:\
|
||||
return static_cast<QAccessibleActionInterface*>(this);\
|
||||
case QAccessible::ValueInterface:\
|
||||
return static_cast<QAccessibleValueInterface*>(this);\
|
||||
default:\
|
||||
return nullptr;\
|
||||
}\
|
||||
}\
|
||||
QVariant currentValue() const override;\
|
||||
void setCurrentValue(const QVariant &value) override;\
|
||||
QVariant maximumValue() const override;\
|
||||
QVariant minimumValue() const override;\
|
||||
QVariant minimumStepSize() const override;\
|
||||
private:\
|
||||
classname *m_w;\
|
||||
QString m_description;\
|
||||
};\
|
||||
FUNC_TEXT(classname,accessiblename)\
|
||||
FUNC_CURRENTVALUE(classname)\
|
||||
FUNC_SETCURRENTVALUE(classname)\
|
||||
FUNC_MAXMUMVALUE(classname)\
|
||||
FUNC_FUNC_MINIMUMVALUE(classname)\
|
||||
FUNC_FUNC_MINIMUMSTEPSIZE(classname)\
|
||||
|
||||
#define SET_EDITABLE_ACCESSIBLE_WITH_DESCRIPTION(classname,accessiblename,accessdescription) class Accessible##classname : public QAccessibleWidget, public QAccessibleEditableTextInterface, public QAccessibleTextInterface\
|
||||
{\
|
||||
public:\
|
||||
FUNC_CREATE(classname,QAccessible::EditableText,accessdescription)\
|
||||
QString text(QAccessible::Text t) const override;\
|
||||
QAccessibleInterface *child(int index) const override { Q_UNUSED(index); return nullptr; }\
|
||||
void *interface_cast(QAccessible::InterfaceType t) override{\
|
||||
switch (t) {\
|
||||
case QAccessible::ActionInterface:\
|
||||
return static_cast<QAccessibleActionInterface*>(this);\
|
||||
case QAccessible::TextInterface:\
|
||||
return static_cast<QAccessibleTextInterface*>(this);\
|
||||
case QAccessible::EditableTextInterface:\
|
||||
return static_cast<QAccessibleEditableTextInterface*>(this);\
|
||||
default:\
|
||||
return nullptr;\
|
||||
}\
|
||||
}\
|
||||
QString text(int startOffset, int endOffset) const override;\
|
||||
void selection(int selectionIndex, int *startOffset, int *endOffset) const override {\
|
||||
Q_UNUSED(selectionIndex)\
|
||||
Q_UNUSED(startOffset)\
|
||||
Q_UNUSED(endOffset)\
|
||||
}\
|
||||
int selectionCount() const override { return 0; }\
|
||||
void addSelection(int startOffset, int endOffset) override {\
|
||||
Q_UNUSED(startOffset)\
|
||||
Q_UNUSED(endOffset)\
|
||||
}\
|
||||
void removeSelection(int selectionIndex) override { Q_UNUSED(selectionIndex);}\
|
||||
void setSelection(int selectionIndex, int startOffset, int endOffset) override {\
|
||||
Q_UNUSED(selectionIndex)\
|
||||
Q_UNUSED(startOffset)\
|
||||
Q_UNUSED(endOffset)\
|
||||
}\
|
||||
int cursorPosition() const override { return 0; }\
|
||||
void setCursorPosition(int position) override {\
|
||||
Q_UNUSED(position)\
|
||||
}\
|
||||
int characterCount() const override { return 0; }\
|
||||
QRect characterRect(int offset) const override { \
|
||||
Q_UNUSED(offset)\
|
||||
return QRect(); }\
|
||||
int offsetAtPoint(const QPoint &point) const override {\
|
||||
Q_UNUSED(point)\
|
||||
return 0; }\
|
||||
void scrollToSubstring(int startIndex, int endIndex) override {\
|
||||
Q_UNUSED(startIndex)\
|
||||
Q_UNUSED(endIndex)\
|
||||
}\
|
||||
QString attributes(int offset, int *startOffset, int *endOffset) const override {\
|
||||
Q_UNUSED(offset)\
|
||||
Q_UNUSED(startOffset)\
|
||||
Q_UNUSED(endOffset)\
|
||||
return QString(); }\
|
||||
void insertText(int offset, const QString &text) override {\
|
||||
Q_UNUSED(offset)\
|
||||
Q_UNUSED(text)\
|
||||
}\
|
||||
void deleteText(int startOffset, int endOffset) override {\
|
||||
Q_UNUSED(startOffset)\
|
||||
Q_UNUSED(endOffset)\
|
||||
}\
|
||||
void replaceText(int startOffset, int endOffset, const QString &text) override {\
|
||||
Q_UNUSED(startOffset)\
|
||||
Q_UNUSED(endOffset)\
|
||||
Q_UNUSED(text)\
|
||||
}\
|
||||
private:\
|
||||
classname *m_w;\
|
||||
QString m_description;\
|
||||
};\
|
||||
FUNC_TEXT(classname,accessiblename)\
|
||||
FUNC_TEXT_(classname)\
|
||||
|
||||
#define USE_ACCESSIBLE(classnamestring,classname) if (classnamestring == QLatin1String(#classname) && object && object->isWidgetType())\
|
||||
{\
|
||||
interface = new Accessible##classname(static_cast<classname *>(object));\
|
||||
}\
|
||||
|
||||
#define ELSE_USE_ACCESSIBLE(classnamestring,classname) else if (classnamestring == QLatin1String(#classname) && object && object->isWidgetType())\
|
||||
{\
|
||||
interface = new Accessible##classname(static_cast<classname *>(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<classname *>(object));\
|
||||
}\
|
||||
|
||||
#define ELSE_USE_ACCESSIBLE_BY_OBJECTNAME(classnamestring,classname,objectname) else if (classnamestring == QLatin1String(#classname) && object && (object->objectName() == objectname) && object->isWidgetType())\
|
||||
{\
|
||||
interface = new Accessible##classname(static_cast<classname *>(object));\
|
||||
}\
|
||||
|
||||
/*******************************************简化使用*******************************************/
|
||||
#define SET_FORM_ACCESSIBLE(classname,accessiblename) SET_FORM_ACCESSIBLE_WITH_DESCRIPTION(classname,accessiblename,"")
|
||||
|
||||
#define SET_BUTTON_ACCESSIBLE(classname,accessiblename) SET_BUTTON_ACCESSIBLE_WITH_DESCRIPTION(classname,accessiblename,"")
|
||||
|
||||
#define SET_LABEL_ACCESSIBLE(classname,accessiblename) SET_LABEL_ACCESSIBLE_WITH_DESCRIPTION(classname,accessiblename,"")
|
||||
|
||||
#define SET_SLIDER_ACCESSIBLE(classname,accessiblename) SET_SLIDER_ACCESSIBLE_WITH_DESCRIPTION(classname,accessiblename,"")
|
||||
|
||||
#define SET_EDITABLE_ACCESSIBLE(classname,accessiblename) SET_EDITABLE_ACCESSIBLE_WITH_DESCRIPTION(classname,accessiblename,"")
|
||||
/************************************************************************************************/
|
||||
|
||||
#endif // ACCESSIBLEINTERFACE_H
|
@ -4,7 +4,6 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "accessible.h"
|
||||
#include "dbusdockadaptors.h"
|
||||
#include "utils.h"
|
||||
#include "themeappicon.h"
|
||||
@ -13,7 +12,6 @@
|
||||
#include "traymainwindow.h"
|
||||
#include "windowmanager.h"
|
||||
|
||||
#include <QAccessible>
|
||||
#include <QDir>
|
||||
#include <QStandardPaths>
|
||||
#include <QDateTime>
|
||||
@ -177,9 +175,6 @@ int main(int argc, char *argv[])
|
||||
app.loadTranslator();
|
||||
app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
|
||||
|
||||
// 自动化标记由此开始
|
||||
QAccessible::installFactory(accessibleFactory);
|
||||
|
||||
// 设置日志输出到控制台以及文件
|
||||
DLogManager::setLogFormat("%{time}{yyyyMMdd.HH:mm:ss.zzz}[%{type:1}][%{function:-35} %{line:-4}] %{message}\n");
|
||||
DLogManager::registerConsoleAppender();
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
#ifndef SOUNDACCESSIBLE_H
|
||||
#define SOUNDACCESSIBLE_H
|
||||
#include "accessibledefine.h"
|
||||
#include <QAccessibleInterface>
|
||||
|
||||
QAccessibleInterface *soundAccessibleFactory(const QString &classname, QObject *object)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user