Skip to content

Commit 42fab93

Browse files
committed
Build qthelp for QT6
1 parent 6143d2b commit 42fab93

3 files changed

Lines changed: 48 additions & 54 deletions

File tree

qtfred/CMakeLists.txt

Lines changed: 39 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -108,66 +108,58 @@ source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}/help-src"
108108
FILES ${QTFRED_HELP_SOURCES})
109109

110110
add_custom_command(TARGET qtfred_help POST_BUILD
111-
COMMAND ${CMAKE_COMMAND} -E make_directory "$<TARGET_FILE_DIR:qtfred>/help"
111+
112112
COMMAND ${CMAKE_COMMAND} -E copy_if_different
113113
"${QTFRED_HELP_QCH}"
114-
"$<TARGET_FILE_DIR:qtfred>/help/qtfred_help.qch"
114+
"$<TARGET_FILE_DIR:qtfred>/qtfred_help.qch"
115115
VERBATIM)
116116

117117
install(FILES "${QTFRED_HELP_QCH}"
118-
DESTINATION ${BINARY_DESTINATION}/help
118+
DESTINATION ${BINARY_DESTINATION}
119119
COMPONENT "qtFRED")
120120
# --- end QtFRED built-in help ---
121121

122122
enable_clang_tidy(qtfred)
123123
COPY_FILES_TO_TARGET(qtfred)
124124
if(WIN32)
125-
# Retrieve the absolute path to qmake and then use that path to find
126-
# the windeployqt executable
127-
get_target_property(QMAKE_EXE Qt6::qmake IMPORTED_LOCATION)
128-
get_filename_component(QT_BIN_DIR ${QMAKE_EXE} DIRECTORY)
129-
130-
find_program(WINDEPLOYQT_ENV_SETUP qtenv2.bat HINTS "${QT_BIN_DIR}")
131-
find_program(WINDEPLOYQT_EXECUTABLE windeployqt HINTS "${QT_BIN_DIR}")
132-
133-
# Run windeployqt immediately after build
134-
add_custom_command(TARGET qtfred
135-
POST_BUILD
136-
COMMAND Qt6::windeployqt --dir "${CMAKE_CURRENT_BINARY_DIR}/windeployqt" "$<TARGET_FILE_DIR:qtfred>/$<TARGET_FILE_NAME:qtfred>"
137-
)
138-
install(
139-
DIRECTORY
140-
"${CMAKE_CURRENT_BINARY_DIR}/windeployqt/"
141-
DESTINATION ${BINARY_DESTINATION}
142-
COMPONENT "qtFRED"
143-
)
144-
145-
# Windows requires that the qwindows DLL is copied as well
146-
execute_process(COMMAND ${QT_QMAKE_EXECUTABLE} -query QT_INSTALL_PLUGINS OUTPUT_VARIABLE QT_INSTALL_PLUGINS OUTPUT_STRIP_TRAILING_WHITESPACE)
147-
set(qwindows_path "${QT_INSTALL_PLUGINS}/platforms/qwindows$<$<OR:$<CONFIG:Debug>,$<CONFIG:FastDebug>>:d>.dll")
148-
149-
add_custom_command(TARGET qtfred
150-
POST_BUILD
151-
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${qwindows_path}" "$<TARGET_FILE_DIR:qtfred>/platforms/qwindows$<$<OR:$<CONFIG:Debug>,$<CONFIG:FastDebug>>:d>.dll"
152-
VERBATIM)
153-
154-
install(FILES ${qwindows_path}
155-
DESTINATION ${BINARY_DESTINATION}/platforms
156-
COMPONENT "qtFRED"
157-
)
158-
159-
# Qt Help requires the SQLite SQL driver
160-
set(qsqlite_path "${QT_INSTALL_PLUGINS}/sqldrivers/qsqlite$<$<OR:$<CONFIG:Debug>,$<CONFIG:FastDebug>>:d>.dll")
161-
162-
add_custom_command(TARGET qtfred
163-
POST_BUILD
164-
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${qsqlite_path}" "$<TARGET_FILE_DIR:qtfred>/sqldrivers/qsqlite$<$<OR:$<CONFIG:Debug>,$<CONFIG:FastDebug>>:d>.dll"
165-
VERBATIM)
125+
get_target_property(QMAKE_EXE Qt6::qmake IMPORTED_LOCATION)
126+
get_filename_component(QT_BIN_DIR ${_QTFRED_QMAKE} DIRECTORY)
127+
message(STATUS "Qt bin dir: ${QT_BIN_DIR}")
128+
message(STATUS "qmake path: ${QMAKE_EXE}")
129+
find_program(WINDEPLOYQT_EXECUTABLE
130+
NAMES windeployqt6 windeployqt
131+
HINTS "${QT_BIN_DIR}"
132+
REQUIRED
133+
)
134+
if(NOT WINDEPLOYQT_EXECUTABLE)
135+
message(WARNING "windeployqt not found in '${QT_BIN_DIR}' — Qt DLLs will not be deployed")
136+
else()
137+
message(STATUS "Found windeployqt: ${WINDEPLOYQT_EXECUTABLE}")
138+
endif()
139+
add_custom_command(TARGET qtfred POST_BUILD
140+
COMMAND ${CMAKE_COMMAND} -E echo "Target file is: $<TARGET_FILE:qtfred>"
141+
COMMENT "Debug: checking target file path"
142+
)
143+
add_custom_command(TARGET qtfred POST_BUILD
144+
COMMAND "${WINDEPLOYQT_EXECUTABLE}"
145+
--qthelp
146+
$<$<OR:$<CONFIG:Debug>,$<CONFIG:FastDebug>>:--debug>
147+
$<$<CONFIG:Release>:--release>
148+
--dir "$<TARGET_FILE_DIR:qtfred>"
149+
$<TARGET_FILE:qtfred>
150+
COMMENT "Running windeployqt (with Qt Help support)..."
151+
)
166152

167-
install(FILES ${qsqlite_path}
168-
DESTINATION ${BINARY_DESTINATION}/sqldrivers
153+
install(
154+
DIRECTORY "$<TARGET_FILE_DIR:qtfred>/"
155+
DESTINATION ${BINARY_DESTINATION}
169156
COMPONENT "qtFRED"
170-
)
157+
FILES_MATCHING
158+
PATTERN "Qt6Help*.dll"
159+
PATTERN "qsqlite*.dll"
160+
PATTERN "qwindows*.dll"
161+
PATTERN "*.dll"
162+
)
171163
elseif(FSO_BUILD_APPIMAGE)
172164
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/AppRun.in" "${CMAKE_CURRENT_BINARY_DIR}/AppRun.gen" @ONLY)
173165
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AppRun-$<CONFIG>"

qtfred/src/mission/dialogs/HelpTopicsDialogModel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <QDir>
55
#include <QFile>
66
#include <QFileInfo>
7-
#include <QHelpEngine>
7+
#include <QtHelp/QHelpEngine>
88
#include <QHelpEngineCore>
99
#include <QHelpSearchEngine>
1010
#include <QRegularExpression>

qtfred/src/ui/dialogs/HelpTopicsDialog.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <QTextDocument>
2424
#include <QTreeView>
2525
#include <QVBoxLayout>
26+
#include <QHelpLink>
2627

2728
#include "mission/dialogs/HelpTopicsDialogModel.h"
2829
#include "ui/Theme.h"
@@ -174,9 +175,9 @@ HelpTopicsDialog::HelpTopicsDialog(QWidget* parent)
174175
connect(ui->forwardButton, &QToolButton::clicked, ui->helpBrowser, &QTextBrowser::forward);
175176
connect(ui->helpBrowser, &QTextBrowser::backwardAvailable, ui->backButton, &QToolButton::setEnabled);
176177
connect(ui->helpBrowser, &QTextBrowser::forwardAvailable, ui->forwardButton, &QToolButton::setEnabled);
177-
178-
connect(engine->indexWidget(), &QHelpIndexWidget::linkActivated,
179-
this, &HelpTopicsDialog::loadHelpPage);
178+
ui->helpBrowser->setOpenExternalLinks(true);
179+
//connect(engine->indexWidget(), &QHelpIndexWidget::linkActivated,
180+
// this, &HelpTopicsDialog::loadHelpPage);
180181
connect(ui->helpBrowser, &QTextBrowser::anchorClicked,
181182
this, &HelpTopicsDialog::loadHelpPage);
182183

@@ -238,6 +239,7 @@ void HelpTopicsDialog::findInPage(bool backward) {
238239
}
239240

240241
void HelpTopicsDialog::buildContentsTab() {
242+
241243
QHelpEngine* engine = HelpTopicsDialogModel::helpEngine();
242244
if (engine == nullptr)
243245
return;
@@ -351,7 +353,7 @@ void HelpTopicsDialog::searchTutorials(const QString& query) {
351353
}
352354

353355
static const QRegularExpression tagRe(QStringLiteral("<[^>]+>"));
354-
const QStringList terms = trimmed.split(QLatin1Char(' '), QString::SkipEmptyParts);
356+
const QStringList terms = trimmed.split(QLatin1Char(' '), Qt::SkipEmptyParts);
355357

356358
for (const auto& t : searchablePages) {
357359
const auto& content = HelpTopicsDialogModel::tutorialContent();
@@ -408,9 +410,9 @@ void HelpTopicsDialog::navigateTo(const QString& keywordId) {
408410
QHelpEngine* engine = HelpTopicsDialogModel::helpEngine();
409411
if (engine == nullptr)
410412
return;
411-
const auto links = engine->linksForIdentifier(keywordId);
413+
const auto links = engine->documentsForIdentifier(keywordId);
412414
if (!links.isEmpty())
413-
loadHelpPage(links.constBegin().value());
415+
loadHelpPage(links.constBegin()->url);
414416
}
415417

416418
} // namespace fso::fred::dialogs

0 commit comments

Comments
 (0)