mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
fix: show same accessible name after widget destroyed
控件销毁后显示相同的标记名称
This commit is contained in:
parent
eecce9d618
commit
1057ce28af
@ -61,7 +61,7 @@ MainPanelControl::MainPanelControl(QWidget *parent)
|
||||
, m_appAreaWidget(new QWidget(this))
|
||||
, m_trayAreaWidget(new QWidget(this))
|
||||
, m_pluginAreaWidget(new QWidget(this))
|
||||
, m_desktopWidget(new QWidget(this))
|
||||
, m_desktopWidget(new DesktopWidget(this))
|
||||
, m_fixedAreaLayout(new QBoxLayout(QBoxLayout::LeftToRight))
|
||||
, m_trayAreaLayout(new QBoxLayout(QBoxLayout::LeftToRight))
|
||||
, m_pluginLayout(new QBoxLayout(QBoxLayout::LeftToRight))
|
||||
|
@ -39,6 +39,15 @@ public:
|
||||
virtual bool appIsOnDock(const QString &appDesktop) = 0;
|
||||
};
|
||||
|
||||
class DesktopWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DesktopWidget(QWidget *parent) : QWidget(parent){
|
||||
}
|
||||
};
|
||||
|
||||
class DockItem;
|
||||
class PlaceholderItem;
|
||||
class AppDragWidget;
|
||||
@ -108,7 +117,7 @@ private:
|
||||
QWidget *m_appAreaWidget;
|
||||
QWidget *m_trayAreaWidget;
|
||||
QWidget *m_pluginAreaWidget;
|
||||
QWidget *m_desktopWidget;
|
||||
DesktopWidget *m_desktopWidget;
|
||||
QBoxLayout *m_fixedAreaLayout;
|
||||
QBoxLayout *m_trayAreaLayout;
|
||||
QBoxLayout *m_pluginLayout;
|
||||
|
@ -93,7 +93,7 @@ SET_FORM_ACCESSIBLE(QWidget, m_w->objectName().isEmpty() ? "widget" : m_w->objec
|
||||
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())
|
||||
|
||||
SET_BUTTON_ACCESSIBLE(DesktopWidget, "desktopWidget");
|
||||
QAccessibleInterface *accessibleFactory(const QString &classname, QObject *object)
|
||||
{
|
||||
QAccessibleInterface *interface = nullptr;
|
||||
@ -127,6 +127,7 @@ QAccessibleInterface *accessibleFactory(const QString &classname, QObject *objec
|
||||
// USE_ACCESSIBLE(classname, SinkInputWidget);
|
||||
// USE_ACCESSIBLE(classname, VolumeSlider);
|
||||
// USE_ACCESSIBLE(classname, HorizontalSeparator);
|
||||
USE_ACCESSIBLE(classname, DesktopWidget);
|
||||
USE_ACCESSIBLE(classname, DatetimeWidget);
|
||||
USE_ACCESSIBLE(classname, OnboardItem);
|
||||
USE_ACCESSIBLE(classname, TrashWidget);
|
||||
|
@ -84,11 +84,21 @@ inline QString getAccessibleName(QWidget *w, QAccessible::Role r, const QString
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -219,18 +229,47 @@ inline QString getAccessibleName(QWidget *w, QAccessible::Role r, const QString
|
||||
}\
|
||||
}\
|
||||
QString text(int startOffset, int endOffset) const override;\
|
||||
void selection(int selectionIndex, 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 {}\
|
||||
void removeSelection(int selectionIndex) override {}\
|
||||
void setSelection(int selectionIndex, int startOffset, int endOffset) override {}\
|
||||
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 {}\
|
||||
void setCursorPosition(int position) override {\
|
||||
Q_UNUSED(position)\
|
||||
}\
|
||||
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(); }\
|
||||
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;\
|
||||
|
@ -60,6 +60,7 @@ private:
|
||||
public:
|
||||
DragWidget(QWidget *parent) : QWidget(parent)
|
||||
{
|
||||
setObjectName(tr("DragWidget"));
|
||||
m_dragStatus = false;
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@ OnboardPlugin::OnboardPlugin(QObject *parent)
|
||||
{
|
||||
m_tipsLabel->setText(tr("Onboard"));
|
||||
m_tipsLabel->setVisible(false);
|
||||
m_tipsLabel->setAccessibleName(tr("Onboard"));
|
||||
}
|
||||
|
||||
const QString OnboardPlugin::pluginName() const
|
||||
|
@ -36,6 +36,7 @@ ShutdownPlugin::ShutdownPlugin(QObject *parent)
|
||||
|
||||
{
|
||||
m_tipsLabel->setVisible(false);
|
||||
m_tipsLabel->setAccessibleName(tr("shutdown"));
|
||||
}
|
||||
|
||||
const QString ShutdownPlugin::pluginName() const
|
||||
|
@ -50,6 +50,7 @@ FashionTrayWidgetWrapper::FashionTrayWidgetWrapper(const QString &itemKey, Abstr
|
||||
{
|
||||
setStyleSheet("background: transparent;");
|
||||
setAcceptDrops(true);
|
||||
setObjectName(itemKey);
|
||||
|
||||
m_layout->setSpacing(0);
|
||||
m_layout->setMargin(0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user