mirror of
https://github.com/PrismLauncher/PrismLauncher.git
synced 2025-05-08 10:34:39 +02:00
Merge pull request #3007 from Trial97/open_source
add open source filter
This commit is contained in:
commit
d4bf61da50
@ -76,6 +76,7 @@ class ResourceAPI {
|
||||
std::optional<std::list<Version> > versions;
|
||||
std::optional<QString> side;
|
||||
std::optional<QStringList> categoryIds;
|
||||
bool openSource;
|
||||
};
|
||||
struct SearchCallbacks {
|
||||
std::function<void(QJsonDocument&)> on_succeed;
|
||||
|
@ -116,6 +116,8 @@ class ModrinthAPI : public NetworkResourceAPI {
|
||||
}
|
||||
if (args.categoryIds.has_value() && !args.categoryIds->empty())
|
||||
facets_list.append(QString("[%1]").arg(getCategoriesFilters(args.categoryIds.value())));
|
||||
if (args.openSource)
|
||||
facets_list.append("[\"open_source:true\"]");
|
||||
|
||||
facets_list.append(QString("[\"project_type:%1\"]").arg(resourceTypeParameter(args.type)));
|
||||
|
||||
|
@ -39,7 +39,9 @@ ResourceAPI::SearchArgs ModModel::createSearchArguments()
|
||||
|
||||
auto sort = getCurrentSortingMethodByIndex();
|
||||
|
||||
return { ModPlatform::ResourceType::MOD, m_next_search_offset, m_search_term, sort, loaders, versions, side, categories };
|
||||
return {
|
||||
ModPlatform::ResourceType::MOD, m_next_search_offset, m_search_term, sort, loaders, versions, side, categories, m_filter->openSource
|
||||
};
|
||||
}
|
||||
|
||||
ResourceAPI::VersionSearchArgs ModModel::createVersionsArguments(QModelIndex& entry)
|
||||
|
@ -189,7 +189,7 @@ void ListModel::performPaginatedSearch()
|
||||
|
||||
auto netJob = makeShared<NetJob>("Flame::Search", APPLICATION->network());
|
||||
auto searchUrl = FlameAPI().getSearchURL({ ModPlatform::ResourceType::MODPACK, nextSearchOffset, currentSearchTerm, sort,
|
||||
m_filter->loaders, m_filter->versions, "", m_filter->categoryIds });
|
||||
m_filter->loaders, m_filter->versions, "", m_filter->categoryIds, m_filter->openSource });
|
||||
|
||||
netJob->addNetAction(Net::ApiDownload::makeByteArray(QUrl(searchUrl.value()), response));
|
||||
jobPtr = netJob;
|
||||
|
@ -155,7 +155,7 @@ void ModpackListModel::performPaginatedSearch()
|
||||
ResourceAPI::SortingMethod sort{};
|
||||
sort.name = currentSort;
|
||||
auto searchUrl = ModrinthAPI().getSearchURL({ ModPlatform::ResourceType::MODPACK, nextSearchOffset, currentSearchTerm, sort,
|
||||
m_filter->loaders, m_filter->versions, "", m_filter->categoryIds });
|
||||
m_filter->loaders, m_filter->versions, "", m_filter->categoryIds, m_filter->openSource });
|
||||
|
||||
auto netJob = makeShared<NetJob>("Modrinth::SearchModpack", APPLICATION->network());
|
||||
netJob->addNetAction(Net::ApiDownload::makeByteArray(QUrl(searchUrl.value()), m_allResponse));
|
||||
|
@ -134,6 +134,7 @@ ModFilterWidget::ModFilterWidget(MinecraftInstance* instance, bool extended, QWi
|
||||
ui->versions->hide();
|
||||
ui->showAllVersions->hide();
|
||||
ui->environmentGroup->hide();
|
||||
ui->openSource->hide();
|
||||
}
|
||||
|
||||
ui->versions->setStyleSheet("combobox-popup: 0;");
|
||||
@ -159,6 +160,7 @@ ModFilterWidget::ModFilterWidget(MinecraftInstance* instance, bool extended, QWi
|
||||
}
|
||||
|
||||
connect(ui->hideInstalled, &QCheckBox::stateChanged, this, &ModFilterWidget::onHideInstalledFilterChanged);
|
||||
connect(ui->openSource, &QCheckBox::stateChanged, this, &ModFilterWidget::onOpenSourceFilterChanged);
|
||||
|
||||
setHidden(true);
|
||||
loadVersionList();
|
||||
@ -208,6 +210,7 @@ void ModFilterWidget::loadVersionList()
|
||||
|
||||
void ModFilterWidget::prepareBasicFilter()
|
||||
{
|
||||
m_filter->openSource = false;
|
||||
if (m_instance) {
|
||||
m_filter->hideInstalled = false;
|
||||
m_filter->side = ""; // or "both"
|
||||
@ -337,4 +340,13 @@ void ModFilterWidget::setCategories(const QList<ModPlatform::Category>& categori
|
||||
}
|
||||
}
|
||||
|
||||
void ModFilterWidget::onOpenSourceFilterChanged()
|
||||
{
|
||||
auto open = ui->openSource->isChecked();
|
||||
m_filter_changed = open != m_filter->openSource;
|
||||
m_filter->openSource = open;
|
||||
if (m_filter_changed)
|
||||
emit filterChanged();
|
||||
}
|
||||
|
||||
#include "ModFilterWidget.moc"
|
@ -64,11 +64,12 @@ class ModFilterWidget : public QTabWidget {
|
||||
QString side;
|
||||
bool hideInstalled;
|
||||
QStringList categoryIds;
|
||||
bool openSource;
|
||||
|
||||
bool operator==(const Filter& other) const
|
||||
{
|
||||
return hideInstalled == other.hideInstalled && side == other.side && loaders == other.loaders && versions == other.versions &&
|
||||
releases == other.releases && categoryIds == other.categoryIds;
|
||||
releases == other.releases && categoryIds == other.categoryIds && openSource == other.openSource;
|
||||
}
|
||||
bool operator!=(const Filter& other) const { return !(*this == other); }
|
||||
|
||||
@ -107,6 +108,7 @@ class ModFilterWidget : public QTabWidget {
|
||||
void onSideFilterChanged();
|
||||
void onHideInstalledFilterChanged();
|
||||
void onShowAllVersionsChanged();
|
||||
void onOpenSourceFilterChanged();
|
||||
|
||||
private:
|
||||
Ui::ModFilterWidget* ui;
|
||||
|
@ -188,6 +188,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="openSource">
|
||||
<property name="text">
|
||||
<string>Open source only</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
|
Loading…
x
Reference in New Issue
Block a user