qtquick: Ported the old DockWidgetQuick to the new architecture

Mostly anyway. Facing several blockers that need to be ported first,
for example DockWidget::setWidget() is still receiving QWidget
This commit is contained in:
Sergio Martins
2022-05-08 13:27:37 +01:00
parent 984bcd5f06
commit 76b1a394f2
5 changed files with 169 additions and 317 deletions

View File

@@ -16,51 +16,101 @@
* @author Sérgio Martins \<sergio.martins@kdab.com\>
*/
#pragma once
#ifndef KD_DOCKWIDGET_QUICK_H
#define KD_DOCKWIDGET_QUICK_H
#include "controllers/DockWidget.h"
#include "View_qtquick.h"
QT_BEGIN_NAMESPACE
class QCloseEvent;
class QQmlEngine;
QT_END_NAMESPACE
namespace KDDockWidgets {
namespace Views {
namespace Controllers {
class Frame;
class TitleBar;
}
namespace Views {
/**
* @brief Represents a dock widget.
*
* Most of the interface lives in DockWidgetBase, to facilitate sharing with QtQuick.
*/
class DOCKS_EXPORT DockWidget_qtquick : public View_qtquick<QQuickItem>
class DOCKS_EXPORT DockWidget_qtquick : public Views::View_qtquick
{
Q_OBJECT
Q_PROPERTY(QObject *actualTitleBar READ actualTitleBarObj NOTIFY actualTitleBarChanged)
public:
/**
* @brief constructs a new DockWidget
* @param uniqueName Mandatory name that should be unique between all DockWidget instances.
* This name won't be user visible and just used internally for the save/restore.
* Use setTitle() for user visible text.
* @param uniqueName the name of the dockwidget, should be unique. Use title for user visible text.
* @param options optional options controlling behaviour
* @param layoutSaverOptions options regarding LayoutSaver behaviour
* @param engine the QML engine this dock widget will be created on. If not specified then
* Config::self().qmlEngine() will be used
*
* There's no parent argument. The DockWidget is either parented to FloatingWindow or MainWindow
* when visible, or stays without a parent when hidden. This allows to support docking
* to different main windows.
* when visible, or stays without a parent when hidden.
*/
explicit DockWidget_qtquick(Controllers::DockWidget *controller,
Qt::WindowFlags windowFlags = {});
Qt::WindowFlags windowFlags = {},
QQmlEngine *engine = nullptr);
///@brief destructor
~DockWidget_qtquick() override;
Controllers::DockWidget *dockWidget() const;
/// Sets the DockWidget's guest item
/// Similar to DockWidgetBase::setWidget(QQuickItem*)
void setWidget(const QString &qmlFilename);
/// @reimp
// void setWidget(QQuickItem *widget);
/// @reimp
Q_INVOKABLE void setWidget(QQuickItem *widget);
/// @reimp
QSize minSize() const override;
/// @reimp
QSize maximumSize() const override;
/// @brief Returns the title bar
QObject *actualTitleBar() const;
/// @brief Returns the title bar
/// Qt6 requires us to include TitleBar_p.h, so instead the Q_PROPERTY uses
/// QObject so we don't include private headers in public headers
QObject *actualTitleBarObj() const;
/// @brief Returns the visual item which represents Frame in the screen
/// Equivalent to Frame::visualItem().
QQuickItem *frameVisualItem() const;
///@internal
Q_INVOKABLE KDDockWidgets::Controllers::Frame *frame() const;
/// @brief Called by QtQuick when min-size changes
Q_INVOKABLE void onGeometryUpdated();
Q_SIGNALS:
/// @brief The geometry of the frame container this dock widget is in changed
/// For example, when dragging a dockwidget
void frameGeometryChanged(QRect);
protected:
bool event(QEvent *e) override;
private:
class Private;
Private *const d;
};
}
}
#endif