qtquick: Allow the user to pass a different QQmlEngine to DockWidget
Like was the case in v1.x
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "DockWidgetInstantiator.h"
|
||||
#include "private/DockRegistry_p.h"
|
||||
#include "ViewFactory.h"
|
||||
#include "ViewFactory_qtquick.h"
|
||||
#include "Config.h"
|
||||
|
||||
using namespace KDDockWidgets;
|
||||
@@ -193,8 +193,7 @@ void DockWidgetInstantiator::componentComplete()
|
||||
return;
|
||||
}
|
||||
|
||||
// TODOm2: Pass qmlEngine(this). Instantiate the DockWidget view directly.
|
||||
m_dockWidget = Config::self().viewFactory()->createDockWidget(m_uniqueName)->asDockWidgetController();
|
||||
m_dockWidget = ViewFactory_qtquick::self()->createDockWidget(m_uniqueName, qmlEngine(this))->asDockWidgetController();
|
||||
|
||||
connect(m_dockWidget, &Controllers::DockWidget::titleChanged, this,
|
||||
&DockWidgetInstantiator::titleChanged);
|
||||
|
||||
@@ -53,7 +53,16 @@ View *ViewFactory_qtquick::createDockWidget(const QString &uniqueName,
|
||||
Controllers::DockWidget::LayoutSaverOptions layoutSaverOptions,
|
||||
Qt::WindowFlags windowFlags) const
|
||||
{
|
||||
return new Views::DockWidget_qtquick(uniqueName, options, layoutSaverOptions, windowFlags);
|
||||
return createDockWidget(uniqueName, /*engine=*/nullptr, options, layoutSaverOptions, windowFlags);
|
||||
}
|
||||
|
||||
View *ViewFactory_qtquick::createDockWidget(const QString &uniqueName,
|
||||
QQmlEngine *qmlEngine,
|
||||
Controllers::DockWidget::Options options,
|
||||
Controllers::DockWidget::LayoutSaverOptions layoutSaverOptions,
|
||||
Qt::WindowFlags windowFlags) const
|
||||
{
|
||||
return new Views::DockWidget_qtquick(uniqueName, options, layoutSaverOptions, windowFlags, qmlEngine);
|
||||
}
|
||||
|
||||
View *ViewFactory_qtquick::createFrame(Controllers::Frame *controller, View *parent) const
|
||||
@@ -200,3 +209,14 @@ Views::ClassicIndicatorWindow *ViewFactory_qtquick::createClassicIndicatorWindow
|
||||
{
|
||||
return new IndicatorWindow_qtquick(classicIndicators);
|
||||
}
|
||||
|
||||
ViewFactory_qtquick *ViewFactory_qtquick::self()
|
||||
{
|
||||
auto factory = qobject_cast<ViewFactory_qtquick *>(Config::self().viewFactory());
|
||||
|
||||
if (!factory)
|
||||
qWarning() << Q_FUNC_INFO << "Expected a ViewFactory_qtquick subclass, not"
|
||||
<< Config::self().viewFactory();
|
||||
|
||||
return factory;
|
||||
}
|
||||
|
||||
@@ -25,12 +25,9 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAbstractButton;
|
||||
class QQmlEngine;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Layouting {
|
||||
class Widget;
|
||||
}
|
||||
|
||||
namespace KDDockWidgets {
|
||||
|
||||
class DropIndicatorOverlay;
|
||||
@@ -58,6 +55,10 @@ public:
|
||||
Controllers::DockWidget::Options options = {},
|
||||
Controllers::DockWidget::LayoutSaverOptions layoutSaverOptions = {},
|
||||
Qt::WindowFlags windowFlags = {}) const override;
|
||||
virtual View *createDockWidget(const QString &uniqueName,
|
||||
QQmlEngine *, Controllers::DockWidget::Options options = {},
|
||||
Controllers::DockWidget::LayoutSaverOptions layoutSaverOptions = {},
|
||||
Qt::WindowFlags windowFlags = {}) const;
|
||||
View *createFrame(Controllers::Frame *, View *parent) const override;
|
||||
View *createTitleBar(Controllers::TitleBar *, Controllers::Frame *) const override;
|
||||
View *createTitleBar(Controllers::TitleBar *, Controllers::FloatingWindow *) const override;
|
||||
@@ -82,6 +83,8 @@ public:
|
||||
Views::ClassicIndicatorWindow *createClassicIndicatorWindow(Controllers::ClassicIndicators *) const override;
|
||||
View *createSegmentedDropIndicatorOverlayView(Controllers::SegmentedIndicators *controller, View *parent = nullptr) const override;
|
||||
|
||||
static ViewFactory_qtquick *self();
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(ViewFactory_qtquick)
|
||||
};
|
||||
|
||||
@@ -27,9 +27,6 @@ QT_BEGIN_NAMESPACE
|
||||
class QAbstractButton;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Layouting {
|
||||
class Widget;
|
||||
}
|
||||
|
||||
namespace KDDockWidgets {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user