mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
feat(accessible):Unified naming && set overlaywarningwidget accessible
统一命名方式,所有的控件均以统一,添加overlaywarningwidget的accessible代码
This commit is contained in:
parent
df819075e3
commit
06ac0b986a
@ -104,7 +104,7 @@ AppItem::AppItem(const QDBusObjectPath &entry, QWidget *parent)
|
||||
m_active = m_itemEntryInter->isActive();
|
||||
|
||||
m_appNameTips->setObjectName("AppItemTips");
|
||||
m_appNameTips->setAccessibleName(m_itemEntryInter->name() + "-tips");
|
||||
m_appNameTips->setAccessibleName(m_itemEntryInter->name());
|
||||
m_appNameTips->setVisible(false);
|
||||
m_appNameTips->installEventFilter(this);
|
||||
|
||||
|
@ -60,13 +60,12 @@ AppSnapshot::AppSnapshot(const WId wid, QWidget *parent)
|
||||
, m_wmHelper(DWindowManagerHelper::instance())
|
||||
{
|
||||
m_closeBtn2D->setFixedSize(24, 24);
|
||||
m_closeBtn2D->setAccessibleName("closebutton-2d");
|
||||
m_closeBtn2D->setObjectName("closebutton-2d");
|
||||
m_closeBtn2D->setNormalPic(":/icons/resources/close_round_normal.svg");
|
||||
m_closeBtn2D->setHoverPic(":/icons/resources/close_round_hover.svg");
|
||||
m_closeBtn2D->setPressPic(":/icons/resources/close_round_press.svg");
|
||||
m_closeBtn2D->setVisible(false);
|
||||
m_title->setObjectName("AppSnapshotTitle");
|
||||
m_title->setAccessibleName("AppSnapshotTitle");
|
||||
|
||||
QHBoxLayout *centralLayout = new QHBoxLayout;
|
||||
centralLayout->addWidget(m_title);
|
||||
|
@ -38,7 +38,7 @@ FloatingPreview::FloatingPreview(QWidget *parent)
|
||||
, m_closeBtn3D(new DImageButton)
|
||||
, m_titleBtn(new DPushButton)
|
||||
{
|
||||
m_closeBtn3D->setAccessibleName("closebutton-3d");
|
||||
m_closeBtn3D->setObjectName("closebutton-3d");
|
||||
m_closeBtn3D->setFixedSize(24, 24);
|
||||
m_closeBtn3D->setNormalPic(":/icons/resources/close_round_normal.svg");
|
||||
m_closeBtn3D->setHoverPic(":/icons/resources/close_round_hover.svg");
|
||||
|
@ -102,9 +102,9 @@ MainPanelControl::~MainPanelControl()
|
||||
void MainPanelControl::init()
|
||||
{
|
||||
// 主窗口
|
||||
m_fixedSpliter->setAccessibleName("spliter_fix");
|
||||
m_appSpliter->setAccessibleName("spliter_app");
|
||||
m_traySpliter->setAccessibleName("spliter_tray");
|
||||
m_fixedSpliter->setObjectName("spliter_fix");
|
||||
m_appSpliter->setObjectName("spliter_app");
|
||||
m_traySpliter->setObjectName("spliter_tray");
|
||||
|
||||
m_mainPanelLayout->addWidget(m_fixedAreaWidget);
|
||||
m_mainPanelLayout->addWidget(m_fixedSpliter);
|
||||
@ -123,28 +123,28 @@ void MainPanelControl::init()
|
||||
|
||||
// 固定区域
|
||||
m_fixedAreaWidget->setLayout(m_fixedAreaLayout);
|
||||
m_fixedAreaWidget->setAccessibleName("fixedarea");
|
||||
m_fixedAreaWidget->setObjectName("fixedarea");
|
||||
m_fixedAreaLayout->setMargin(0);
|
||||
m_fixedAreaLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_fixedAreaLayout->setSpacing(0);
|
||||
|
||||
// 应用程序
|
||||
m_appAreaSonWidget->setLayout(m_appAreaSonLayout);
|
||||
m_appAreaSonWidget->setAccessibleName("apparea");
|
||||
m_appAreaSonWidget->setObjectName("apparea");
|
||||
m_appAreaSonLayout->setMargin(0);
|
||||
m_appAreaSonLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_appAreaSonLayout->setSpacing(0);
|
||||
|
||||
// 托盘
|
||||
m_trayAreaWidget->setLayout(m_trayAreaLayout);
|
||||
m_trayAreaWidget->setAccessibleName("trayarea");
|
||||
m_trayAreaWidget->setObjectName("trayarea");
|
||||
m_trayAreaLayout->setMargin(0);
|
||||
m_trayAreaLayout->setContentsMargins(0, 10, 0, 10);
|
||||
m_trayAreaLayout->setSpacing(0);
|
||||
|
||||
// 插件
|
||||
m_pluginAreaWidget->setLayout(m_pluginLayout);
|
||||
m_pluginAreaWidget->setAccessibleName("pluginarea");
|
||||
m_pluginAreaWidget->setObjectName("pluginarea");
|
||||
m_pluginLayout->setMargin(0);
|
||||
m_pluginLayout->setSpacing(10);
|
||||
|
||||
|
@ -73,7 +73,7 @@ DockSettings::DockSettings(QWidget *parent)
|
||||
, m_itemManager(DockItemManager::instance(this))
|
||||
, m_trashPluginShow(true)
|
||||
{
|
||||
m_settingsMenu.setAccessibleName("dock-settingsmenu");
|
||||
m_settingsMenu.setAccessibleName("settingsmenu");
|
||||
checkService();
|
||||
|
||||
m_primaryRawRect = m_displayInter->primaryRawRect();
|
||||
|
@ -35,14 +35,13 @@
|
||||
#include "../plugins/sound/componments/volumeslider.h"
|
||||
#include "../plugins/sound/componments/horizontalseparator.h"
|
||||
|
||||
//#include "../plugins/network/item/deviceitem.h" //TODO
|
||||
#include "../plugins/datetime/datetimewidget.h"
|
||||
#include "../plugins/onboard/onboarditem.h"
|
||||
#include "../plugins/trash/trashwidget.h"
|
||||
#include "../plugins/trash/popupcontrolwidget.h"
|
||||
#include "../plugins/shutdown/shutdownwidget.h"
|
||||
#include "../plugins/multitasking/multitaskingwidget.h"
|
||||
//#include "../plugins/overlay-warning/overlaywarningwidget.h"// TODO
|
||||
#include "../plugins/overlay-warning/overlaywarningwidget.h"
|
||||
|
||||
#include <DImageButton>
|
||||
#include <DSwitchButton>
|
||||
@ -53,10 +52,10 @@ DWIDGET_USE_NAMESPACE
|
||||
// 添加accessible
|
||||
SET_FORM_ACCESSIBLE(MainWindow, "mainwindow")
|
||||
SET_BUTTON_ACCESSIBLE_SHOWMENU(MainPanelControl, "mainpanelcontrol")
|
||||
SET_LABEL_ACCESSIBLE(TipsWidget,"Tips")
|
||||
SET_FORM_ACCESSIBLE(DockPopupWindow,"PopupWindow")
|
||||
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_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())
|
||||
@ -87,9 +86,11 @@ 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_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())
|
||||
|
||||
QAccessibleInterface *accessibleFactory(const QString &classname, QObject *object)
|
||||
{
|
||||
@ -131,8 +132,13 @@ QAccessibleInterface *accessibleFactory(const QString &classname, QObject *objec
|
||||
USE_ACCESSIBLE(classname, ShutdownWidget);
|
||||
USE_ACCESSIBLE(classname, MultitaskingWidget);
|
||||
USE_ACCESSIBLE(classname, ShowDesktopWidget);
|
||||
// USE_ACCESSIBLE(classname,OverlayWarningWidget);
|
||||
USE_ACCESSIBLE(classname, OverlayWarningWidget);
|
||||
USE_ACCESSIBLE_BY_OBJECTNAME(classname, QWidget, "Btn_showdesktoparea");//TODO 点击坐标有偏差
|
||||
USE_ACCESSIBLE(classname, QWidget);
|
||||
USE_ACCESSIBLE_BY_OBJECTNAME(classname, QLabel, "spliter_fix");
|
||||
USE_ACCESSIBLE_BY_OBJECTNAME(classname, QLabel, "spliter_app");
|
||||
USE_ACCESSIBLE_BY_OBJECTNAME(classname, QLabel, "spliter_tray");
|
||||
USE_ACCESSIBLE(classname, QLabel);
|
||||
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, "");
|
||||
|
@ -61,15 +61,16 @@
|
||||
|
||||
#define SEPARATOR "_"
|
||||
|
||||
inline QString getAccessibleName(QWidget *w, QAccessible::Role r, QString fallback)
|
||||
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();
|
||||
QString oldAccessName = w->accessibleName().toLower();
|
||||
oldAccessName.replace(SEPARATOR, "");
|
||||
|
||||
// 按照类型添加固定前缀
|
||||
@ -83,7 +84,7 @@ inline QString getAccessibleName(QWidget *w, QAccessible::Role r, QString fallba
|
||||
|
||||
// 再加上标识
|
||||
QString accessibleName = QString::fromLatin1(prefix) + SEPARATOR;
|
||||
accessibleName += oldAccessName.isEmpty() ? fallback : oldAccessName;
|
||||
accessibleName += oldAccessName.isEmpty() ? lowerFallback : oldAccessName;
|
||||
// 检查名称是否唯一
|
||||
if (accessibleMap[r].contains(accessibleName)) {
|
||||
if (!objnameMap.key(accessibleName)) {
|
||||
|
@ -148,7 +148,7 @@ MainWindow::MainWindow(QWidget *parent)
|
||||
m_sniWatcher(new StatusNotifierWatcher(SNI_WATCHER_SERVICE, SNI_WATCHER_PATH, QDBusConnection::sessionBus(), this)),
|
||||
m_dragWidget(new DragWidget(this))
|
||||
{
|
||||
setAccessibleName("dock-mainwindow");
|
||||
setAccessibleName("mainwindow");
|
||||
m_mainPanel->setAccessibleName("mainpanel");
|
||||
setAttribute(Qt::WA_TranslucentBackground);
|
||||
setMouseTracking(true);
|
||||
|
@ -21,6 +21,7 @@
|
||||
*/
|
||||
|
||||
#include "overlaywarningwidget.h"
|
||||
#include "../../interfaces/constants.h"
|
||||
|
||||
#include <QSvgRenderer>
|
||||
#include <QPainter>
|
||||
|
@ -20,10 +20,8 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef PLUGINWIDGET_H
|
||||
#define PLUGINWIDGET_H
|
||||
|
||||
#include "../../interfaces/constants.h"
|
||||
#ifndef OVERLAYWARNINGWIDGET_H
|
||||
#define OVERLAYWARNINGWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
@ -40,9 +38,6 @@ protected:
|
||||
|
||||
private:
|
||||
const QPixmap loadSvg(const QString &fileName, const QSize &size) const;
|
||||
|
||||
private:
|
||||
Dock::DisplayMode m_displayMode;
|
||||
};
|
||||
|
||||
#endif // PLUGINWIDGET_H
|
||||
#endif // OVERLAYWARNINGWIDGET_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user