mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +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_appAreaWidget(new QWidget(this))
|
||||||
, m_trayAreaWidget(new QWidget(this))
|
, m_trayAreaWidget(new QWidget(this))
|
||||||
, m_pluginAreaWidget(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_fixedAreaLayout(new QBoxLayout(QBoxLayout::LeftToRight))
|
||||||
, m_trayAreaLayout(new QBoxLayout(QBoxLayout::LeftToRight))
|
, m_trayAreaLayout(new QBoxLayout(QBoxLayout::LeftToRight))
|
||||||
, m_pluginLayout(new QBoxLayout(QBoxLayout::LeftToRight))
|
, m_pluginLayout(new QBoxLayout(QBoxLayout::LeftToRight))
|
||||||
|
@ -39,6 +39,15 @@ public:
|
|||||||
virtual bool appIsOnDock(const QString &appDesktop) = 0;
|
virtual bool appIsOnDock(const QString &appDesktop) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class DesktopWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
DesktopWidget(QWidget *parent) : QWidget(parent){
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class DockItem;
|
class DockItem;
|
||||||
class PlaceholderItem;
|
class PlaceholderItem;
|
||||||
class AppDragWidget;
|
class AppDragWidget;
|
||||||
@ -108,7 +117,7 @@ private:
|
|||||||
QWidget *m_appAreaWidget;
|
QWidget *m_appAreaWidget;
|
||||||
QWidget *m_trayAreaWidget;
|
QWidget *m_trayAreaWidget;
|
||||||
QWidget *m_pluginAreaWidget;
|
QWidget *m_pluginAreaWidget;
|
||||||
QWidget *m_desktopWidget;
|
DesktopWidget *m_desktopWidget;
|
||||||
QBoxLayout *m_fixedAreaLayout;
|
QBoxLayout *m_fixedAreaLayout;
|
||||||
QBoxLayout *m_trayAreaLayout;
|
QBoxLayout *m_trayAreaLayout;
|
||||||
QBoxLayout *m_pluginLayout;
|
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_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(DImageButton, m_w->objectName().isEmpty() ? "imagebutton" : m_w->objectName())
|
||||||
SET_BUTTON_ACCESSIBLE(DSwitchButton, m_w->text().isEmpty() ? "switchbutton" : m_w->text())
|
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 *accessibleFactory(const QString &classname, QObject *object)
|
||||||
{
|
{
|
||||||
QAccessibleInterface *interface = nullptr;
|
QAccessibleInterface *interface = nullptr;
|
||||||
@ -127,6 +127,7 @@ QAccessibleInterface *accessibleFactory(const QString &classname, QObject *objec
|
|||||||
// USE_ACCESSIBLE(classname, SinkInputWidget);
|
// USE_ACCESSIBLE(classname, SinkInputWidget);
|
||||||
// USE_ACCESSIBLE(classname, VolumeSlider);
|
// USE_ACCESSIBLE(classname, VolumeSlider);
|
||||||
// USE_ACCESSIBLE(classname, HorizontalSeparator);
|
// USE_ACCESSIBLE(classname, HorizontalSeparator);
|
||||||
|
USE_ACCESSIBLE(classname, DesktopWidget);
|
||||||
USE_ACCESSIBLE(classname, DatetimeWidget);
|
USE_ACCESSIBLE(classname, DatetimeWidget);
|
||||||
USE_ACCESSIBLE(classname, OnboardItem);
|
USE_ACCESSIBLE(classname, OnboardItem);
|
||||||
USE_ACCESSIBLE(classname, TrashWidget);
|
USE_ACCESSIBLE(classname, TrashWidget);
|
||||||
|
@ -84,11 +84,21 @@ inline QString getAccessibleName(QWidget *w, QAccessible::Role r, const QString
|
|||||||
accessibleMap[r].append(newAccessibleName);
|
accessibleMap[r].append(newAccessibleName);
|
||||||
objnameMap.insert(w, newAccessibleName);
|
objnameMap.insert(w, newAccessibleName);
|
||||||
|
|
||||||
|
// 对象销毁后移除占用名称
|
||||||
|
QObject::connect(w, &QWidget::destroyed, [ = ] (QObject *obj) {
|
||||||
|
objnameMap.remove(obj);
|
||||||
|
accessibleMap[r].removeOne(newAccessibleName);
|
||||||
|
});
|
||||||
return newAccessibleName;
|
return newAccessibleName;
|
||||||
} else {
|
} else {
|
||||||
accessibleMap[r].append(accessibleName);
|
accessibleMap[r].append(accessibleName);
|
||||||
objnameMap.insert(w, accessibleName);
|
objnameMap.insert(w, accessibleName);
|
||||||
|
|
||||||
|
// 对象销毁后移除占用名称
|
||||||
|
QObject::connect(w, &QWidget::destroyed, [ = ] (QObject *obj) {
|
||||||
|
objnameMap.remove(obj);
|
||||||
|
accessibleMap[r].removeOne(accessibleName);
|
||||||
|
});
|
||||||
return 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;\
|
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; }\
|
int selectionCount() const override { return 0; }\
|
||||||
void addSelection(int startOffset, int endOffset) override {}\
|
void addSelection(int startOffset, int endOffset) override {\
|
||||||
void removeSelection(int selectionIndex) override {}\
|
Q_UNUSED(startOffset)\
|
||||||
void setSelection(int selectionIndex, int startOffset, int endOffset) override {}\
|
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; }\
|
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; }\
|
int characterCount() const override { return 0; }\
|
||||||
QRect characterRect(int offset) const override { return QRect(); }\
|
QRect characterRect(int offset) const override {\
|
||||||
int offsetAtPoint(const QPoint &point) const override { return 0; }\
|
Q_UNUSED(offset)\
|
||||||
void scrollToSubstring(int startIndex, int endIndex) override {}\
|
return QRect();\
|
||||||
QString attributes(int offset, int *startOffset, int *endOffset) const override { return QString(); }\
|
}\
|
||||||
|
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:\
|
private:\
|
||||||
classname *m_w;\
|
classname *m_w;\
|
||||||
QString m_description;\
|
QString m_description;\
|
||||||
|
@ -60,6 +60,7 @@ private:
|
|||||||
public:
|
public:
|
||||||
DragWidget(QWidget *parent) : QWidget(parent)
|
DragWidget(QWidget *parent) : QWidget(parent)
|
||||||
{
|
{
|
||||||
|
setObjectName(tr("DragWidget"));
|
||||||
m_dragStatus = false;
|
m_dragStatus = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ OnboardPlugin::OnboardPlugin(QObject *parent)
|
|||||||
{
|
{
|
||||||
m_tipsLabel->setText(tr("Onboard"));
|
m_tipsLabel->setText(tr("Onboard"));
|
||||||
m_tipsLabel->setVisible(false);
|
m_tipsLabel->setVisible(false);
|
||||||
|
m_tipsLabel->setAccessibleName(tr("Onboard"));
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString OnboardPlugin::pluginName() const
|
const QString OnboardPlugin::pluginName() const
|
||||||
|
@ -36,6 +36,7 @@ ShutdownPlugin::ShutdownPlugin(QObject *parent)
|
|||||||
|
|
||||||
{
|
{
|
||||||
m_tipsLabel->setVisible(false);
|
m_tipsLabel->setVisible(false);
|
||||||
|
m_tipsLabel->setAccessibleName(tr("shutdown"));
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString ShutdownPlugin::pluginName() const
|
const QString ShutdownPlugin::pluginName() const
|
||||||
|
@ -50,6 +50,7 @@ FashionTrayWidgetWrapper::FashionTrayWidgetWrapper(const QString &itemKey, Abstr
|
|||||||
{
|
{
|
||||||
setStyleSheet("background: transparent;");
|
setStyleSheet("background: transparent;");
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
setObjectName(itemKey);
|
||||||
|
|
||||||
m_layout->setSpacing(0);
|
m_layout->setSpacing(0);
|
||||||
m_layout->setMargin(0);
|
m_layout->setMargin(0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user