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:42 -0500 (EST)

branch: old/qt-info
commit dd2e991c568ee6119a0a225655f6bd5da7ca2a90
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Thu Apr 18 19:31:32 2019 +0100

    input box changes
---
 js/docbrowser/core.cpp       | 40 ++++++++++++++++++++--------------------
 js/docbrowser/core.h         |  1 +
 js/docbrowser/mainwindow.cpp | 12 +++++++++---
 3 files changed, 30 insertions(+), 23 deletions(-)

diff --git a/js/docbrowser/core.cpp b/js/docbrowser/core.cpp
index 81f3be38d0..2d1e8869f4 100644
--- a/js/docbrowser/core.cpp
+++ b/js/docbrowser/core.cpp
@@ -25,11 +25,11 @@ Core::load_manual (const char *manual)
 
     if (path)
       {
-        qDebug() << "got path" << path;
-
         main_window->load_url(QString("file:") + path);
 
-        this->index_data.clear(); // FIXME: this should be done automatically, 
maybe by having a separate map for each window.
+        /* Maybe this should be done automatically by having a separate 
+           map for each manual. */
+        this->index_data.clear();
 
         free (path);
         return true;
@@ -54,27 +54,21 @@ Core::activate_input (const QString &arg)
 void
 Core::show_text_input (const QString &input, const QJsonObject &data)
 {
-  bool populate_combo = false;
-
   if (input == "regexp-search")
     {
-      input_search = true;
-    }
-  else if (index_data.isEmpty())
-    {
-      input_search = false;
-      populate_combo = true;
+      input_search = 1;
+      clear_prompt();
     }
-  if (populate_combo)
+  else
     {
-      index_data = data.toVariantMap();
-      main_window->populate_combo(index_data);
+      input_search = 0;
+      if (index_data.isEmpty())
+        {
+          index_data = data.toVariantMap();
+          main_window->populate_combo(index_data);
+        }
     }
-
   main_window->show_prompt();
-
-  if (!input_search)
-    main_window->clear_prompt();
 }
 
 
@@ -90,11 +84,17 @@ Core::external_manual (const QString &url)
     if (manual)
       {
         load_manual (manual);
-        // and set node to node
-        qDebug () << "got node" << node;
         //emit setNode (node);
      }
 
     free (manual); free (node);
 }
 
+/****************** Private Functions **********************/
+void
+Core::clear_prompt ()
+{
+  this->index_data.clear();
+  main_window->clear_prompt();
+}
+
diff --git a/js/docbrowser/core.h b/js/docbrowser/core.h
index 15ea47a76f..968947d794 100644
--- a/js/docbrowser/core.h
+++ b/js/docbrowser/core.h
@@ -35,6 +35,7 @@ private:
     QVariantMap index_data;
     bool input_search;
 
+    void clear_prompt ();
 };
 
 #endif // CORE_H
diff --git a/js/docbrowser/mainwindow.cpp b/js/docbrowser/mainwindow.cpp
index 818ef609d8..a6ff8d2068 100644
--- a/js/docbrowser/mainwindow.cpp
+++ b/js/docbrowser/mainwindow.cpp
@@ -180,8 +180,8 @@ void MainWindow::quit()
 
 void MainWindow::focusChanged (QWidget *old, QWidget *now)
 {
-    if (now == ui->webEngineView)
-       hide_prompt();
+    if (now != ui->promptCombo && now != ui->promptCombo->view())
+       hide_prompt ();
 }
 
 void MainWindow::on_quitButton_clicked()
@@ -220,18 +220,24 @@ MainWindow::show_prompt()
   ui->promptLabel->setVisible(true);
   ui->promptCombo->setVisible(true);
   ui->promptCombo->setFocus();
+  ui->promptCombo->setEditText("");
 }
 
 
 void
 MainWindow::clear_prompt()
 {
-  ui->promptCombo->setEditText("");
+  ui->promptCombo->clear();
 }
 
+/* Add suggestions for the combo box from DATA.
+   We should be able to do this a faster way with setModel, to choose
+   whether to use the index suggestions or allow free input for the text 
+   search. */
 void
 MainWindow::populate_combo (const QMap<QString, QVariant> &data)
 {
+  clear_prompt();
   QMapIterator<QString, QVariant> i(data);
   while (i.hasNext())
     {



reply via email to

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