XC optional tabs

This commit is contained in:
jafea7 2025-04-10 21:41:52 +10:00
parent 3d83fe6557
commit 5bbd74efd8
2 changed files with 85 additions and 27 deletions

View File

@ -1,5 +1,8 @@
package ctbrec.ui.sites.xlovecam; package ctbrec.ui.sites.xlovecam;
import java.util.ArrayList;
import java.util.List;
import ctbrec.Config; import ctbrec.Config;
import ctbrec.sites.xlovecam.XloveCam; import ctbrec.sites.xlovecam.XloveCam;
import ctbrec.ui.DesktopIntegration; import ctbrec.ui.DesktopIntegration;
@ -72,6 +75,53 @@ public class XloveCamConfigUI extends AbstractConfigUI {
GridPane.setColumnSpan(password, 2); GridPane.setColumnSpan(password, 2);
layout.add(password, 1, row++); layout.add(password, 1, row++);
Label tabsLabel = new Label("Tabs");
layout.add(tabsLabel, 0, row);
List<String> tabs = getEnabledTabs();
GridPane checkboxGrid = new GridPane();
checkboxGrid.setHgap(10);
checkboxGrid.setVgap(5);
checkboxGrid.setPadding(new Insets(0, 0, 0, 7));
CheckBox girls = new CheckBox("Young Women");
girls.setSelected(tabs.contains("1"));
girls.setOnAction(e -> toggleTab("1", girls.isSelected()));
checkboxGrid.add(girls, 0, 0);
CheckBox ladies = new CheckBox("Ladies");
ladies.setSelected(tabs.contains("13"));
ladies.setOnAction(e -> toggleTab("13", ladies.isSelected()));
checkboxGrid.add(ladies, 1, 0);
CheckBox mature = new CheckBox("Mature Female");
mature.setSelected(tabs.contains("6"));
mature.setOnAction(e -> toggleTab("6", mature.isSelected()));
checkboxGrid.add(mature, 2, 0);
CheckBox couples = new CheckBox("Couples");
couples.setSelected(tabs.contains("2"));
couples.setOnAction(e -> toggleTab("2", couples.isSelected()));
checkboxGrid.add(couples, 3, 0);
CheckBox lesbian = new CheckBox("Lesbian");
lesbian.setSelected(tabs.contains("3"));
lesbian.setOnAction(e -> toggleTab("3", lesbian.isSelected()));
checkboxGrid.add(lesbian, 0, 1);
CheckBox male = new CheckBox("Male");
male.setSelected(tabs.contains("7"));
male.setOnAction(e -> toggleTab("7", male.isSelected()));
checkboxGrid.add(male, 1, 1);
CheckBox trans = new CheckBox("Trans");
trans.setSelected(tabs.contains("5"));
trans.setOnAction(e -> toggleTab("5", trans.isSelected()));
checkboxGrid.add(trans, 2, 1);
layout.add(checkboxGrid, 1, row, 4, 2);
row += 2;
var createAccount = new Button("Create new Account"); var createAccount = new Button("Create new Account");
createAccount.setOnAction(e -> DesktopIntegration.open(site.getAffiliateLink())); createAccount.setOnAction(e -> DesktopIntegration.open(site.getAffiliateLink()));
layout.add(createAccount, 1, row++); layout.add(createAccount, 1, row++);
@ -89,4 +139,18 @@ public class XloveCamConfigUI extends AbstractConfigUI {
return layout; return layout;
} }
private void toggleTab(String tab, boolean selected) {
var settings = Config.getInstance().getSettings();
if (selected) {
settings.xlovecamTabs.add(tab);
} else {
settings.xlovecamTabs.remove(tab);
}
save();
}
private List<String> getEnabledTabs() {
return new ArrayList<>(Config.getInstance().getSettings().xlovecamTabs);
}
} }

View File

@ -1,5 +1,6 @@
package ctbrec.ui.sites.xlovecam; package ctbrec.ui.sites.xlovecam;
import ctbrec.Config;
import ctbrec.sites.xlovecam.XloveCam; import ctbrec.sites.xlovecam.XloveCam;
import ctbrec.ui.sites.AbstractTabProvider; import ctbrec.ui.sites.AbstractTabProvider;
import ctbrec.ui.tabs.PaginatedScheduledService; import ctbrec.ui.tabs.PaginatedScheduledService;
@ -9,8 +10,10 @@ import javafx.scene.control.Tab;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
// import java.util.Objects;
public class XloveCamTabProvider extends AbstractTabProvider { public class XloveCamTabProvider extends AbstractTabProvider {
@ -36,33 +39,20 @@ public class XloveCamTabProvider extends AbstractTabProvider {
updateService = new XloveCamUpdateService(xloveCam, Map.of(FILTER_PARAM_NEW, "3")); updateService = new XloveCamUpdateService(xloveCam, Map.of(FILTER_PARAM_NEW, "3"));
tabs.add(createTab("New", updateService)); tabs.add(createTab("New", updateService));
// Young Women Map<String, String> tabMap = new HashMap<>();
updateService = new XloveCamUpdateService(xloveCam, Map.of(FILTER_PARAM, "1")); tabMap.put("1", "Young Women");
tabs.add(createTab("Young Women", updateService)); tabMap.put("13", "Ladies");
tabMap.put("6", "Mature Female");
// Ladies tabMap.put("2", "Couples");
updateService = new XloveCamUpdateService(xloveCam, Map.of(FILTER_PARAM, "13")); tabMap.put("3", "Lesbian");
tabs.add(createTab("Ladies", updateService)); tabMap.put("7", "Male");
tabMap.put("5", "Trans");
// Mature List<String> enabledTabs = getEnabledTabs();
updateService = new XloveCamUpdateService(xloveCam, Map.of(FILTER_PARAM, "6")); for (String tab : enabledTabs) {
tabs.add(createTab("Mature Female", updateService)); String title = tabMap.getOrDefault(tab, tab);
updateService = new XloveCamUpdateService(xloveCam, Map.of(FILTER_PARAM, tab));
// Couples tabs.add(createTab(title, updateService));
updateService = new XloveCamUpdateService(xloveCam, Map.of(FILTER_PARAM, "2")); }
tabs.add(createTab("Couples", updateService));
// Lesbian
updateService = new XloveCamUpdateService(xloveCam, Map.of(FILTER_PARAM, "3"));
tabs.add(createTab("Lesbian", updateService));
// Male
updateService = new XloveCamUpdateService(xloveCam, Map.of(FILTER_PARAM, "7"));
tabs.add(createTab("Male", updateService));
// Trans
updateService = new XloveCamUpdateService(xloveCam, Map.of(FILTER_PARAM, "5"));
tabs.add(createTab("Trans", updateService));
return tabs; return tabs;
} }
@ -73,4 +63,8 @@ public class XloveCamTabProvider extends AbstractTabProvider {
return tab; return tab;
} }
private List<String> getEnabledTabs() {
return new ArrayList<>(Config.getInstance().getSettings().xlovecamTabs);
}
} }