Mercurial > octave
changeset 29031:a0ff81c8b8e8 stable
fix index in document browser for Qt 5.15 (bug #59375)
* documentation.cc: include QHelpLink if available;
(documentation): activate new filter engine in help engine if available,
connect new documentActivated signal to old link activation slot via
lambda expression
* a4include: add test for structure QHelpLink which was added in Qt 5.15
together with the new filter engine in the Qhelp system
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Thu, 05 Nov 2020 21:41:44 +0100 |
parents | 7c9a40fb3337 |
children | 2cbfd91aafb9 |
files | libgui/src/documentation.cc m4/acinclude.m4 |
diffstat | 2 files changed, 46 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/documentation.cc Thu Nov 05 12:06:45 2020 -0500 +++ b/libgui/src/documentation.cc Thu Nov 05 21:41:44 2020 +0100 @@ -36,6 +36,9 @@ #include <QFileInfo> #include <QHelpContentWidget> #include <QHelpIndexWidget> +#if defined (HAVE_QHELPLINK) +#include <QHelpLink> +#endif #include <QHelpSearchEngine> #include <QHelpSearchQueryWidget> #include <QHelpSearchResultWidget> @@ -182,6 +185,10 @@ if (m_help_engine) { +#if defined (HAVE_QHELPLINK) + // Help engine uses filters instead of old api since Qt 5.15 + m_help_engine->setUsesFilterEngine (true); +#endif // Layout contents, index and search QTabWidget *navi = new QTabWidget (this); navi->setTabsClosable (false); @@ -227,10 +234,17 @@ navi->addTab (index_all, tr ("Function Index")); +#if defined (HAVE_QHELPLINK) + connect (m_help_engine->indexWidget (), + &QHelpIndexWidget::documentActivated, + this, [this](const QHelpLink &link) { + m_doc_browser->handle_index_clicked (link.url);}); +#else connect(m_help_engine->indexWidget (), SIGNAL (linkActivated (const QUrl&, const QString&)), m_doc_browser, SLOT(handle_index_clicked (const QUrl&, const QString&))); +#endif connect (m_filter, SIGNAL (editTextChanged (const QString&)), this, SLOT(filter_update (const QString&)));
--- a/m4/acinclude.m4 Thu Nov 05 12:06:45 2020 -0500 +++ b/m4/acinclude.m4 Thu Nov 05 21:41:44 2020 +0100 @@ -604,6 +604,37 @@ fi ]) dnl +dnl Check whether the structure QtHelpLink is defined. Then, +dnl QHelpIndexWidget emits documentActivates instead of linkActivated. +dnl This structure/signal was introduced in Qt 5.15. +dnl +dnl FIXME: Delete this entirely when we drop support for Qt 5.14 or older. +dnl +AC_DEFUN([OCTAVE_CHECK_FUNC_QHELPLINK], [ + AC_CACHE_CHECK([for QHelpLink], + [octave_cv_func_qhelplink], + [AC_LANG_PUSH(C++) + ac_octave_save_CPPFLAGS="$CPPFLAGS" + ac_octave_save_CXXFLAGS="$CXXFLAGS" + CPPFLAGS="$QT_CPPFLAGS $CXXPICFLAG $CPPFLAGS" + CXXFLAGS="$CXXPICFLAG $CPPFLAGS" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include <QHelpLink> + ]], [[ + QHelpLink link; + ]])], + octave_cv_func_qhelplink=yes, + octave_cv_func_qhelplink=no) + CPPFLAGS="$ac_octave_save_CPPFLAGS" + CXXFLAGS="$ac_octave_save_CXXFLAGS" + AC_LANG_POP(C++) + ]) + if test $octave_cv_func_qhelplink = yes; then + AC_DEFINE(HAVE_QHELPLINK, 1, + [Define to 1 if you have the `QHelpLink' structure.]) + fi +]) +dnl dnl Check whether the Qt function qInstallMessageHandler is available. dnl This function was introduced in Qt 5. dnl @@ -2367,6 +2398,7 @@ OCTAVE_CHECK_FUNC_QHEADERVIEW_SETSECTIONSCLICKABLE OCTAVE_CHECK_FUNC_QHEADERVIEW_SETSECTIONSMOVABLE OCTAVE_CHECK_FUNC_QHELPSEARCHQUERYWIDGET_SEARCHINPUT + OCTAVE_CHECK_FUNC_QHELPLINK OCTAVE_CHECK_FUNC_QINSTALLMESSAGEHANDLER OCTAVE_CHECK_FUNC_QLINEEDIT_SETPLACEHOLDERTEXT OCTAVE_CHECK_FUNC_QLIST_ITERATOR_CONSTRUCTOR