add open source filter

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
Trial97
2024-10-27 11:56:48 +02:00
parent 5b8ea89092
commit 935b2e8fb2
8 changed files with 31 additions and 5 deletions

View File

@ -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
}
}
#include "ModFilterWidget.moc"
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"

View File

@ -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;

View File

@ -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">