Add KDDockWidgets::initPlatform()
Instead of using the static variable, which is initialized before having QApplication. Will allow us to remove the QTimer from Platform init
This commit is contained in:
@@ -22,6 +22,7 @@ add_definitions(-DQT_NO_SIGNALS_SLOTS_KEYWORDS
|
||||
)
|
||||
|
||||
set(DOCKSLIBS_SRCS
|
||||
KDDockWidgets.cpp
|
||||
Config.cpp
|
||||
Config.h
|
||||
Qt5Qt6Compat_p.h
|
||||
|
||||
33
src/KDDockWidgets.cpp
Normal file
33
src/KDDockWidgets.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
This file is part of KDDockWidgets.
|
||||
|
||||
SPDX-FileCopyrightText: 2019-2022 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
|
||||
Author: Sérgio Martins <sergio.martins@kdab.com>
|
||||
|
||||
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
|
||||
|
||||
Contact KDAB at <info@kdab.com> for commercial licensing options.
|
||||
*/
|
||||
|
||||
|
||||
#include "KDDockWidgets.h"
|
||||
|
||||
#include "qtwidgets/Platform_qtwidgets.h"
|
||||
#include "qtquick/Platform_qtquick.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
void KDDockWidgets::initFrontend(FrontendType type)
|
||||
{
|
||||
if (Platform::instance())
|
||||
return;
|
||||
|
||||
switch (type) {
|
||||
case FrontendType::QtWidgets:
|
||||
new Platform_qtwidgets();
|
||||
break;
|
||||
case FrontendType::QtQuick:
|
||||
// new Platform_qtquick(); // TODOv2
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -60,12 +60,12 @@ enum MainWindowOption {
|
||||
Q_DECLARE_FLAGS(MainWindowOptions, MainWindowOption)
|
||||
Q_ENUM_NS(MainWindowOptions)
|
||||
|
||||
enum class FrontEndType
|
||||
enum class FrontendType
|
||||
{
|
||||
QtWidgets = 1,
|
||||
QtQuick
|
||||
};
|
||||
Q_ENUM_NS(FrontEndType)
|
||||
Q_ENUM_NS(FrontendType)
|
||||
|
||||
///@internal
|
||||
///@brief Describes some sizing strategies for the layouting engine.
|
||||
@@ -310,7 +310,11 @@ inline QString locationStr(Location loc)
|
||||
|
||||
return QString();
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Initializes the desired frontend
|
||||
void DOCKS_EXPORT initFrontend(FrontendType);
|
||||
|
||||
} // end namespace
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
///@internal
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*/
|
||||
|
||||
#include "Platform.h"
|
||||
|
||||
#include <qglobal.h>
|
||||
#include <QDebug>
|
||||
|
||||
@@ -19,6 +20,7 @@ static Platform *s_platform = nullptr;
|
||||
|
||||
Platform::Platform()
|
||||
{
|
||||
Q_ASSERT(!s_platform);
|
||||
s_platform = this;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "Window_qt.h"
|
||||
|
||||
#include <QWindow>
|
||||
#include <QDebug>
|
||||
#include <QGuiApplication>
|
||||
|
||||
using namespace KDDockWidgets;
|
||||
@@ -20,6 +21,8 @@ using namespace KDDockWidgets;
|
||||
|
||||
Platform_qt::Platform_qt()
|
||||
{
|
||||
if (!qApp)
|
||||
qWarning() << "Please call KDDockWidgets::initPlatform() after QGuiApplication";
|
||||
}
|
||||
|
||||
Platform_qt::~Platform_qt()
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
#include <QTimer>
|
||||
#include <QWindow>
|
||||
|
||||
static KDDockWidgets::Platform_qtquick s_platformQtQuick;
|
||||
|
||||
using namespace KDDockWidgets;
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
#include <memory.h>
|
||||
|
||||
static KDDockWidgets::Platform_qtwidgets s_platformQtWidgets;
|
||||
|
||||
using namespace KDDockWidgets;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user