| | |
| | | |
| | | WidgetItemDelegate::~WidgetItemDelegate() = default; |
| | | |
| | | QWindow *WidgetItemDelegate::window(QObject *obj) const { |
| | | return static_cast<QWidget *>(obj)->windowHandle(); |
| | | QWindow *WidgetItemDelegate::window(const QObject *obj) const { |
| | | return static_cast<const QWidget *>(obj)->windowHandle(); |
| | | } |
| | | |
| | | bool WidgetItemDelegate::isEnabled(QObject *obj) const { |
| | | return static_cast<QWidget *>(obj)->isEnabled(); |
| | | bool WidgetItemDelegate::isEnabled(const QObject *obj) const { |
| | | return static_cast<const QWidget *>(obj)->isEnabled(); |
| | | } |
| | | |
| | | bool WidgetItemDelegate::isVisible(QObject *obj) const { |
| | | return static_cast<QWidget *>(obj)->isVisible(); |
| | | bool WidgetItemDelegate::isVisible(const QObject *obj) const { |
| | | return static_cast<const QWidget *>(obj)->isVisible(); |
| | | } |
| | | |
| | | QRect WidgetItemDelegate::mapGeometryToScene(const QObject *obj) const { |
| | |
| | | return {originPoint, size}; |
| | | } |
| | | |
| | | bool WidgetItemDelegate::resetQtGrabbedControl() const { |
| | | if (qt_button_down) { |
| | | static constexpr const auto invalidPos = QPoint{-99999, -99999}; |
| | | const auto event = |
| | | new QMouseEvent(QEvent::MouseButtonRelease, invalidPos, invalidPos, invalidPos, |
| | | Qt::LeftButton, QGuiApplication::mouseButtons() ^ Qt::LeftButton, |
| | | QGuiApplication::keyboardModifiers()); |
| | | QApplication::postEvent(qt_button_down, event); |
| | | qt_button_down = nullptr; |
| | | QWindow *WidgetItemDelegate::hostWindow(const QObject *host) const { |
| | | return static_cast<const QWidget *>(host)->windowHandle(); |
| | | } |
| | | |
| | | bool WidgetItemDelegate::isHostSizeFixed(const QObject *host) const { |
| | | const auto widget = static_cast<const 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::isWindowActive(const QObject *host) const { |
| | | return static_cast<const QWidget *>(host)->isActiveWindow(); |
| | | } |
| | | |
| | | void WidgetItemDelegate::resetQtGrabbedControl(QObject *host) const { |
| | | Q_UNUSED(host); |
| | | if (!qt_button_down) { |
| | | return; |
| | | } |
| | | static constexpr const auto invalidPos = |
| | | QPoint{std::numeric_limits<int>::lowest(), std::numeric_limits<int>::lowest()}; |
| | | const auto event = new QMouseEvent( |
| | | QEvent::MouseButtonRelease, invalidPos, invalidPos, invalidPos, Qt::LeftButton, |
| | | QGuiApplication::mouseButtons() ^ Qt::LeftButton, QGuiApplication::keyboardModifiers()); |
| | | 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); |
| | | } |
| | | |
| | | } |