Improve yes no toggle display for categories

This commit is contained in:
crschnick
2025-11-22 22:18:04 +00:00
parent 473ddc528d
commit 6cdb386d9c
22 changed files with 36 additions and 5 deletions

View File

@@ -5,6 +5,7 @@ import io.xpipe.app.comp.CompStructure;
import io.xpipe.app.comp.SimpleCompStructure;
import io.xpipe.app.platform.PlatformThread;
import javafx.application.Platform;
import javafx.beans.property.Property;
import javafx.beans.value.ObservableValue;
import javafx.scene.control.ToggleButton;
@@ -14,6 +15,7 @@ import javafx.scene.layout.HBox;
import atlantafx.base.theme.Styles;
import java.util.Map;
import java.util.Objects;
public class ToggleGroupComp<T> extends Comp<CompStructure<HBox>> {
@@ -39,8 +41,11 @@ public class ToggleGroupComp<T> extends Comp<CompStructure<HBox>> {
box.getChildren().clear();
for (var entry : val.entrySet()) {
var b = new ToggleButton(entry.getValue().getValue());
if (entry.getKey() == null) {
b.disableProperty().bind(b.selectedProperty());
}
b.setOnAction(e -> {
if (entry.getKey().equals(value.getValue())) {
if (Objects.equals(entry.getKey(), value.getValue())) {
value.setValue(null);
} else {
value.setValue(entry.getKey());
@@ -49,9 +54,15 @@ public class ToggleGroupComp<T> extends Comp<CompStructure<HBox>> {
});
group.getToggles().add(b);
box.getChildren().add(b);
if (entry.getKey().equals(value.getValue())) {
if (Objects.equals(entry.getKey(), value.getValue())) {
b.setSelected(true);
}
value.addListener((observable, oldValue, newValue) -> {
if (Objects.equals(newValue, entry.getKey())) {
b.setSelected(true);
}
});
}
if (box.getChildren().size() > 0) {

View File

@@ -281,8 +281,9 @@ public class OptionsBuilder {
public OptionsBuilder addYesNoToggle(Property<Boolean> prop) {
var map = new LinkedHashMap<Boolean, ObservableValue<String>>();
map.put(Boolean.FALSE, AppI18n.observable("app.no"));
map.put(Boolean.TRUE, AppI18n.observable("app.yes"));
map.put(Boolean.FALSE, AppI18n.observable("no"));
map.put(null, AppI18n.observable("inherit"));
map.put(Boolean.TRUE, AppI18n.observable("yes"));
var comp = new ToggleGroupComp<>(prop, new SimpleObjectProperty<>(map));
pushComp(comp);
props.add(prop);

View File

@@ -359,7 +359,7 @@
-fx-background-color: -color-success-1;
}
.browser .table-row-cell:folder:drag-over {
.browser .table-row-cell:drag-over {
-fx-background-color: -color-success-muted;
}

View File

@@ -156,6 +156,7 @@
.toggle-group-comp .toggle-button {
-fx-padding: 3 10;
-fx-opacity: 1.0;
}
.root .ikonli-font-icon.graphic.supported {

View File

@@ -1667,3 +1667,4 @@ addProfile=Tilføj profil
netbirdProfileNameAsktext=Navn på ny netbird-profil
openSftp=Åbn i SFTP-session
capslockWarning=Du har aktiveret capslock
inherit=Arve

View File

@@ -1662,3 +1662,4 @@ addProfile=Profil hinzufügen
netbirdProfileNameAsktext=Name des neuen Netbird-Profils
openSftp=In SFTP-Sitzung öffnen
capslockWarning=Du hast Capslock aktiviert
inherit=Erbe

View File

@@ -1692,3 +1692,4 @@ addProfile=Add profile
netbirdProfileNameAsktext=Name of new netbird profile
openSftp=Open in SFTP session
capslockWarning=You have capslock enabled
inherit=Inherit

View File

@@ -1626,3 +1626,4 @@ addProfile=Añadir perfil
netbirdProfileNameAsktext=Nombre del nuevo perfil netbird
openSftp=Abrir en sesión SFTP
capslockWarning=Tienes activado el bloqueo de mayúsculas
inherit=Hereda

View File

@@ -1667,3 +1667,4 @@ addProfile=Ajouter un profil
netbirdProfileNameAsktext=Nom du nouveau profil netbird
openSftp=Ouvrir une session SFTP
capslockWarning=Tu as activé le verrouillage des caps
inherit=Hériter

View File

@@ -1626,3 +1626,4 @@ addProfile=Menambahkan profil
netbirdProfileNameAsktext=Nama profil netbird baru
openSftp=Buka dalam sesi SFTP
capslockWarning=Anda telah mengaktifkan capslock
inherit=Mewarisi

View File

@@ -1626,3 +1626,4 @@ addProfile=Aggiungi profilo
netbirdProfileNameAsktext=Nome del nuovo profilo Netbird
openSftp=Aprire una sessione SFTP
capslockWarning=Hai attivato il capslock
inherit=Eredita

View File

@@ -1626,3 +1626,4 @@ addProfile=プロファイルを追加する
netbirdProfileNameAsktext=新しいネットバードプロファイルの名前
openSftp=SFTPセッションで開く
capslockWarning=キャップロックを有効にしている
inherit=継承する

View File

@@ -1626,3 +1626,4 @@ addProfile=프로필 추가
netbirdProfileNameAsktext=새 넷버드 프로필의 이름
openSftp=SFTP 세션에서 열기
capslockWarning=캡록이 활성화되어 있습니다
inherit=Inherit

View File

@@ -1626,3 +1626,4 @@ addProfile=Profiel toevoegen
netbirdProfileNameAsktext=Naam van nieuw netbird profiel
openSftp=Openen in SFTP-sessie
capslockWarning=Je hebt capslock ingeschakeld
inherit=Erven

View File

@@ -1627,3 +1627,4 @@ addProfile=Dodaj profil
netbirdProfileNameAsktext=Nazwa nowego profilu netbird
openSftp=Otwórz w sesji SFTP
capslockWarning=Masz włączony capslock
inherit=Dziedzicz

View File

@@ -1626,3 +1626,4 @@ addProfile=Adicionar perfil
netbirdProfileNameAsktext=Nome do novo perfil Netbird
openSftp=Abre uma sessão SFTP
capslockWarning=Tens o capslock ativado
inherit=Herdar

View File

@@ -1739,3 +1739,4 @@ addProfile=Добавить профиль
netbirdProfileNameAsktext=Имя нового профиля netbird
openSftp=Открыть в SFTP-сессии
capslockWarning=У тебя включен capslock
inherit=Наследуй

View File

@@ -1626,3 +1626,4 @@ addProfile=Lägg till profil
netbirdProfileNameAsktext=Namn på ny netbird-profil
openSftp=Öppna i en SFTP-session
capslockWarning=Du har aktiverat capslock
inherit=Ärva

View File

@@ -1626,3 +1626,4 @@ addProfile=Profil ekle
netbirdProfileNameAsktext=Yeni netbird profilinin adı
openSftp=SFTP oturumunda açın
capslockWarning=Capslock'u etkinleştirdiniz
inherit=Miras

View File

@@ -1626,3 +1626,4 @@ addProfile=Thêm hồ sơ
netbirdProfileNameAsktext=Tên của hồ sơ Netbird mới
openSftp=Mở trong phiên SFTP
capslockWarning=Cậu đã bật chế độ Caps Lock
inherit=Kế thừa

View File

@@ -2261,3 +2261,4 @@ addProfile=添加配置文件
netbirdProfileNameAsktext=新网鸟配置文件的名称
openSftp=在 SFTP 会话中打开
capslockWarning=您已启用盖帽锁
inherit=继承

View File

@@ -1626,3 +1626,4 @@ addProfile=新增設定檔
netbirdProfileNameAsktext=新 netbird 配置文件的名稱
openSftp=在 SFTP 會話中開啟
capslockWarning=您已啟用上限鎖定功能
inherit=繼承