File indexing completed on 2025-01-26 03:28:31
0001 /* 0002 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL 0005 */ 0006 0007 #pragma once 0008 0009 #include <QWidget> 0010 #include <qaccessibilityclient/accessibleobject.h> 0011 0012 class UiView; 0013 class UiWidget : public QWidget 0014 { 0015 Q_OBJECT 0016 public: 0017 explicit UiWidget(QWidget *view = nullptr); 0018 void setAccessibleObject(const QAccessibleClient::AccessibleObject &acc); 0019 [[nodiscard]] QSize sizeHint() const override; 0020 0021 protected: 0022 QImage *m_image = nullptr; 0023 QPixmap m_screen; 0024 QRect m_bounds; 0025 QAccessibleClient::AccessibleObject m_object; 0026 QMap<QAccessibleClient::AccessibleObject::Role, const char *> m_roleColors; 0027 0028 void paintEvent(QPaintEvent *event) override; 0029 0030 private: 0031 [[nodiscard]] QPixmap grabScreen(); 0032 [[nodiscard]] QRect bounds(const QAccessibleClient::AccessibleObject &acc) const; 0033 void drawObject(QPainter *painter, const QAccessibleClient::AccessibleObject &acc, int depth = 0); 0034 };