aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorConfuSomu2023-08-02 02:34:01 +0200
committerConfuSomu2023-08-02 02:34:01 +0200
commit56a64ae4c5c4cf3fb567445a1bcec0f3a9db143c (patch)
treec43c1f1def305c8fcaf38cc31c118cf295650355 /src
parent88e272b40dd9b0a182662ac77296dc2330b2027f (diff)
downloadActorViewer-56a64ae4c5c4cf3fb567445a1bcec0f3a9db143c.tar
ActorViewer-56a64ae4c5c4cf3fb567445a1bcec0f3a9db143c.tar.gz
ActorViewer-56a64ae4c5c4cf3fb567445a1bcec0f3a9db143c.zip
Initialize find dialog with text from main window
Properly emit the text that was entered in the search bar before the find dialog was opened. This makes sure that it is queried as expected by the user.
Diffstat (limited to 'src')
-rw-r--r--src/finddialog.cpp4
-rw-r--r--src/finddialog.h2
-rw-r--r--src/mainwindow.cpp3
-rw-r--r--src/mainwindow.h2
4 files changed, 8 insertions, 3 deletions
diff --git a/src/finddialog.cpp b/src/finddialog.cpp
index 4de17d0..26538d2 100644
--- a/src/finddialog.cpp
+++ b/src/finddialog.cpp
@@ -47,8 +47,10 @@ void FindDialog::on_textInputSearch_textEdited(const QString &text) {
differed_search->start();
}
-void FindDialog::set_search_text(const QString &text) {
+void FindDialog::set_search_text(const QString &text, bool search_immediately) {
ui->textInputSearch->setText(text);
+ if (search_immediately) init_search();
+ else on_textInputSearch_textEdited(text);
}
inline void FindDialog::run_search() {
diff --git a/src/finddialog.h b/src/finddialog.h
index c6907f8..c26f8fd 100644
--- a/src/finddialog.h
+++ b/src/finddialog.h
@@ -15,7 +15,7 @@ public:
~FindDialog();
public slots:
- void set_search_text(const QString &text);
+ void set_search_text(const QString &text, bool search_immediately = false);
void set_qlist_widget(QListWidget* widget);
inline void run_search();
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 4b3b010..89f550d 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -108,6 +108,9 @@ void MainWindow::on_actionFind_triggered(bool checked) {
connect(find_dialog, &FindDialog::item_selected, this, &MainWindow::select_list_item);
connect(this, &MainWindow::search_text_changed, find_dialog, &FindDialog::set_search_text);
connect(find_dialog, &FindDialog::search_text_changed, this, &MainWindow::set_search_text);
+
+ if (not ui->textInputSearch->text().isEmpty())
+ emit search_text_changed(ui->textInputSearch->text(), true);
}
find_dialog->show();
diff --git a/src/mainwindow.h b/src/mainwindow.h
index fedbc9d..162e6bf 100644
--- a/src/mainwindow.h
+++ b/src/mainwindow.h
@@ -30,7 +30,7 @@ public slots:
void set_search_text(const QString &text);
signals:
- void search_text_changed(const QString &text);
+ void search_text_changed(const QString &text, bool search_immediately = false);
private slots:
void on_actionOpen_triggered(bool checked);