diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a22408c..2dadc1f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -173,3 +173,33 @@ jobs: files: Reclass-x86_64.AppImage env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + linux-qt5: + runs-on: ubuntu-22.04 + + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install Qt5 + uses: jurplel/install-qt-action@v4 + with: + version: '5.15.2' + cache: true + + - name: Install dependencies + run: | + sudo apt-get update + sudo apt-get install -y ninja-build libgl1-mesa-dev + + - name: Configure + run: cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Release + + - name: Build + run: cmake --build build + + - name: Test + run: xvfb-run ctest --test-dir build --output-on-failure --exclude-regex "test_editor" + env: + QT_QPA_PLATFORM: offscreen diff --git a/src/main.cpp b/src/main.cpp index b01e3c9..33c1df7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,5 @@ #include "mainwindow.h" +#include "qt5compat.h" #include "generator.h" #include "mcp/mcp_bridge.h" #include @@ -359,14 +360,14 @@ QIcon MainWindow::makeIcon(const QString& svgPath) { void MainWindow::createMenus() { // File auto* file = m_titleBar->menuBar()->addMenu("&File"); - file->addAction("&New", QKeySequence::New, this, &MainWindow::newDocument); - file->addAction("New &Tab", QKeySequence(Qt::CTRL | Qt::Key_T), this, &MainWindow::newFile); - file->addAction(makeIcon(":/vsicons/folder-opened.svg"), "&Open...", QKeySequence::Open, this, &MainWindow::openFile); + rcx::compat::addAction(file, "&New", QKeySequence::New, this, &MainWindow::newDocument); + rcx::compat::addAction(file, "New &Tab", QKeySequence(Qt::CTRL | Qt::Key_T), this, &MainWindow::newFile); + rcx::compat::addAction(file, makeIcon(":/vsicons/folder-opened.svg"), "&Open...", QKeySequence::Open, this, &MainWindow::openFile); file->addSeparator(); - file->addAction(makeIcon(":/vsicons/save.svg"), "&Save", QKeySequence::Save, this, &MainWindow::saveFile); - file->addAction(makeIcon(":/vsicons/save-as.svg"), "Save &As...", QKeySequence::SaveAs, this, &MainWindow::saveFileAs); + rcx::compat::addAction(file, makeIcon(":/vsicons/save.svg"), "&Save", QKeySequence::Save, this, &MainWindow::saveFile); + rcx::compat::addAction(file, makeIcon(":/vsicons/save-as.svg"), "Save &As...", QKeySequence::SaveAs, this, &MainWindow::saveFileAs); file->addSeparator(); - file->addAction("&Unload Project", QKeySequence(Qt::CTRL | Qt::Key_W), this, &MainWindow::closeFile); + rcx::compat::addAction(file, "&Unload Project", QKeySequence(Qt::CTRL | Qt::Key_W), this, &MainWindow::closeFile); file->addSeparator(); file->addAction(makeIcon(":/vsicons/export.svg"), "Export &C++ Header...", this, &MainWindow::exportCpp); file->addSeparator(); @@ -374,12 +375,12 @@ void MainWindow::createMenus() { file->addSeparator(); file->addAction(makeIcon(":/vsicons/settings-gear.svg"), "&Options...", this, &MainWindow::showOptionsDialog); file->addSeparator(); - file->addAction(makeIcon(":/vsicons/close.svg"), "E&xit", QKeySequence(Qt::Key_Close), this, &QMainWindow::close); + rcx::compat::addAction(file, makeIcon(":/vsicons/close.svg"), "E&xit", QKeySequence(Qt::Key_Close), this, &QMainWindow::close); // Edit auto* edit = m_titleBar->menuBar()->addMenu("&Edit"); - edit->addAction(makeIcon(":/vsicons/arrow-left.svg"), "&Undo", QKeySequence::Undo, this, &MainWindow::undo); - edit->addAction(makeIcon(":/vsicons/arrow-right.svg"), "&Redo", QKeySequence::Redo, this, &MainWindow::redo); + rcx::compat::addAction(edit, makeIcon(":/vsicons/arrow-left.svg"), "&Undo", QKeySequence::Undo, this, &MainWindow::undo); + rcx::compat::addAction(edit, makeIcon(":/vsicons/arrow-right.svg"), "&Redo", QKeySequence::Redo, this, &MainWindow::redo); edit->addSeparator(); edit->addAction("&Type Aliases...", this, &MainWindow::showTypeAliasesDialog); diff --git a/src/qt5compat.h b/src/qt5compat.h new file mode 100644 index 0000000..89dbc30 --- /dev/null +++ b/src/qt5compat.h @@ -0,0 +1,37 @@ +#pragma once +#include +#include +#include +#include +#include + +namespace rcx { namespace compat { + +// QMenu::addAction with shortcut — Qt6 puts shortcut before receiver, +// Qt5 puts it after. These normalize to the Qt6 argument order. + +template +inline QAction* addAction(QMenu* menu, const QString& text, + const QKeySequence& shortcut, + const Obj* receiver, Func slot) +{ +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + return menu->addAction(text, shortcut, receiver, slot); +#else + return menu->addAction(text, receiver, slot, shortcut); +#endif +} + +template +inline QAction* addAction(QMenu* menu, const QIcon& icon, const QString& text, + const QKeySequence& shortcut, + const Obj* receiver, Func slot) +{ +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + return menu->addAction(icon, text, shortcut, receiver, slot); +#else + return menu->addAction(icon, text, receiver, slot, shortcut); +#endif +} + +}} // namespace rcx::compat