From dddf96c011723a12b11acc2980c10eb370961021 Mon Sep 17 00:00:00 2001 From: Zhao Yuhang <2546789017@qq.com> Date: 周五, 15 12月 2023 21:35:17 +0800 Subject: [PATCH] add qt impl --- src/widgets/widgetitemdelegate.cpp | 33 +++++++++++++++++++++++++++++---- 1 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/widgets/widgetitemdelegate.cpp b/src/widgets/widgetitemdelegate.cpp index ca8bb99..d838a0f 100644 --- a/src/widgets/widgetitemdelegate.cpp +++ b/src/widgets/widgetitemdelegate.cpp @@ -12,7 +12,7 @@ WidgetItemDelegate::~WidgetItemDelegate() = default; - QWindow *WidgetItemDelegate::window(QObject *obj) const { + QWindow *WidgetItemDelegate::window(const QObject *obj) const { return static_cast<const QWidget *>(obj)->windowHandle(); } @@ -31,7 +31,7 @@ return {originPoint, size}; } - QWindow *WidgetItemDelegate::hostWindow(QObject *host) const { + QWindow *WidgetItemDelegate::hostWindow(const QObject *host) const { return static_cast<const QWidget *>(host)->windowHandle(); } @@ -60,7 +60,8 @@ return static_cast<const QWidget *>(host)->isActiveWindow(); } - void WidgetItemDelegate::resetQtGrabbedControl() const { + void WidgetItemDelegate::resetQtGrabbedControl(QObject *host) const { + Q_UNUSED(host); if (!qt_button_down) { return; } @@ -69,8 +70,32 @@ const auto event = new QMouseEvent( QEvent::MouseButtonRelease, invalidPos, invalidPos, invalidPos, Qt::LeftButton, QGuiApplication::mouseButtons() ^ Qt::LeftButton, QGuiApplication::keyboardModifiers()); - QApplication::postEvent(qt_button_down, event); + QCoreApplication::postEvent(qt_button_down, event); qt_button_down = nullptr; } + Qt::WindowStates WidgetItemDelegate::getWindowState(const QObject *host) const { + return static_cast<const QWidget *>(host)->windowState(); + } + + void WidgetItemDelegate::setWindowState(QObject *host, const Qt::WindowStates &state) const { + static_cast<QWidget *>(host)->setWindowState(state); + } + + void WidgetItemDelegate::setCursorShape(QObject *host, const Qt::CursorShape shape) const { + static_cast<QWidget *>(host)->setCursor(QCursor(shape)); + } + + void WidgetItemDelegate::restoreCursorShape(QObject *host) const { + static_cast<QWidget *>(host)->unsetCursor(); + } + + Qt::WindowFlags WidgetItemDelegate::getWindowFlags(const QObject *host) const { + return static_cast<const QWidget *>(host)->windowFlags(); + } + + void WidgetItemDelegate::setWindowFlags(QObject *host, const Qt::WindowFlags &flags) const { + static_cast<QWidget *>(host)->setWindowFlags(flags); + } + } \ No newline at end of file -- Gitblit v1.9.1