Qt6 support (#1363)

* Initial Qt6 config

* Change Package order to reingfence missing packages

* Update to QT 6.2.0

* Qt 6.2.0 updates

* macOS fix

* Simplify handling QT5 & Qt6 in parallel

* Updates for Windows

* Fix macos build

* macOS linker fix

* General support of QTDIR, update docu

* MaxOS add default qt directories

* Fix merge typo

* Update default CMakeSettings.json with installation path options

* Add additional libs required by Qt6 to CompileHowTo

* Fix Qt5 items

Co-authored-by: Paulchen-Panther <16664240+Paulchen-Panther@users.noreply.github.com>
This commit is contained in:
LordGrey
2021-11-16 17:12:56 +00:00
committed by GitHub
parent 3b1ca20b10
commit 25d79a9f3f
76 changed files with 645 additions and 541 deletions

View File

@@ -12,7 +12,7 @@ else()
include_directories(${PYTHON_INCLUDE_DIRS} ${PYTHON_INCLUDE_DIRS}/..)
endif()
find_package(Qt5Widgets REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Network Gui Widgets REQUIRED)
# generate windows .rc file for this binary
if (WIN32)
@@ -56,7 +56,10 @@ target_link_libraries(${PROJECT_NAME}
database
python
resources
Qt5::Widgets
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Network
Qt${QT_VERSION_MAJOR}::Widgets
)
if (NOT CMAKE_VERSION VERSION_LESS "3.12")
@@ -71,7 +74,7 @@ endif (ENABLE_AVAHI)
if (ENABLE_AMLOGIC)
target_link_libraries(${PROJECT_NAME}
Qt5::Core
#Qt${QT_VERSION_MAJOR}::Core
pcre16 dl z
)
endif(ENABLE_AMLOGIC)
@@ -172,12 +175,20 @@ endif()
# Deploy Qt DLLs into the binary folder.
# This is necessary for starting the application from within the IDE
if (WIN32)
get_target_property(QMAKE_EXECUTABLE Qt5::qmake IMPORTED_LOCATION)
get_target_property(QT_QMAKE_EXECUTABLE Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION)
get_filename_component(QT_BIN_DIR "${QT_QMAKE_EXECUTABLE}" DIRECTORY)
find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${QT_BIN_DIR}")
set(WINDEPLOYQT_PARAMS --verbose 0 --no-compiler-runtime --no-opengl-sw --no-system-d3d-compiler)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${WINDEPLOYQT_EXECUTABLE} ${WINDEPLOYQT_PARAMS} "$<TARGET_FILE:${PROJECT_NAME}>")
if (NOT WINDEPLOYQT_EXECUTABLE)
find_program(WINDEPLOYQT_EXECUTABLE windeployqt)
endif()
if (WINDEPLOYQT_EXECUTABLE AND NOT CMAKE_GITHUB_ACTION)
set(WINDEPLOYQT_PARAMS_RUNTIME --verbose 0 --no-compiler-runtime --no-opengl-sw --no-system-d3d-compiler)
message(STATUS "Found windeployqt: ${WINDEPLOYQT_EXECUTABLE} PATH_HINT:${QT_BIN_DIR}")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${WINDEPLOYQT_EXECUTABLE} ${WINDEPLOYQT_PARAMS_RUNTIME} "$<TARGET_FILE:${PROJECT_NAME}>")
endif()
endif(WIN32)
if(ENABLE_DEPLOY_DEPENDENCIES)

View File

@@ -3,7 +3,7 @@
#include <QByteArray>
#include <QDir>
#include <QFile>
#include <QRegExp>
#include <QRegularExpression>
#include <QString>
#include <QTextStream>
@@ -40,7 +40,7 @@ QStringList getProcessIdsByProcessName(const char *processName)
/* Walk through the snapshot of processes */
do
{
if (strcmp(processName, pe32.szExeFile) == 0)
if (QString::compare(processName, QString::fromUtf16(reinterpret_cast<char16_t*>(pe32.szExeFile)), Qt::CaseInsensitive) == 0)
listOfPids.append(QString::number(pe32.th32ProcessID));
} while(Process32Next(hProcessSnap, &pe32));
@@ -54,8 +54,8 @@ QStringList getProcessIdsByProcessName(const char *processName)
dir.setSorting(QDir::Name | QDir::Reversed);
for (const QString & pid : dir.entryList()) {
QRegExp regexp("\\d*");
if (!regexp.exactMatch(pid))
QRegularExpression regexp("^\\d*$");
if (!regexp.match(pid).hasMatch())
{
/* Not a number, can not be PID */
continue;

View File

@@ -66,7 +66,9 @@ void SysTray::iconActivated(QSystemTrayIcon::ActivationReason reason)
void SysTray::createTrayIcon()
{
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
quitAction = new QAction(tr("&Quit"), this);
quitAction->setIcon(QPixmap(":/quit.svg"));