From 1869dd0de3bf490abb0fe789236dd6f6909ecf8d Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Sat, 16 Oct 2021 23:36:31 +0100 Subject: [PATCH] NOISSUE Search as you type for modpacks.ch Since we just filter data locally now, this isn't painfully slow - indeed it's very quick. This also matches other platforms, such as ATLauncher. --- launcher/pages/modplatform/ftb/FtbPage.cpp | 8 +++++++- launcher/pages/modplatform/ftb/FtbPage.h | 2 ++ launcher/pages/modplatform/ftb/FtbPage.ui | 12 ++++++------ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/launcher/pages/modplatform/ftb/FtbPage.cpp b/launcher/pages/modplatform/ftb/FtbPage.cpp index 5917b979e..aca93cfef 100644 --- a/launcher/pages/modplatform/ftb/FtbPage.cpp +++ b/launcher/pages/modplatform/ftb/FtbPage.cpp @@ -32,7 +32,8 @@ FtbPage::FtbPage(NewInstanceDialog* dialog, QWidget *parent) } ui->sortByBox->setCurrentText(filterModel->translateCurrentSorting()); - connect(ui->searchButton, &QPushButton::clicked, this, &FtbPage::triggerSearch); + connect(ui->searchEdit, &QLineEdit::textChanged, this, &FtbPage::triggerSearch); + connect(ui->resetButton, &QPushButton::clicked, this, &FtbPage::resetSearch); connect(ui->sortByBox, &QComboBox::currentTextChanged, this, &FtbPage::onSortingSelectionChanged); connect(ui->packView->selectionModel(), &QItemSelectionModel::currentChanged, this, &FtbPage::onSelectionChanged); connect(ui->versionSelectionBox, &QComboBox::currentTextChanged, this, &FtbPage::onVersionSelectionChanged); @@ -104,6 +105,11 @@ void FtbPage::triggerSearch() filterModel->setSearchTerm(ui->searchEdit->text()); } +void FtbPage::resetSearch() +{ + ui->searchEdit->setText(""); +} + void FtbPage::onSortingSelectionChanged(QString data) { auto toSet = filterModel->getAvailableSortings().value(data); diff --git a/launcher/pages/modplatform/ftb/FtbPage.h b/launcher/pages/modplatform/ftb/FtbPage.h index bca09e25c..0dfac1a44 100644 --- a/launcher/pages/modplatform/ftb/FtbPage.h +++ b/launcher/pages/modplatform/ftb/FtbPage.h @@ -65,6 +65,8 @@ private: private slots: void triggerSearch(); + void resetSearch(); + void onSortingSelectionChanged(QString data); void onSelectionChanged(QModelIndex first, QModelIndex second); void onVersionSelectionChanged(QString data); diff --git a/launcher/pages/modplatform/ftb/FtbPage.ui b/launcher/pages/modplatform/ftb/FtbPage.ui index 135afc6da..dc8004978 100644 --- a/launcher/pages/modplatform/ftb/FtbPage.ui +++ b/launcher/pages/modplatform/ftb/FtbPage.ui @@ -39,9 +39,9 @@ - + - Search + Reset @@ -49,15 +49,15 @@ + + true + 48 48 - - true - @@ -76,7 +76,7 @@ searchEdit - searchButton + resetButton versionSelectionBox