qtquick: Move m_qmlEngine from Config to Platform_qtquick
As it's QtQuick specific it should be in the qtquick frontend folder.
This commit is contained in:
@@ -207,6 +207,7 @@ set(KDDW_QTQUICK_FRONTEND_SRCS
|
||||
qtquick/Window_qtquick.h
|
||||
qtquick/Platform_qtquick.cpp
|
||||
qtquick/Platform_qtquick.h
|
||||
qtquick/Helpers.cpp
|
||||
qtquick/TestHelpers_qtquick.cpp
|
||||
qtquick/LayoutSaverInstantiator.cpp
|
||||
qtquick/LayoutSaverInstantiator.h
|
||||
|
||||
@@ -30,12 +30,6 @@
|
||||
#include <QDebug>
|
||||
#include <QOperatingSystemVersion>
|
||||
|
||||
#ifdef KDDOCKWIDGETS_QTQUICK
|
||||
#include "private/quick/Helpers_p.h"
|
||||
#include <QQmlEngine>
|
||||
#include <QQmlContext>
|
||||
#endif
|
||||
|
||||
namespace KDDockWidgets {
|
||||
|
||||
class Config::Private
|
||||
@@ -53,7 +47,6 @@ public:
|
||||
|
||||
void fixFlags();
|
||||
|
||||
QQmlEngine *m_qmlEngine = nullptr;
|
||||
DockWidgetFactoryFunc m_dockWidgetFactoryFunc = nullptr;
|
||||
MainWindowFactoryFunc m_mainWindowFactoryFunc = nullptr;
|
||||
TabbingAllowedFunc m_tabbingAllowedFunc = nullptr;
|
||||
@@ -65,9 +58,6 @@ public:
|
||||
qreal m_draggedWindowOpacity = Q_QNAN;
|
||||
int m_mdiPopupThreshold = 250;
|
||||
bool m_dropIndicatorsInhibited = false;
|
||||
#ifdef KDDOCKWIDGETS_QTQUICK
|
||||
QtQuickHelpers m_qquickHelpers;
|
||||
#endif
|
||||
};
|
||||
|
||||
Config::Config()
|
||||
@@ -234,38 +224,6 @@ void Config::setInternalFlags(InternalFlags flags)
|
||||
d->m_internalFlags = flags;
|
||||
}
|
||||
|
||||
#ifdef KDDOCKWIDGETS_QTQUICK
|
||||
void Config::setQmlEngine(QQmlEngine *qmlEngine)
|
||||
{
|
||||
if (d->m_qmlEngine) {
|
||||
qWarning() << Q_FUNC_INFO << "Already has QML engine";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!qmlEngine) {
|
||||
qWarning() << Q_FUNC_INFO << "Null QML engine";
|
||||
return;
|
||||
}
|
||||
|
||||
auto dr = DockRegistry::self(); // make sure our QML types are registered
|
||||
QQmlContext *context = qmlEngine->rootContext();
|
||||
context->setContextProperty(QStringLiteral("_kddwHelpers"), &d->m_qquickHelpers);
|
||||
context->setContextProperty(QStringLiteral("_kddwDockRegistry"), dr);
|
||||
context->setContextProperty(QStringLiteral("_kddwDragController"), DragController::instance());
|
||||
context->setContextProperty(QStringLiteral("_kddw_widgetFactory"), d->m_frameworkWidgetFactory);
|
||||
|
||||
d->m_qmlEngine = qmlEngine;
|
||||
}
|
||||
|
||||
QQmlEngine *Config::qmlEngine() const
|
||||
{
|
||||
if (!d->m_qmlEngine)
|
||||
qWarning() << "Please call KDDockWidgets::Config::self()->setQmlEngine(engine)";
|
||||
|
||||
return d->m_qmlEngine;
|
||||
}
|
||||
#endif
|
||||
|
||||
void Config::Private::fixFlags()
|
||||
{
|
||||
#if defined(Q_OS_WIN)
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
#include <qglobal.h>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QQmlEngine;
|
||||
class QSize;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
@@ -316,12 +315,6 @@ public:
|
||||
void setMDIPopupThreshold(int);
|
||||
int mdiPopupThreshold() const;
|
||||
|
||||
#ifdef KDDOCKWIDGETS_QTQUICK
|
||||
///@brief Sets the QQmlEngine to use. Applicable only when using QtQuick.
|
||||
void setQmlEngine(QQmlEngine *);
|
||||
QQmlEngine *qmlEngine() const;
|
||||
#endif
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(Config)
|
||||
Config();
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
*/
|
||||
|
||||
#include "Helpers_p.h"
|
||||
#include "QWidgetAdapter.h"
|
||||
|
||||
#include <QQuickItem>
|
||||
|
||||
@@ -19,5 +18,5 @@ using namespace KDDockWidgets;
|
||||
qreal QtQuickHelpers::logicalDpiFactor(const QQuickItem *) const
|
||||
{
|
||||
return 1; // TODO: Support the actual dpi factor.
|
||||
//return KDDockWidgets::logicalDpiFactor(item);
|
||||
// return KDDockWidgets::logicalDpiFactor(item);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
#include "Window_qtquick.h"
|
||||
#include "views/View_qtquick.h"
|
||||
#include "qtquick/Window_qtquick.h"
|
||||
#include "private/DockRegistry_p.h"
|
||||
#include "private/DragController_p.h"
|
||||
#include "FrameworkWidgetFactory.h"
|
||||
|
||||
#include <QQmlEngine>
|
||||
#include <QQuickStyle>
|
||||
@@ -25,10 +28,11 @@
|
||||
#include <QScreen>
|
||||
#include <QQuickItem>
|
||||
#include <QGuiApplication>
|
||||
#include <QQmlContext>
|
||||
|
||||
using namespace KDDockWidgets;
|
||||
|
||||
QQmlEngine *Platform_qtquick::m_qmlEngine = nullptr;
|
||||
// QQmlEngine *Platform_qtquick::m_qmlEngine = nullptr;
|
||||
|
||||
Platform_qtquick::Platform_qtquick()
|
||||
{
|
||||
@@ -106,3 +110,31 @@ QSize Platform_qtquick::screenSizeFor(View *view) const
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
QQmlEngine *Platform_qtquick::qmlEngine() const
|
||||
{
|
||||
if (!m_qmlEngine)
|
||||
qWarning() << "Please call KDDockWidgets::Platform_qtquick::self()->setQmlEngine(engine)";
|
||||
|
||||
return m_qmlEngine;
|
||||
}
|
||||
|
||||
void Platform_qtquick::setQmlEngine(QQmlEngine *qmlEngine)
|
||||
{
|
||||
if (m_qmlEngine) {
|
||||
qWarning() << Q_FUNC_INFO << "Already has QML engine";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!qmlEngine) {
|
||||
qWarning() << Q_FUNC_INFO << "Null QML engine";
|
||||
return;
|
||||
}
|
||||
|
||||
auto dr = DockRegistry::self(); // make sure our QML types are registered
|
||||
QQmlContext *context = qmlEngine->rootContext();
|
||||
context->setContextProperty(QStringLiteral("_kddwHelpers"), &m_qquickHelpers);
|
||||
context->setContextProperty(QStringLiteral("_kddwDockRegistry"), dr);
|
||||
context->setContextProperty(QStringLiteral("_kddwDragController"), DragController::instance());
|
||||
context->setContextProperty(QStringLiteral("_kddw_widgetFactory"), Config::self().frameworkWidgetFactory());
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include "KDDockWidgets.h"
|
||||
#include "qtcommon/Platform_qt.h"
|
||||
#include "Helpers_p.h"
|
||||
|
||||
class QQmlEngine;
|
||||
|
||||
@@ -33,17 +34,24 @@ public:
|
||||
using Platform_qt::screenNumberFor;
|
||||
int screenNumberFor(View *) const override;
|
||||
QSize screenSizeFor(View *) const override;
|
||||
void setQmlEngine(QQmlEngine *);
|
||||
QQmlEngine *qmlEngine() const;
|
||||
|
||||
#ifdef DOCKS_DEVELOPER_MODE
|
||||
explicit Platform_qtquick(int argc, char *argv[]);
|
||||
void tests_initPlatform_impl() override;
|
||||
void tests_deinitPlatform_impl() override;
|
||||
View *tests_createView(CreateViewOptions, View *parent = nullptr) override;
|
||||
|
||||
static QQmlEngine *m_qmlEngine;
|
||||
#endif
|
||||
private:
|
||||
void init();
|
||||
QQmlEngine *m_qmlEngine = nullptr;
|
||||
QtQuickHelpers m_qquickHelpers;
|
||||
};
|
||||
|
||||
inline Platform_qtquick *plat()
|
||||
{
|
||||
return static_cast<Platform_qtquick *>(Platform::instance());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ void Platform_qtquick::tests_initPlatform_impl()
|
||||
Platform_qt::tests_initPlatform_impl();
|
||||
|
||||
QQuickStyle::setStyle(QStringLiteral("Material")); // so we don't load KDE plugins
|
||||
m_qmlEngine = new QQmlEngine();
|
||||
plat()->setQmlEngine(new QQmlEngine());
|
||||
}
|
||||
|
||||
void Platform_qtquick::tests_deinitPlatform_impl()
|
||||
|
||||
Reference in New Issue
Block a user