texinfo-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]


From: Gavin D. Smith
Date: Wed, 30 Nov 2022 13:36:40 -0500 (EST)

branch: old/qt-info
commit 126eb1be8dd5aaaffd997bfec759a6d2925b8dd1
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Fri Apr 12 16:05:55 2019 +0100

    implement search
---
 js/docbrowser/core.cpp  | 20 ++++++++++++++++----
 js/docbrowser/core.h    |  2 ++
 js/docbrowser/qtinfo.js | 17 ++++++++++-------
 3 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/js/docbrowser/core.cpp b/js/docbrowser/core.cpp
index c76a9e9e18..24cdc9126e 100644
--- a/js/docbrowser/core.cpp
+++ b/js/docbrowser/core.cpp
@@ -48,12 +48,17 @@ Core::hide_prompt()
     ui->promptCombo->setVisible(false);
 }
 
+/* Return has been pressed in the input box. */
 void
 Core::activate_input (const QString &arg)
 {
+  if (input_search)
+    emit search (arg);
+  else
     emit set_current_url (index_data[arg].toString());
-    hide_prompt();
-    ui->webEngineView->setFocus();
+
+  hide_prompt();
+  ui->webEngineView->setFocus();
 }
 
 /********************* Public Slots **********************/
@@ -62,8 +67,13 @@ Core::activate_input (const QString &arg)
 void
 Core::show_text_input (const QString &input, const QJsonObject &data)
 {
-  if (index_data.isEmpty())
+  if (input == "regexp-search")
+    {
+      input_search = true;
+    }
+  else if (index_data.isEmpty())
     {
+      input_search = false;
       index_data = data.toVariantMap();
       QMapIterator<QString, QVariant> i(index_data);
       while (i.hasNext())
@@ -76,7 +86,9 @@ Core::show_text_input (const QString &input, const 
QJsonObject &data)
   ui->promptLabel->setVisible(true);
   ui->promptCombo->setVisible(true);
   ui->promptCombo->setFocus();
-  ui->promptCombo->setEditText("");
+
+  if (!input_search)
+    ui->promptCombo->setEditText("");
 }
 
 
diff --git a/js/docbrowser/core.h b/js/docbrowser/core.h
index fa146f5527..91e282ce37 100644
--- a/js/docbrowser/core.h
+++ b/js/docbrowser/core.h
@@ -24,6 +24,7 @@ signals:
     // Signals emitted from the C++ side and received on the HTML client side.
     void setUrl (const QString &text);
     void set_current_url (const QString &text);
+    void search (const QString &text);
 
 public slots:
     // Signals emitted from the HTML client side and received on the C++ side.
@@ -33,6 +34,7 @@ public slots:
 private:
     Ui::MainWindow *ui;
     QVariantMap index_data;
+    bool input_search;
 
 };
 
diff --git a/js/docbrowser/qtinfo.js b/js/docbrowser/qtinfo.js
index 580da49d7a..8cb05f5ab7 100644
--- a/js/docbrowser/qtinfo.js
+++ b/js/docbrowser/qtinfo.js
@@ -23,16 +23,12 @@
 /* object shared with controlling Qt/C++ process */
 var core;
 
-/* Whether we are being controlled via a QWebChannel, and the JavaScript is 
-   being injected into the HTML pages.  Try to keep the use of this 
conditional 
-   to a minimum. */
-var wc_controlled = 0;
-
 /* For use with QWebChannel.  To be called after qwebchannel.js has been 
    loaded. */
 function wc_init()
 {
-  wc_controlled = 1;
+  if (!inside_top_page)
+    return;
 
   if (location.search != "")
     var baseUrl
@@ -63,7 +59,7 @@ function wc_init()
              We don't have code to receive "actions" from the C++ side:
              the action message-passing architecture is only used to 
              circumvent same-origin policy restrictions on some browsers for 
-             file: URI's. */
+             file: URI's, and for web_channel_override to hook into. */
 
           channel.objects.core.setUrl.connect(function(url) {
             alert("asked to go to " + url);
@@ -72,6 +68,11 @@ function wc_init()
           channel.objects.core.set_current_url.connect(function(linkid) {
             store.dispatch (actions.set_current_url (linkid));
           });
+
+          channel.objects.core.search.connect(function(string) {
+            store.dispatch (actions.search (string));
+          });
+
         });
     };
 
@@ -110,6 +111,8 @@ function web_channel_override (store, action)
             else
               store.dispatch (actions.warn ("No menu in this node"));
           }
+        else if (action.input == "regexp-search")
+          window.core.show_text_input (action.input, {});
         return 1;
       }
     default:



reply via email to

[Prev in Thread] Current Thread [Next in Thread]