mirror of
https://github.com/chris2511/xca.git
synced 2026-09-14 11:06:19 +05:00
Fix and improve building help and documentation
- Always build html documentation if sphinx-build is available.
to be installable during install
- Collect "${D}/qthelp/xca.qhc" "${D}/qthelp/xca.qch" in QTHELP_IDX
and use this instead.
- On linux also install the qthelp in an html subdirectory like WIN32
- Don't instanciate QHelpEngine if no help available.
This commit is contained in:
parent
7ee80dc1e3
commit
25d2fdabb2
@ -4,7 +4,7 @@ set(D "${PROJECT_BINARY_DIR}/doc")
|
||||
file(MAKE_DIRECTORY "${D}")
|
||||
|
||||
find_program(SPHINX sphinx-build)
|
||||
find_program(QTCOLLGEN qcollectiongenerator)
|
||||
find_program(QTCOLLGEN NAMES qhelpgenerator qcollectiongenerator)
|
||||
|
||||
set(FILENAMES
|
||||
index commandline requests object-ids common-actions database options
|
||||
@ -64,7 +64,7 @@ if(SPHINX)
|
||||
COMMAND xcadoc rst "${D}/rst/arguments.rst"
|
||||
COMMENT "Generate 'rst' commandline documentation"
|
||||
)
|
||||
add_custom_target(sphinx-html DEPENDS ${D}/html/index.html)
|
||||
add_custom_target(sphinx-html ALL DEPENDS ${HTML_DEST})
|
||||
add_custom_target(sphinx-src
|
||||
DEPENDS ${D}/rst/COPYRIGHT ${D}/rst/changelog
|
||||
${D}/rst/_static/bigcert.png
|
||||
@ -78,31 +78,28 @@ if(SPHINX)
|
||||
DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/${CMAKE_PROJECT_NAME}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(QTCOLLGEN)
|
||||
set(QTHELP_IDX ${D}/qthelp/xca.qhc ${D}/qthelp/xca.qch)
|
||||
add_custom_command(
|
||||
OUTPUT "${D}/qthelp/xca.qhc" "${D}/qthelp/xca.qch"
|
||||
COMMAND ${QTCOLLGEN} "${D}/qthelp/xca.qhcp"
|
||||
DEPENDS "${D}/qthelp/xca.qhcp"
|
||||
OUTPUT ${QTHELP_IDX}
|
||||
COMMAND ${QTCOLLGEN} ${D}/qthelp/xca.qhcp
|
||||
DEPENDS ${D}/qthelp/xca.qhcp
|
||||
COMMENT "Create context sensitive help index"
|
||||
)
|
||||
add_custom_target(sphinx-qthelp ALL DEPENDS
|
||||
"${D}/qthelp/xca.qhc" "${D}/qthelp/xca.qch"
|
||||
)
|
||||
target_sources(${CMAKE_PROJECT_NAME} PRIVATE
|
||||
"${QTHELP_DEST}"
|
||||
"${D}/qthelp/xca.qhc"
|
||||
"${D}/qthelp/xca.qch"
|
||||
)
|
||||
list(APPEND APP_RESOURCES ${QTHELP_DEST} "${D}/qthelp/xca.qhc"
|
||||
"${D}/qthelp/xca.qch"
|
||||
)
|
||||
add_custom_target(sphinx-qthelp ALL DEPENDS ${QTHELP_IDX})
|
||||
|
||||
endif()
|
||||
endif()
|
||||
target_sources(${CMAKE_PROJECT_NAME} PRIVATE ${QTHELP_DEST} ${QTHELP_IDX})
|
||||
list(APPEND APP_RESOURCES ${QTHELP_DEST} ${QTHELP_IDX})
|
||||
|
||||
if (NOT SPHINX OR NOT QTCOLLGEN)
|
||||
add_custom_target(sphinx-qthelp)
|
||||
endif()
|
||||
if (UNIX AND NOT APPLE)
|
||||
install(FILES ${QTHELP_DEST} ${QTHELP_IDX}
|
||||
DESTINATION ${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJECT_NAME}/html
|
||||
)
|
||||
endif()
|
||||
|
||||
endif(QTCOLLGEN)
|
||||
endif(SPHINX)
|
||||
|
||||
if (NOT WIN32)
|
||||
add_custom_command(
|
||||
|
||||
@ -239,9 +239,10 @@ const QString getDocDir()
|
||||
#endif
|
||||
docs += QStandardPaths::standardLocations(QStandardPaths::DataLocation);
|
||||
foreach (docdir, docs) {
|
||||
#if defined(Q_OS_WIN32)
|
||||
#if !defined(Q_OS_MAC)
|
||||
docdir += "/html";
|
||||
#endif
|
||||
qWarning() << "DOCDIR" << docdir;
|
||||
if (QFileInfo::exists(docdir + "/xca.qhc")) {
|
||||
qDebug() << "Detected" << docdir + "/xca.qhc";
|
||||
return docdir;
|
||||
|
||||
@ -13,14 +13,15 @@
|
||||
#include <QHelpEngine>
|
||||
#include <QDialogButtonBox>
|
||||
|
||||
Help::Help() : QWidget(NULL)
|
||||
Help::Help() : QWidget(NULL), helpengine(nullptr)
|
||||
{
|
||||
setupUi(this);
|
||||
setWindowTitle(XCA_TITLE);
|
||||
textbox->setSearchPaths(QStringList(getDocDir()));
|
||||
textbox->setOpenExternalLinks(true);
|
||||
textbox->clearHistory();
|
||||
helpengine = new QHelpEngineCore(getDocDir() + "/xca.qhc");
|
||||
if (!getDocDir().isEmpty())
|
||||
helpengine = new QHelpEngineCore(getDocDir() + "/xca.qhc");
|
||||
}
|
||||
|
||||
Help::~Help()
|
||||
@ -43,6 +44,8 @@ void Help::content()
|
||||
|
||||
QMap<QString, QUrl> Help::url_by_ctx(const QString &ctx) const
|
||||
{
|
||||
if (!helpengine)
|
||||
return QMap<QString, QUrl>();
|
||||
return helpengine->linksForIdentifier(QString("%1.%1").arg(ctx));
|
||||
}
|
||||
|
||||
@ -78,7 +81,7 @@ void Help::register_ctxhelp_button(QDialog *dlg, const QString &help_ctx) const
|
||||
buttonBox->setProperty("help_ctx", QVariant(help_ctx));
|
||||
connect(buttonBox, SIGNAL(helpRequested()), this, SLOT(contexthelp()));
|
||||
|
||||
if (url_by_ctx(help_ctx).count() == 0) {
|
||||
if (helpengine && url_by_ctx(help_ctx).count() == 0) {
|
||||
qWarning() << "Unknown help context: " << help_ctx;
|
||||
buttonBox->button(QDialogButtonBox::Help)->setEnabled(false);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user