From bc8868d519702c5a55f21377711cf4db54714650 Mon Sep 17 00:00:00 2001 From: SineStriker <55847490+SineStriker@users.noreply.github.com> Date: 周一, 29 1月 2024 22:03:10 +0800 Subject: [PATCH] Fix centerize issue (#34) --- src/widgets/widgetitemdelegate.cpp | 30 ++++++++++++++++++++---------- 1 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/widgets/widgetitemdelegate.cpp b/src/widgets/widgetitemdelegate.cpp index d838a0f..4c7a40b 100644 --- a/src/widgets/widgetitemdelegate.cpp +++ b/src/widgets/widgetitemdelegate.cpp @@ -1,10 +1,14 @@ +// 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> -extern Q_WIDGETS_EXPORT QWidget *qt_button_down; +extern Q_DECL_IMPORT QWidget *qt_button_down; namespace QWK { @@ -47,12 +51,6 @@ 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; } @@ -78,11 +76,11 @@ return static_cast<const QWidget *>(host)->windowState(); } - void WidgetItemDelegate::setWindowState(QObject *host, const Qt::WindowStates &state) const { + void WidgetItemDelegate::setWindowState(QObject *host, Qt::WindowStates state) const { static_cast<QWidget *>(host)->setWindowState(state); } - void WidgetItemDelegate::setCursorShape(QObject *host, const Qt::CursorShape shape) const { + void WidgetItemDelegate::setCursorShape(QObject *host, Qt::CursorShape shape) const { static_cast<QWidget *>(host)->setCursor(QCursor(shape)); } @@ -94,8 +92,20 @@ return static_cast<const QWidget *>(host)->windowFlags(); } - void WidgetItemDelegate::setWindowFlags(QObject *host, const Qt::WindowFlags &flags) const { + 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); } + void WidgetItemDelegate::setWindowVisible(QObject *host, bool visible) const { + static_cast<QWidget *>(host)->setVisible(visible); + } + + void WidgetItemDelegate::bringWindowToTop(QObject *host) const { + static_cast<QWidget *>(host)->raise(); + } + } \ No newline at end of file -- Gitblit v1.9.1