1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-03-03 20:39:40 +00:00

Add an initial Qt6 support

This commit is contained in:
Andrei Kortunov 2023-02-05 15:30:28 +04:00
parent 72efd3a650
commit 7e2aedf637
10 changed files with 50 additions and 23 deletions

View file

@ -934,7 +934,7 @@ printf "Qt ${QT_VER}... "
else else
DLLSUFFIX="" DLLSUFFIX=""
fi fi
add_runtime_dlls $CONFIGURATION "$(pwd)/bin/Qt5"{Core,Gui,Network,OpenGL,Widgets}${DLLSUFFIX}.dll add_runtime_dlls $CONFIGURATION "$(pwd)/bin/Qt${QT_VER:0:1}"{Core,Gui,Network,OpenGL,Widgets}${DLLSUFFIX}.dll
add_qt_platform_dlls $CONFIGURATION "$(pwd)/plugins/platforms/qwindows${DLLSUFFIX}.dll" add_qt_platform_dlls $CONFIGURATION "$(pwd)/plugins/platforms/qwindows${DLLSUFFIX}.dll"
add_qt_style_dlls $CONFIGURATION "$(pwd)/plugins/styles/qwindowsvistastyle${DLLSUFFIX}.dll" add_qt_style_dlls $CONFIGURATION "$(pwd)/plugins/styles/qwindowsvistastyle${DLLSUFFIX}.dll"
done done

View file

@ -131,7 +131,7 @@ configure_file ("${OpenMW_SOURCE_DIR}/docs/mainpage.hpp.cmake" "${OpenMW_BINARY_
option(BOOST_STATIC "Link static build of Boost into the binaries" FALSE) option(BOOST_STATIC "Link static build of Boost into the binaries" FALSE)
option(SDL2_STATIC "Link static build of SDL into the binaries" FALSE) option(SDL2_STATIC "Link static build of SDL into the binaries" FALSE)
option(QT_STATIC "Link static build of QT into the binaries" FALSE) option(QT_STATIC "Link static build of Qt into the binaries" FALSE)
option(OPENMW_USE_SYSTEM_BULLET "Use system provided bullet physics library" ON) option(OPENMW_USE_SYSTEM_BULLET "Use system provided bullet physics library" ON)
if(OPENMW_USE_SYSTEM_BULLET) if(OPENMW_USE_SYSTEM_BULLET)
@ -236,10 +236,14 @@ find_package(OpenGL REQUIRED)
find_package(LZ4 REQUIRED) find_package(LZ4 REQUIRED)
if (USE_QT) if (USE_QT)
find_package(Qt5Core 5.12 REQUIRED) find_package(Qt5 5.15 COMPONENTS Core Widgets Network OpenGL)
find_package(Qt5Widgets REQUIRED) if (Qt5_FOUND)
find_package(Qt5Network REQUIRED) message(STATUS "Using Qt5")
find_package(Qt5OpenGL REQUIRED) else()
find_package(Qt6 6.4 COMPONENTS Core Widgets Network OpenGL REQUIRED)
message(STATUS "Using Qt6")
message(STATUS "Warning: Qt6 support is experimental and incomplete")
endif()
endif() endif()
set(USED_OSG_COMPONENTS set(USED_OSG_COMPONENTS
@ -618,7 +622,7 @@ endif (CMAKE_CXX_COMPILER_ID STREQUAL GNU OR CMAKE_CXX_COMPILER_ID STREQUAL Clan
add_subdirectory (extern/osg-ffmpeg-videoplayer) add_subdirectory (extern/osg-ffmpeg-videoplayer)
add_subdirectory (extern/oics) add_subdirectory (extern/oics)
add_subdirectory (extern/Base64) add_subdirectory (extern/Base64)
if (BUILD_OPENCS) if (BUILD_OPENCS AND Qt5_FOUND)
add_subdirectory (extern/osgQt) add_subdirectory (extern/osgQt)
endif() endif()
@ -815,13 +819,13 @@ if (OPENMW_OSX_DEPLOYMENT AND APPLE)
message(FATAL_ERROR "macOS packaging requires CMake 3.19 or higher to sign macOS app bundles.") message(FATAL_ERROR "macOS packaging requires CMake 3.19 or higher to sign macOS app bundles.")
endif () endif ()
get_property(QT_COCOA_PLUGIN_PATH TARGET Qt5::QCocoaIntegrationPlugin PROPERTY LOCATION_RELEASE) get_property(QT_COCOA_PLUGIN_PATH TARGET Qt::QCocoaIntegrationPlugin PROPERTY LOCATION_RELEASE)
get_filename_component(QT_COCOA_PLUGIN_DIR "${QT_COCOA_PLUGIN_PATH}" DIRECTORY) get_filename_component(QT_COCOA_PLUGIN_DIR "${QT_COCOA_PLUGIN_PATH}" DIRECTORY)
get_filename_component(QT_COCOA_PLUGIN_GROUP "${QT_COCOA_PLUGIN_DIR}" NAME) get_filename_component(QT_COCOA_PLUGIN_GROUP "${QT_COCOA_PLUGIN_DIR}" NAME)
get_filename_component(QT_COCOA_PLUGIN_NAME "${QT_COCOA_PLUGIN_PATH}" NAME) get_filename_component(QT_COCOA_PLUGIN_NAME "${QT_COCOA_PLUGIN_PATH}" NAME)
configure_file("${QT_COCOA_PLUGIN_PATH}" "${APP_BUNDLE_DIR}/Contents/PlugIns/${QT_COCOA_PLUGIN_GROUP}/${QT_COCOA_PLUGIN_NAME}" COPYONLY) configure_file("${QT_COCOA_PLUGIN_PATH}" "${APP_BUNDLE_DIR}/Contents/PlugIns/${QT_COCOA_PLUGIN_GROUP}/${QT_COCOA_PLUGIN_NAME}" COPYONLY)
get_property(QT_QMACSTYLE_PLUGIN_PATH TARGET Qt5::QMacStylePlugin PROPERTY LOCATION_RELEASE) get_property(QT_QMACSTYLE_PLUGIN_PATH TARGET Qt::QMacStylePlugin PROPERTY LOCATION_RELEASE)
get_filename_component(QT_QMACSTYLE_PLUGIN_DIR "${QT_QMACSTYLE_PLUGIN_PATH}" DIRECTORY) get_filename_component(QT_QMACSTYLE_PLUGIN_DIR "${QT_QMACSTYLE_PLUGIN_PATH}" DIRECTORY)
get_filename_component(QT_QMACSTYLE_PLUGIN_GROUP "${QT_QMACSTYLE_PLUGIN_DIR}" NAME) get_filename_component(QT_QMACSTYLE_PLUGIN_GROUP "${QT_QMACSTYLE_PLUGIN_DIR}" NAME)
get_filename_component(QT_QMACSTYLE_PLUGIN_NAME "${QT_QMACSTYLE_PLUGIN_PATH}" NAME) get_filename_component(QT_QMACSTYLE_PLUGIN_NAME "${QT_QMACSTYLE_PLUGIN_PATH}" NAME)

View file

@ -54,8 +54,8 @@ if(WIN32)
set(QT_USE_QTMAIN TRUE) set(QT_USE_QTMAIN TRUE)
endif(WIN32) endif(WIN32)
QT5_ADD_RESOURCES(RCC_SRCS ${CMAKE_SOURCE_DIR}/files/launcher/launcher.qrc) QT_ADD_RESOURCES(RCC_SRCS ${CMAKE_SOURCE_DIR}/files/launcher/launcher.qrc)
QT5_WRAP_UI(UI_HDRS ${LAUNCHER_UI}) QT_WRAP_UI(UI_HDRS ${LAUNCHER_UI})
include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR})
if(NOT WIN32) if(NOT WIN32)
@ -82,7 +82,7 @@ target_link_libraries(openmw-launcher
components_qt components_qt
) )
target_link_libraries(openmw-launcher Qt5::Widgets Qt5::Core) target_link_libraries(openmw-launcher Qt::Widgets Qt::Core)
if (BUILD_WITH_CODE_COVERAGE) if (BUILD_WITH_CODE_COVERAGE)
add_definitions (--coverage) add_definitions (--coverage)

View file

@ -149,8 +149,8 @@ if(WIN32)
set(QT_USE_QTMAIN TRUE) set(QT_USE_QTMAIN TRUE)
endif(WIN32) endif(WIN32)
qt5_wrap_ui(OPENCS_UI_HDR ${OPENCS_UI}) qt_wrap_ui(OPENCS_UI_HDR ${OPENCS_UI})
qt5_add_resources(OPENCS_RES_SRC ${OPENCS_RES}) qt_add_resources(OPENCS_RES_SRC ${OPENCS_RES})
# for compiled .ui files # for compiled .ui files
include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR})
@ -228,7 +228,7 @@ target_link_libraries(openmw-cs
components_qt components_qt
) )
target_link_libraries(openmw-cs Qt5::Widgets Qt5::Core Qt5::Network Qt5::OpenGL) target_link_libraries(openmw-cs Qt::Widgets Qt::Core Qt::Network Qt::OpenGL)
if (WIN32) if (WIN32)
target_link_libraries(openmw-cs ${Boost_LOCALE_LIBRARY}) target_link_libraries(openmw-cs ${Boost_LOCALE_LIBRARY})

View file

@ -66,11 +66,13 @@ void CSMPrefs::State::declare()
.addValue(scrollbarOnly) .addValue(scrollbarOnly)
.addValue("Grow Only", "The view window grows as subviews are added. No scrollbars.") .addValue("Grow Only", "The view window grows as subviews are added. No scrollbars.")
.addValue("Grow then Scroll", "The view window grows. The scrollbar appears once it cannot grow any further."); .addValue("Grow then Scroll", "The view window grows. The scrollbar appears once it cannot grow any further.");
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
declareBool("grow-limit", "Grow Limit Screen", false) declareBool("grow-limit", "Grow Limit Screen", false)
.setTooltip( .setTooltip(
"When \"Grow then Scroll\" option is selected, the window size grows to" "When \"Grow then Scroll\" option is selected, the window size grows to"
" the width of the virtual desktop. \nIf this option is selected the the window growth" " the width of the virtual desktop. \nIf this option is selected the the window growth"
"is limited to the current screen."); "is limited to the current screen.");
#endif
declareCategory("Records"); declareCategory("Records");
EnumValue iconAndText("Icon and Text"); EnumValue iconAndText("Icon and Text");

View file

@ -2,7 +2,11 @@
#include <QApplication> #include <QApplication>
#include <QCloseEvent> #include <QCloseEvent>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <QDesktopWidget> #include <QDesktopWidget>
#endif
#include <QMenuBar> #include <QMenuBar>
#include <QMessageBox> #include <QMessageBox>
#include <QScreen> #include <QScreen>
@ -651,7 +655,11 @@ void CSVDoc::View::addSubView(const CSMWorld::UniversalId& id, const std::string
// //
mScrollbarOnly = windows["mainwindow-scrollbar"].toString() == "Scrollbar Only"; mScrollbarOnly = windows["mainwindow-scrollbar"].toString() == "Scrollbar Only";
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
updateWidth(windows["grow-limit"].isTrue(), minWidth); updateWidth(windows["grow-limit"].isTrue(), minWidth);
#else
updateWidth(true, minWidth);
#endif
mSubViewWindow.addDockWidget(Qt::TopDockWidgetArea, view); mSubViewWindow.addDockWidget(Qt::TopDockWidgetArea, view);
@ -1098,12 +1106,15 @@ void CSVDoc::View::merge()
void CSVDoc::View::updateWidth(bool isGrowLimit, int minSubViewWidth) void CSVDoc::View::updateWidth(bool isGrowLimit, int minSubViewWidth)
{ {
QDesktopWidget* dw = QApplication::desktop(); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QRect rect; QRect rect;
if (isGrowLimit) if (isGrowLimit)
rect = dw->screenGeometry(this); rect = QApplication::screenAt(pos())->geometry();
else else
rect = QGuiApplication::screens().at(dw->screenNumber(this))->geometry(); rect = QGuiApplication::screens().at(QApplication::desktop()->screenNumber(this))->geometry();
#else
QRect rect = QApplication::screenAt(pos())->geometry();
#endif
if (!mScrollbarOnly && mScroll && mSubViews.size() > 1) if (!mScrollbarOnly && mScroll && mSubViews.size() > 1)
{ {

View file

@ -13,7 +13,9 @@
#include <apps/opencs/view/render/lightingday.hpp> #include <apps/opencs/view/render/lightingday.hpp>
#include <apps/opencs/view/render/lightingnight.hpp> #include <apps/opencs/view/render/lightingnight.hpp>
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
#include <extern/osgQt/GraphicsWindowQt> #include <extern/osgQt/GraphicsWindowQt>
#endif
#include <osg/Array> #include <osg/Array>
#include <osg/Camera> #include <osg/Camera>
@ -90,6 +92,7 @@ namespace CSVRender
mView = new osgViewer::View; mView = new osgViewer::View;
updateCameraParameters(traits->width / static_cast<double>(traits->height)); updateCameraParameters(traits->width / static_cast<double>(traits->height));
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
osg::ref_ptr<osgQt::GraphicsWindowQt> window = new osgQt::GraphicsWindowQt(traits.get()); osg::ref_ptr<osgQt::GraphicsWindowQt> window = new osgQt::GraphicsWindowQt(traits.get());
QLayout* layout = new QHBoxLayout(this); QLayout* layout = new QHBoxLayout(this);
layout->setContentsMargins(0, 0, 0, 0); layout->setContentsMargins(0, 0, 0, 0);
@ -97,6 +100,7 @@ namespace CSVRender
setLayout(layout); setLayout(layout);
mView->getCamera()->setGraphicsContext(window); mView->getCamera()->setGraphicsContext(window);
#endif
mView->getCamera()->setViewport(new osg::Viewport(0, 0, traits->width, traits->height)); mView->getCamera()->setViewport(new osg::Viewport(0, 0, traits->width, traits->height));
SceneUtil::LightManager* lightMgr = new SceneUtil::LightManager; SceneUtil::LightManager* lightMgr = new SceneUtil::LightManager;

View file

@ -141,6 +141,7 @@ void CSVWorld::Table::contextMenuEvent(QContextMenuEvent* event)
} }
} }
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (selectedRows.size() == 1) if (selectedRows.size() == 1)
{ {
int row = selectedRows.begin()->row(); int row = selectedRows.begin()->row();
@ -172,6 +173,7 @@ void CSVWorld::Table::contextMenuEvent(QContextMenuEvent* event)
menu.addAction(mPreviewAction); menu.addAction(mPreviewAction);
} }
} }
#endif
if (mHelpAction) if (mHelpAction)
menu.addAction(mHelpAction); menu.addAction(mHelpAction);
@ -388,14 +390,18 @@ CSVWorld::Table::Table(const CSMWorld::UniversalId& id, bool createAndDelete, bo
mViewAction->setIcon(QIcon(":/cell.png")); mViewAction->setIcon(QIcon(":/cell.png"));
addAction(mViewAction); addAction(mViewAction);
CSMPrefs::Shortcut* viewShortcut = new CSMPrefs::Shortcut("table-view", this); CSMPrefs::Shortcut* viewShortcut = new CSMPrefs::Shortcut("table-view", this);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
viewShortcut->associateAction(mViewAction); viewShortcut->associateAction(mViewAction);
#endif
mPreviewAction = new QAction(tr("Preview"), this); mPreviewAction = new QAction(tr("Preview"), this);
connect(mPreviewAction, &QAction::triggered, this, &Table::previewRecord); connect(mPreviewAction, &QAction::triggered, this, &Table::previewRecord);
mPreviewAction->setIcon(QIcon(":edit-preview")); mPreviewAction->setIcon(QIcon(":edit-preview"));
addAction(mPreviewAction); addAction(mPreviewAction);
CSMPrefs::Shortcut* previewShortcut = new CSMPrefs::Shortcut("table-preview", this); CSMPrefs::Shortcut* previewShortcut = new CSMPrefs::Shortcut("table-preview", this);
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
previewShortcut->associateAction(mPreviewAction); previewShortcut->associateAction(mPreviewAction);
#endif
mExtendedDeleteAction = new QAction(tr("Extended Delete Record"), this); mExtendedDeleteAction = new QAction(tr("Extended Delete Record"), this);
connect(mExtendedDeleteAction, &QAction::triggered, this, &Table::executeExtendedDelete); connect(mExtendedDeleteAction, &QAction::triggered, this, &Table::executeExtendedDelete);

View file

@ -62,8 +62,8 @@ if(WIN32)
set(QT_USE_QTMAIN TRUE) set(QT_USE_QTMAIN TRUE)
endif(WIN32) endif(WIN32)
QT5_ADD_RESOURCES(RCC_SRCS ${CMAKE_SOURCE_DIR}/files/wizard/wizard.qrc) QT_ADD_RESOURCES(RCC_SRCS ${CMAKE_SOURCE_DIR}/files/wizard/wizard.qrc)
QT5_WRAP_UI(UI_HDRS ${WIZARD_UI}) QT_WRAP_UI(UI_HDRS ${WIZARD_UI})
include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR})
@ -83,7 +83,7 @@ target_link_libraries(openmw-wizard
components_qt components_qt
) )
target_link_libraries(openmw-wizard Qt5::Widgets Qt5::Core) target_link_libraries(openmw-wizard Qt::Widgets Qt::Core)
if (OPENMW_USE_UNSHIELD) if (OPENMW_USE_UNSHIELD)
target_link_libraries(openmw-wizard ${LIBUNSHIELD_LIBRARIES}) target_link_libraries(openmw-wizard ${LIBUNSHIELD_LIBRARIES})

View file

@ -387,7 +387,7 @@ if (USE_QT)
qtconfigpath qtconfigpath
) )
QT5_WRAP_UI(ESM_UI_HDR ${ESM_UI}) QT_WRAP_UI(ESM_UI_HDR ${ESM_UI})
endif() endif()
if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
@ -455,7 +455,7 @@ endif()
if (USE_QT) if (USE_QT)
add_library(components_qt STATIC ${COMPONENT_QT_FILES} ${ESM_UI_HDR}) add_library(components_qt STATIC ${COMPONENT_QT_FILES} ${ESM_UI_HDR})
target_link_libraries(components_qt components Qt5::Widgets Qt5::Core) target_link_libraries(components_qt components Qt::Widgets Qt::Core)
target_compile_definitions(components_qt PRIVATE OPENMW_DOC_BASEURL="${OPENMW_DOC_BASEURL}") target_compile_definitions(components_qt PRIVATE OPENMW_DOC_BASEURL="${OPENMW_DOC_BASEURL}")
endif() endif()