From 4649cf024839d90b5ac202652367ede62d2dacd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jind=C5=99ich=20Makovi=C4=8Dka?= Date: Fri, 14 Jul 2023 16:04:57 +0200 Subject: Allow the use of either Qt5 or Qt6 on Linux (#11413) * Look for MOC in QT_HOME/libexec if not found in QT_HOME/bin * Use the Qt6* libraries if the Qt version is >= 6 * Switch the include paths for QAction & QActionGroup for Qt >= 6 * Replace the deprecated + operator for keys with | --- scripts/src/osd/modules.lua | 36 ++++++++++++++++------- src/osd/modules/debugger/qt/breakpointswindow.cpp | 4 +++ src/osd/modules/debugger/qt/dasmwindow.cpp | 7 ++++- src/osd/modules/debugger/qt/mainwindow.cpp | 7 ++++- src/osd/modules/debugger/qt/memorywindow.cpp | 4 +++ 5 files changed, 46 insertions(+), 12 deletions(-) diff --git a/scripts/src/osd/modules.lua b/scripts/src/osd/modules.lua index 6cb47db91a6..7ea3e26b753 100644 --- a/scripts/src/osd/modules.lua +++ b/scripts/src/osd/modules.lua @@ -378,12 +378,19 @@ function qtdebuggerbuild() MOC = "moc" else if _OPTIONS["QT_HOME"]~=nil then - QMAKETST = backtick(_OPTIONS["QT_HOME"] .. "/bin/qmake --version 2>/dev/null") - if (QMAKETST=='') then - print("Qt's Meta Object Compiler (moc) wasn't found!") - os.exit(1) + MOCTST = backtick(_OPTIONS["QT_HOME"] .. "/bin/moc --version 2>/dev/null") + if (MOCTST=='') then + MOCTST = backtick(_OPTIONS["QT_HOME"] .. "/libexec/moc --version 2>/dev/null") + if (MOCTST=='') then + print("Qt's Meta Object Compiler (moc) wasn't found!") + os.exit(1) + else + MOC = _OPTIONS["QT_HOME"] .. "/libexec/moc" + end + else + MOC = _OPTIONS["QT_HOME"] .. "/bin/moc" end - MOC = _OPTIONS["QT_HOME"] .. "/bin/moc" + MOC = _OPTIONS["QT_HOME"] .. "/libexec/moc" else MOCTST = backtick("which moc-qt5 2>/dev/null") if (MOCTST=='') then @@ -494,14 +501,23 @@ function osdmodulestargetconf() } else if _OPTIONS["QT_HOME"]~=nil then + local qt_version = str_to_version(backtick(_OPTIONS["QT_HOME"] .. "/bin/qmake -query QT_VERSION")) linkoptions { "-L" .. backtick(_OPTIONS["QT_HOME"] .. "/bin/qmake -query QT_INSTALL_LIBS"), } - links { - "Qt5Core", - "Qt5Gui", - "Qt5Widgets", - } + if qt_version < 60000 then + links { + "Qt5Core", + "Qt5Gui", + "Qt5Widgets", + } + else + links { + "Qt6Core", + "Qt6Gui", + "Qt6Widgets", + } + end else local str = backtick(pkgconfigcmd() .. " --libs Qt5Widgets") addlibfromstring(str) diff --git a/src/osd/modules/debugger/qt/breakpointswindow.cpp b/src/osd/modules/debugger/qt/breakpointswindow.cpp index 60ceae6d16f..16c8af6bdb3 100644 --- a/src/osd/modules/debugger/qt/breakpointswindow.cpp +++ b/src/osd/modules/debugger/qt/breakpointswindow.cpp @@ -8,7 +8,11 @@ #include "util/xmlfile.h" +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#include +#else #include +#endif #include #include #include diff --git a/src/osd/modules/debugger/qt/dasmwindow.cpp b/src/osd/modules/debugger/qt/dasmwindow.cpp index d528be04d14..144e2f32f5d 100644 --- a/src/osd/modules/debugger/qt/dasmwindow.cpp +++ b/src/osd/modules/debugger/qt/dasmwindow.cpp @@ -13,7 +13,12 @@ #include #include #include +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#include +#include +#else #include +#endif #include #include @@ -86,7 +91,7 @@ DasmWindow::DasmWindow(DebuggerQt &debugger, QWidget *parent) : m_breakpointEnableAct = new QAction("Disable Breakpoint at Cursor", this); m_runToCursorAct = new QAction("Run to Cursor", this); m_breakpointToggleAct->setShortcut(Qt::Key_F9); - m_breakpointEnableAct->setShortcut(Qt::SHIFT + Qt::Key_F9); + m_breakpointEnableAct->setShortcut(Qt::SHIFT | Qt::Key_F9); m_runToCursorAct->setShortcut(Qt::Key_F4); connect(m_breakpointToggleAct, &QAction::triggered, this, &DasmWindow::toggleBreakpointAtCursor); connect(m_breakpointEnableAct, &QAction::triggered, this, &DasmWindow::enableBreakpointAtCursor); diff --git a/src/osd/modules/debugger/qt/mainwindow.cpp b/src/osd/modules/debugger/qt/mainwindow.cpp index 5e97376aa7d..dba5d18b9ac 100644 --- a/src/osd/modules/debugger/qt/mainwindow.cpp +++ b/src/osd/modules/debugger/qt/mainwindow.cpp @@ -11,7 +11,12 @@ #include "util/xmlfile.h" #include +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#include +#include +#else #include +#endif #include #include #include @@ -61,7 +66,7 @@ MainWindow::MainWindow(DebuggerQt &debugger, QWidget *parent) : m_breakpointEnableAct = new QAction("Disable Breakpoint at Cursor", this); m_runToCursorAct = new QAction("Run to Cursor", this); m_breakpointToggleAct->setShortcut(Qt::Key_F9); - m_breakpointEnableAct->setShortcut(Qt::SHIFT + Qt::Key_F9); + m_breakpointEnableAct->setShortcut(Qt::SHIFT | Qt::Key_F9); m_runToCursorAct->setShortcut(Qt::Key_F4); connect(m_breakpointToggleAct, &QAction::triggered, this, &MainWindow::toggleBreakpointAtCursor); connect(m_breakpointEnableAct, &QAction::triggered, this, &MainWindow::enableBreakpointAtCursor); diff --git a/src/osd/modules/debugger/qt/memorywindow.cpp b/src/osd/modules/debugger/qt/memorywindow.cpp index a2213846c93..030eb4ab24d 100644 --- a/src/osd/modules/debugger/qt/memorywindow.cpp +++ b/src/osd/modules/debugger/qt/memorywindow.cpp @@ -12,7 +12,11 @@ #include #include #include +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#include +#else #include +#endif #include #include #include -- cgit v1.2.3