[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:43 -0500 (EST) |
branch: old/qt-info
commit 3217b46be203706daae0ad548394aa37f3a92e88
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Thu Apr 18 23:27:25 2019 +0100
use separate widget for input search
---
js/docbrowser/core.cpp | 19 +++++++++++++------
js/docbrowser/core.h | 2 ++
js/docbrowser/mainwindow.cpp | 32 ++++++++++++++++++++++++++++++--
js/docbrowser/mainwindow.h | 3 +++
js/docbrowser/mainwindow.ui | 16 +++++++++++++++-
js/docbrowser/qtinfo.js | 6 ++++--
6 files changed, 67 insertions(+), 11 deletions(-)
diff --git a/js/docbrowser/core.cpp b/js/docbrowser/core.cpp
index 2d1e8869f4..37024752c6 100644
--- a/js/docbrowser/core.cpp
+++ b/js/docbrowser/core.cpp
@@ -42,10 +42,13 @@ Core::load_manual (const char *manual)
void
Core::activate_input (const QString &arg)
{
- if (input_search)
- emit search (arg);
- else
- emit set_current_url (index_data[arg].toString());
+ emit set_current_url (index_data[arg].toString());
+}
+
+void
+Core::do_search (const QString &arg)
+{
+ emit search (arg);
}
/********************* Public Slots **********************/
@@ -71,12 +74,16 @@ Core::show_text_input (const QString &input, const
QJsonObject &data)
main_window->show_prompt();
}
+void
+Core::show_search ()
+{
+ main_window->show_search();
+}
+
void
Core::external_manual (const QString &url)
{
- qDebug() << "sent url" << url;
-
// Repace the file being viewed
char *manual, *node;
parse_external_url (qPrintable(url), &manual, &node);
diff --git a/js/docbrowser/core.h b/js/docbrowser/core.h
index 968947d794..b36dd273fb 100644
--- a/js/docbrowser/core.h
+++ b/js/docbrowser/core.h
@@ -18,6 +18,7 @@ public:
bool load_manual (const char *manual);
void activate_input (const QString &arg);
+ void do_search (const QString &arg);
signals:
// Signals emitted from the C++ side and received on the HTML client side.
@@ -29,6 +30,7 @@ public slots:
// Signals emitted from the HTML client side and received on the C++ side.
void external_manual (const QString &url);
void show_text_input (const QString &input, const QJsonObject &data);
+ void show_search ();
private:
MainWindow *main_window;
diff --git a/js/docbrowser/mainwindow.cpp b/js/docbrowser/mainwindow.cpp
index a6ff8d2068..b8263feb5a 100644
--- a/js/docbrowser/mainwindow.cpp
+++ b/js/docbrowser/mainwindow.cpp
@@ -31,6 +31,7 @@ MainWindow::MainWindow(QWidget *parent) :
setup_channel ();
hide_prompt();
+ hide_search();
auto *profile = new QWebEngineProfile(this);
setup_profile(profile);
@@ -182,6 +183,9 @@ void MainWindow::focusChanged (QWidget *old, QWidget *now)
{
if (now != ui->promptCombo && now != ui->promptCombo->view())
hide_prompt ();
+ if (now != ui->searchEdit)
+ hide_search ();
+
}
void MainWindow::on_quitButton_clicked()
@@ -220,7 +224,6 @@ MainWindow::show_prompt()
ui->promptLabel->setVisible(true);
ui->promptCombo->setVisible(true);
ui->promptCombo->setFocus();
- ui->promptCombo->setEditText("");
}
@@ -230,6 +233,7 @@ MainWindow::clear_prompt()
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
@@ -246,7 +250,31 @@ MainWindow::populate_combo (const QMap<QString, QVariant>
&data)
}
}
-void MainWindow::on_manualEdit_returnPressed()
+
+void
+MainWindow::show_search()
+{
+ ui->searchLabel->setVisible(true);
+ ui->searchEdit->setVisible(true);
+ ui->searchEdit->setFocus();
+}
+
+void
+MainWindow::hide_search()
+{
+ ui->searchLabel->setVisible(false);
+ ui->searchEdit->setVisible(false);
+}
+
+
+void
+MainWindow::on_manualEdit_returnPressed()
{
on_loadButton_clicked();
}
+
+void
+MainWindow::on_searchEdit_returnPressed()
+{
+ core->do_search (ui->searchEdit->text());
+}
diff --git a/js/docbrowser/mainwindow.h b/js/docbrowser/mainwindow.h
index 47618127a2..97461a890e 100644
--- a/js/docbrowser/mainwindow.h
+++ b/js/docbrowser/mainwindow.h
@@ -25,12 +25,15 @@ public:
void show_prompt ();
void clear_prompt ();
void populate_combo (const QMap<QString, QVariant> &data);
+ void show_search();
+ void hide_search();
void load_url (const QString &string);
private slots:
void on_quitButton_clicked();
void on_loadButton_clicked();
void on_promptCombo_activated(const QString &arg1);
+ void on_searchEdit_returnPressed();
void on_manualEdit_returnPressed();
diff --git a/js/docbrowser/mainwindow.ui b/js/docbrowser/mainwindow.ui
index 8310cdee01..7118299be5 100644
--- a/js/docbrowser/mainwindow.ui
+++ b/js/docbrowser/mainwindow.ui
@@ -26,7 +26,7 @@
</sizepolicy>
</property>
<property name="text">
- <string>Prompt:</string>
+ <string>Index:</string>
</property>
</widget>
</item>
@@ -45,6 +45,20 @@
</item>
</layout>
</item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QLabel" name="searchLabel">
+ <property name="text">
+ <string>Search:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="searchEdit"/>
+ </item>
+ </layout>
+ </item>
<item>
<widget class="QWebEngineView" name="webEngineView">
<property name="url">
diff --git a/js/docbrowser/qtinfo.js b/js/docbrowser/qtinfo.js
index 4dc4fa40f2..996cf2d1aa 100644
--- a/js/docbrowser/qtinfo.js
+++ b/js/docbrowser/qtinfo.js
@@ -110,8 +110,10 @@ function web_channel_override (store, action)
{
if (action.input == "index")
window.core.show_text_input (action.input, state.index);
- else if (action.input == "menu")
+ else if (0 && action.input == "menu")
{
+ /* Menu code is disabled currently - it is not especially
+ useful. */
var current_menu = state.loaded_nodes[state.current].menu;
if (current_menu)
window.core.show_text_input (action.input, current_menu);
@@ -119,7 +121,7 @@ function web_channel_override (store, action)
store.dispatch (actions.warn ("No menu in this node"));
}
else if (action.input == "regexp-search")
- window.core.show_text_input (action.input, {});
+ window.core.show_search ();
return 1;
}
default:
- [no subject], (continued)
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject],
Gavin D. Smith <=
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30
- [no subject], Gavin D. Smith, 2022/11/30