/* This file is part of KDDockWidgets. SPDX-FileCopyrightText: 2019-2022 Klarälvdalens Datakonsult AB, a KDAB Group company Author: Sérgio Martins SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only Contact KDAB at for commercial licensing options. */ /** * @file * @brief Represents a dock widget. * * @author Sérgio Martins \ */ #ifndef KD_DOCKWIDGET_QUICK_H #define KD_DOCKWIDGET_QUICK_H #include "kddockwidgets/controllers/DockWidget.h" #include "kddockwidgets/views/DockWidgetViewInterface.h" #include "View_qtquick.h" QT_BEGIN_NAMESPACE class QQmlEngine; QT_END_NAMESPACE namespace KDDockWidgets { namespace Controllers { class Frame; class TitleBar; } namespace Views { /** * @brief Represents a dock widget. * * Most of the interface lives in Controllers::DockWidget, to facilitate sharing with QtQuick. */ class DOCKS_EXPORT DockWidget_qtquick : public Views::View_qtquick, public Views::DockWidgetViewInterface { Q_OBJECT Q_PROPERTY(QObject *actualTitleBar READ actualTitleBarView NOTIFY actualTitleBarChanged) public: /** * @brief constructs a new DockWidget * @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. */ explicit DockWidget_qtquick(const QString &uniqueName, Controllers::DockWidget::Options = {}, Controllers::DockWidget::LayoutSaverOptions = {}, Qt::WindowFlags = Qt::Tool, QQmlEngine *engine = nullptr); ///@brief destructor ~DockWidget_qtquick() override; /// Sets the DockWidget's guest item void setGuestItem(const QString &qmlFilename); /// @reimp Q_INVOKABLE void setGuestItem(QQuickItem *); /// @reimp QSize minSize() const override; /// @reimp QSize maximumSize() const override; /// @brief Returns the title bar view /// 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 *actualTitleBarView() const; /// @brief Returns the visual item which represents Frame in the screen /// Equivalent to Frame::visualItem(). QQuickItem *frameVisualItem() 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); void actualTitleBarChanged(); protected: bool event(QEvent *e) override; void init() override; private: class Private; Private *const d; }; } } #endif