diff options
author | Trial97 <alexandru.tripon97@gmail.com> | 2023-08-27 15:04:42 +0300 |
---|---|---|
committer | Trial97 <alexandru.tripon97@gmail.com> | 2023-08-27 15:04:42 +0300 |
commit | 4036cecfc02142c403a45e18474ad7aab6fc8834 (patch) | |
tree | cada4cbd4a7e7773ee8ce5112e7cda65a4d8c43e /launcher/ui/pages/modplatform/flame | |
parent | 05094b7382aafc0a9dcda17c13d5294dbaa89c36 (diff) | |
download | PrismLauncher-4036cecfc02142c403a45e18474ad7aab6fc8834.tar.gz PrismLauncher-4036cecfc02142c403a45e18474ad7aab6fc8834.tar.bz2 PrismLauncher-4036cecfc02142c403a45e18474ad7aab6fc8834.zip |
Added progress widget to some modpack providers
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
Diffstat (limited to 'launcher/ui/pages/modplatform/flame')
-rw-r--r-- | launcher/ui/pages/modplatform/flame/FlameModel.h | 1 | ||||
-rw-r--r-- | launcher/ui/pages/modplatform/flame/FlamePage.cpp | 10 | ||||
-rw-r--r-- | launcher/ui/pages/modplatform/flame/FlamePage.h | 3 | ||||
-rw-r--r-- | launcher/ui/pages/modplatform/flame/FlamePage.ui | 4 |
4 files changed, 15 insertions, 3 deletions
diff --git a/launcher/ui/pages/modplatform/flame/FlameModel.h b/launcher/ui/pages/modplatform/flame/FlameModel.h index cd73fce3..fd8496df 100644 --- a/launcher/ui/pages/modplatform/flame/FlameModel.h +++ b/launcher/ui/pages/modplatform/flame/FlameModel.h @@ -41,6 +41,7 @@ class ListModel : public QAbstractListModel { void searchWithTerm(const QString& term, const int sort); [[nodiscard]] bool hasActiveSearchJob() const { return jobPtr && jobPtr->isRunning(); } + [[nodiscard]] Task::Ptr activeSearchJob() { return hasActiveSearchJob() ? jobPtr : nullptr; } private slots: void performPaginatedSearch(); diff --git a/launcher/ui/pages/modplatform/flame/FlamePage.cpp b/launcher/ui/pages/modplatform/flame/FlamePage.cpp index 79fcc821..50656f42 100644 --- a/launcher/ui/pages/modplatform/flame/FlamePage.cpp +++ b/launcher/ui/pages/modplatform/flame/FlamePage.cpp @@ -50,7 +50,8 @@ static FlameAPI api; -FlamePage::FlamePage(NewInstanceDialog* dialog, QWidget* parent) : QWidget(parent), ui(new Ui::FlamePage), dialog(dialog) +FlamePage::FlamePage(NewInstanceDialog* dialog, QWidget* parent) + : QWidget(parent), ui(new Ui::FlamePage), dialog(dialog), m_fetch_progress(this, false) { ui->setupUi(this); connect(ui->searchButton, &QPushButton::clicked, this, &FlamePage::triggerSearch); @@ -66,6 +67,12 @@ FlamePage::FlamePage(NewInstanceDialog* dialog, QWidget* parent) : QWidget(paren connect(&m_search_timer, &QTimer::timeout, this, &FlamePage::triggerSearch); + m_fetch_progress.hideIfInactive(true); + m_fetch_progress.setFixedHeight(24); + m_fetch_progress.progressFormat(""); + + ui->gridLayout->addWidget(&m_fetch_progress, 2, 0, 1, ui->gridLayout->columnCount()); + // index is used to set the sorting with the curseforge api ui->sortByBox->addItem(tr("Sort by Featured")); ui->sortByBox->addItem(tr("Sort by Popularity")); @@ -124,6 +131,7 @@ void FlamePage::openedImpl() void FlamePage::triggerSearch() { listModel->searchWithTerm(ui->searchEdit->text(), ui->sortByBox->currentIndex()); + m_fetch_progress.watch(listModel->activeSearchJob().get()); } void FlamePage::onSelectionChanged(QModelIndex curr, [[maybe_unused]] QModelIndex prev) diff --git a/launcher/ui/pages/modplatform/flame/FlamePage.h b/launcher/ui/pages/modplatform/flame/FlamePage.h index a45c9e40..d35858fb 100644 --- a/launcher/ui/pages/modplatform/flame/FlamePage.h +++ b/launcher/ui/pages/modplatform/flame/FlamePage.h @@ -41,6 +41,7 @@ #include <modplatform/flame/FlamePackIndex.h> #include <QTimer> #include "ui/pages/BasePage.h" +#include "ui/widgets/ProgressWidget.h" namespace Ui { class FlamePage; @@ -87,6 +88,8 @@ class FlamePage : public QWidget, public BasePage { int m_selected_version_index = -1; + ProgressWidget m_fetch_progress; + // Used to do instant searching with a delay to cache quick changes QTimer m_search_timer; }; diff --git a/launcher/ui/pages/modplatform/flame/FlamePage.ui b/launcher/ui/pages/modplatform/flame/FlamePage.ui index 71d19513..f9e1fe67 100644 --- a/launcher/ui/pages/modplatform/flame/FlamePage.ui +++ b/launcher/ui/pages/modplatform/flame/FlamePage.ui @@ -47,7 +47,7 @@ </item> </layout> </item> - <item row="2" column="0"> + <item row="3" column="0"> <layout class="QHBoxLayout"> <item> <widget class="QListView" name="packView"> @@ -77,7 +77,7 @@ </item> </layout> </item> - <item row="3" column="0"> + <item row="4" column="0"> <layout class="QHBoxLayout"> <item> <widget class="QComboBox" name="sortByBox"/> |