mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
feat:complete accessible
This commit is contained in:
parent
3498bc8d8f
commit
01142e5595
@ -65,48 +65,6 @@ void RegisterDdeSession()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QAccessibleInterface *accessibleFactory(const QString &classname, QObject *object)
|
|
||||||
{
|
|
||||||
QAccessibleInterface *interface = nullptr;
|
|
||||||
|
|
||||||
USE_ACCESSIBLE(classname,MainPanelControl);
|
|
||||||
USE_ACCESSIBLE(classname,LauncherItem);
|
|
||||||
USE_ACCESSIBLE(classname,AppItem);
|
|
||||||
USE_ACCESSIBLE(classname,PreviewContainer);
|
|
||||||
USE_ACCESSIBLE(classname,PluginsItem);
|
|
||||||
USE_ACCESSIBLE(classname,TrayPluginItem);
|
|
||||||
USE_ACCESSIBLE(classname,PlaceholderItem);
|
|
||||||
USE_ACCESSIBLE(classname,AppDragWidget);
|
|
||||||
USE_ACCESSIBLE(classname,AppSnapshot);
|
|
||||||
USE_ACCESSIBLE(classname,FloatingPreview);
|
|
||||||
USE_ACCESSIBLE(classname,SNITrayWidget);
|
|
||||||
USE_ACCESSIBLE(classname,SystemTrayItem);
|
|
||||||
USE_ACCESSIBLE(classname,FashionTrayItem);
|
|
||||||
USE_ACCESSIBLE(classname,FashionTrayWidgetWrapper);
|
|
||||||
USE_ACCESSIBLE(classname,FashionTrayControlWidget);
|
|
||||||
USE_ACCESSIBLE(classname,AttentionContainer);
|
|
||||||
USE_ACCESSIBLE(classname,HoldContainer);
|
|
||||||
USE_ACCESSIBLE(classname,NormalContainer);
|
|
||||||
USE_ACCESSIBLE(classname,SpliterAnimated);
|
|
||||||
USE_ACCESSIBLE(classname,IndicatorTrayWidget);
|
|
||||||
USE_ACCESSIBLE(classname,XEmbedTrayWidget);
|
|
||||||
USE_ACCESSIBLE(classname,ShowDesktopWidget);
|
|
||||||
USE_ACCESSIBLE(classname,SoundItem);
|
|
||||||
USE_ACCESSIBLE(classname,SoundApplet);
|
|
||||||
USE_ACCESSIBLE(classname,SinkInputWidget);
|
|
||||||
USE_ACCESSIBLE(classname,VolumeSlider);
|
|
||||||
USE_ACCESSIBLE(classname,HorizontalSeparator);
|
|
||||||
USE_ACCESSIBLE(classname,TipsWidget);
|
|
||||||
USE_ACCESSIBLE(classname,DatetimeWidget);
|
|
||||||
USE_ACCESSIBLE(classname,OnboardItem);
|
|
||||||
USE_ACCESSIBLE(classname,TrashWidget);
|
|
||||||
USE_ACCESSIBLE(classname,PopupControlWidget);
|
|
||||||
USE_ACCESSIBLE(classname,ShutdownWidget);
|
|
||||||
USE_ACCESSIBLE(classname,MultitaskingWidget);
|
|
||||||
// USE_ACCESSIBLE(classname,OverlayWarningWidget);
|
|
||||||
return interface;
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
DGuiApplicationHelper::setUseInactiveColorGroup(false);
|
DGuiApplicationHelper::setUseInactiveColorGroup(false);
|
||||||
|
@ -1,427 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
|
||||||
*
|
|
||||||
* Author: fpc_diesel <fanpengcheng@uniontech.com>
|
|
||||||
*
|
|
||||||
* Maintainer: fpc_diesel <fanpengcheng@uniontech.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
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
#include "accessible.h"
|
|
||||||
|
|
||||||
|
|
||||||
QString getAccesibleName(QWidget *w,QString fallback)
|
|
||||||
{
|
|
||||||
return w->accessibleName().isEmpty()?fallback:w->accessibleName();
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AccessibleMainPanelControl::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,"mainpanelcontrol");
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AccessibleLauncherItem::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,"launcheritem");
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AccessibleAppItem::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,m_w->accessibleName());
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QString AccessiblePreviewContainer::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,"previewcontainer");
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AccessiblePluginsItem::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,m_w->pluginName());
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AccessibleTrayPluginItem::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,m_w->pluginName());
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QString AccessiblePlaceholderItem::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,"placeholderitem");
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QString AccessibleAppDragWidget::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,"appdragwidget");
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QString AccessibleAppSnapshot::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,"appsnapshot");
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AccessibleFloatingPreview::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,"floatingpreview");
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AccessibleSNITrayWidget::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,m_w->itemKeyForConfig());
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AccessibleSystemTrayItem::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,m_w->itemKeyForConfig());
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QString AccessibleFashionTrayItem::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,"fashiontrayitem");
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QString AccessibleFashionTrayWidgetWrapper::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,"fashiontraywrapper");
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QString AccessibleFashionTrayControlWidget::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,"fashiontraycontrolwidget");
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QString AccessibleAttentionContainer::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,"attentioncontainer");
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QString AccessibleHoldContainer::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,"holdcontainer");
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QString AccessibleNormalContainer::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,"normalcontainer");
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QString AccessibleSpliterAnimated::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,"spliteranimated");
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QString AccessibleIndicatorTrayWidget::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,m_w->itemKeyForConfig());
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AccessibleXEmbedTrayWidget::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,m_w->itemKeyForConfig());
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AccessibleShowDesktopWidget::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,"showdesktop");
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AccessibleSoundItem::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,"sounditem");
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AccessibleSoundApplet::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,"soundapplet");
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AccessibleSinkInputWidget::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,"sinkinputwidget");
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AccessibleVolumeSlider::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,"volumeslider");
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QString AccessibleHorizontalSeparator::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,"horizontalseparator");
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QString AccessibleTipsWidget::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,m_w->text());
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QString AccessibleDatetimeWidget::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,"datetimewidget");
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QString AccessibleOnboardItem::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,"onboarditem");
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QString AccessibleTrashWidget::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,"trashwidget");
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QString AccessiblePopupControlWidget::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,"popupcontrolwidget");
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QString AccessibleShutdownWidget::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,"shutdownwidget");
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QString AccessibleMultitaskingWidget::text(QAccessible::Text t) const
|
|
||||||
{
|
|
||||||
switch (t) {
|
|
||||||
case QAccessible::Name:
|
|
||||||
return getAccesibleName(m_w,"multitaskingwidget");
|
|
||||||
case QAccessible::Description:
|
|
||||||
return m_description;
|
|
||||||
default:
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//QString AccessibleOverlayWarningWidget::text(QAccessible::Text t) const
|
|
||||||
//{
|
|
||||||
// switch (t) {
|
|
||||||
// case QAccessible::Name:
|
|
||||||
// return "overlaywarningwidget";
|
|
||||||
// case QAccessible::Description:
|
|
||||||
// return m_description;
|
|
||||||
// default:
|
|
||||||
// return QString();
|
|
||||||
// }
|
|
||||||
//}
|
|
@ -1,27 +1,9 @@
|
|||||||
/*
|
#include "accessibledefine.h"
|
||||||
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
|
||||||
*
|
|
||||||
* Author: fpc_diesel <fanpengcheng@uniontech.com>
|
|
||||||
*
|
|
||||||
* Maintainer: fpc_diesel <fanpengcheng@uniontech.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
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* 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 ACCESSIBLE_H
|
|
||||||
#define ACCESSIBLE_H
|
|
||||||
|
|
||||||
|
#include "mainwindow.h"
|
||||||
#include "../panel/mainpanelcontrol.h"
|
#include "../panel/mainpanelcontrol.h"
|
||||||
|
#include "../../widgets/tipswidget.h"
|
||||||
|
#include "../util/dockpopupwindow.h"
|
||||||
|
|
||||||
#include "../item/launcheritem.h"
|
#include "../item/launcheritem.h"
|
||||||
#include "../item/appitem.h"
|
#include "../item/appitem.h"
|
||||||
@ -53,194 +35,107 @@
|
|||||||
#include "../plugins/sound/componments/volumeslider.h"
|
#include "../plugins/sound/componments/volumeslider.h"
|
||||||
#include "../plugins/sound/componments/horizontalseparator.h"
|
#include "../plugins/sound/componments/horizontalseparator.h"
|
||||||
|
|
||||||
#include "../../widgets/tipswidget.h"
|
//#include "../plugins/network/item/deviceitem.h" //TODO
|
||||||
|
|
||||||
#include "../plugins/datetime/datetimewidget.h"
|
#include "../plugins/datetime/datetimewidget.h"
|
||||||
#include "../plugins/onboard/onboarditem.h"
|
#include "../plugins/onboard/onboarditem.h"
|
||||||
#include "../plugins/trash/trashwidget.h"
|
#include "../plugins/trash/trashwidget.h"
|
||||||
#include "../plugins/trash/popupcontrolwidget.h"
|
#include "../plugins/trash/popupcontrolwidget.h"
|
||||||
#include "../plugins/shutdown/shutdownwidget.h"
|
#include "../plugins/shutdown/shutdownwidget.h"
|
||||||
#include "../plugins/multitasking/multitaskingwidget.h"
|
#include "../plugins/multitasking/multitaskingwidget.h"
|
||||||
//#include "../plugins/overlay-warning/overlaywarningwidget.h"
|
//#include "../plugins/overlay-warning/overlaywarningwidget.h"// TODO
|
||||||
|
|
||||||
#include <QAccessible>
|
#include <DImageButton>
|
||||||
#include <QAccessibleWidget>
|
#include <DSwitchButton>
|
||||||
#include <QEvent>
|
#include <DPushButton>
|
||||||
#include <QMouseEvent>
|
|
||||||
#include <QApplication>
|
|
||||||
|
|
||||||
/**************************************************************************************/
|
DWIDGET_USE_NAMESPACE
|
||||||
// 构造函数
|
|
||||||
#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{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{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{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);\
|
|
||||||
}\
|
|
||||||
}\
|
|
||||||
|
|
||||||
// 实现rect接口
|
|
||||||
#define FUNC_RECT(classobj) QRect rect() const override{\
|
|
||||||
if (!classobj->isVisible())\
|
|
||||||
return QRect();\
|
|
||||||
return classobj->geometry();\
|
|
||||||
}\
|
|
||||||
|
|
||||||
// 启用accessible
|
|
||||||
#define USE_ACCESSIBLE(classnamestring,classname) if (classnamestring == QLatin1String(#classname) && object && object->isWidgetType())\
|
|
||||||
{\
|
|
||||||
interface = new Accessible##classname(static_cast<classname *>(object));\
|
|
||||||
}\
|
|
||||||
|
|
||||||
//// 启用accessible[指定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 SET_BUTTON_ACCESSIBLE_PRESS_DESCRIPTION(classname,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,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,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,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) SET_BUTTON_ACCESSIBLE_PRESS_SHOEMENU_DESCRIPTION(classname,"")
|
|
||||||
#define SET_BUTTON_ACCESSIBLE_SHOWMENU(classname) SET_BUTTON_ACCESSIBLE_SHOWMENU_DESCRIPTION(classname,"")
|
|
||||||
#define SET_BUTTON_ACCESSIBLE(classname) SET_BUTTON_ACCESSIBLE_PRESS_DESCRIPTION(classname,"")
|
|
||||||
|
|
||||||
#define SET_LABEL_ACCESSIBLE(classname) SET_LABEL_ACCESSIBLE_WITH_DESCRIPTION(classname,QAccessible::StaticText,"")
|
|
||||||
#define SET_FORM_ACCESSIBLE(classname) SET_LABEL_ACCESSIBLE_WITH_DESCRIPTION(classname,QAccessible::Form,"")
|
|
||||||
#define SET_SLIDER_ACCESSIBLE(classname) SET_LABEL_ACCESSIBLE_WITH_DESCRIPTION(classname,QAccessible::Slider,"")
|
|
||||||
#define SET_SEPARATOR_ACCESSIBLE(classname) SET_LABEL_ACCESSIBLE_WITH_DESCRIPTION(classname,QAccessible::Separator,"")
|
|
||||||
/**************************************************************************************/
|
|
||||||
|
|
||||||
// 添加accessible
|
// 添加accessible
|
||||||
SET_BUTTON_ACCESSIBLE_SHOWMENU(MainPanelControl)
|
SET_FORM_ACCESSIBLE(MainWindow,"mainwindow")
|
||||||
|
SET_BUTTON_ACCESSIBLE_SHOWMENU(MainPanelControl,"mainpanelcontrol")
|
||||||
|
SET_LABEL_ACCESSIBLE(TipsWidget,"Tips")
|
||||||
|
SET_FORM_ACCESSIBLE(DockPopupWindow,"PopupWindow")
|
||||||
|
SET_BUTTON_ACCESSIBLE(LauncherItem,"launcheritem")
|
||||||
|
SET_BUTTON_ACCESSIBLE_PRESS_SHOWMENU(AppItem,"AppItem")
|
||||||
|
SET_BUTTON_ACCESSIBLE(PreviewContainer,"previewcontainer")
|
||||||
|
SET_BUTTON_ACCESSIBLE_PRESS_SHOWMENU(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_PRESS_SHOWMENU(XEmbedTrayWidget,m_w->itemKeyForConfig())
|
||||||
|
SET_BUTTON_ACCESSIBLE_PRESS_SHOWMENU(IndicatorTrayWidget,m_w->itemKeyForConfig())
|
||||||
|
SET_BUTTON_ACCESSIBLE_PRESS_SHOWMENU(SNITrayWidget,m_w->itemKeyForConfig())
|
||||||
|
SET_BUTTON_ACCESSIBLE_PRESS_SHOWMENU(SystemTrayItem,m_w->itemKeyForConfig())
|
||||||
|
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_BUTTON_ACCESSIBLE(SoundItem,"plugin-sounditem")
|
||||||
|
SET_FORM_ACCESSIBLE(SoundApplet,"soundapplet")
|
||||||
|
SET_FORM_ACCESSIBLE(SinkInputWidget,"sinkinputwidget")
|
||||||
|
SET_SLIDER_ACCESSIBLE(VolumeSlider,"volumeslider")
|
||||||
|
SET_SEPARATOR_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_FORM_ACCESSIBLE(ShutdownWidget,"plugin-shutdown")
|
||||||
|
SET_FORM_ACCESSIBLE(MultitaskingWidget,"plugin-multitasking")
|
||||||
|
SET_FORM_ACCESSIBLE(ShowDesktopWidget,"plugin-showdesktop")
|
||||||
|
SET_BUTTON_ACCESSIBLE(QWidget,m_w->objectName())
|
||||||
|
SET_BUTTON_ACCESSIBLE(DImageButton,m_w->objectName())
|
||||||
|
SET_BUTTON_ACCESSIBLE(DSwitchButton,m_w->text())
|
||||||
|
|
||||||
SET_BUTTON_ACCESSIBLE(LauncherItem)
|
QAccessibleInterface *accessibleFactory(const QString &classname, QObject *object)
|
||||||
SET_BUTTON_ACCESSIBLE(AppItem)
|
{
|
||||||
SET_BUTTON_ACCESSIBLE(PreviewContainer)
|
QAccessibleInterface *interface = nullptr;
|
||||||
SET_BUTTON_ACCESSIBLE_PRESS_SHOWMENU(PluginsItem)
|
|
||||||
SET_BUTTON_ACCESSIBLE(TrayPluginItem)
|
|
||||||
SET_BUTTON_ACCESSIBLE(PlaceholderItem)
|
|
||||||
SET_BUTTON_ACCESSIBLE(AppDragWidget)
|
|
||||||
SET_BUTTON_ACCESSIBLE(AppSnapshot)
|
|
||||||
SET_BUTTON_ACCESSIBLE(FloatingPreview)
|
|
||||||
|
|
||||||
// tray plugin
|
USE_ACCESSIBLE(classname, MainWindow);
|
||||||
SET_BUTTON_ACCESSIBLE_PRESS_SHOWMENU(XEmbedTrayWidget)
|
USE_ACCESSIBLE(classname, MainPanelControl);
|
||||||
SET_BUTTON_ACCESSIBLE_PRESS_SHOWMENU(IndicatorTrayWidget)
|
USE_ACCESSIBLE(classname, TipsWidget);
|
||||||
SET_BUTTON_ACCESSIBLE_PRESS_SHOWMENU(SNITrayWidget)
|
USE_ACCESSIBLE(classname, DockPopupWindow);
|
||||||
SET_BUTTON_ACCESSIBLE_PRESS_SHOWMENU(SystemTrayItem)
|
USE_ACCESSIBLE(classname, LauncherItem);
|
||||||
SET_FORM_ACCESSIBLE(FashionTrayItem)
|
USE_ACCESSIBLE(classname, AppItem);
|
||||||
SET_FORM_ACCESSIBLE(FashionTrayWidgetWrapper)
|
USE_ACCESSIBLE(classname, PreviewContainer);
|
||||||
SET_FORM_ACCESSIBLE(FashionTrayControlWidget)
|
USE_ACCESSIBLE(classname, PluginsItem);
|
||||||
SET_FORM_ACCESSIBLE(AttentionContainer)
|
USE_ACCESSIBLE(classname, TrayPluginItem);
|
||||||
SET_FORM_ACCESSIBLE(HoldContainer)
|
USE_ACCESSIBLE(classname, PlaceholderItem);
|
||||||
SET_FORM_ACCESSIBLE(NormalContainer)
|
USE_ACCESSIBLE(classname, AppDragWidget);
|
||||||
SET_FORM_ACCESSIBLE(SpliterAnimated)
|
USE_ACCESSIBLE(classname, AppSnapshot);
|
||||||
|
USE_ACCESSIBLE(classname, FloatingPreview);
|
||||||
|
USE_ACCESSIBLE(classname, SNITrayWidget);
|
||||||
|
USE_ACCESSIBLE(classname, SystemTrayItem);
|
||||||
|
USE_ACCESSIBLE(classname, FashionTrayItem);
|
||||||
|
USE_ACCESSIBLE(classname, FashionTrayWidgetWrapper);
|
||||||
|
USE_ACCESSIBLE(classname, FashionTrayControlWidget);
|
||||||
|
USE_ACCESSIBLE(classname, AttentionContainer);
|
||||||
|
USE_ACCESSIBLE(classname, HoldContainer);
|
||||||
|
USE_ACCESSIBLE(classname, NormalContainer);
|
||||||
|
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, DatetimeWidget);
|
||||||
|
USE_ACCESSIBLE(classname, OnboardItem);
|
||||||
|
USE_ACCESSIBLE(classname, TrashWidget);
|
||||||
|
USE_ACCESSIBLE(classname, PopupControlWidget);
|
||||||
|
USE_ACCESSIBLE(classname, ShutdownWidget);
|
||||||
|
USE_ACCESSIBLE(classname, MultitaskingWidget);
|
||||||
|
USE_ACCESSIBLE(classname, ShowDesktopWidget);
|
||||||
|
// USE_ACCESSIBLE(classname,OverlayWarningWidget);
|
||||||
|
USE_ACCESSIBLE_BY_OBJECTNAME(classname, QWidget, "Btn_showdesktoparea");//TODO 点击坐标有偏差
|
||||||
|
USE_ACCESSIBLE_BY_OBJECTNAME(QString(classname).replace("Dtk::Widget::", ""), DImageButton, "closebutton-2d");
|
||||||
|
USE_ACCESSIBLE_BY_OBJECTNAME(QString(classname).replace("Dtk::Widget::", ""), DImageButton, "closebutton-3d");
|
||||||
|
USE_ACCESSIBLE_BY_OBJECTNAME(QString(classname).replace("Dtk::Widget::", ""), DSwitchButton, "");
|
||||||
|
|
||||||
// showdesktop plugin
|
return interface;
|
||||||
SET_BUTTON_ACCESSIBLE(ShowDesktopWidget)// 未生效
|
}
|
||||||
|
|
||||||
// sound plugin
|
|
||||||
SET_BUTTON_ACCESSIBLE(SoundItem)
|
|
||||||
SET_FORM_ACCESSIBLE(SoundApplet)
|
|
||||||
SET_FORM_ACCESSIBLE(SinkInputWidget)
|
|
||||||
SET_SLIDER_ACCESSIBLE(VolumeSlider)
|
|
||||||
SET_SEPARATOR_ACCESSIBLE(HorizontalSeparator)
|
|
||||||
|
|
||||||
SET_LABEL_ACCESSIBLE(TipsWidget)
|
|
||||||
|
|
||||||
// fixed plugin
|
|
||||||
SET_FORM_ACCESSIBLE(DatetimeWidget)
|
|
||||||
SET_FORM_ACCESSIBLE(OnboardItem)
|
|
||||||
SET_FORM_ACCESSIBLE(TrashWidget)
|
|
||||||
SET_FORM_ACCESSIBLE(PopupControlWidget)
|
|
||||||
SET_FORM_ACCESSIBLE(ShutdownWidget)
|
|
||||||
|
|
||||||
// multitasking plugin
|
|
||||||
SET_FORM_ACCESSIBLE(MultitaskingWidget)
|
|
||||||
|
|
||||||
//SET_FORM_ACCESSIBLE(OverlayWarningWidget)
|
|
||||||
|
|
||||||
#endif // ACCESSIBLE_H
|
|
||||||
|
261
frame/window/accessibledefine.h
Normal file
261
frame/window/accessibledefine.h
Normal file
@ -0,0 +1,261 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
||||||
|
*
|
||||||
|
* Author: fpc_diesel <fanpengcheng@uniontech.com>
|
||||||
|
*
|
||||||
|
* Maintainer: fpc_diesel <fanpengcheng@uniontech.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
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* 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_*宏开启即可
|
||||||
|
/* 宏参数说明
|
||||||
|
* 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 <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, 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(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;
|
||||||
|
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(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);
|
||||||
|
|
||||||
|
return newAccessibleName;
|
||||||
|
} else {
|
||||||
|
accessibleMap[r].append(accessibleName);
|
||||||
|
objnameMap.insert(w, accessibleName);
|
||||||
|
|
||||||
|
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<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 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)
|
||||||
|
/************************************************************************************************/
|
||||||
|
|
||||||
|
#endif // ACCESSIBLEDEFINE_H
|
Loading…
x
Reference in New Issue
Block a user