KDDockWidgets API Documentation  1.5
QWidgetAdapter_widgets.cpp
Go to the documentation of this file.
1 /*
2  This file is part of KDDockWidgets.
3 
4  SPDX-FileCopyrightText: 2019-2022 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
5  Author: SĂ©rgio Martins <sergio.martins@kdab.com>
6 
7  SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
8 
9  Contact KDAB at <info@kdab.com> for commercial licensing options.
10 */
11 
21 #include "QWidgetAdapter.h"
22 #include "../FloatingWindow_p.h"
23 #include "../Utils_p.h"
24 #include "Qt5Qt6Compat_p.h"
25 
26 #include <QResizeEvent>
27 #include <QMouseEvent>
28 #include <QWindow>
29 
30 #include <QtWidgets/private/qwidget_p.h>
31 
32 using namespace KDDockWidgets;
33 
34 QWidgetAdapter::QWidgetAdapter(QWidget *parent, Qt::WindowFlags f)
35  : QWidget(parent, f)
36 {
37 }
38 
39 QWidgetAdapter::~QWidgetAdapter()
40 {
41 }
42 
43 FloatingWindow *QWidgetAdapter::floatingWindow() const
44 {
45  if (auto fw = qobject_cast<FloatingWindow *>(window()))
46  return fw;
47 
48  return nullptr;
49 }
50 
51 void QWidgetAdapter::raiseAndActivate()
52 {
53  window()->raise();
54  if (!isWayland())
55  window()->activateWindow();
56 }
57 
58 bool QWidgetAdapter::event(QEvent *e)
59 {
60  if (e->type() == QEvent::LayoutRequest)
61  onLayoutRequest();
62 
63  return QWidget::event(e);
64 }
65 
66 void QWidgetAdapter::resizeEvent(QResizeEvent *ev)
67 {
68  if (!onResize(ev->size()))
70 }
71 
72 void QWidgetAdapter::mousePressEvent(QMouseEvent *)
73 {
74  onMousePress();
75 }
76 
77 void QWidgetAdapter::mouseMoveEvent(QMouseEvent *ev)
78 {
79  onMouseMove(Qt5Qt6Compat::eventGlobalPos(ev));
80 }
81 
82 void QWidgetAdapter::mouseReleaseEvent(QMouseEvent *)
83 {
84  onMouseRelease();
85 }
86 
87 void QWidgetAdapter::closeEvent(QCloseEvent *e)
88 {
89  onCloseEvent(e);
90 }
91 
92 void QWidgetAdapter::setFlag(Qt::WindowType f, bool on)
93 {
95 }
96 
97 void QWidgetAdapter::setSize(QSize size)
98 {
99  QRect geo = geometry();
100  geo.setSize(size);
101  setGeometry(geo);
102 }
103 
104 bool QWidgetAdapter::onResize(QSize)
105 {
106  return false;
107 }
108 void QWidgetAdapter::onLayoutRequest()
109 {
110 }
111 
112 void QWidgetAdapter::onMousePress()
113 {
114 }
115 void QWidgetAdapter::onMouseMove(QPoint)
116 {
117 }
118 void QWidgetAdapter::onMouseRelease()
119 {
120 }
121 
122 void QWidgetAdapter::onCloseEvent(QCloseEvent *)
123 {
124 }
125 
126 QWidget *KDDockWidgets::Private::widgetForWindow(QWindow *window)
127 {
128  if (!window)
129  return nullptr;
130 
131  return window->property("kddockwidgets_qwidget").value<QWidget *>();
132 }
133 
134 void QWidgetAdapter::setNormalGeometry(QRect geo)
135 {
136  if (isNormalWindowState(windowState())) {
137  setGeometry(geo);
138  } else {
139  QWidgetPrivate *priv = QWidgetPrivate::get(this);
140  if (priv->extra && priv->extra->topextra) {
141  priv->topData()->normalGeometry = geo;
142  } else {
143  qWarning() << Q_FUNC_INFO << "Failing to set normal geometry";
144  }
145  }
146 }
147 
148 LayoutGuestWidget::~LayoutGuestWidget() = default;
QRect::setSize
void setSize(const QSize &size)
QEvent::LayoutRequest
LayoutRequest
QRect
QVariant::value
T value() const const
QWidget::resizeEvent
virtual void resizeEvent(QResizeEvent *event)
QWindow
QWidget::event
virtual bool event(QEvent *event) override
QWidget
QSize
QResizeEvent::size
const QSize & size() const const
QMouseEvent
QWidgetAdapter.h
Abstraction for supporting both QtWidgets and QtQuick.
Qt::WindowFlags
typedef WindowFlags
QCloseEvent
QWidget::raise
void raise()
QEvent::type
QEvent::Type type() const const
QEvent
QResizeEvent
KDDockWidgets
Definition: Config.cpp:36
QPoint
QWidget::setWindowFlag
void setWindowFlag(Qt::WindowType flag, bool on)
QObject::property
QVariant property(const char *name) const const

© 2019-2022 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
KDDockWidgets
Advanced Dock Widget Framework for Qt
https://www.kdab.com/development-resources/qt-tools/kddockwidgets/
Generated on Mon Mar 7 2022 02:01:21 for KDDockWidgets API Documentation by doxygen 1.8.20