From c2b97c3e3f5ecb5a995b342c4e0afec6a1a3b2f6 Mon Sep 17 00:00:00 2001 From: flow Date: Sat, 2 Apr 2022 18:33:50 -0300 Subject: feat: Integrate newly created filter dialog in ModPage --- launcher/ui/pages/modplatform/ModPage.cpp | 28 ++++++++++++++++++++++++---- launcher/ui/pages/modplatform/ModPage.h | 7 +++++++ launcher/ui/pages/modplatform/ModPage.ui | 11 +++++++++-- 3 files changed, 40 insertions(+), 6 deletions(-) (limited to 'launcher/ui/pages') diff --git a/launcher/ui/pages/modplatform/ModPage.cpp b/launcher/ui/pages/modplatform/ModPage.cpp index eabd8379..16e44c0d 100644 --- a/launcher/ui/pages/modplatform/ModPage.cpp +++ b/launcher/ui/pages/modplatform/ModPage.cpp @@ -2,21 +2,29 @@ #include "ui_ModPage.h" #include +#include #include "minecraft/MinecraftInstance.h" #include "minecraft/PackProfile.h" #include "ui/dialogs/ModDownloadDialog.h" ModPage::ModPage(ModDownloadDialog* dialog, BaseInstance* instance, ModAPI* api) - : QWidget(dialog), m_instance(instance), ui(new Ui::ModPage), dialog(dialog), api(api) + : QWidget(dialog) + , m_instance(instance) + , ui(new Ui::ModPage) + , dialog(dialog) + , filter_dialog(static_cast(instance)->getPackProfile()->getComponentVersion("net.minecraft"), this) + , api(api) { ui->setupUi(this); connect(ui->searchButton, &QPushButton::clicked, this, &ModPage::triggerSearch); + connect(ui->modFilterButton, &QPushButton::clicked, this, &ModPage::filterMods); ui->searchEdit->installEventFilter(this); ui->versionSelectionBox->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); ui->versionSelectionBox->view()->parentWidget()->setMaximumHeight(300); + m_filter = filter_dialog.getFilter(); } ModPage::~ModPage() @@ -49,6 +57,13 @@ auto ModPage::eventFilter(QObject* watched, QEvent* event) -> bool /******** Callbacks to events in the UI (set up in the derived classes) ********/ +void ModPage::filterMods() +{ + filter_dialog.execWithInstance(static_cast(m_instance)); + + m_filter = filter_dialog.getFilter(); +} + void ModPage::triggerSearch() { listModel->searchWithTerm(ui->searchEdit->text(), ui->sortByBox->currentIndex()); @@ -141,11 +156,16 @@ void ModPage::updateModVersions() for (int i = 0; i < current.versions.size(); i++) { auto version = current.versions[i]; + bool valid = false; //NOTE: Flame doesn't care about loaderString, so passing it changes nothing. - if (!validateVersion(version, mcVersion, loaderString)) { - continue; + for(auto& mcVer : m_filter->versions){ + if (validateVersion(version, mcVer.toString(), loaderString)) { + valid = true; + break; + } } - ui->versionSelectionBox->addItem(version.version, QVariant(i)); + if(valid) + ui->versionSelectionBox->addItem(version.version, QVariant(i)); } if (ui->versionSelectionBox->count() == 0) { ui->versionSelectionBox->addItem(tr("No valid version found!"), QVariant(-1)); } diff --git a/launcher/ui/pages/modplatform/ModPage.h b/launcher/ui/pages/modplatform/ModPage.h index 0cd13f37..3c71e6fe 100644 --- a/launcher/ui/pages/modplatform/ModPage.h +++ b/launcher/ui/pages/modplatform/ModPage.h @@ -5,6 +5,7 @@ #include "Application.h" #include "modplatform/ModAPI.h" #include "modplatform/ModIndex.h" +#include "ui/dialogs/FilterModsDialog.h" #include "ui/pages/BasePage.h" #include "ui/pages/modplatform/ModModel.h" @@ -39,6 +40,7 @@ class ModPage : public QWidget, public BasePage { virtual auto validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, QString loaderVer = "") const -> bool = 0; auto apiProvider() const -> const ModAPI* { return api.get(); }; + auto getFilter() const -> const std::shared_ptr { return m_filter; } auto getCurrent() -> ModPlatform::IndexedPack& { return current; } void updateModVersions(); @@ -52,6 +54,7 @@ class ModPage : public QWidget, public BasePage { void updateSelectionButton(); protected slots: + void filterMods(); void triggerSearch(); void onSelectionChanged(QModelIndex first, QModelIndex second); void onVersionSelectionChanged(QString data); @@ -60,6 +63,10 @@ class ModPage : public QWidget, public BasePage { protected: Ui::ModPage* ui = nullptr; ModDownloadDialog* dialog = nullptr; + + FilterModsDialog filter_dialog; + std::shared_ptr m_filter; + ModPlatform::ListModel* listModel = nullptr; ModPlatform::IndexedPack current; diff --git a/launcher/ui/pages/modplatform/ModPage.ui b/launcher/ui/pages/modplatform/ModPage.ui index 508f1bac..4444583e 100644 --- a/launcher/ui/pages/modplatform/ModPage.ui +++ b/launcher/ui/pages/modplatform/ModPage.ui @@ -51,12 +51,12 @@ - Search and filter... + Search for mods... - + @@ -80,6 +80,13 @@ + + + + Filter options + + + -- cgit From c730fd6e5f125cde324d110282ed33ea4b9df136 Mon Sep 17 00:00:00 2001 From: flow Date: Sat, 2 Apr 2022 18:34:26 -0300 Subject: feat: Use version filter when searching mods --- launcher/ui/pages/modplatform/ModModel.cpp | 8 +++----- launcher/ui/pages/modplatform/ModModel.h | 3 ++- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'launcher/ui/pages') diff --git a/launcher/ui/pages/modplatform/ModModel.cpp b/launcher/ui/pages/modplatform/ModModel.cpp index f75d2847..1998fe99 100644 --- a/launcher/ui/pages/modplatform/ModModel.cpp +++ b/launcher/ui/pages/modplatform/ModModel.cpp @@ -72,7 +72,7 @@ void ListModel::performPaginatedSearch() auto profile = (dynamic_cast((dynamic_cast(parent()))->m_instance))->getPackProfile(); m_parent->apiProvider()->searchMods(this, - { nextSearchOffset, currentSearchTerm, getSorts()[currentSort], profile->getModLoader(), getMineVersions().at(0) }); + { nextSearchOffset, currentSearchTerm, getSorts()[currentSort], profile->getModLoader(), getMineVersions() }); } void ListModel::searchWithTerm(const QString& term, const int sort) @@ -223,9 +223,7 @@ void ListModel::versionRequestSucceeded(QJsonDocument doc, QString addonId) /******** Helpers ********/ -auto ModPlatform::ListModel::getMineVersions() const -> QList +auto ModPlatform::ListModel::getMineVersions() const -> std::list { - return { (dynamic_cast((dynamic_cast(parent()))->m_instance)) - ->getPackProfile() - ->getComponentVersion("net.minecraft") }; + return m_parent->getFilter()->versions; } diff --git a/launcher/ui/pages/modplatform/ModModel.h b/launcher/ui/pages/modplatform/ModModel.h index dbadbeee..1b7601c2 100644 --- a/launcher/ui/pages/modplatform/ModModel.h +++ b/launcher/ui/pages/modplatform/ModModel.h @@ -7,6 +7,7 @@ #include "net/NetJob.h" class ModPage; +class Version; namespace ModPlatform { @@ -62,7 +63,7 @@ class ListModel : public QAbstractListModel { void requestLogo(QString file, QString url); - inline auto getMineVersions() const -> QList; + inline auto getMineVersions() const -> std::list; protected: ModPage* m_parent; -- cgit From 5cb0e750936f09513b98a8b0fd57746ca18dc8bc Mon Sep 17 00:00:00 2001 From: flow Date: Sat, 2 Apr 2022 19:21:02 -0300 Subject: fix(ui): Refresh mod list when changing filtering options --- launcher/ui/pages/modplatform/ModModel.cpp | 14 ++++++++++---- launcher/ui/pages/modplatform/ModModel.h | 1 + launcher/ui/pages/modplatform/ModPage.cpp | 7 +++++++ 3 files changed, 18 insertions(+), 4 deletions(-) (limited to 'launcher/ui/pages') diff --git a/launcher/ui/pages/modplatform/ModModel.cpp b/launcher/ui/pages/modplatform/ModModel.cpp index 1998fe99..0ff784db 100644 --- a/launcher/ui/pages/modplatform/ModModel.cpp +++ b/launcher/ui/pages/modplatform/ModModel.cpp @@ -75,11 +75,8 @@ void ListModel::performPaginatedSearch() { nextSearchOffset, currentSearchTerm, getSorts()[currentSort], profile->getModLoader(), getMineVersions() }); } -void ListModel::searchWithTerm(const QString& term, const int sort) +void ListModel::refresh() { - if (currentSearchTerm == term && currentSearchTerm.isNull() == term.isNull() && currentSort == sort) { return; } - currentSearchTerm = term; - currentSort = sort; if (jobPtr) { jobPtr->abort(); searchState = ResetRequested; @@ -94,6 +91,15 @@ void ListModel::searchWithTerm(const QString& term, const int sort) performPaginatedSearch(); } +void ListModel::searchWithTerm(const QString& term, const int sort) +{ + if (currentSearchTerm == term && currentSearchTerm.isNull() == term.isNull() && currentSort == sort) { return; } + currentSearchTerm = term; + currentSort = sort; + + refresh(); +} + void ListModel::getLogo(const QString& logo, const QString& logoUrl, LogoCallback callback) { if (m_logoMap.contains(logo)) { diff --git a/launcher/ui/pages/modplatform/ModModel.h b/launcher/ui/pages/modplatform/ModModel.h index 1b7601c2..d4dc872d 100644 --- a/launcher/ui/pages/modplatform/ModModel.h +++ b/launcher/ui/pages/modplatform/ModModel.h @@ -34,6 +34,7 @@ class ListModel : public QAbstractListModel { /* Ask the API for more information */ void fetchMore(const QModelIndex& parent) override; + void refresh(); void searchWithTerm(const QString& term, const int sort); void requestModVersions(const ModPlatform::IndexedPack& current); diff --git a/launcher/ui/pages/modplatform/ModPage.cpp b/launcher/ui/pages/modplatform/ModPage.cpp index 16e44c0d..ece97ef2 100644 --- a/launcher/ui/pages/modplatform/ModPage.cpp +++ b/launcher/ui/pages/modplatform/ModPage.cpp @@ -62,6 +62,13 @@ void ModPage::filterMods() filter_dialog.execWithInstance(static_cast(m_instance)); m_filter = filter_dialog.getFilter(); + + listModel->refresh(); + + if(ui->versionSelectionBox->count() > 0){ + ui->versionSelectionBox->clear(); + updateModVersions(); + } } void ModPage::triggerSearch() -- cgit From 76dfb7825ade6554095ac3a09b3accdbd4db5138 Mon Sep 17 00:00:00 2001 From: flow Date: Sat, 2 Apr 2022 20:08:37 -0300 Subject: fix: 'All' filter working and get around CF API capabilities --- launcher/ui/pages/modplatform/ModPage.cpp | 5 ++--- launcher/ui/pages/modplatform/ModPage.h | 2 +- launcher/ui/pages/modplatform/flame/FlameModPage.cpp | 19 +++++++++++++++++++ launcher/ui/pages/modplatform/flame/FlameModPage.h | 2 ++ 4 files changed, 24 insertions(+), 4 deletions(-) (limited to 'launcher/ui/pages') diff --git a/launcher/ui/pages/modplatform/ModPage.cpp b/launcher/ui/pages/modplatform/ModPage.cpp index ece97ef2..ba56c3b8 100644 --- a/launcher/ui/pages/modplatform/ModPage.cpp +++ b/launcher/ui/pages/modplatform/ModPage.cpp @@ -64,7 +64,6 @@ void ModPage::filterMods() m_filter = filter_dialog.getFilter(); listModel->refresh(); - if(ui->versionSelectionBox->count() > 0){ ui->versionSelectionBox->clear(); updateModVersions(); @@ -164,14 +163,14 @@ void ModPage::updateModVersions() for (int i = 0; i < current.versions.size(); i++) { auto version = current.versions[i]; bool valid = false; - //NOTE: Flame doesn't care about loaderString, so passing it changes nothing. for(auto& mcVer : m_filter->versions){ + //NOTE: Flame doesn't care about loaderString, so passing it changes nothing. if (validateVersion(version, mcVer.toString(), loaderString)) { valid = true; break; } } - if(valid) + if(valid || m_filter->versions.size() == 0) ui->versionSelectionBox->addItem(version.version, QVariant(i)); } if (ui->versionSelectionBox->count() == 0) { ui->versionSelectionBox->addItem(tr("No valid version found!"), QVariant(-1)); } diff --git a/launcher/ui/pages/modplatform/ModPage.h b/launcher/ui/pages/modplatform/ModPage.h index 3c71e6fe..0befc7c3 100644 --- a/launcher/ui/pages/modplatform/ModPage.h +++ b/launcher/ui/pages/modplatform/ModPage.h @@ -54,7 +54,7 @@ class ModPage : public QWidget, public BasePage { void updateSelectionButton(); protected slots: - void filterMods(); + virtual void filterMods(); void triggerSearch(); void onSelectionChanged(QModelIndex first, QModelIndex second); void onVersionSelectionChanged(QString data); diff --git a/launcher/ui/pages/modplatform/flame/FlameModPage.cpp b/launcher/ui/pages/modplatform/flame/FlameModPage.cpp index 864ae8e6..5398bda3 100644 --- a/launcher/ui/pages/modplatform/flame/FlameModPage.cpp +++ b/launcher/ui/pages/modplatform/flame/FlameModPage.cpp @@ -67,6 +67,25 @@ auto FlameModPage::validateVersion(ModPlatform::IndexedVersion& ver, QString min return ver.mcVersion.contains(mineVer); } +// We override this so that it refreshes correctly, otherwise it wouldn't show +// any mod on the mod list, because the CF API does not support it :( +void FlameModPage::filterMods() +{ + filter_dialog.execWithInstance(static_cast(m_instance)); + + int prev_size = m_filter->versions.size(); + m_filter = filter_dialog.getFilter(); + int new_size = m_filter->versions.size(); + + if(new_size <= 1 && new_size != prev_size) + listModel->refresh(); + + if(ui->versionSelectionBox->count() > 0){ + ui->versionSelectionBox->clear(); + updateModVersions(); + } +} + // I don't know why, but doing this on the parent class makes it so that // other mod providers start loading before being selected, at least with // my Qt, so we need to implement this in every derived class... diff --git a/launcher/ui/pages/modplatform/flame/FlameModPage.h b/launcher/ui/pages/modplatform/flame/FlameModPage.h index dc58fd7f..7078e889 100644 --- a/launcher/ui/pages/modplatform/flame/FlameModPage.h +++ b/launcher/ui/pages/modplatform/flame/FlameModPage.h @@ -56,5 +56,7 @@ class FlameModPage : public ModPage { auto validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, QString loaderVer = "") const -> bool override; + void filterMods() override; + auto shouldDisplay() const -> bool override; }; -- cgit From 63bce0464895236a043aa8a98e2905ab1bf34cc1 Mon Sep 17 00:00:00 2001 From: flow Date: Sun, 3 Apr 2022 10:21:48 -0300 Subject: fix: Polish usage in some cases Also fiz some typos --- launcher/ui/pages/modplatform/ModPage.cpp | 19 +++++++++++-------- launcher/ui/pages/modplatform/ModPage.h | 2 +- launcher/ui/pages/modplatform/flame/FlameModPage.cpp | 20 ++++++++++---------- 3 files changed, 22 insertions(+), 19 deletions(-) (limited to 'launcher/ui/pages') diff --git a/launcher/ui/pages/modplatform/ModPage.cpp b/launcher/ui/pages/modplatform/ModPage.cpp index ba56c3b8..37f68291 100644 --- a/launcher/ui/pages/modplatform/ModPage.cpp +++ b/launcher/ui/pages/modplatform/ModPage.cpp @@ -59,14 +59,15 @@ auto ModPage::eventFilter(QObject* watched, QEvent* event) -> bool void ModPage::filterMods() { - filter_dialog.execWithInstance(static_cast(m_instance)); - + auto ret = filter_dialog.execWithInstance(static_cast(m_instance)); m_filter = filter_dialog.getFilter(); - listModel->refresh(); - if(ui->versionSelectionBox->count() > 0){ + if(ret == QDialog::DialogCode::Accepted){ + listModel->refresh(); + + int prev_count = ui->versionSelectionBox->count(); ui->versionSelectionBox->clear(); - updateModVersions(); + updateModVersions(prev_count); } } @@ -152,7 +153,7 @@ void ModPage::retranslate() ui->retranslateUi(this); } -void ModPage::updateModVersions() +void ModPage::updateModVersions(int prev_count) { auto packProfile = (dynamic_cast(m_instance))->getPackProfile(); @@ -173,9 +174,11 @@ void ModPage::updateModVersions() if(valid || m_filter->versions.size() == 0) ui->versionSelectionBox->addItem(version.version, QVariant(i)); } - if (ui->versionSelectionBox->count() == 0) { ui->versionSelectionBox->addItem(tr("No valid version found!"), QVariant(-1)); } + if (ui->versionSelectionBox->count() == 0 && prev_count != 0) { + ui->versionSelectionBox->addItem(tr("No valid version found!"), QVariant(-1)); + ui->modSelectionButton->setText(tr("Cannot select invalid version :(")); + } - ui->modSelectionButton->setText(tr("Cannot select invalid version :(")); updateSelectionButton(); } diff --git a/launcher/ui/pages/modplatform/ModPage.h b/launcher/ui/pages/modplatform/ModPage.h index 0befc7c3..06581ab2 100644 --- a/launcher/ui/pages/modplatform/ModPage.h +++ b/launcher/ui/pages/modplatform/ModPage.h @@ -43,7 +43,7 @@ class ModPage : public QWidget, public BasePage { auto getFilter() const -> const std::shared_ptr { return m_filter; } auto getCurrent() -> ModPlatform::IndexedPack& { return current; } - void updateModVersions(); + void updateModVersions(int prev_count = -1); void openedImpl() override; auto eventFilter(QObject* watched, QEvent* event) -> bool override; diff --git a/launcher/ui/pages/modplatform/flame/FlameModPage.cpp b/launcher/ui/pages/modplatform/flame/FlameModPage.cpp index 5398bda3..6e666c4c 100644 --- a/launcher/ui/pages/modplatform/flame/FlameModPage.cpp +++ b/launcher/ui/pages/modplatform/flame/FlameModPage.cpp @@ -67,22 +67,22 @@ auto FlameModPage::validateVersion(ModPlatform::IndexedVersion& ver, QString min return ver.mcVersion.contains(mineVer); } -// We override this so that it refreshes correctly, otherwise it wouldn't show -// any mod on the mod list, because the CF API does not support it :( +// We override this so that it refreshes correctly, otherwise it would show +// invalid mods on the mod list, because the API would return mods for the +// wrong mod loader :( void FlameModPage::filterMods() { - filter_dialog.execWithInstance(static_cast(m_instance)); - - int prev_size = m_filter->versions.size(); + auto ret = filter_dialog.execWithInstance(static_cast(m_instance)); m_filter = filter_dialog.getFilter(); - int new_size = m_filter->versions.size(); - if(new_size <= 1 && new_size != prev_size) - listModel->refresh(); + if(ret == QDialog::DialogCode::Accepted){ + // CF API can't handle well this + if(!m_filter->versions.empty()) + listModel->refresh(); - if(ui->versionSelectionBox->count() > 0){ + int prev_count = ui->versionSelectionBox->count(); ui->versionSelectionBox->clear(); - updateModVersions(); + updateModVersions(prev_count); } } -- cgit From 277de4120052b2630850a18969a56ee92e8c2c63 Mon Sep 17 00:00:00 2001 From: flow Date: Thu, 14 Apr 2022 10:27:03 -0300 Subject: rework: make the filter as a tabbed widget in the dialog itself Still needs a clear indication that the filter only applies after you click the search button... --- launcher/ui/pages/modplatform/ModModel.cpp | 9 +++++-- launcher/ui/pages/modplatform/ModModel.h | 2 +- launcher/ui/pages/modplatform/ModPage.cpp | 30 ++++++++++++---------- launcher/ui/pages/modplatform/ModPage.h | 8 +++--- launcher/ui/pages/modplatform/ModPage.ui | 27 +++++++++++-------- .../ui/pages/modplatform/flame/FlameModPage.cpp | 19 -------------- launcher/ui/pages/modplatform/flame/FlameModPage.h | 2 -- 7 files changed, 46 insertions(+), 51 deletions(-) (limited to 'launcher/ui/pages') diff --git a/launcher/ui/pages/modplatform/ModModel.cpp b/launcher/ui/pages/modplatform/ModModel.cpp index 0ff784db..da0331b5 100644 --- a/launcher/ui/pages/modplatform/ModModel.cpp +++ b/launcher/ui/pages/modplatform/ModModel.cpp @@ -91,9 +91,14 @@ void ListModel::refresh() performPaginatedSearch(); } -void ListModel::searchWithTerm(const QString& term, const int sort) +void ListModel::searchWithTerm(const QString& term, const int sort, const bool filter_changed) { - if (currentSearchTerm == term && currentSearchTerm.isNull() == term.isNull() && currentSort == sort) { return; } + if (currentSearchTerm == term + && currentSearchTerm.isNull() == term.isNull() + && currentSort == sort + && !filter_changed) + { return; } + currentSearchTerm = term; currentSort = sort; diff --git a/launcher/ui/pages/modplatform/ModModel.h b/launcher/ui/pages/modplatform/ModModel.h index d4dc872d..d460cff2 100644 --- a/launcher/ui/pages/modplatform/ModModel.h +++ b/launcher/ui/pages/modplatform/ModModel.h @@ -35,7 +35,7 @@ class ListModel : public QAbstractListModel { /* Ask the API for more information */ void fetchMore(const QModelIndex& parent) override; void refresh(); - void searchWithTerm(const QString& term, const int sort); + void searchWithTerm(const QString& term, const int sort, const bool filter_changed); void requestModVersions(const ModPlatform::IndexedPack& current); virtual void loadIndexedPack(ModPlatform::IndexedPack& m, QJsonObject& obj) = 0; diff --git a/launcher/ui/pages/modplatform/ModPage.cpp b/launcher/ui/pages/modplatform/ModPage.cpp index 37f68291..57c2e45d 100644 --- a/launcher/ui/pages/modplatform/ModPage.cpp +++ b/launcher/ui/pages/modplatform/ModPage.cpp @@ -13,7 +13,7 @@ ModPage::ModPage(ModDownloadDialog* dialog, BaseInstance* instance, ModAPI* api) , m_instance(instance) , ui(new Ui::ModPage) , dialog(dialog) - , filter_dialog(static_cast(instance)->getPackProfile()->getComponentVersion("net.minecraft"), this) + , filter_widget(static_cast(instance)->getPackProfile()->getComponentVersion("net.minecraft"), this) , api(api) { ui->setupUi(this); @@ -24,7 +24,10 @@ ModPage::ModPage(ModDownloadDialog* dialog, BaseInstance* instance, ModAPI* api) ui->versionSelectionBox->view()->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); ui->versionSelectionBox->view()->parentWidget()->setMaximumHeight(300); - m_filter = filter_dialog.getFilter(); + ui->gridLayout_3->addWidget(&filter_widget, 0, 0, 1, ui->gridLayout_3->columnCount()); + + filter_widget.setInstance(static_cast(m_instance)); + m_filter = filter_widget.getFilter(); } ModPage::~ModPage() @@ -59,21 +62,22 @@ auto ModPage::eventFilter(QObject* watched, QEvent* event) -> bool void ModPage::filterMods() { - auto ret = filter_dialog.execWithInstance(static_cast(m_instance)); - m_filter = filter_dialog.getFilter(); - - if(ret == QDialog::DialogCode::Accepted){ - listModel->refresh(); - - int prev_count = ui->versionSelectionBox->count(); - ui->versionSelectionBox->clear(); - updateModVersions(prev_count); - } + filter_widget.setHidden(!filter_widget.isHidden()); } void ModPage::triggerSearch() { - listModel->searchWithTerm(ui->searchEdit->text(), ui->sortByBox->currentIndex()); + auto changed = filter_widget.changed(); + m_filter = filter_widget.getFilter(); + + if(changed){ + ui->packView->clearSelection(); + ui->packDescription->clear(); + ui->versionSelectionBox->clear(); + updateSelectionButton(); + } + + listModel->searchWithTerm(ui->searchEdit->text(), ui->sortByBox->currentIndex(), changed); } void ModPage::onSelectionChanged(QModelIndex first, QModelIndex second) diff --git a/launcher/ui/pages/modplatform/ModPage.h b/launcher/ui/pages/modplatform/ModPage.h index 06581ab2..85aaede9 100644 --- a/launcher/ui/pages/modplatform/ModPage.h +++ b/launcher/ui/pages/modplatform/ModPage.h @@ -5,9 +5,9 @@ #include "Application.h" #include "modplatform/ModAPI.h" #include "modplatform/ModIndex.h" -#include "ui/dialogs/FilterModsDialog.h" #include "ui/pages/BasePage.h" #include "ui/pages/modplatform/ModModel.h" +#include "ui/widgets/ModFilterWidget.h" class ModDownloadDialog; @@ -40,7 +40,7 @@ class ModPage : public QWidget, public BasePage { virtual auto validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, QString loaderVer = "") const -> bool = 0; auto apiProvider() const -> const ModAPI* { return api.get(); }; - auto getFilter() const -> const std::shared_ptr { return m_filter; } + auto getFilter() const -> const std::shared_ptr { return m_filter; } auto getCurrent() -> ModPlatform::IndexedPack& { return current; } void updateModVersions(int prev_count = -1); @@ -64,8 +64,8 @@ class ModPage : public QWidget, public BasePage { Ui::ModPage* ui = nullptr; ModDownloadDialog* dialog = nullptr; - FilterModsDialog filter_dialog; - std::shared_ptr m_filter; + ModFilterWidget filter_widget; + std::shared_ptr m_filter; ModPlatform::ListModel* listModel = nullptr; ModPlatform::IndexedPack current; diff --git a/launcher/ui/pages/modplatform/ModPage.ui b/launcher/ui/pages/modplatform/ModPage.ui index 4444583e..afcd9bb7 100644 --- a/launcher/ui/pages/modplatform/ModPage.ui +++ b/launcher/ui/pages/modplatform/ModPage.ui @@ -11,7 +11,7 @@ - + @@ -41,7 +41,7 @@ - + Search @@ -55,7 +55,7 @@ - + @@ -80,15 +80,22 @@ - - - - Filter options - - - + + + + Filter options + + + + + + + Qt::Vertical + + + diff --git a/launcher/ui/pages/modplatform/flame/FlameModPage.cpp b/launcher/ui/pages/modplatform/flame/FlameModPage.cpp index 6e666c4c..864ae8e6 100644 --- a/launcher/ui/pages/modplatform/flame/FlameModPage.cpp +++ b/launcher/ui/pages/modplatform/flame/FlameModPage.cpp @@ -67,25 +67,6 @@ auto FlameModPage::validateVersion(ModPlatform::IndexedVersion& ver, QString min return ver.mcVersion.contains(mineVer); } -// We override this so that it refreshes correctly, otherwise it would show -// invalid mods on the mod list, because the API would return mods for the -// wrong mod loader :( -void FlameModPage::filterMods() -{ - auto ret = filter_dialog.execWithInstance(static_cast(m_instance)); - m_filter = filter_dialog.getFilter(); - - if(ret == QDialog::DialogCode::Accepted){ - // CF API can't handle well this - if(!m_filter->versions.empty()) - listModel->refresh(); - - int prev_count = ui->versionSelectionBox->count(); - ui->versionSelectionBox->clear(); - updateModVersions(prev_count); - } -} - // I don't know why, but doing this on the parent class makes it so that // other mod providers start loading before being selected, at least with // my Qt, so we need to implement this in every derived class... diff --git a/launcher/ui/pages/modplatform/flame/FlameModPage.h b/launcher/ui/pages/modplatform/flame/FlameModPage.h index 7078e889..dc58fd7f 100644 --- a/launcher/ui/pages/modplatform/flame/FlameModPage.h +++ b/launcher/ui/pages/modplatform/flame/FlameModPage.h @@ -56,7 +56,5 @@ class FlameModPage : public ModPage { auto validateVersion(ModPlatform::IndexedVersion& ver, QString mineVer, QString loaderVer = "") const -> bool override; - void filterMods() override; - auto shouldDisplay() const -> bool override; }; -- cgit From 5f15f51610f861521afdb295df0de6d9407ba951 Mon Sep 17 00:00:00 2001 From: flow Date: Thu, 14 Apr 2022 10:52:23 -0300 Subject: ui: underline search button text when changing filters This hopefully makes it easier to the user to know that their changes will only apply after hitting the search button. I tried setting the background color, but it seems more unreliable on cross-platform than underlining. Also, it could be worse for daltonic people, so I don't know what to do :( --- launcher/ui/pages/modplatform/ModPage.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'launcher/ui/pages') diff --git a/launcher/ui/pages/modplatform/ModPage.cpp b/launcher/ui/pages/modplatform/ModPage.cpp index 57c2e45d..29f6b601 100644 --- a/launcher/ui/pages/modplatform/ModPage.cpp +++ b/launcher/ui/pages/modplatform/ModPage.cpp @@ -28,6 +28,13 @@ ModPage::ModPage(ModDownloadDialog* dialog, BaseInstance* instance, ModAPI* api) filter_widget.setInstance(static_cast(m_instance)); m_filter = filter_widget.getFilter(); + + connect(&filter_widget, &ModFilterWidget::filterChanged, this, [&]{ + ui->searchButton->setStyleSheet("text-decoration: underline"); + }); + connect(&filter_widget, &ModFilterWidget::filterUnchanged, this, [&]{ + ui->searchButton->setStyleSheet("text-decoration: none"); + }); } ModPage::~ModPage() -- cgit