changeset 29779:58e7df720752

fix doc browser startup when launched from cli * documentation.cc (documentation): init new data members, connect indexingFinished signal to new slot load_index, do not load index automatically; (load_index): new slot for indexingFinished signal, loading index or the desired page if given by the user; (load_ref): store ref name in new data member for later use in load:index, return if indexing not yet ready * documentation.h new slot load_index, load_ref with emtpy argument by default, new data memebrs m_indexed and m_current_ref_name
author Torsten Lilge <ttl-octave@mailbox.org>
date Fri, 18 Jun 2021 21:22:21 +0200
parents c44e54bb018b
children d79f65e37e89
files libgui/src/documentation.cc libgui/src/documentation.h
diffstat 2 files changed, 28 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/documentation.cc	Fri Jun 18 08:55:00 2021 +0200
+++ b/libgui/src/documentation.cc	Fri Jun 18 21:22:21 2021 +0200
@@ -71,6 +71,8 @@
       m_octave_qobj (oct_qobj), m_doc_widget (this),
       m_tool_bar (new QToolBar (this)),
       m_query_string (QString ()),
+      m_indexed (false),
+      m_current_ref_name (QString ()),
       m_prev_pages_menu (new QMenu (this)),
       m_next_pages_menu (new QMenu (this)),
       m_prev_pages_count (0),
@@ -113,8 +115,10 @@
                                 "%1").arg (m_help_engine->error ()));
 #endif
 
-    connect(m_help_engine, SIGNAL(setupFinished()),
-            m_help_engine->searchEngine(), SLOT(indexDocumentation()));
+    connect(m_help_engine->searchEngine (), SIGNAL(indexingFinished ()),
+            this, SLOT(load_index ()));
+    connect(m_help_engine, SIGNAL(setupFinished ()),
+            m_help_engine->searchEngine (), SLOT(reindexDocumentation ()));
 
     if (! m_help_engine->setupData())
       {
@@ -293,18 +297,6 @@
         insertWidget (1, browser_find);
         setStretchFactor (1, 1);
       }
-
-    // Initial view: Contents
-    // FIXME: Setting the URL immediately leads to the "No dcument error"
-    //        although the data setup of the help engine seems to be finished.
-    //        At least, when when calling m_doc_browser->setSource in a slot
-    //        of the setupFinished signal, m_doc_browser is still NULL.
-    //        The current workaround is to delay setting the url by 100 ms.
-    QTimer::singleShot (100, this, [=] ()
-      { m_doc_browser->setSource
-        (QUrl ("qthelp://org.octave.interpreter-1.0/doc/octave.html/index.html"));
-      });
-
   }
 
   documentation::~documentation (void)
@@ -664,11 +656,28 @@
 
   void documentation::selectAll (void) { }
 
+  void documentation::load_index (void)
+  {
+    m_indexed = true;
+
+    // Show index if no other page is required.
+    if (m_current_ref_name.isEmpty ())
+      m_doc_browser->setSource
+        (QUrl ("qthelp://org.octave.interpreter-1.0/doc/octave.html/index.html"));
+    else
+      load_ref (m_current_ref_name);
+  }
+
   void documentation::load_ref (const QString& ref_name)
   {
     if (! m_help_engine || ref_name.isEmpty ())
       return;
 
+    m_current_ref_name = ref_name;
+
+    if (! m_indexed)
+      return;
+
 #if defined (HAVE_QHELPENGINE_DOCUMENTSFORIDENTIFIER)
     QList<QHelpLink> found_links
       = m_help_engine->documentsForIdentifier (ref_name);
--- a/libgui/src/documentation.h	Fri Jun 18 08:55:00 2021 +0200
+++ b/libgui/src/documentation.h	Fri Jun 18 21:22:21 2021 +0200
@@ -129,7 +129,8 @@
     void pasteClipboard (void);
     void selectAll (void);
 
-    void load_ref (const QString & name);
+    void load_index (void);
+    void load_ref (const QString & name = QString ());
     void registerDoc (const QString & name);
     void unregisterDoc (const QString & name);
 
@@ -177,6 +178,9 @@
     QToolBar *m_tool_bar;
     QString m_query_string;
 
+    bool m_indexed;
+    QString m_current_ref_name;
+
     QAction *m_action_go_home;
     QAction *m_action_go_prev;
     QAction *m_action_go_next;