Skip to content

Commit 5f1f9ec

Browse files
committed
feat: Support both Qt5 and Qt6
1 parent fc73e1c commit 5f1f9ec

File tree

23 files changed

+206
-130
lines changed

23 files changed

+206
-130
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ jobs:
1212

1313
steps:
1414
- uses: actions/checkout@v2
15+
- uses: jurplel/[email protected]
1516

1617
- name: Install dependencies
1718
run: |
1819
sudo apt-get update
19-
sudo apt-get install -y build-essential gcc-10 g++-10 qt5-default libqt5x11extras5-dev cmake
20+
sudo apt-get install -y build-essential gcc-10 g++-10 cmake
2021
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-10 100 --slave /usr/bin/g++ g++ /usr/bin/g++-10 --slave /usr/bin/gcov gcov /usr/bin/gcov-10
2122
git submodule update --init --recursive
2223

CMakeLists.txt

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ cmake_minimum_required(VERSION 3.12)
22

33
project(REDasm)
44

5-
set(_QT_VERSION_REQ 5.11)
6-
set(QT_VERSION_REQ "${_QT_VERSION_REQ}")
75
set(CMAKE_AUTOMOC ON)
86
set(CMAKE_AUTOUIC ON)
97
set(CMAKE_AUTORCC ON)
@@ -12,12 +10,15 @@ include(${CMAKE_SOURCE_DIR}/LibREDasm/cmake/sanitizers.cmake)
1210

1311
string(TIMESTAMP REDASM_BUILD_TIMESTAMP "%Y%m%d")
1412
set(REDASM_GIT_VERSION "unknown")
15-
set(REDASM_VERSION_BASE "3.0-BETA6")
13+
set(REDASM_VERSION_BASE "3.0-BETA7")
1614

1715
find_package(Git)
18-
find_package(Qt5 ${_QT_VERSION_REQ} REQUIRED COMPONENTS Widgets)
19-
#find_package(Qt5X11Extras ${_QT_VERSION_REQ} REQUIRED) # Needed for KDDockWidgets
20-
find_package(Qt5LinguistTools ${_QT_VERSION_REQ})
16+
find_package(Qt6 COMPONENTS Widgets)
17+
18+
if(NOT Qt6_FOUND)
19+
find_package(Qt5 REQUIRED COMPONENTS Widgets)
20+
find_package(Qt5LinguistTools)
21+
endif()
2122

2223
include(LibREDasm/cmake/CPM.cmake)
2324

@@ -34,14 +35,21 @@ endif()
3435
set(REDASM_BUILD_VERSION "${REDASM_BUILD_TIMESTAMP}.${REDASM_GIT_VERSION}")
3536
add_definitions(-DREDASM_VERSION="${REDASM_VERSION_BASE} \(${REDASM_BUILD_VERSION}\)")
3637

37-
set(KDDOCKWIDGETS_OPTIONS "KDDockWidgets_STATIC ON"
38-
"KDDockWidgets_EXAMPLES OFF"
39-
"KDDockWidgets_UNITY_BUILD OFF")
38+
if(Qt6_FOUND)
39+
set(KDDOCKWIDGETS_OPTIONS "KDDockWidgets_QT6 ON"
40+
"KDDockWidgets_STATIC ON"
41+
"KDDockWidgets_EXAMPLES OFF"
42+
"KDDockWidgets_UNITY_BUILD OFF")
43+
else()
44+
set(KDDOCKWIDGETS_OPTIONS "KDDockWidgets_STATIC ON"
45+
"KDDockWidgets_EXAMPLES OFF"
46+
"KDDockWidgets_UNITY_BUILD OFF")
47+
endif()
4048

4149
CPMAddPackage(
42-
NAME KDDockWidgetes
50+
NAME KDDockWidgets
4351
GIT_REPOSITORY https://github.com/KDAB/KDDockWidgets
44-
VERSION 1.4.0
52+
VERSION 1.7.0
4553
OPTIONS ${KDDOCKWIDGETS_OPTIONS}
4654
EXCLUDE_FROM_ALL ON
4755
)
@@ -56,7 +64,7 @@ add_subdirectory(submodules/plugins)
5664
add_subdirectory(submodules/assemblers)
5765
add_subdirectory(submodules/loaders)
5866
add_subdirectory(submodules/database)
59-
qt5_wrap_ui(UI_HDRS ${UI_FILES})
67+
qt_wrap_ui(UI_HDRS ${UI_FILES})
6068

6169
# Widgets
6270
file(GLOB_RECURSE WIDGETS_HEADERS CONFIGURE_DEPENDS widgets/*.h )
@@ -90,7 +98,6 @@ file(GLOB_RECURSE UI_SOURCES CONFIGURE_DEPENDS ui/*.cpp)
9098
file(GLOB_RECURSE UI_UIS CONFIGURE_DEPENDS ui/*.ui)
9199

92100
SET(HEADERS
93-
${QHEXVIEW_HEADERS}
94101
${REDASM_TEST_HEADERS}
95102
${WIDGETS_HEADERS}
96103
${DIALOGS_HEADERS}
@@ -105,7 +112,6 @@ SET(HEADERS
105112
redasmfonts.h)
106113

107114
SET(SOURCES
108-
${QHEXVIEW_SOURCES}
109115
${REDASM_TEST_SOURCES}
110116
${WIDGETS_SOURCES}
111117
${DIALOGS_SOURCES}
@@ -135,20 +141,21 @@ endif()
135141

136142
set(ALL_SOURCES ${SOURCES} ${HEADERS} ${FORMS})
137143

138-
if(Qt5LinguistTools_FOUND) # Prepare translations
144+
if(QtLinguistTools_FOUND) # Prepare translations
139145
message(STATUS "${PROJECT_NAME}: Adding multilanguage support")
140-
qt5_create_translation(QM_FILES ${ALL_SOURCES} translations/redasm_en.ts)
146+
qt_create_translation(QM_FILES ${ALL_SOURCES} translations/redasm_en.ts)
141147
configure_file(translations.qrc ${CMAKE_BINARY_DIR} COPYONLY)
142148
set(TRANSLATIONS_QRC ${CMAKE_BINARY_DIR}/translations.qrc)
143149
else()
144150
message(STATUS "${PROJECT_NAME}: Multilanguage support NOT available")
145151
endif()
146152

147-
add_executable(${PROJECT_NAME} ${GUI_TYPE}
148-
${ALL_SOURCES} ${RESOURCES}
153+
add_executable(${PROJECT_NAME} ${GUI_TYPE} ${RESOURCES}
149154
${TRANSLATIONS_QRC} ${QM_FILES}
150155
"${CMAKE_SOURCE_DIR}/res/windows/resources.rc")
151156

157+
target_sources(${PROJECT_NAME} PRIVATE ${ALL_SOURCES})
158+
152159
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17)
153160
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_EXTENSIONS OFF)
154161

@@ -159,11 +166,11 @@ target_include_directories(${PROJECT_NAME} PRIVATE
159166
libs)
160167

161168
target_link_libraries(${PROJECT_NAME} PRIVATE
162-
Qt5::Core
163-
Qt5::Gui
164-
Qt5::Widgets
169+
Qt::Core
170+
Qt::Gui
171+
Qt::Widgets
165172
KDAB::kddockwidgets
166-
qhexview-lib
173+
QHexView
167174
LibREDasm)
168175

169176
# Include Threads
@@ -181,16 +188,16 @@ set(REDASM_DEPLOY_DIR ${CMAKE_BINARY_DIR}/deploy)
181188

182189
# Deploy Qt DLLs on Windows
183190
# https://stackoverflow.com/a/41199492/1806760
184-
if(Qt5_FOUND AND WIN32 AND TARGET Qt5::qmake AND NOT TARGET Qt5::windeployqt)
185-
get_target_property(_qt5_qmake_location Qt5::qmake IMPORTED_LOCATION)
191+
if(Qt_FOUND AND WIN32 AND TARGET Qt::qmake AND NOT TARGET Qt::windeployqt)
192+
get_target_property(_qt_qmake_location Qt::qmake IMPORTED_LOCATION)
186193

187194
execute_process(
188-
COMMAND "${_qt5_qmake_location}" -query QT_INSTALL_PREFIX
195+
COMMAND "${_qt_qmake_location}" -query QT_INSTALL_PREFIX
189196
RESULT_VARIABLE return_code
190-
OUTPUT_VARIABLE qt5_install_prefix
197+
OUTPUT_VARIABLE qt_install_prefix
191198
OUTPUT_STRIP_TRAILING_WHITESPACE)
192199

193-
set(_WINDEPLOYQT_EXECUTABLE "${qt5_install_prefix}/bin/windeployqt.exe")
200+
set(_WINDEPLOYQT_EXECUTABLE "${qt_install_prefix}/bin/windeployqt.exe")
194201

195202
if(EXISTS ${_WINDEPLOYQT_EXECUTABLE})
196203
set(WINDEPLOYQT_EXECUTABLE ${_WINDEPLOYQT_EXECUTABLE})

dialogs/devdialog/tabs/documenttab.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ QString DocumentTab::padHexDump(const QString& hexdump) const
113113
for(int i = 0; i < hexdump.size(); i += 2)
114114
{
115115
if(!phexdump.isEmpty()) phexdump += " ";
116-
phexdump += hexdump.midRef(i, 2);
116+
phexdump += hexdump.mid(i, 2);
117117
}
118118

119119
return phexdump;

hooks/disassemblerhooks.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ void DisassemblerHooks::showDialog(const QString& title, QWidget* w)
422422
{
423423
QVBoxLayout* l = new QVBoxLayout();
424424
l->setSpacing(0);
425-
l->setMargin(0);
425+
l->setContentsMargins(0, 0, 0, 0);
426426
l->addWidget(w);
427427

428428
QDialog* dialog = new QDialog();

hooks/disassemblerhooks.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <QPushButton>
1818
#include <QLabel>
1919
#include <QFileInfo>
20+
#include <QMenu>
2021
#include <rdapi/rdapi.h>
2122
#include "isurface.h"
2223

@@ -26,6 +27,22 @@ class OutputWidget;
2627
class DisassemblerDocks;
2728
class DockWidget;
2829

30+
namespace REDasmCompat {
31+
32+
template<typename Slot>
33+
inline QAction* addAction(QMenu* m, const QString& text, const QObject* object, Slot slot, const QKeySequence& shortcut) {
34+
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
35+
return m->addAction(text, shortcut, object, slot);
36+
#else
37+
return m->addAction(text, object, slot, shortcut);
38+
#endif
39+
}
40+
41+
template<typename Slot>
42+
inline QAction* addAction(QMenu* m, const QString& text, const QObject* object, Slot slot) { return m->addAction(text, object, slot); }
43+
44+
}
45+
2946
class DisassemblerHooks: public QObject
3047
{
3148
Q_OBJECT

libs/qhexview

Submodule qhexview updated 55 files

models/dev/blocklistmodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ QVariant BlockListModel::data(const QModelIndex& index, int role) const
5656
if(index.column() == 3) return THEME_VALUE(Theme_Type);
5757
if(index.column() == 4) return THEME_VALUE(Theme_Label);
5858
}
59-
else if(role == Qt::TextAlignmentRole) return (index.column() < 4) ? Qt::AlignCenter : (Qt::AlignLeft + Qt::AlignVCenter);
59+
else if(role == Qt::TextAlignmentRole) return QVariant{(index.column() < 4) ? Qt::AlignCenter : (Qt::AlignLeft | Qt::AlignVCenter)};
6060

6161
return QVariant();
6262
}

models/functionsmodel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ QVariant FunctionsModel::data(const QModelIndex& index, int role) const
2626
}
2727
else if(role == Qt::TextAlignmentRole)
2828
{
29-
if(index.column() == 0) return Qt::AlignRight + Qt::AlignVCenter;
30-
if(index.column() == 1) return Qt::AlignLeft + Qt::AlignVCenter;
29+
if(index.column() == 0) return QVariant{Qt::AlignRight | Qt::AlignVCenter};
30+
if(index.column() == 1) return QVariant{Qt::AlignLeft | Qt::AlignVCenter};
3131
}
3232
else if((role == Qt::ForegroundRole) && (index.column() == 0))
3333
return THEME_VALUE(Theme_Address);

models/gotomodel.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ QVariant GotoModel::data(const QModelIndex &index, int role) const
2828
}
2929
else if(role == Qt::TextAlignmentRole)
3030
{
31-
if(index.column() == 0) return Qt::AlignRight + Qt::AlignVCenter;
32-
if(index.column() == 1) return Qt::AlignLeft + Qt::AlignVCenter;
31+
if(index.column() == 0) return QVariant{Qt::AlignRight | Qt::AlignVCenter};
32+
if(index.column() == 1) return QVariant{Qt::AlignLeft | Qt::AlignVCenter};
3333
}
3434
else if((role == Qt::ForegroundRole) && (index.column() == 0))
3535
return THEME_VALUE(Theme_Address);

models/labelsmodel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ QVariant LabelsModel::data(const QModelIndex& index, int role) const
6262
}
6363
}
6464
else if(role == Qt::ForegroundRole) return (index.column() == 0) ? THEME_VALUE(Theme_Address) : QVariant();
65-
else if(role == Qt::TextAlignmentRole) return (index.column() < 3) ? Qt::AlignCenter + Qt::AlignVCenter : Qt::AlignLeft + Qt::AlignVCenter;
65+
else if(role == Qt::TextAlignmentRole) return QVariant{(index.column() < 3) ? (Qt::AlignCenter | Qt::AlignVCenter) : (Qt::AlignLeft | Qt::AlignVCenter)};
6666

6767
return QVariant();
6868
}

0 commit comments

Comments
 (0)