mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
feat(accessible):update accessible on uos branch
This commit is contained in:
parent
8ebf52f9d3
commit
eecce9d618
@ -88,7 +88,7 @@ AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
|
||||
centralLayout->setMargin(0);
|
||||
centralLayout->setSpacing(0);
|
||||
|
||||
setAccessibleName(m_itemEntryInter->name());
|
||||
setObjectName(m_itemEntryInter->name());
|
||||
setAcceptDrops(true);
|
||||
setLayout(centralLayout);
|
||||
|
||||
@ -96,7 +96,7 @@ AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
|
||||
m_active = m_itemEntryInter->isActive();
|
||||
|
||||
m_appNameTips->setObjectName("AppItemTips");
|
||||
m_appNameTips->setAccessibleName(m_itemEntryInter->name());
|
||||
m_appNameTips->setObjectName(m_itemEntryInter->name());
|
||||
m_appNameTips->setVisible(false);
|
||||
m_appNameTips->installEventFilter(this);
|
||||
|
||||
|
@ -53,6 +53,7 @@ DockItem::DockItem(QWidget *parent)
|
||||
arrowRectangle->setShadowXOffset(0);
|
||||
arrowRectangle->setArrowWidth(18);
|
||||
arrowRectangle->setArrowHeight(10);
|
||||
arrowRectangle->setObjectName("apppopup");
|
||||
PopupWindow = arrowRectangle;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,6 @@ LauncherItem::LauncherItem(QWidget *parent)
|
||||
|
||||
m_tips->setVisible(false);
|
||||
m_tips->setObjectName("launcher");
|
||||
m_tips->setAccessibleName("launchertips");
|
||||
|
||||
connect(m_gsettings, &QGSettings::changed, this, &LauncherItem::onGSettingsChanged);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ PluginsItem::PluginsItem(PluginsItemInterface *const pluginInter, const QString
|
||||
|
||||
m_centralWidget->setParent(this);
|
||||
m_centralWidget->setVisible(true);
|
||||
m_centralWidget->setAccessibleName("centralwidget");
|
||||
m_centralWidget->setObjectName(pluginInter->pluginName() + "-centralwidget");
|
||||
m_centralWidget->installEventFilter(this);
|
||||
|
||||
QBoxLayout *hLayout = new QHBoxLayout;
|
||||
|
@ -107,6 +107,8 @@ void MainPanelControl::init()
|
||||
m_appSpliter->setObjectName("spliter_app");
|
||||
m_traySpliter->setObjectName("spliter_tray");
|
||||
|
||||
m_appAreaWidget->setAccessibleName("AppFullArea");
|
||||
|
||||
m_mainPanelLayout->addWidget(m_fixedAreaWidget);
|
||||
m_mainPanelLayout->addWidget(m_fixedSpliter);
|
||||
m_mainPanelLayout->addWidget(m_appAreaWidget);
|
||||
|
@ -32,16 +32,12 @@ DWIDGET_USE_NAMESPACE
|
||||
DockPopupWindow::DockPopupWindow(QWidget *parent)
|
||||
: DArrowRectangle(ArrowBottom, parent),
|
||||
m_model(false),
|
||||
|
||||
m_acceptDelayTimer(new QTimer(this)),
|
||||
|
||||
m_regionInter(new DRegionMonitor(this))
|
||||
{
|
||||
m_acceptDelayTimer->setSingleShot(true);
|
||||
m_acceptDelayTimer->setInterval(100);
|
||||
|
||||
setAccessibleName("popup");
|
||||
|
||||
m_wmHelper = DWindowManagerHelper::instance();
|
||||
|
||||
compositeChanged();
|
||||
|
@ -29,11 +29,13 @@
|
||||
|
||||
#include "../plugins/show-desktop/showdesktopwidget.h"
|
||||
|
||||
#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"
|
||||
// 这部分由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 "../plugins/datetime/datetimewidget.h"
|
||||
#include "../plugins/onboard/onboarditem.h"
|
||||
@ -50,10 +52,10 @@
|
||||
DWIDGET_USE_NAMESPACE
|
||||
|
||||
// 添加accessible
|
||||
SET_WIDGET_ACCESSIBLE(MainWindow, QAccessible::Form, "mainwindow")
|
||||
SET_FORM_ACCESSIBLE(MainWindow, "mainwindow")
|
||||
SET_BUTTON_ACCESSIBLE(MainPanelControl, "mainpanelcontrol")
|
||||
SET_LABEL_ACCESSIBLE(TipsWidget, "tips")
|
||||
SET_WIDGET_ACCESSIBLE(DockPopupWindow, QAccessible::Form, "popupwindow")
|
||||
SET_FORM_ACCESSIBLE(DockPopupWindow, "popupwindow")
|
||||
SET_BUTTON_ACCESSIBLE(LauncherItem, "launcheritem")
|
||||
SET_BUTTON_ACCESSIBLE(AppItem, "appitem")
|
||||
SET_BUTTON_ACCESSIBLE(PreviewContainer, "previewcontainer")
|
||||
@ -67,27 +69,27 @@ SET_BUTTON_ACCESSIBLE(XEmbedTrayWidget, m_w->itemKeyForConfig())
|
||||
SET_BUTTON_ACCESSIBLE(IndicatorTrayWidget, m_w->itemKeyForConfig())
|
||||
SET_BUTTON_ACCESSIBLE(SNITrayWidget, m_w->itemKeyForConfig())
|
||||
SET_BUTTON_ACCESSIBLE(SystemTrayItem, m_w->itemKeyForConfig())
|
||||
SET_WIDGET_ACCESSIBLE(FashionTrayItem, QAccessible::Form, "fashiontrayitem")
|
||||
SET_WIDGET_ACCESSIBLE(FashionTrayWidgetWrapper, QAccessible::Form, "fashiontraywrapper")
|
||||
SET_FORM_ACCESSIBLE(FashionTrayItem, "fashiontrayitem")
|
||||
SET_FORM_ACCESSIBLE(FashionTrayWidgetWrapper, "fashiontraywrapper")
|
||||
SET_BUTTON_ACCESSIBLE(FashionTrayControlWidget, "fashiontraycontrolwidget")
|
||||
SET_WIDGET_ACCESSIBLE(AttentionContainer, QAccessible::Form, "attentioncontainer")
|
||||
SET_WIDGET_ACCESSIBLE(HoldContainer, QAccessible::Form, "holdcontainer")
|
||||
SET_WIDGET_ACCESSIBLE(NormalContainer, QAccessible::Form, "normalcontainer")
|
||||
SET_WIDGET_ACCESSIBLE(SpliterAnimated, QAccessible::Form, "spliteranimated")
|
||||
SET_BUTTON_ACCESSIBLE(SoundItem, "plugin-sounditem")
|
||||
SET_WIDGET_ACCESSIBLE(SoundApplet, QAccessible::Form, "soundapplet")
|
||||
SET_WIDGET_ACCESSIBLE(SinkInputWidget, QAccessible::Form, "sinkinputwidget")
|
||||
SET_WIDGET_ACCESSIBLE(VolumeSlider, QAccessible::Slider, "volumeslider")
|
||||
SET_WIDGET_ACCESSIBLE(HorizontalSeparator, QAccessible::Separator, "horizontalseparator")
|
||||
SET_WIDGET_ACCESSIBLE(DatetimeWidget, QAccessible::Form, "plugin-datetime")
|
||||
SET_WIDGET_ACCESSIBLE(OnboardItem, QAccessible::Form, "plugin-onboard")
|
||||
SET_WIDGET_ACCESSIBLE(TrashWidget, QAccessible::Form, "plugin-trash")
|
||||
SET_FORM_ACCESSIBLE(AttentionContainer, "attentioncontainer")
|
||||
SET_FORM_ACCESSIBLE(HoldContainer, "holdcontainer")
|
||||
SET_FORM_ACCESSIBLE(NormalContainer, "normalcontainer")
|
||||
SET_FORM_ACCESSIBLE(SpliterAnimated, "spliteranimated")
|
||||
//SET_BUTTON_ACCESSIBLE(SoundItem, "plugin-sounditem")
|
||||
//SET_FORM_ACCESSIBLE(SoundApplet, "soundapplet")
|
||||
//SET_FORM_ACCESSIBLE(SinkInputWidget, "sinkinputwidget")
|
||||
//SET_SLIDER_ACCESSIBLE(VolumeSlider, QAccessible::Slider, "volumeslider")
|
||||
//SET_FORM_ACCESSIBLE(HorizontalSeparator, "horizontalseparator")
|
||||
SET_FORM_ACCESSIBLE(DatetimeWidget, "plugin-datetime")
|
||||
SET_FORM_ACCESSIBLE(OnboardItem, "plugin-onboard")
|
||||
SET_FORM_ACCESSIBLE(TrashWidget, "plugin-trash")
|
||||
SET_BUTTON_ACCESSIBLE(PopupControlWidget, "popupcontrolwidget")
|
||||
SET_WIDGET_ACCESSIBLE(ShutdownWidget, QAccessible::Form, "plugin-shutdown")
|
||||
SET_WIDGET_ACCESSIBLE(MultitaskingWidget, QAccessible::Form, "plugin-multitasking")
|
||||
SET_WIDGET_ACCESSIBLE(ShowDesktopWidget, QAccessible::Form, "plugin-showdesktop")
|
||||
SET_WIDGET_ACCESSIBLE(OverlayWarningWidget, QAccessible::Form, "plugin-overlaywarningwidget")
|
||||
SET_WIDGET_ACCESSIBLE(QWidget, QAccessible::Form, m_w->objectName().isEmpty() ? "widget" : m_w->objectName())
|
||||
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->text().isEmpty() ? m_w->objectName().isEmpty() ? "text" : m_w->objectName() : m_w->text())
|
||||
SET_BUTTON_ACCESSIBLE(DImageButton, m_w->objectName().isEmpty() ? "imagebutton" : m_w->objectName())
|
||||
SET_BUTTON_ACCESSIBLE(DSwitchButton, m_w->text().isEmpty() ? "switchbutton" : m_w->text())
|
||||
@ -120,11 +122,11 @@ QAccessibleInterface *accessibleFactory(const QString &classname, QObject *objec
|
||||
USE_ACCESSIBLE(classname, SpliterAnimated);
|
||||
USE_ACCESSIBLE(classname, IndicatorTrayWidget);
|
||||
USE_ACCESSIBLE(classname, XEmbedTrayWidget);
|
||||
USE_ACCESSIBLE(classname, SoundItem);
|
||||
USE_ACCESSIBLE(classname, SoundApplet);
|
||||
USE_ACCESSIBLE(classname, SinkInputWidget);
|
||||
USE_ACCESSIBLE(classname, VolumeSlider);
|
||||
USE_ACCESSIBLE(classname, HorizontalSeparator);
|
||||
// USE_ACCESSIBLE(classname, SoundItem);
|
||||
// USE_ACCESSIBLE(classname, SoundApplet);
|
||||
// USE_ACCESSIBLE(classname, SinkInputWidget);
|
||||
// USE_ACCESSIBLE(classname, VolumeSlider);
|
||||
// USE_ACCESSIBLE(classname, HorizontalSeparator);
|
||||
USE_ACCESSIBLE(classname, DatetimeWidget);
|
||||
USE_ACCESSIBLE(classname, OnboardItem);
|
||||
USE_ACCESSIBLE(classname, TrashWidget);
|
||||
|
@ -1,9 +1,9 @@
|
||||
/*
|
||||
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2018 ~ 2028 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: fpc_diesel <fanpengcheng@uniontech.com>
|
||||
* Author: fanpengcheng <fanpengcheng_cm@deepin.com>
|
||||
*
|
||||
* Maintainer: fpc_diesel <fanpengcheng@uniontech.com>
|
||||
* Maintainer: fanpengcheng <fanpengcheng_cm@deepin.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -18,40 +18,14 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef ACCESSIBLEDEFINE_H
|
||||
#define ACCESSIBLEDEFINE_H
|
||||
|
||||
// 为了方便使用,把相关定义独立出来,如有需要,直接包含这个头文件,然后使用SET_*的宏去设置,USE_*宏开启即可
|
||||
// 注意:对项目中出现的所有的QWidget的派生类都要再启用一次accessiblity,包括qt的原生控件[qt未限制其标记名称为空的情况]
|
||||
// 注意:使用USE_ACCESSIBLE_BY_OBJECTNAME开启accessiblity的时候,一定要再最这个类用一下USE_ACCESSIBLE,否则标记可能会遗漏
|
||||
|
||||
/* 宏参数说明
|
||||
* 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接口
|
||||
* FUNC_TEXT_BY_LABEL:实现text接口,使用这个宏,需要被添加的类有text接口,从而得到其Value
|
||||
* 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类型,用于分隔符控件
|
||||
*/
|
||||
#ifndef ACCESSIBLEINTERFACE_H
|
||||
#define ACCESSIBLEINTERFACE_H
|
||||
|
||||
#include <QAccessible>
|
||||
#include <QAccessibleWidget>
|
||||
#include <QEvent>
|
||||
@ -88,7 +62,8 @@ inline QString getAccessibleName(QWidget *w, QAccessible::Role r, const QString
|
||||
|
||||
// 再加上标识
|
||||
QString accessibleName = QString::fromLatin1(prefix) + SEPARATOR;
|
||||
accessibleName += oldAccessName.isEmpty() ? lowerFallback : oldAccessName;
|
||||
QString objectName = w->objectName().toLower();
|
||||
accessibleName += oldAccessName.isEmpty() ? (objectName.isEmpty() ?lowerFallback : objectName) : oldAccessName;
|
||||
// 检查名称是否唯一
|
||||
if (accessibleMap[r].contains(accessibleName)) {
|
||||
if (!objnameMap.key(accessibleName)) {
|
||||
@ -118,137 +93,278 @@ inline QString getAccessibleName(QWidget *w, QAccessible::Role r, const QString
|
||||
}
|
||||
}
|
||||
|
||||
// 公共的功能
|
||||
#define FUNC_CREATE(classname,accessibletype,accessdescription) Accessible##classname(classname *w) \
|
||||
: QAccessibleWidget(w,accessibletype,#classname)\
|
||||
, m_w(w)\
|
||||
, m_description(accessdescription)\
|
||||
{}\
|
||||
: 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());\
|
||||
}\
|
||||
|
||||
#define FUNC_FUNC_MINIMUMSTEPSIZE(classname) QVariant Accessible##classname::minimumStepSize() const{\
|
||||
return QVariant(m_w->singleStep());\
|
||||
}\
|
||||
|
||||
#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 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 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 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 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 {}\
|
||||
int selectionCount() const override { return 0; }\
|
||||
void addSelection(int startOffset, int endOffset) override {}\
|
||||
void removeSelection(int selectionIndex) override {}\
|
||||
void setSelection(int selectionIndex, int startOffset, int endOffset) override {}\
|
||||
int cursorPosition() const override { return 0; }\
|
||||
void setCursorPosition(int position) override {}\
|
||||
int characterCount() const override { return 0; }\
|
||||
QRect characterRect(int offset) const override { return QRect(); }\
|
||||
int offsetAtPoint(const QPoint &point) const override { return 0; }\
|
||||
void scrollToSubstring(int startIndex, int endIndex) override {}\
|
||||
QString attributes(int offset, int *startOffset, int *endOffset) const override { return QString(); }\
|
||||
private:\
|
||||
classname *m_w;\
|
||||
QString m_description;\
|
||||
};\
|
||||
FUNC_TEXT(classname,accessiblename)\
|
||||
FUNC_TEXT_(classname)\
|
||||
|
||||
#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 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 FUNC_RECT(classobj) QRect rect() const override{\
|
||||
if (!classobj->isVisible())\
|
||||
return QRect();\
|
||||
QPoint pos = classobj->mapToGlobal(QPoint(0, 0));\
|
||||
return QRect(pos.x(), pos.y(), classobj->width(), classobj->height());\
|
||||
#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 { 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;\
|
||||
}\
|
||||
|
||||
#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 FUNC_TEXT_BY_LABEL(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;\
|
||||
case QAccessible::Value:\
|
||||
return m_w->text();\
|
||||
default:\
|
||||
return QString();\
|
||||
}\
|
||||
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 {}\
|
||||
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));\
|
||||
{\
|
||||
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));\
|
||||
{\
|
||||
interface = new Accessible##classname(static_cast<classname *>(object));\
|
||||
}\
|
||||
|
||||
#define SET_ACCESSIBLE_WITH_PRESS_SHOWMENU_DESCRIPTION(classname,aaccessibletype,accessdescription) class Accessible##classname : public QAccessibleWidget\
|
||||
{\
|
||||
public:\
|
||||
FUNC_CREATE(classname,aaccessibletype,accessdescription)\
|
||||
QString text(QAccessible::Text t) const override;\
|
||||
FUNC_PRESS_SHOWMENU(m_w)\
|
||||
};\
|
||||
|
||||
#define SET_ACCESSIBLE_WITH_DESCRIPTION(classname,aaccessibletype,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(classname,accessiblename) SET_ACCESSIBLE_WITH_PRESS_SHOWMENU_DESCRIPTION(classname,QAccessible::Button,"")\
|
||||
FUNC_TEXT(classname,accessiblename)
|
||||
#define SET_FORM_ACCESSIBLE(classname,accessiblename) SET_FORM_ACCESSIBLE_WITH_DESCRIPTION(classname,accessiblename,"")
|
||||
|
||||
#define SET_MENU_ACCESSIBLE(classname,accessiblename) SET_ACCESSIBLE_WITH_PRESS_SHOWMENU_DESCRIPTION(classname,QAccessible::PopupMenu,"")\
|
||||
FUNC_TEXT(classname,accessiblename)
|
||||
#define SET_BUTTON_ACCESSIBLE(classname,accessiblename) SET_BUTTON_ACCESSIBLE_WITH_DESCRIPTION(classname,accessiblename,"")
|
||||
|
||||
#define SET_LABEL_ACCESSIBLE(classname,accessiblename) SET_ACCESSIBLE_WITH_DESCRIPTION(classname,QAccessible::StaticText,"")\
|
||||
FUNC_TEXT_BY_LABEL(classname,accessiblename)
|
||||
#define SET_LABEL_ACCESSIBLE(classname,accessiblename) SET_LABEL_ACCESSIBLE_WITH_DESCRIPTION(classname,accessiblename,"")
|
||||
|
||||
#define SET_WIDGET_ACCESSIBLE(classname,aaccessibletype,accessiblename) SET_ACCESSIBLE_WITH_DESCRIPTION(classname,aaccessibletype,"");\
|
||||
FUNC_TEXT(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 // ACCESSIBLEDEFINE_H
|
||||
#endif // ACCESSIBLEINTERFACE_H
|
||||
|
30
plugins/sound/soundaccessible.h
Normal file
30
plugins/sound/soundaccessible.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef SOUNDACCESSIBLE_H
|
||||
#define SOUNDACCESSIBLE_H
|
||||
#include "../frame/window/accessibledefine.h"
|
||||
|
||||
#include "sounditem.h"
|
||||
#include "soundapplet.h"
|
||||
#include "sinkinputwidget.h"
|
||||
#include "./componments/volumeslider.h"
|
||||
#include "./componments/horizontalseparator.h"
|
||||
|
||||
SET_BUTTON_ACCESSIBLE(SoundItem, "plugin-sounditem")
|
||||
SET_FORM_ACCESSIBLE(SoundApplet, "soundapplet")
|
||||
SET_FORM_ACCESSIBLE(SinkInputWidget, "sinkinputwidget")
|
||||
SET_SLIDER_ACCESSIBLE(VolumeSlider, "volumeslider")
|
||||
SET_FORM_ACCESSIBLE(HorizontalSeparator, "horizontalseparator")
|
||||
|
||||
QAccessibleInterface *soundAccessibleFactory(const QString &classname, QObject *object)
|
||||
{
|
||||
QAccessibleInterface *interface = nullptr;
|
||||
|
||||
USE_ACCESSIBLE(classname, SoundItem);
|
||||
USE_ACCESSIBLE(classname, SoundApplet);
|
||||
USE_ACCESSIBLE(classname, SinkInputWidget);
|
||||
USE_ACCESSIBLE(classname, VolumeSlider);
|
||||
USE_ACCESSIBLE(classname, HorizontalSeparator);
|
||||
|
||||
return interface;
|
||||
}
|
||||
|
||||
#endif // SOUNDACCESSIBLE_H
|
@ -20,7 +20,10 @@
|
||||
*/
|
||||
|
||||
#include "soundplugin.h"
|
||||
#include "soundaccessible.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QAccessible>
|
||||
|
||||
#define STATE_KEY "enable"
|
||||
|
||||
@ -28,6 +31,7 @@ SoundPlugin::SoundPlugin(QObject *parent)
|
||||
: QObject(parent),
|
||||
m_soundItem(nullptr)
|
||||
{
|
||||
QAccessible::installFactory(soundAccessibleFactory);
|
||||
}
|
||||
|
||||
const QString SoundPlugin::pluginName() const
|
||||
|
@ -53,7 +53,6 @@ PopupControlWidget::PopupControlWidget(QWidget *parent)
|
||||
{
|
||||
connect(m_fsWatcher, &QFileSystemWatcher::directoryChanged, this, &PopupControlWidget::trashStatusChanged, Qt::QueuedConnection);
|
||||
|
||||
setObjectName("trash");
|
||||
setFixedWidth(80);
|
||||
|
||||
trashStatusChanged();
|
||||
|
@ -37,7 +37,7 @@ TrashPlugin::TrashPlugin(QObject *parent)
|
||||
, m_trashWidget(nullptr)
|
||||
, m_tipsLabel(new TipsWidget)
|
||||
{
|
||||
m_tipsLabel->setObjectName("trash");
|
||||
m_tipsLabel->setObjectName("trashtips");
|
||||
}
|
||||
|
||||
const QString TrashPlugin::pluginName() const
|
||||
|
@ -59,6 +59,7 @@ SNITrayWidget::SNITrayWidget(const QString &sniServicePath, QWidget *parent)
|
||||
arrowRectangle->setShadowXOffset(0);
|
||||
arrowRectangle->setArrowWidth(18);
|
||||
arrowRectangle->setArrowHeight(10);
|
||||
arrowRectangle->setObjectName("snitraypopup");
|
||||
PopupWindow = arrowRectangle;
|
||||
}
|
||||
|
||||
|
@ -63,6 +63,7 @@ SystemTrayItem::SystemTrayItem(PluginsItemInterface *const pluginInter, const QS
|
||||
arrowRectangle->setShadowXOffset(0);
|
||||
arrowRectangle->setArrowWidth(18);
|
||||
arrowRectangle->setArrowHeight(10);
|
||||
arrowRectangle->setObjectName("systemtraypopup");
|
||||
PopupWindow = arrowRectangle;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include "tipswidget.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QAccessible>
|
||||
|
||||
TipsWidget::TipsWidget(QWidget *parent) : QFrame(parent)
|
||||
{
|
||||
@ -15,6 +16,13 @@ void TipsWidget::setText(const QString &text)
|
||||
setFixedSize(fontMetrics().width(text) + 6, fontMetrics().height());
|
||||
|
||||
update();
|
||||
|
||||
#ifndef QT_NO_ACCESSIBILITY
|
||||
if (accessibleName().isEmpty()) {
|
||||
QAccessibleEvent event(this, QAccessible::NameChanged);
|
||||
QAccessible::updateAccessibility(&event);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void TipsWidget::setTextList(const QStringList &textList)
|
||||
|
Loading…
x
Reference in New Issue
Block a user