Skip to content

Commit

Permalink
fixes for Qt5.12
Browse files Browse the repository at this point in the history
  • Loading branch information
Neverous committed Oct 11, 2023
1 parent 6ee7e35 commit d319e00
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 13 deletions.
24 changes: 17 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand All @@ -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)
Expand All @@ -93,7 +95,11 @@ if(${QT_VERSION_MAJOR} LESS_EQUAL 5)
endforeach ()
file(APPEND ${QRC} "</qresource></RCC>")

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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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="$<TARGET_FILE_DIR:${PROJECT_NAME}>/$<TARGET_FILE_NAME:${PROJECT_NAME}>"
Expand Down
2 changes: 1 addition & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 14 additions & 3 deletions include/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<QString>
{
size_t operator()(const QString &s) const noexcept { return static_cast<size_t>(qHash(s)); }
};

}
#endif

/* QString helpers */
inline std::tstring QStringToStdTString(const QString &string)
{
#if defined(UNICODE) || defined(_UNICODE)
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions include/efibooteditorcli.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
#include "compat.h"
#include "efibootdata.h"

#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
#include <QtGlobal>
namespace Qt
{
static const auto endl = ::endl;

Check notice

Code scanning / CodeQL

Unused static variable Note

Static variable endl is never read.
}
#endif

class EFIBootEditorCLI: public QObject
{
Q_OBJECT
Expand Down
6 changes: 5 additions & 1 deletion src/efibooteditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ EFIBootEditor::EFIBootEditor(const std::optional<std::tstring> &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<int>::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);
Expand Down Expand Up @@ -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 &)
Expand Down

0 comments on commit d319e00

Please sign in to comment.