18#include "core/Logging_p.h"
19#include "core/Utils_p.h"
20#include "core/View_p.h"
21#include "core/FloatingWindow_p.h"
22#include "core/layouting/Item_p.h"
24#include "kddockwidgets/core/DropArea.h"
25#include "kddockwidgets/core/FloatingWindow.h"
26#include "kddockwidgets/core/MainWindow.h"
27#include "kddockwidgets/core/TitleBar.h"
29#include "core/WidgetResizeHandler_p.h"
31#include "qtquick/Window_p.h"
44class QuickView :
public QQuickView
49 : QQuickView(qmlEngine, nullptr)
58 connect(item, &QQuickItem::widthChanged,
this, &QuickView::onRootItemWidthChanged);
59 connect(item, &QQuickItem::heightChanged,
this, &QuickView::onRootItemHeightChanged);
62 ~QuickView()
override;
64 bool event(
QEvent *ev)
override
81 Core::AtomicSanityChecks checks(m_view->rootItem());
82 auto res = QQuickView::event(ev);
85 return QQuickView::event(ev);
89 void onRootItemWidthChanged()
91 setWidth(
int(m_view->width()));
94 void onRootItemHeightChanged()
96 setHeight(
int(m_view->height()));
101 resize(m_view->Core::View::size());
104 void updateRootItemSize()
106 if (m_view->asFloatingWindowController()->beingDeleted())
109 Core::AtomicSanityChecks checks(m_view->rootItem());
110 m_view->Core::View::setSize(size());
113#ifdef KDDW_FRONTEND_QT_WINDOWS
114 bool nativeEvent(
const QByteArray &eventType,
void *message,
115 Qt5Qt6Compat::qintptr *result)
override
120 && WidgetResizeHandler::handleWindowsNativeEvent(fw, eventType, message, result))
130QuickView::~QuickView() =
default;
139 , m_quickWindow(new QuickView(
plat()->qmlEngine(), this))
140 , m_controller(controller)
149 if (qobject_cast<QQuickView *>(m_quickWindow))
151 delete m_quickWindow;
158 const int margins = contentsMargins();
160 +
QSize(margins * 2, margins * 2);
168 parentItem()->setSize(geo.
size());
169 m_quickWindow->setGeometry(geo);
172int FloatingWindow::contentsMargins()
const
174 return m_visualItem->property(
"margins").toInt();
177int FloatingWindow::titleBarHeight()
const
179 return m_visualItem->property(
"titleBarHeight").toInt();
182QWindow *FloatingWindow::candidateParentWindow()
const
185 return mainWindow->QQuickItem::window();
191void FloatingWindow::init()
193 if (
QWindow *transientParent = candidateParentWindow()) {
194 m_quickWindow->setTransientParent(candidateParentWindow());
197 m_quickWindow->QObject::setParent(transientParent);
198 m_quickWindow->setObjectName(QStringLiteral(
"Floating QWindow with parent"));
200 m_quickWindow->setObjectName(QStringLiteral(
"Floating QWindow"));
204 WidgetResizeHandler::setupWindow(Core::Window::Ptr(
new QtQuick::Window(m_quickWindow)));
205 m_quickWindow->installEventFilter(
this);
208 m_visualItem =
createItem(m_quickWindow->engine(),
209 plat()->viewFactory()->floatingWindowFilename().toString());
210 Q_ASSERT(m_visualItem);
215 m_visualItem->setParent(
this);
216 m_visualItem->setParentItem(
this);
218 m_quickWindow->setFlags(
flags());
222 m_quickWindow->show();
224 connect(
this, &QQuickItem::visibleChanged,
this, [
this] {
232 if (
auto tb = m_controller->
titleBar())
233 return qobject_cast<TitleBar *>(
asQQuickItem(tb->view()));
240 if (
auto da = m_controller->
dropArea())
241 return qobject_cast<DropArea *>(
asQQuickItem(da->view()));
248 if (
auto da = m_controller->
dropArea())
249 return da->rootItem();
256 m_controller->
dptr()->windowStateChanged.emit();
259#include "FloatingWindow.moc"
Application-wide config to tune certain behaviours of the framework.
A docking area for dock widgets Named MainWindow as it's the QtWidgets/QMainWindow counterpart....
void connect(T &&future, QObjectSubclass *context, Callback func)
QEvent::Type type() const const
QObject * parent() const const
void setSize(const QSize &size)
QSize expandedTo(const QSize &otherSize) const const
A factory class for allowing the user to customize some internal widgets.
virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result)
void windowStateChanged(Qt::WindowState windowState)