| | |
| | | // Copyright (C) 2023-2024 Stdware Collections |
| | | // Copyright (C) 2023-2024 Stdware Collections (https://www.github.com/stdware) |
| | | // Copyright (C) 2021-2023 wangwenx190 (Yuhang Zhao) |
| | | // SPDX-License-Identifier: Apache-2.0 |
| | | |
| | | #include "widgetitemdelegate_p.h" |
| | | |
| | | #include <QtGui/QMouseEvent> |
| | | #include <QtWidgets/QWidget> |
| | | #include <QtWidgets/QApplication> |
| | | #include <QtWidgets/QWidget> |
| | | |
| | | #include <QWKCore/private/abstractwindowcontext_p.h> |
| | | |
| | | extern Q_DECL_IMPORT QWidget *qt_button_down; |
| | | |
| | | namespace QWK { |
| | | |
| | | class WidgetWinIdChangeEventFilter : public WinIdChangeEventFilter { |
| | | public: |
| | | explicit WidgetWinIdChangeEventFilter(QObject *host, AbstractWindowContext *ctx) |
| | | : WinIdChangeEventFilter(host, ctx), widget(static_cast<QWidget *>(host)) { |
| | | widget->installEventFilter(this); |
| | | } |
| | | |
| | | WId winId() const override { |
| | | return widget->effectiveWinId(); |
| | | } |
| | | |
| | | protected: |
| | | bool eventFilter(QObject *obj, QEvent *event) override { |
| | | Q_UNUSED(obj) |
| | | if (event->type() == QEvent::WinIdChange) { |
| | | context->notifyWinIdChange(); |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | QWidget *widget; |
| | | }; |
| | | |
| | | WidgetItemDelegate::WidgetItemDelegate() = default; |
| | | |
| | |
| | | return static_cast<const QWidget *>(host)->windowFlags(); |
| | | } |
| | | |
| | | QRect WidgetItemDelegate::getGeometry(const QObject *host) const { |
| | | return static_cast<const QWidget *>(host)->geometry(); |
| | | } |
| | | |
| | | void WidgetItemDelegate::setWindowFlags(QObject *host, Qt::WindowFlags flags) const { |
| | | static_cast<QWidget *>(host)->setWindowFlags(flags); |
| | | } |
| | |
| | | static_cast<QWidget *>(host)->setVisible(visible); |
| | | } |
| | | |
| | | void WidgetItemDelegate::setGeometry(QObject *host, const QRect &rect) { |
| | | static_cast<QWidget *>(host)->setGeometry(rect); |
| | | } |
| | | |
| | | void WidgetItemDelegate::bringWindowToTop(QObject *host) const { |
| | | static_cast<QWidget *>(host)->raise(); |
| | | } |
| | | |
| | | WinIdChangeEventFilter * |
| | | WidgetItemDelegate::createWinIdEventFilter(QObject *host, |
| | | AbstractWindowContext *context) const { |
| | | return new WidgetWinIdChangeEventFilter(host, context); |
| | | } |
| | | |
| | | } |