fakeaccessible.cpp 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #include "fakeaccessible.h"
  2. #include <QAccessible>
  3. #include <QDebug>
  4. using namespace vnotex;
  5. QAccessibleInterface *FakeAccessible::accessibleFactory(const QString &p_className, QObject *p_obj)
  6. {
  7. // Try to fix non-responsible issue caused by Youdao Dict.
  8. if (p_className.startsWith(QStringLiteral("vnotex::"))
  9. || p_className.startsWith(QStringLiteral("vte::"))) {
  10. // Qt's docs: All interfaces are managed by an internal cache and should not be deleted.
  11. return new FakeAccessibleInterface(p_obj);
  12. }
  13. return nullptr;
  14. }
  15. FakeAccessibleInterface::FakeAccessibleInterface(QObject *p_obj)
  16. : m_object(p_obj)
  17. {
  18. }
  19. QAccessibleInterface *FakeAccessibleInterface::child(int p_index) const
  20. {
  21. Q_UNUSED(p_index);
  22. return nullptr;
  23. }
  24. QAccessibleInterface *FakeAccessibleInterface::childAt(int p_x, int p_y) const
  25. {
  26. Q_UNUSED(p_x);
  27. Q_UNUSED(p_y);
  28. return nullptr;
  29. }
  30. int FakeAccessibleInterface::childCount() const
  31. {
  32. return 0;
  33. }
  34. int FakeAccessibleInterface::indexOfChild(const QAccessibleInterface *p_child) const
  35. {
  36. Q_UNUSED(p_child);
  37. return -1;
  38. }
  39. bool FakeAccessibleInterface::isValid() const
  40. {
  41. return false;
  42. }
  43. QObject *FakeAccessibleInterface::object() const
  44. {
  45. return m_object;
  46. }
  47. QAccessibleInterface *FakeAccessibleInterface::parent() const
  48. {
  49. return nullptr;
  50. }
  51. QRect FakeAccessibleInterface::rect() const
  52. {
  53. return QRect();
  54. }
  55. QAccessible::Role FakeAccessibleInterface::role() const
  56. {
  57. return QAccessible::NoRole;
  58. }
  59. void FakeAccessibleInterface::setText(QAccessible::Text p_t, const QString &p_text)
  60. {
  61. Q_UNUSED(p_t);
  62. Q_UNUSED(p_text);
  63. }
  64. QAccessible::State FakeAccessibleInterface::state() const
  65. {
  66. QAccessible::State state;
  67. state.disabled = true;
  68. return state;
  69. }
  70. QString FakeAccessibleInterface::text(QAccessible::Text p_t) const
  71. {
  72. Q_UNUSED(p_t);
  73. return QString();
  74. }