fakeaccessible.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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 == QLatin1String("vnotex::LineEdit")
  9. || p_className == QLatin1String("vnotex::TitleBar")
  10. || p_className == QLatin1String("vnotex::NotebookSelector")
  11. || p_className == QLatin1String("vnotex::TagExplorer")
  12. || p_className == QLatin1String("vnotex::SearchPanel")
  13. || p_className == QLatin1String("vnotex::SnippetPanel")
  14. || p_className == QLatin1String("vnotex::OutlineViewer")
  15. || p_className == QLatin1String("vnotex::TitleToolBar")
  16. || p_className == QLatin1String("vnotex::MainWindow")
  17. || p_className == QLatin1String("vnotex::ViewArea")
  18. || p_className == QLatin1String("vte::VTextEdit")
  19. || p_className == QLatin1String("vte::IndicatorsBorder")
  20. || p_className == QLatin1String("vte::MarkdownEditor")
  21. || p_className == QLatin1String("vte::VMarkdownEditor")
  22. || p_className == QLatin1String("vte::VTextEditor")
  23. || p_className == QLatin1String("vte::ViStatusBar")
  24. || p_className == QLatin1String("vte::StatusIndicator")
  25. || p_className == QLatin1String("vte::ScrollBar")) {
  26. return new FakeAccessibleInterface(p_obj);
  27. }
  28. return nullptr;
  29. }
  30. FakeAccessibleInterface::FakeAccessibleInterface(QObject *p_obj)
  31. : m_object(p_obj)
  32. {
  33. }
  34. QAccessibleInterface *FakeAccessibleInterface::child(int p_index) const
  35. {
  36. Q_UNUSED(p_index);
  37. return nullptr;
  38. }
  39. QAccessibleInterface *FakeAccessibleInterface::childAt(int p_x, int p_y) const
  40. {
  41. Q_UNUSED(p_x);
  42. Q_UNUSED(p_y);
  43. return nullptr;
  44. }
  45. int FakeAccessibleInterface::childCount() const
  46. {
  47. return 0;
  48. }
  49. int FakeAccessibleInterface::indexOfChild(const QAccessibleInterface *p_child) const
  50. {
  51. Q_UNUSED(p_child);
  52. return -1;
  53. }
  54. bool FakeAccessibleInterface::isValid() const
  55. {
  56. return false;
  57. }
  58. QObject *FakeAccessibleInterface::object() const
  59. {
  60. return m_object;
  61. }
  62. QAccessibleInterface *FakeAccessibleInterface::parent() const
  63. {
  64. return nullptr;
  65. }
  66. QRect FakeAccessibleInterface::rect() const
  67. {
  68. return QRect();
  69. }
  70. QAccessible::Role FakeAccessibleInterface::role() const
  71. {
  72. return QAccessible::NoRole;
  73. }
  74. void FakeAccessibleInterface::setText(QAccessible::Text p_t, const QString &p_text)
  75. {
  76. Q_UNUSED(p_t);
  77. Q_UNUSED(p_text);
  78. }
  79. QAccessible::State FakeAccessibleInterface::state() const
  80. {
  81. QAccessible::State state;
  82. state.disabled = true;
  83. return state;
  84. }
  85. QString FakeAccessibleInterface::text(QAccessible::Text p_t) const
  86. {
  87. Q_UNUSED(p_t);
  88. return QString();
  89. }