diff --git a/.github/workflows/asset.yml b/.github/workflows/asset.yml index 487ec8bd..861343a4 100644 --- a/.github/workflows/asset.yml +++ b/.github/workflows/asset.yml @@ -24,6 +24,7 @@ jobs: fail-fast: false matrix: qt-version: + - 5.12.12 # Supported in Ubuntu Focal Fossa until 2025-04-02 - 5.15.2 # Supported in Ubuntu Jammy Jellyfish until 2027-04-01 - 6.2.4 # Supported in Ubuntu Jammy Jellyfish until 2027-04-01 - 6.5.3 # Supported until 2024-03-31 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f6f009b7..fcac87b5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,6 +27,7 @@ jobs: fail-fast: false matrix: qt-version: + - 5.12.12 # Supported in Ubuntu Focal Fossa until 2025-04-02 - 5.15.2 # Supported in Ubuntu Jammy Jellyfish until 2027-04-01 - 6.2.4 # Supported in Ubuntu Jammy Jellyfish until 2027-04-01 - 6.5.3 # Supported until 2024-03-31 diff --git a/.github/workflows/codacy.yml b/.github/workflows/codacy.yml index d2d36ee8..4e336cc6 100644 --- a/.github/workflows/codacy.yml +++ b/.github/workflows/codacy.yml @@ -2,11 +2,11 @@ name: Codacy code analysis on: push: - branches: [ master ] + branches: [master] pull_request: - branches: [ master ] + branches: [master] schedule: - - cron: '0 8 * * 5' + - cron: 0 8 * * 5 jobs: codacy-analysis: @@ -23,7 +23,7 @@ jobs: uses: actions/checkout@v4 - name: Run Codacy Code Analysis - uses: codacy/codacy-analysis-cli-action@v4.3.0 + uses: codacy/codacy-analysis-cli-action@master with: output: codacy.sarif format: sarif diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml index 5c94e7c7..fcb11849 100644 --- a/.github/workflows/debug.yml +++ b/.github/workflows/debug.yml @@ -2,11 +2,11 @@ name: Debug build on: push: - branches: [ master ] + branches: [master] pull_request: - branches: [ master ] + branches: [master] schedule: - - cron: '0 8 * * 5' + - cron: 0 8 * * 5 concurrency: group: debug-${{ github.ref }} diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 5c70da50..04c9d0f5 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -9,5 +9,5 @@ jobs: - uses: actions/checkout@v4 - uses: DoozyX/clang-format-lint-action@v0.16.2 with: - source: 'src include' + source: src include clangFormatVersion: 16 diff --git a/CMakeLists.txt b/CMakeLists.txt index 1fdcc1f2..5a69c2f9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,6 +52,8 @@ message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") if("${QT_VERSION_MAJOR}" STREQUAL "") find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED) +else() + find_package(QT NAMES Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED) endif() message(STATUS "Qt: ${QT_VERSION_MAJOR}") @@ -72,10 +74,10 @@ add_executable(${PROJECT_NAME} WIN32 MACOSX_BUNDLE target_include_directories(${PROJECT_NAME} PRIVATE "${CMAKE_SOURCE_DIR}/include") target_link_libraries(${PROJECT_NAME} PRIVATE - Qt::Core - Qt::Gui - Qt::Network - Qt::Widgets + Qt${QT_VERSION_MAJOR}::Core + Qt${QT_VERSION_MAJOR}::Gui + Qt${QT_VERSION_MAJOR}::Network + Qt${QT_VERSION_MAJOR}::Widgets ) if(${QT_VERSION_MAJOR} LESS_EQUAL 5) @@ -93,7 +95,11 @@ if(${QT_VERSION_MAJOR} LESS_EQUAL 5) endforeach () file(APPEND ${QRC} "") - qt_add_resources(RESOURCES ${QRC}) + if(${QT_VERSION_MINOR} LESS 15) + qt5_add_resources(RESOURCES ${QRC}) + else() + qt_add_resources(RESOURCES ${QRC}) + endif() target_sources(${PROJECT_NAME} PRIVATE ${RESOURCES}) endfunction() endif() @@ -273,7 +279,11 @@ target_sources(${PROJECT_NAME} PRIVATE ) # Resources: -qt_add_resources(RESOURCES icons.qrc) +if(${QT_VERSION} VERSION_GREATER_EQUAL 5.15) + qt_add_resources(RESOURCES icons.qrc) +else() + qt5_add_resources(RESOURCES icons.qrc) +endif() target_sources(${PROJECT_NAME} PRIVATE ${RESOURCES}) if(WIN32) @@ -416,7 +426,7 @@ else() endif() if(LINUXDEPLOY_EXECUTABLE) - get_target_property(QMAKE_EXECUTABLE Qt::qmake IMPORTED_LOCATION) + get_target_property(QMAKE_EXECUTABLE Qt${QT_VERSION_MAJOR}::qmake IMPORTED_LOCATION) add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND QMAKE=${QMAKE_EXECUTABLE} ${LINUXDEPLOY_EXECUTABLE} --plugin=qt --appdir=${CMAKE_BINARY_DIR}/appdir/ --executable="$/$" diff --git a/INSTALL.md b/INSTALL.md index 739fa9b4..79201331 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -18,7 +18,7 @@ Required libraries[^1]: [^1]: Remember to install **development** files as well. For example `qt6-base-dev`, `libefivar-dev`, `libefiboot-dev` on Ubuntu. -- [Qt5](//doc.qt.io/qt-5/gettingstarted.html) (>= 5.15) +- [Qt5](//doc.qt.io/qt-5/gettingstarted.html) (>= 5.12) or [Qt6](//doc.qt.io/qt-6/get-and-install-qt.html) (>= 6.2) - [efivar](//github.com/rhboot/efivar) (>= 37) on Linux diff --git a/README.md b/README.md index 638adadf..f245db23 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ Options: ## Requirements -* [Qt](//www.qt.io/) (>=5.15.2) +* [Qt](//www.qt.io/) (>=5.12) * [efivar](//github.com/rhboot/efivar) (>=37) on linux ## Installation diff --git a/include/compat.h b/include/compat.h index 05a58c29..9492a39f 100644 --- a/include/compat.h +++ b/include/compat.h @@ -122,8 +122,21 @@ inline tstring to_tstring(const Type &value) const int HEX_BASE = 16; -QT_BEGIN_NAMESPACE +/* Qt compatibility */ +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) +namespace std +{ + +template <> +struct hash +{ + size_t operator()(const QString &s) const noexcept { return static_cast(qHash(s)); } +}; +} +#endif + +/* QString helpers */ inline std::tstring QStringToStdTString(const QString &string) { #if defined(UNICODE) || defined(_UNICODE) @@ -157,8 +170,6 @@ inline QString toHex(unsigned long long number, int min_width = 0, const QString return prefix + QString("%1").arg(number, min_width, HEX_BASE, QChar('0')).toUpper(); } -QT_END_NAMESPACE - inline bool isxnumber(const std::tstring_view &string) { #if defined(UNICODE) || defined(_UNICODE) diff --git a/include/efibooteditorcli.h b/include/efibooteditorcli.h index f539494d..23175609 100644 --- a/include/efibooteditorcli.h +++ b/include/efibooteditorcli.h @@ -7,6 +7,14 @@ #include "compat.h" #include "efibootdata.h" +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) +#include +namespace Qt +{ +static const auto endl = ::endl; +} +#endif + class EFIBootEditorCLI: public QObject { Q_OBJECT diff --git a/src/efibooteditor.cpp b/src/efibooteditor.cpp index ca44c2df..8ca37e23 100644 --- a/src/efibooteditor.cpp +++ b/src/efibooteditor.cpp @@ -43,7 +43,7 @@ EFIBootEditor::EFIBootEditor(const std::optional &efi_error_messag QObject::connect(&data, &EFIBootData::done, this, &EFIBootEditor::hideProgressBar); QObject::connect(&data, &EFIBootData::timeoutChanged, ui->timeout_number, &QSpinBox::setValue); - QObject::connect(ui->timeout_number, &QSpinBox::valueChanged, &data, &EFIBootData::setTimeout); + QObject::connect(ui->timeout_number, QOverload::of(&QSpinBox::valueChanged), &data, &EFIBootData::setTimeout); QObject::connect(&data, &EFIBootData::secureBootChanged, ui->secure_boot, &QRadioButton::setChecked); QObject::connect(&data, &EFIBootData::vendorKeysChanged, ui->vendor_keys, &QRadioButton::setChecked); @@ -299,7 +299,11 @@ void EFIBootEditor::updateBootOptionSupport(uint32_t flags) { // TODO: (flags & EFIBoot::EFI_BOOT_OPTION_SUPPORT_KEY) ui->entry_form->showCategory(flags & EFIBoot::EFI_BOOT_OPTION_SUPPORT_APP); +#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) + ui->entries->setTabEnabled(ui->entries->indexOf(ui->sysprep_tab), flags & EFIBoot::EFI_BOOT_OPTION_SUPPORT_SYSPREP); +#else ui->entries->setTabVisible(ui->entries->indexOf(ui->sysprep_tab), flags & EFIBoot::EFI_BOOT_OPTION_SUPPORT_SYSPREP); +#endif } void EFIBootEditor::undoViewChanged(const QModelIndex &)