Note that a complate Qt6 port will require QML changes.
I don't know of a way to have QML be compatible with both Qt5 and Qt6.
project(AniPlayer)
-set(QT_MIN_VERSION "5.3.0")
+
+
+option(WITH_QT6 "Build with Qt6" OFF)
+add_feature_info(BuildWithQt6 WITH_QT6 "Qt6 build")
option(WITH_DESKTOP_UI "Build default QML desktop UI" ON)
add_feature_info(QmlDesktopUI WITH_DESKTOP_UI "default desktop UI, using QML")
cmake_dependent_option(USE_SHARED_DLIB "Use shared dlib" OFF "WITH_FEATURE_ANNOTATIONS" OFF)
+if (WITH_FEATURE_LOCALMYLIST AND WITH_QT6)
+ message(FATAL_ERROR "LocalMyList is currently not supported with Qt6")
+endif()
+
+if (WITH_QT6)
+ set(QT_PACKAGE "Qt6")
+ set(QT_MIN_VERSION "6.4.0")
+else()
+ set(QT_PACKAGE "Qt5")
+ set(QT_MIN_VERSION "5.3.0")
+endif()
+
add_subdirectory(pluginapi)
add_subdirectory(core)
add_subdirectory(backendplugins)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
project(backend_mpv)
-find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
+find_package(${QT_PACKAGE} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
Core
Gui
Qml
Quick
+ OpenGL
)
set(backend_mpv_LIBS
- Qt5::Core
- Qt5::Gui
+ ${QT_PACKAGE}::Core
+ ${QT_PACKAGE}::Gui
+ ${QT_PACKAGE}::OpenGL
pluginapi
# TODO find_package this
mpv
// "QVariant::Type(obsolete), the return value should be interpreted
// as QMetaType::Type."
// So a cast really seems to be needed to avoid warnings (urgh).
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ return static_cast<int>(v.typeId()) == static_cast<int>(t);
+#else
return static_cast<int>(v.type()) == static_cast<int>(t);
+#endif
}
void set(mpv_node *dst, const QVariant &src) {
if (test_type(src, QMetaType::QString)) {
add_subdirectory("qtsingleapplication")
-find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
+find_package(${QT_PACKAGE} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
Core
Gui
Widgets
Quick
)
-find_package(LocalMyList CONFIG REQUIRED)
-
set(core_LIBS
- Qt5::Core
- Qt5::Gui
- Qt5::Widgets
- Qt5::Qml
- Qt5::Quick
+ ${QT_PACKAGE}::Core
+ ${QT_PACKAGE}::Gui
+ ${QT_PACKAGE}::Widgets
+ ${QT_PACKAGE}::Qml
+ ${QT_PACKAGE}::Quick
pluginapi
qtsingleapplication
)
)
elseif(UNIX AND WITH_FEATURE_DBUS)
add_definitions(-DWITH_FEATURE_DBUS)
- find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
+ find_package(${QT_PACKAGE} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
DBus
)
set(core_LIBS ${core_LIBS}
set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
project(qtsingleapplication)
-find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
+find_package(${QT_PACKAGE} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
Core
Widgets
Network
)
set(qtsingleapplication_LIBS
- Qt5::Core
- Qt5::Widgets
- Qt5::Network
+ ${QT_PACKAGE}::Core
+ ${QT_PACKAGE}::Widgets
+ ${QT_PACKAGE}::Network
)
set(qtsingleapplication_SOURCES
**
****************************************************************************/
-
#include "qtlocalpeer.h"
#include <QCoreApplication>
-#include <QTime>
#include <QDataStream>
+#include <QRegularExpression>
+#include <QTime>
#if defined(Q_OS_WIN)
#include <QLibrary>
#endif
prefix = id.section(QLatin1Char('/'), -1);
}
- prefix.remove(QRegExp("[^a-zA-Z]"));
+ prefix.remove(QRegularExpression("[^a-zA-Z]"));
prefix.truncate(6);
QByteArray idc = id.toUtf8();
- quint16 idNum = qChecksum(idc.constData(), idc.size());
+ quint16 idNum =
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ qChecksum(QByteArrayView{idc.constData(), idc.size()});
+#else
+ qChecksum(idc.constData(), idc.size());
+#endif
socketName = QLatin1String("qtsingleapp-") + prefix
+ QLatin1Char('-') + QString::number(idNum, 16);
set(CMAKE_INCLUDE_CURRENT_DIR ON)
project(feature_annotations)
-find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
+find_package(${QT_PACKAGE} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
Core
Gui
Concurrent
endif()
set(feature_annotations_LIBS
- Qt5::Core
- Qt5::Gui
- Qt5::Concurrent
+ ${QT_PACKAGE}::Core
+ ${QT_PACKAGE}::Gui
+ ${QT_PACKAGE}::Concurrent
${DLIB_LIBRARY_NAME}
pluginapi
)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
project(feature_localmylist)
-find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
+find_package(${QT_PACKAGE} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
Core
)
find_package(LocalMyList CONFIG REQUIRED)
set(feature_localmylist_LIBS
- Qt5::Core
+ ${QT_PACKAGE}::Core
pluginapi
# TODO find_package this
LocalMyList::LocalMyList
)
add_library(pluginapi INTERFACE ${pluginapi_PUBLIC_HEADERS})
-find_package(Qt5 COMPONENTS Core)
-target_link_libraries(pluginapi INTERFACE Qt5::Core)
+find_package(${QT_PACKAGE} COMPONENTS Core)
+target_link_libraries(pluginapi INTERFACE ${QT_PACKAGE}::Core)
install(FILES ${pluginapi_PUBLIC_HEADERS}
DESTINATION include/aniplayer
set(CMAKE_INCLUDE_CURRENT_DIR ON)
project(ui_desktop_qml_default)
-find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
+find_package(${QT_PACKAGE} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS
Core
Gui
Qml
)
set(ui_desktop_qml_default_LIBS
- Qt5::Core
- Qt5::Gui
- Qt5::Qml
- Qt5::Quick
+ ${QT_PACKAGE}::Core
+ ${QT_PACKAGE}::Gui
+ ${QT_PACKAGE}::Qml
+ ${QT_PACKAGE}::Quick
pluginapi
)
+if (WITH_QT6)
+ find_package(${QT_PACKAGE} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS QuickControls2)
+ set(ui_desktop_qml_default_LIBS ${ui_desktop_qml_default_LIBS} ${QT_PACKAGE}::QuickControls2)
+endif()
+
set(ui_desktop_qml_default_SOURCES
uidesktopqmldefault.cpp
timeformatter.cpp
)
set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTOUIC ON)
+# POSSIBLE CMAKE BUG
+# the "ui_" prefix makes cmake think there should be a .ui file to run uic on.
+set(CMAKE_AUTOUIC OFF)
set(CMAKE_AUTORCC ON)
add_library(ui_desktop_qml_default MODULE
qCDebug(uidqdCategory, "Player Added");\r
engine->load(\r
QUrl(QStringLiteral("qrc:/ui_desktop_qml_default/qml/main.qml")));\r
+ m_engine = engine;\r
+ m_player = player;\r
qCDebug(uidqdCategory, "QML engine loaded");\r
}\r
\r
+UiDesktopQmlDefaultInstance::~UiDesktopQmlDefaultInstance() {\r
+ // Ensure the UI is deleted before the player\r
+ delete m_engine;\r
+ delete m_player;\r
+}\r
+\r
UiInstance *UiDesktopQmlDefault::createUi(QObject *player, QObject *settings,\r
QObject *parent) {\r
return new UiDesktopQmlDefaultInstance{player, settings, parent};\r
public:\r
explicit UiDesktopQmlDefaultInstance(QObject *player, QObject *settings,\r
QObject *parent = nullptr);\r
+ ~UiDesktopQmlDefaultInstance() override;\r
+\r
+private:\r
+ QObject *m_engine;\r
+ QObject *m_player;\r
};\r
\r
class UI_DESKTOP_QML_DEFAULTSHARED_EXPORT UiDesktopQmlDefault\r