From d02f3b0bc32f711bf33a7fd288185963e9e96189 Mon Sep 17 00:00:00 2001
From: Yuhang Zhao <zhaoyuhang@rankyee.com>
Date: 周二, 05 12月 2023 16:21:28 +0800
Subject: [PATCH] add isFixedSize implementation

---
 src/widgets/widgetitemdelegate.cpp |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/src/widgets/widgetitemdelegate.cpp b/src/widgets/widgetitemdelegate.cpp
index 08b3804..bfa730c 100644
--- a/src/widgets/widgetitemdelegate.cpp
+++ b/src/widgets/widgetitemdelegate.cpp
@@ -31,6 +31,31 @@
         return {originPoint, size};
     }
 
+    QWindow *WidgetItemDelegate::hostWindow(QObject *host) const {
+        return static_cast<QWidget *>(host)->windowHandle();
+    }
+
+    bool WidgetItemDelegate::isHostSizeFixed(QObject *host) const {
+        const auto widget = static_cast<QWidget *>(host);
+        // "Qt::MSWindowsFixedSizeDialogHint" is used cross-platform actually.
+        if (widget->windowFlags() & Qt::MSWindowsFixedSizeDialogHint) {
+            return true;
+        }
+        // Caused by setFixedWidth/Height/Size().
+        const QSize minSize = widget->minimumSize();
+        const QSize maxSize = widget->maximumSize();
+        if (!minSize.isEmpty() && !maxSize.isEmpty() && (minSize == maxSize)) {
+            return true;
+        }
+        // Usually set by the user.
+        const QSizePolicy sizePolicy = widget->sizePolicy();
+        if ((sizePolicy.horizontalPolicy() == QSizePolicy::Fixed)
+            && (sizePolicy.verticalPolicy() == QSizePolicy::Fixed)) {
+            return true;
+        }
+        return false;
+    }
+
     bool WidgetItemDelegate::resetQtGrabbedControl() const {
         if (qt_button_down) {
             static constexpr const auto invalidPos = QPoint{-99999, -99999};

--
Gitblit v1.9.1