qml: Layout the drop area and title bar inside the FloatingWindow

We could just control geometry of the c++ title bar and geometry,
but then the user wouldn't be able to style it, and users rather
style things in QML than subclassing FloatingWindow and writing C++.

So instance some .qml files to represent the drop area and floating
window, so user can muck with.

Hierarchy looks like this now:

-QQuickWindow
--FloatingWindowQuick (C++ QQuickItem)
---FloatingWindow.qml
----TitleBar.qml (reads state from TitleBar c++)
----DropArea.qml
-----DropArea (C++ QQuickItem)
------Frame
      etc
This commit is contained in:
Sergio Martins
2020-07-29 23:28:05 +01:00
parent c13f9c00aa
commit f8f596ad30
9 changed files with 106 additions and 25 deletions

View File

@@ -24,6 +24,9 @@
#include <QResizeEvent>
#include <QMouseEvent>
#include <QWindow>
#include <QQmlComponent>
#include <QQuickItem>
#include <QQmlEngine>
using namespace KDDockWidgets;
@@ -211,6 +214,18 @@ Qt::WindowFlags QWidgetAdapter::windowFlags() const
return m_requestedWindowFlags;
}
QQuickItem *QWidgetAdapter::createItem(QQmlEngine *engine, const QString &filename) const
{
QQmlComponent component(engine, filename);
QObject *obj = component.create();
if (!obj) {
qWarning() << Q_FUNC_INFO << component.errorString();
return nullptr;
}
return qobject_cast<QQuickItem*>(obj);
}
void QWidgetAdapter::setFlag(Qt::WindowType f, bool on)
{
if (QWindow *w = windowHandle()) {