diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c2005ca4..416e57acd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -249,7 +249,8 @@ find_package(TBB REQUIRED) if(ENABLE_LAUNCHER) # Widgets finds its own dependencies (QtGui and QtCore). - find_package(Qt5 COMPONENTS Widgets Network REQUIRED) + find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets Network) + find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets Network) endif() if(ENABLE_LUA) @@ -389,7 +390,7 @@ if(WIN32) endif() if(ENABLE_LAUNCHER) - get_target_property(QtCore_location Qt5::Core LOCATION) + get_target_property(QtCore_location Qt${QT_VERSION_MAJOR}::Core LOCATION) get_filename_component(Qtbin_folder ${QtCore_location} PATH) file(GLOB dep_files ${dep_files} @@ -398,9 +399,9 @@ if(WIN32) ${Qtbin_folder}/Qt5Widgets${debug_postfix}.dll ${Qtbin_folder}/Qt5Network${debug_postfix}.dll ${Qtbin_folder}/icu*.dll) - get_target_property(integration_type Qt5::QWindowsIntegrationPlugin TYPE) + get_target_property(integration_type Qt${QT_VERSION_MAJOR}::QWindowsIntegrationPlugin TYPE) if(NOT(integration_type STREQUAL "INTERFACE_LIBRARY")) - get_target_property(integration_loc Qt5::QWindowsIntegrationPlugin LOCATION) + get_target_property(integration_loc Qt${QT_VERSION_MAJOR}::QWindowsIntegrationPlugin LOCATION) install( FILES ${integration_loc} DESTINATION ${BIN_DIR}/platforms diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt index 363382715..c671cb677 100644 --- a/launcher/CMakeLists.txt +++ b/launcher/CMakeLists.txt @@ -63,14 +63,12 @@ endif() # to always look for includes there: set(CMAKE_INCLUDE_CURRENT_DIR ON) -if("${CMAKE_VERSION}" VERSION_LESS 2.8.12) - # Executables fail to build with Qt 5 in the default configuration - # without -fPIE. We add that here. - set(CMAKE_CXX_FLAGS "${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS} ${CMAKE_CXX_FLAGS}") +if(TARGET Qt6::Core) + qt_wrap_ui(launcher_UI_HEADERS ${launcher_FORMS}) +else() + qt5_wrap_ui(launcher_UI_HEADERS ${launcher_FORMS}) endif() -qt5_wrap_ui(launcher_UI_HEADERS ${launcher_FORMS}) - if(WIN32) set(launcher_ICON VCMI_launcher.rc) endif() @@ -90,7 +88,7 @@ if(WIN32) # - cmake_policy in all possible places # - used NO_POLICY_SCOPE to make sure no other parts reset policies # Still nothing worked, warning kept appearing and WinMain didn't link automatically - target_link_libraries(vcmilauncher Qt5::WinMain) + target_link_libraries(vcmilauncher Qt${QT_VERSION_MAJOR}::WinMain) endif() if(APPLE) @@ -98,7 +96,7 @@ if(APPLE) set_property(GLOBAL PROPERTY AUTOGEN_TARGETS_FOLDER vcmilauncher) endif() -target_link_libraries(vcmilauncher vcmi Qt5::Widgets Qt5::Network) +target_link_libraries(vcmilauncher vcmi Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network) target_include_directories(vcmilauncher PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ) diff --git a/launcher/jsonutils.cpp b/launcher/jsonutils.cpp index e82bdcdc7..fb2c66834 100644 --- a/launcher/jsonutils.cpp +++ b/launcher/jsonutils.cpp @@ -106,9 +106,9 @@ JsonNode toJson(QVariant object) ret.Struct() = VariantToMap(object.toMap()); else if(object.canConvert()) ret.Vector() = VariantToList(object.toList()); - else if(static_cast(object.type()) == QMetaType::QString) + else if(object.userType() == QMetaType::QString) ret.String() = object.toString().toUtf8().data(); - else if(static_cast(object.type()) == QMetaType::Bool) + else if(object.userType() == QMetaType::Bool) ret.Bool() = object.toBool(); else if(object.canConvert()) ret.Float() = object.toFloat(); diff --git a/launcher/mainwindow_moc.cpp b/launcher/mainwindow_moc.cpp index df475eb12..08b4b8d63 100644 --- a/launcher/mainwindow_moc.cpp +++ b/launcher/mainwindow_moc.cpp @@ -102,7 +102,7 @@ void MainWindow::startExecutable(QString name) QProcess process; // Start the executable - if(process.startDetached(name)) + if(process.startDetached(name, {})) { close(); // exit launcher } diff --git a/launcher/modManager/cmodlistmodel_moc.cpp b/launcher/modManager/cmodlistmodel_moc.cpp index ac5fd08aa..780f4f855 100644 --- a/launcher/modManager/cmodlistmodel_moc.cpp +++ b/launcher/modManager/cmodlistmodel_moc.cpp @@ -253,7 +253,7 @@ bool CModFilterModel::filterAcceptsRow(int source_row, const QModelIndex & sourc for(size_t i = 0; i < base->rowCount(index); i++) { - if(filterMatchesThis(index.child((int)i, 0))) + if(filterMatchesThis(base->index((int)i, 0, index))) return true; } diff --git a/launcher/modManager/cmodlistview_moc.cpp b/launcher/modManager/cmodlistview_moc.cpp index 702896900..70419b9cb 100644 --- a/launcher/modManager/cmodlistview_moc.cpp +++ b/launcher/modManager/cmodlistview_moc.cpp @@ -15,6 +15,7 @@ #include #include +#include #include "cmodlistmodel_moc.h" #include "cmodmanager.h" @@ -352,8 +353,16 @@ void CModListView::on_allModsView_activated(const QModelIndex & index) void CModListView::on_lineEdit_textChanged(const QString & arg1) { - QRegExp regExp(arg1, Qt::CaseInsensitive, QRegExp::Wildcard); - filterModel->setFilterRegExp(regExp); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + auto baseStr = QRegularExpression::wildcardToRegularExpression(arg1, QRegularExpression::UnanchoredWildcardConversion); +#else + auto baseStr = QRegularExpression::wildcardToRegularExpression(arg1); + //Hack due to lack QRegularExpression::UnanchoredWildcardConversion in Qt5 + baseStr.chop(3); + baseStr.remove(0,5); +#endif + QRegularExpression regExp{baseStr, QRegularExpression::CaseInsensitiveOption}; + filterModel->setFilterRegularExpression(regExp); } void CModListView::on_comboBox_currentIndexChanged(int index) diff --git a/launcher/modManager/imageviewer_moc.cpp b/launcher/modManager/imageviewer_moc.cpp index b244f49a3..8022250a9 100644 --- a/launcher/modManager/imageviewer_moc.cpp +++ b/launcher/modManager/imageviewer_moc.cpp @@ -9,7 +9,7 @@ */ #include "StdInc.h" -#include +#include #include "imageviewer_moc.h" #include "ui_imageviewer_moc.h" @@ -27,8 +27,7 @@ ImageViewer::~ImageViewer() QSize ImageViewer::calculateWindowSize() { - QDesktopWidget desktop; - return desktop.availableGeometry(desktop.primaryScreen()).size() * 0.8; + return QGuiApplication::primaryScreen()->availableGeometry().size() * 0.8; } void ImageViewer::showPixmap(QPixmap & pixmap, QWidget * parent) diff --git a/launcher/settingsView/csettingsview_moc.cpp b/launcher/settingsView/csettingsview_moc.cpp index 29b167a1b..58534d506 100644 --- a/launcher/settingsView/csettingsview_moc.cpp +++ b/launcher/settingsView/csettingsview_moc.cpp @@ -12,6 +12,7 @@ #include "ui_csettingsview_moc.h" #include +#include #include "../../lib/CConfigHandler.h" #include "../../lib/VCMIDirs.h" @@ -34,12 +35,12 @@ static const std::string knownEncodingsList[] = //TODO: remove hardcode void CSettingsView::setDisplayList() { QStringList list; - QDesktopWidget * widget = QApplication::desktop(); - for(int display = 0; display < widget->screenCount(); display++) + + for (const auto screen : QGuiApplication::screens()) { QString string; - auto rect = widget->screenGeometry(display); - QTextStream(&string) << display << " - " << rect.width() << "x" << rect.height(); + const auto & rect = screen->geometry(); + QTextStream(&string) << screen->name() << " - " << rect.width() << "x" << rect.height(); list << string; }