Skip to content

Commit

Permalink
Merge pull request #28 from visuve/master
Browse files Browse the repository at this point in the history
Add support for Qt 6
  • Loading branch information
hasherezade authored Apr 3, 2024
2 parents 951711b + 4068298 commit a328c38
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ build_qt5/
build_qt4/
test_cases/
docs/

.vs/
41 changes: 41 additions & 0 deletions build_qt6.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
echo "Trying to autobuild bearparser..."

#QT check

QT_VER=$(qmake -v)
str=$QT_VER
substr="Qt version 6"

echo "$QT_VER"
if [[ $str == *"$substr"* ]]; then
echo "[+] Qt6 found!"
else
str2=$(whereis qt6)
substr2="/qt6"
if [[ $str2 == *"$substr2"* ]]; then
echo "[+] Qt6 found!"
else
echo "Install Qt6 SDK first"
exit -1
fi
fi

CMAKE_VER=$(cmake --version)
CMAKEV="cmake version"
if echo "$CMAKE_VER" | grep -q "$CMAKEV"; then
echo "[+] CMake found!"
else
echo "[-] CMake NOT found!"
echo "Install cmake first"
exit -1
fi

BUILD_DIR=build

mkdir $BUILD_DIR
echo "[+] build directory created"
cd $BUILD_DIR
cmake -G "CodeLite - Unix Makefiles" -DUSE_QT4=OFF -DCMAKE_INSTALL_PREFIX:PATH=$(pwd) ..
cmake --build . --target install

7 changes: 4 additions & 3 deletions commander/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ if(USE_QT4)
INCLUDE( ${QT_USE_FILE} )
ADD_DEFINITIONS( ${QT_DEFINITIONS} )
else()
find_package(Qt5Core REQUIRED)
get_target_property(QtCore_location Qt5::Core LOCATION)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)
get_target_property(QtCore_location Qt${QT_VERSION_MAJOR}::Core LOCATION)
endif()

set (imps_srcs
Expand All @@ -30,7 +31,7 @@ target_link_libraries(${PROJECT_NAME} ${PARSER_LIB})
if(USE_QT4)
target_link_libraries (${PROJECT_NAME} ${QT_QTCORE_LIBRARIES} )
else()
target_link_libraries(${PROJECT_NAME} Qt5::Core)
target_link_libraries(${PROJECT_NAME} Qt${QT_VERSION_MAJOR}::Core)
endif()

#install
Expand Down
7 changes: 4 additions & 3 deletions parser/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ if(USE_QT4)
INCLUDE( ${QT_USE_FILE} )
ADD_DEFINITIONS( ${QT_DEFINITIONS} )
else()
find_package(Qt5Core REQUIRED)
get_target_property(QtCore_location Qt5::Core LOCATION)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core REQUIRED)
get_target_property(QtCore_location Qt${QT_VERSION_MAJOR}::Core LOCATION)
endif()

include_directories (include/bearparser)
Expand Down Expand Up @@ -157,7 +158,7 @@ target_include_directories(bearparser PUBLIC "${CMAKE_CURRENT_LIST_DIR}/include/
if(USE_QT4)
target_link_libraries (bearparser ${QT_QTCORE_LIBRARIES} )
else()
target_link_libraries(bearparser Qt5::Core)
target_link_libraries(bearparser Qt${QT_VERSION_MAJOR}::Core)
endif()


2 changes: 1 addition & 1 deletion parser/Formatter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const QString Formatter::operator[](std::size_t idx) const
}
return "\\x"+ QString::number(b, 16).leftJustified(2,'0');
}
return QString(b);
return QChar(b);
}

/*
Expand Down
5 changes: 5 additions & 0 deletions parser/include/bearparser/WatchedLocker.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
#include <iostream>
#include <QtCore>


#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
class WatchedLocker : public QMutexLocker<QMutex> {
#else
class WatchedLocker : public QMutexLocker {
#endif
public:
WatchedLocker(QMutex *mutex, bool show = false, const char *func = nullptr)
: QMutexLocker(mutex), showLock(show)
Expand Down
6 changes: 5 additions & 1 deletion parser/pe/FileHdrWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ namespace util {
{
const time_t rawtime = (const time_t)timestamp;
QString format = "dddd, dd.MM.yyyy hh:mm:ss";
QDateTime date1(QDateTime(QDateTime::fromTime_t(rawtime)));
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
QDateTime date1(QDateTime::fromSecsSinceEpoch(rawtime));
#else
QDateTime date1(QDateTime::fromTime_t(rawtime));
#endif
return date1.toUTC().toString(format) + " UTC";
}
};
Expand Down

0 comments on commit a328c38

Please sign in to comment.