Settings values are Setting<T>: one key each, change listeners
Each setting is declared once with its key, type and range, and loaded and saved from that list. Output device, volume and receive buffer, the status bar and the master volume slider take effect through listeners instead of calls wherever they change; Android does the same for output settings and country flags. The Playback page previews voice volume with the master volume applied. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -32,11 +32,11 @@ public final class Main {
|
||||
if (link != null && InstanceChannel.send(link)) return;
|
||||
|
||||
final Settings settings = Settings.load();
|
||||
DisplayScale.configure(settings.uiScale);
|
||||
DisplayScale.configure(settings.uiScale.get());
|
||||
WindowClass.apply();
|
||||
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
LookAndFeelManager.install(settings.appearance);
|
||||
LookAndFeelManager.install(settings.appearance.get());
|
||||
IconTheme.get().reload(settings);
|
||||
DesktopEntry.install();
|
||||
MainFrame frame = new MainFrame(settings);
|
||||
|
||||
@@ -16,7 +16,7 @@ final class ApplicationPanel extends FormPanel {
|
||||
this.settings = settings;
|
||||
GridBagConstraints c = gbc();
|
||||
|
||||
mutedWarning = new JCheckBox("Warn when talking while microphone is muted", settings.mutedTalkWarning);
|
||||
mutedWarning = new JCheckBox("Warn when talking while microphone is muted", settings.mutedTalkWarning.get());
|
||||
clientVersion = new ClientVersionPanel(settings);
|
||||
|
||||
int row = 0;
|
||||
@@ -29,7 +29,7 @@ final class ApplicationPanel extends FormPanel {
|
||||
|
||||
/** Copies the page into the settings; the caller saves them. */
|
||||
void apply() {
|
||||
settings.mutedTalkWarning = mutedWarning.isSelected();
|
||||
settings.mutedTalkWarning.set(mutedWarning.isSelected());
|
||||
clientVersion.apply();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,9 +195,9 @@ final class BanListDialog extends AbstractServerListDialog {
|
||||
onlyOwn.addActionListener(e -> applyFilter());
|
||||
highlightOwn.setToolTipText("Mark bans created by you as bold");
|
||||
highlightOwn.setOpaque(false);
|
||||
highlightOwn.setSelected(settings.banHighlightOwn);
|
||||
highlightOwn.setSelected(settings.banHighlightOwn.get());
|
||||
highlightOwn.addActionListener(e -> {
|
||||
settings.banHighlightOwn = highlightOwn.isSelected();
|
||||
settings.banHighlightOwn.set(highlightOwn.isSelected());
|
||||
settings.save();
|
||||
table.repaint();
|
||||
});
|
||||
@@ -241,7 +241,7 @@ final class BanListDialog extends AbstractServerListDialog {
|
||||
|
||||
private Set<Column> savedColumns() {
|
||||
Set<Column> columns = EnumSet.noneOf(Column.class);
|
||||
for (String name : settings.banListColumns.split(",")) {
|
||||
for (String name : settings.banListColumns.get().split(",")) {
|
||||
try {
|
||||
if (!name.isBlank()) columns.add(Column.valueOf(name.trim()));
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
@@ -255,7 +255,7 @@ final class BanListDialog extends AbstractServerListDialog {
|
||||
}
|
||||
|
||||
private void saveColumns() {
|
||||
settings.banListColumns = visibleColumns.stream().map(Enum::name).collect(Collectors.joining(","));
|
||||
settings.banListColumns.set(visibleColumns.stream().map(Enum::name).collect(Collectors.joining(",")));
|
||||
settings.save();
|
||||
}
|
||||
|
||||
|
||||
@@ -38,11 +38,11 @@ final class CapturePanel extends FormPanel {
|
||||
this.activation = new VoiceActivationSection(settings, audio, liveMic, hotkeys, hotkeysPanel, audioSnapshot);
|
||||
GridBagConstraints c = gbc();
|
||||
|
||||
inputCombo = AudioDevices.combo(audio.io().inputDevices(), settings.inputDevice);
|
||||
inputCombo = AudioDevices.combo(audio.io().inputDevices(), settings.inputDevice.get());
|
||||
limitWidth(inputCombo, FIELD_WIDTH);
|
||||
inputCombo.addActionListener(e -> activation.restartTest());
|
||||
|
||||
inputGain = new JSlider(0, 200, (int) Math.round(settings.inputVolume * 100));
|
||||
inputGain = new JSlider(0, 200, (int) Math.round(settings.inputVolume.get() * 100));
|
||||
JLabel gainLabel = new JLabel(inputGain.getValue() + "%");
|
||||
inputGain.addChangeListener(e -> {
|
||||
gainLabel.setText(inputGain.getValue() + "%");
|
||||
@@ -51,14 +51,14 @@ final class CapturePanel extends FormPanel {
|
||||
|
||||
// Off, then TS3's four denoiser_level steps.
|
||||
denoise = new JSlider(0, DENOISE_STEPS.length - 1,
|
||||
settings.denoise ? Math.max(0, Math.min(3, settings.denoiserLevel)) + 1 : 0);
|
||||
settings.denoise.get() ? Math.max(0, Math.min(3, settings.denoiserLevel.get())) + 1 : 0);
|
||||
denoise.setMajorTickSpacing(1);
|
||||
denoise.setPaintTicks(true);
|
||||
denoise.setSnapToTicks(true);
|
||||
JLabel denoiseLabel = new JLabel(DENOISE_STEPS[denoise.getValue()]);
|
||||
typingCheck = new JCheckBox("Typing attenuation", settings.typingAttenuation);
|
||||
agcCheck = new JCheckBox("Automatic gain control", settings.agc);
|
||||
agcBoost = new JSlider(0, Settings.MAX_AGC_BOOST_DB, settings.agcBoostDb);
|
||||
typingCheck = new JCheckBox("Typing attenuation", settings.typingAttenuation.get());
|
||||
agcCheck = new JCheckBox("Automatic gain control", settings.agc.get());
|
||||
agcBoost = new JSlider(0, Settings.MAX_AGC_BOOST_DB, settings.agcBoostDb.get());
|
||||
agcBoost.setMajorTickSpacing(5);
|
||||
agcBoost.setPaintTicks(true);
|
||||
limitWidth(agcBoost, SLIDER_WIDTH);
|
||||
@@ -98,13 +98,13 @@ final class CapturePanel extends FormPanel {
|
||||
|
||||
/** Copies the page into {@code target}, without touching anything else. */
|
||||
void writeInto(Settings target) {
|
||||
target.inputDevice = AudioDevices.selectedId(inputCombo);
|
||||
target.inputVolume = inputGain.getValue() / 100.0;
|
||||
target.denoise = denoise.getValue() > 0;
|
||||
if (target.denoise) target.denoiserLevel = denoise.getValue() - 1;
|
||||
target.typingAttenuation = typingCheck.isSelected();
|
||||
target.agc = agcCheck.isSelected();
|
||||
target.agcBoostDb = agcBoost.getValue();
|
||||
target.inputDevice.set(AudioDevices.selectedId(inputCombo));
|
||||
target.inputVolume.set(inputGain.getValue() / 100.0);
|
||||
target.denoise.set(denoise.getValue() > 0);
|
||||
if (target.denoise.get()) target.denoiserLevel.set(denoise.getValue() - 1);
|
||||
target.typingAttenuation.set(typingCheck.isSelected());
|
||||
target.agc.set(agcCheck.isSelected());
|
||||
target.agcBoostDb.set(agcBoost.getValue());
|
||||
activation.writeInto(target);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,11 +30,11 @@ final class ChatLogsPanel extends FormPanel {
|
||||
this.settings = settings;
|
||||
GridBagConstraints c = gbc();
|
||||
|
||||
enabled.setSelected(settings.chatLogs);
|
||||
enabled.setSelected(settings.chatLogs.get());
|
||||
enabled.setToolTipText("Write every chat to disk and show its history when it opens again");
|
||||
enabled.addActionListener(e -> updateEnabled());
|
||||
|
||||
folder.setText(settings.chatLogDir);
|
||||
folder.setText(settings.chatLogDir.get());
|
||||
folder.putClientProperty("JTextField.placeholderText", "The TeamSpeak 3 client's folder");
|
||||
folder.setToolTipText("<html>Leave empty to share the TeamSpeak 3 client's logs:<br>"
|
||||
+ AppDirs.chatLogs() + "</html>");
|
||||
@@ -47,7 +47,7 @@ final class ChatLogsPanel extends FormPanel {
|
||||
JLabel nextConnect = new JLabel("Takes effect on the next connect.");
|
||||
nextConnect.setEnabled(false);
|
||||
|
||||
pictures.setSelected(settings.descriptionPictures);
|
||||
pictures.setSelected(settings.descriptionPictures.get());
|
||||
pictures.setToolTipText("Off: only links to them, nothing fetched");
|
||||
|
||||
int row = 0;
|
||||
@@ -81,8 +81,8 @@ final class ChatLogsPanel extends FormPanel {
|
||||
|
||||
/** Copies the page into the settings; the caller saves them. */
|
||||
void apply() {
|
||||
settings.chatLogs = enabled.isSelected();
|
||||
settings.chatLogDir = folder.getText().trim();
|
||||
settings.descriptionPictures = pictures.isSelected();
|
||||
settings.chatLogs.set(enabled.isSelected());
|
||||
settings.chatLogDir.set(folder.getText().trim());
|
||||
settings.descriptionPictures.set(pictures.isSelected());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,10 +57,10 @@ final class ClientVersionPanel extends JPanel {
|
||||
|
||||
/** Copies the edited version into the settings; the caller saves them. */
|
||||
void apply() {
|
||||
settings.customVersion = enabled.isSelected();
|
||||
settings.clientVersion = versionField.getText().trim();
|
||||
settings.clientPlatform = String.valueOf(platformCombo.getEditor().getItem()).trim();
|
||||
settings.clientVersionSign = signField.getText().trim();
|
||||
settings.customVersion.set(enabled.isSelected());
|
||||
settings.clientVersion.set(versionField.getText().trim());
|
||||
settings.clientPlatform.set(String.valueOf(platformCombo.getEditor().getItem()).trim());
|
||||
settings.clientVersionSign.set(signField.getText().trim());
|
||||
}
|
||||
|
||||
private JComponent buildForm() {
|
||||
@@ -117,11 +117,12 @@ final class ClientVersionPanel extends JPanel {
|
||||
}
|
||||
|
||||
private void load() {
|
||||
enabled.setSelected(settings.customVersion);
|
||||
enabled.setSelected(settings.customVersion.get());
|
||||
ClientVersion preset = ClientVersion.match(
|
||||
settings.clientVersion, settings.clientPlatform, settings.clientVersionSign);
|
||||
settings.clientVersion.get(), settings.clientPlatform.get(), settings.clientVersionSign.get());
|
||||
fill(preset != null ? preset
|
||||
: new ClientVersion("", settings.clientVersion, settings.clientPlatform, settings.clientVersionSign));
|
||||
: new ClientVersion("", settings.clientVersion.get(), settings.clientPlatform.get(),
|
||||
settings.clientVersionSign.get()));
|
||||
presetCombo.setSelectedItem(preset != null ? preset : CUSTOM);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ public final class ConnectDialog extends JDialog {
|
||||
public ConnectDialog(Frame owner, Settings settings, IdentityStore identities) {
|
||||
super(owner, "Connect to Server", true);
|
||||
|
||||
String addr = settings.lastAddress;
|
||||
String addr = settings.lastAddress.get();
|
||||
int port = 9987;
|
||||
int colon = addr.lastIndexOf(':');
|
||||
if (colon > 0) {
|
||||
@@ -47,9 +47,9 @@ public final class ConnectDialog extends JDialog {
|
||||
|
||||
addressField = new JTextField(addr, 18);
|
||||
portField = new JTextField(Integer.toString(port), 6);
|
||||
nickField = new JTextField(settings.nickname, 18);
|
||||
passwordField = new JPasswordField(settings.serverPassword, 18);
|
||||
identityChooser = new IdentityChooser(identities, false, settings.defaultIdentityId);
|
||||
nickField = new JTextField(settings.nickname.get(), 18);
|
||||
passwordField = new JPasswordField(settings.serverPassword.get(), 18);
|
||||
identityChooser = new IdentityChooser(identities, false, settings.defaultIdentityId.get());
|
||||
|
||||
JPanel form = new JPanel(new GridBagLayout());
|
||||
form.setBorder(new ScaledEmptyBorder(12, 12, 8, 12));
|
||||
|
||||
@@ -30,10 +30,10 @@ final class ContactsPanel extends FormPanel {
|
||||
this.settings = settings;
|
||||
GridBagConstraints c = gbc();
|
||||
|
||||
colorContacts.setSelected(settings.colorContacts);
|
||||
colorContacts.setSelected(settings.colorContacts.get());
|
||||
colorContacts.setToolTipText("Friends in green and blocked clients in red, as the TeamSpeak client shows them");
|
||||
|
||||
whisperPolicy.setSelectedItem(settings.whisperPolicy);
|
||||
whisperPolicy.setSelectedItem(settings.whisperPolicy.get());
|
||||
whisperPolicy.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index,
|
||||
@@ -68,7 +68,7 @@ final class ContactsPanel extends FormPanel {
|
||||
|
||||
/** Copies the page into the settings; the caller saves them. */
|
||||
void apply() {
|
||||
settings.colorContacts = colorContacts.isSelected();
|
||||
settings.whisperPolicy = (Settings.WhisperPolicy) whisperPolicy.getSelectedItem();
|
||||
settings.colorContacts.set(colorContacts.isSelected());
|
||||
settings.whisperPolicy.set((Settings.WhisperPolicy) whisperPolicy.getSelectedItem());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ final class DescriptionPictures {
|
||||
* and asks for those not on their way yet.
|
||||
*/
|
||||
String state(List<String> urls) {
|
||||
if (!settings.descriptionPictures) return "";
|
||||
if (!settings.descriptionPictures.get()) return "";
|
||||
StringBuilder state = new StringBuilder(urls.size());
|
||||
for (String url : urls) {
|
||||
state.append(downloads.get(url) != null ? 'y' : downloads.failed(url) ? 'n' : '-');
|
||||
@@ -101,7 +101,7 @@ final class DescriptionPictures {
|
||||
}
|
||||
|
||||
private String picture(String url, String anchor, String href, int maxWidth, int maxHeight) {
|
||||
if (!settings.descriptionPictures) return link("ICONVIEWER", url, anchor, href);
|
||||
if (!settings.descriptionPictures.get()) return link("ICONVIEWER", url, anchor, href);
|
||||
File file = downloads.get(url);
|
||||
if (file == null) {
|
||||
return downloads.failed(url) ? link("BROKEN_IMAGE", url, anchor, href) : icon("LOADING_IMAGE");
|
||||
|
||||
@@ -70,10 +70,10 @@ final class DesignPanel extends JPanel {
|
||||
DesignPanel(Settings settings) {
|
||||
super(new BorderLayout(0, UIScale.scale(8)));
|
||||
this.settings = settings;
|
||||
this.originalPackId = settings.iconPack;
|
||||
this.originalPackDir = settings.iconPackDir;
|
||||
this.originalAppearance = settings.appearance;
|
||||
this.packDirField = new JTextField(settings.iconPackDir, 18);
|
||||
this.originalPackId = settings.iconPack.get();
|
||||
this.originalPackDir = settings.iconPackDir.get();
|
||||
this.originalAppearance = settings.appearance.get();
|
||||
this.packDirField = new JTextField(settings.iconPackDir.get(), 18);
|
||||
this.anyColor = new RowColorCombo(settings.clientRowColors.any);
|
||||
this.talkingColor = new RowColorCombo(settings.clientRowColors.talking);
|
||||
this.mutedAwayColor = new RowColorCombo(settings.clientRowColors.mutedAway);
|
||||
@@ -87,27 +87,27 @@ final class DesignPanel extends JPanel {
|
||||
|
||||
/** Copies the chosen appearance and pack into the settings; the caller saves them. */
|
||||
void apply() {
|
||||
settings.appearance = selectedAppearance();
|
||||
if (scaleCombo.getSelectedItem() instanceof Double scale) settings.uiScale = scale;
|
||||
settings.iconPackDir = packDirField.getText().trim();
|
||||
settings.appearance.set(selectedAppearance());
|
||||
if (scaleCombo.getSelectedItem() instanceof Double scale) settings.uiScale.set(scale);
|
||||
settings.iconPackDir.set(packDirField.getText().trim());
|
||||
Object selected = packCombo.getSelectedItem();
|
||||
settings.iconPack = selected instanceof IconPack pack ? pack.id() : "";
|
||||
settings.countryFlags = countryFlags.isSelected();
|
||||
settings.iconPack.set(selected instanceof IconPack pack ? pack.id() : "");
|
||||
settings.countryFlags.set(countryFlags.isSelected());
|
||||
settings.clientRowColors.any = anyColor.value();
|
||||
settings.clientRowColors.talking = talkingColor.value();
|
||||
settings.clientRowColors.mutedAway = mutedAwayColor.value();
|
||||
originalPackId = settings.iconPack;
|
||||
originalPackDir = settings.iconPackDir;
|
||||
originalAppearance = settings.appearance;
|
||||
originalPackId = settings.iconPack.get();
|
||||
originalPackDir = settings.iconPackDir.get();
|
||||
originalAppearance = settings.appearance.get();
|
||||
}
|
||||
|
||||
/** Puts back the appearance and pack last applied, for a cancelled edit. */
|
||||
void revert() {
|
||||
settings.iconPack = originalPackId;
|
||||
settings.iconPackDir = originalPackDir;
|
||||
settings.iconPack.set(originalPackId);
|
||||
settings.iconPackDir.set(originalPackDir);
|
||||
IconTheme.get().reload(settings);
|
||||
if (settings.appearance != originalAppearance) {
|
||||
settings.appearance = originalAppearance;
|
||||
if (settings.appearance.get() != originalAppearance) {
|
||||
settings.appearance.set(originalAppearance);
|
||||
LookAndFeelManager.switchTo(originalAppearance);
|
||||
}
|
||||
}
|
||||
@@ -134,7 +134,7 @@ final class DesignPanel extends JPanel {
|
||||
});
|
||||
|
||||
appearanceCombo.setToolTipText("Light or dark window colours");
|
||||
appearanceCombo.setSelectedItem(settings.appearance);
|
||||
appearanceCombo.setSelectedItem(settings.appearance.get());
|
||||
appearanceCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
public Component getListCellRendererComponent(JList<?> list, Object value, int index,
|
||||
@@ -153,7 +153,7 @@ final class DesignPanel extends JPanel {
|
||||
dirRow.add(browse, BorderLayout.EAST);
|
||||
packDirField.setToolTipText("Extra folder to look for icon packs in");
|
||||
packInfo.setEnabled(false);
|
||||
countryFlags.setSelected(settings.countryFlags);
|
||||
countryFlags.setSelected(settings.countryFlags.get());
|
||||
|
||||
int row = 0;
|
||||
FormPanel.addSection(p, c, row++, "Appearance");
|
||||
@@ -178,10 +178,10 @@ final class DesignPanel extends JPanel {
|
||||
|
||||
private void buildScaleCombo() {
|
||||
for (double scale : SCALES) scaleCombo.addItem(scale);
|
||||
if (settings.uiScale > 0 && Arrays.stream(SCALES).noneMatch(s -> s == settings.uiScale)) {
|
||||
scaleCombo.addItem(settings.uiScale);
|
||||
if (settings.uiScale.get() > 0 && Arrays.stream(SCALES).noneMatch(s -> s == settings.uiScale.get())) {
|
||||
scaleCombo.addItem(settings.uiScale.get());
|
||||
}
|
||||
scaleCombo.setSelectedItem(Math.max(0, settings.uiScale));
|
||||
scaleCombo.setSelectedItem(Math.max(0, settings.uiScale.get()));
|
||||
scaleCombo.setToolTipText("Size of text, icons and controls; takes effect after a restart");
|
||||
scaleCombo.setRenderer(new DefaultListCellRenderer() {
|
||||
@Override
|
||||
@@ -248,8 +248,8 @@ final class DesignPanel extends JPanel {
|
||||
|
||||
private void onAppearanceSelected() {
|
||||
Settings.Appearance chosen = selectedAppearance();
|
||||
if (chosen == settings.appearance) return;
|
||||
settings.appearance = chosen;
|
||||
if (chosen == settings.appearance.get()) return;
|
||||
settings.appearance.set(chosen);
|
||||
LookAndFeelManager.switchTo(chosen);
|
||||
}
|
||||
|
||||
@@ -276,7 +276,7 @@ final class DesignPanel extends JPanel {
|
||||
if (!current.isEmpty()) chooser.setCurrentDirectory(new File(current));
|
||||
if (chooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) return;
|
||||
packDirField.setText(chooser.getSelectedFile().getAbsolutePath());
|
||||
settings.iconPackDir = packDirField.getText();
|
||||
settings.iconPackDir.set(packDirField.getText());
|
||||
reloadPacks();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ final class DesktopNotifier {
|
||||
|
||||
private boolean wanted() {
|
||||
// Some window of ours has the focus exactly when there is an active window.
|
||||
return settings.desktopNotifications
|
||||
return settings.desktopNotifications.get()
|
||||
&& KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow() == null;
|
||||
}
|
||||
|
||||
|
||||
@@ -338,7 +338,7 @@ final class DropIndicatorTree extends JTree {
|
||||
model.serverGroupsOf(cl.serverGroupIds), model.channelGroup(cl.channelGroupId)));
|
||||
addIcon(icons, cl.talkRequest ? "TALK_POWER_REQUEST" : null);
|
||||
// The country's flag comes last, at the row's edge, as in TeamSpeak.
|
||||
Icon flag = settings.countryFlags ? CountryFlagIcons.of(cl.country) : null;
|
||||
Icon flag = settings.countryFlags.get() ? CountryFlagIcons.of(cl.country) : null;
|
||||
if (flag != null) icons.add(flag);
|
||||
return icons;
|
||||
}
|
||||
|
||||
@@ -75,8 +75,8 @@ public final class IconTheme {
|
||||
|
||||
/** Re-scans the pack folders and activates the one the settings name. */
|
||||
public void reload(Settings settings) {
|
||||
packs = IconPacks.findAll(new File(AppDirs.profile(), "gfx"), settings.iconPackDir);
|
||||
IconPack pack = IconPacks.select(packs, settings.iconPack);
|
||||
packs = IconPacks.findAll(new File(AppDirs.profile(), "gfx"), settings.iconPackDir.get());
|
||||
IconPack pack = IconPacks.select(packs, settings.iconPack.get());
|
||||
// The shipped pack survives a re-scan as the same object, so setPack alone may not notice.
|
||||
lookupOrder = IconPacks.lookupOrder(pack, packs, null);
|
||||
setPack(pack);
|
||||
|
||||
@@ -173,7 +173,7 @@ public final class IdentitiesDialog extends JDialog {
|
||||
}
|
||||
|
||||
private String label(IdentityEntry e) {
|
||||
return e.getId().equals(settings.defaultIdentityId) ? e.getName() + " (default)" : e.getName();
|
||||
return e.getId().equals(settings.defaultIdentityId.get()) ? e.getName() + " (default)" : e.getName();
|
||||
}
|
||||
|
||||
private void reload() {
|
||||
@@ -233,8 +233,8 @@ public final class IdentitiesDialog extends JDialog {
|
||||
|
||||
runWithProgress("Generating identity…", (cancelled, status) -> {
|
||||
IdentityEntry created = identities.generate(name.trim(), level);
|
||||
if (settings.defaultIdentityId == null || identities.byId(settings.defaultIdentityId) == null) {
|
||||
settings.defaultIdentityId = created.getId();
|
||||
if (settings.defaultIdentityId.get() == null || identities.byId(settings.defaultIdentityId.get()) == null) {
|
||||
settings.defaultIdentityId.set(created.getId());
|
||||
settings.save();
|
||||
}
|
||||
return created;
|
||||
@@ -249,8 +249,8 @@ public final class IdentitiesDialog extends JDialog {
|
||||
File file = chooser.getSelectedFile();
|
||||
try {
|
||||
IdentityEntry imported = identities.importFile(file, null);
|
||||
if (identities.byId(settings.defaultIdentityId) == null) {
|
||||
settings.defaultIdentityId = imported.getId();
|
||||
if (identities.byId(settings.defaultIdentityId.get()) == null) {
|
||||
settings.defaultIdentityId.set(imported.getId());
|
||||
settings.save();
|
||||
}
|
||||
reload();
|
||||
@@ -315,7 +315,7 @@ public final class IdentitiesDialog extends JDialog {
|
||||
private void setSelectedDefault() {
|
||||
IdentityEntry e = list.getSelectedValue();
|
||||
if (e == null) return;
|
||||
settings.defaultIdentityId = e.getId();
|
||||
settings.defaultIdentityId.set(e.getId());
|
||||
settings.save();
|
||||
reload();
|
||||
}
|
||||
|
||||
@@ -260,16 +260,16 @@ final class MainCommands {
|
||||
|
||||
/** Asks for a new nickname, used on every server. */
|
||||
void changeNickname() {
|
||||
String nickname = JOptionPane.showInputDialog(frame, "New nickname:", settings.nickname);
|
||||
String nickname = JOptionPane.showInputDialog(frame, "New nickname:", settings.nickname.get());
|
||||
if (nickname != null) changeNickname(nickname);
|
||||
}
|
||||
|
||||
/** Uses this nickname on every server; a blank one is ignored. */
|
||||
void changeNickname(String nickname) {
|
||||
if (nickname == null || nickname.isBlank()) return;
|
||||
settings.nickname = nickname.trim();
|
||||
settings.nickname.set(nickname.trim());
|
||||
settings.save();
|
||||
sessions.setNickname(settings.nickname);
|
||||
sessions.setNickname(settings.nickname.get());
|
||||
}
|
||||
|
||||
void joinChannel(List<ServerSession> targets, String path) {
|
||||
@@ -378,15 +378,6 @@ final class MainCommands {
|
||||
|
||||
// ---- the window ----
|
||||
|
||||
/** Master volume, output device and receive buffer are global, so they go to every connection. */
|
||||
void applyOutputSettings() {
|
||||
frame.applyOutputSettingsToAllTabs();
|
||||
}
|
||||
|
||||
void showStatusBar(boolean visible) {
|
||||
frame.showStatusBar(visible);
|
||||
}
|
||||
|
||||
// ---- the client's own windows ----
|
||||
|
||||
void showGiantPtt() {
|
||||
|
||||
@@ -10,6 +10,7 @@ import eu.lixko.ts3j.client.config.Bookmark;
|
||||
import eu.lixko.ts3j.client.config.Bookmarks;
|
||||
import eu.lixko.ts3j.client.session.ServerLink;
|
||||
import eu.lixko.ts3j.client.config.IdentityStore;
|
||||
import eu.lixko.ts3j.client.config.Setting;
|
||||
import eu.lixko.ts3j.client.config.Settings;
|
||||
import eu.lixko.ts3j.client.myts.ChatAttachments;
|
||||
import eu.lixko.ts3j.client.myts.MyTeamSpeakLogin;
|
||||
@@ -102,12 +103,12 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener {
|
||||
public MainFrame(Settings settings) {
|
||||
super("TeamSpook TS3j");
|
||||
this.settings = settings;
|
||||
this.chatZoom = new TextZoom(settings.chatZoom, z -> {
|
||||
settings.chatZoom = z;
|
||||
this.chatZoom = new TextZoom(settings.chatZoom.get(), z -> {
|
||||
settings.chatZoom.set(z);
|
||||
settings.save();
|
||||
});
|
||||
this.infoZoom = new TextZoom(settings.infoZoom, z -> {
|
||||
settings.infoZoom = z;
|
||||
this.infoZoom = new TextZoom(settings.infoZoom.get(), z -> {
|
||||
settings.infoZoom.set(z);
|
||||
settings.save();
|
||||
});
|
||||
this.identities = IdentityStore.load(settings);
|
||||
@@ -117,6 +118,8 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener {
|
||||
this.soundPlayer = audio.createSoundPlayer(settings);
|
||||
this.sounds.setPlayer(soundPlayer);
|
||||
this.notifier = new DesktopNotifier(this, settings);
|
||||
Setting.onAnyChange(this::applyOutputSettingsToAllTabs,
|
||||
settings.outputDevice, settings.outputVolume, settings.masterVolume, settings.receiveBuffer);
|
||||
pictures.addSource("tsattach:", attachments::fetchPicture);
|
||||
// Any of the client's windows coming to the front counts, a dialog included.
|
||||
KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener("activeWindow", e -> {
|
||||
@@ -170,7 +173,8 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener {
|
||||
statusBar = new StatusBar(commands::stopRecording, commands::showOfflineMessages, () -> {
|
||||
if (selected != null) selected.session().cancelReconnect();
|
||||
});
|
||||
statusBar.setVisible(settings.showStatusBar);
|
||||
statusBar.setVisible(settings.showStatusBar.get());
|
||||
settings.showStatusBar.addListener(this::showStatusBar);
|
||||
add(statusBar, BorderLayout.SOUTH);
|
||||
|
||||
statusBar.setCodec(audio.description());
|
||||
@@ -311,7 +315,7 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener {
|
||||
menuBar.rebuildBookmarks();
|
||||
}
|
||||
|
||||
void showStatusBar(boolean visible) {
|
||||
private void showStatusBar(boolean visible) {
|
||||
statusBar.setVisible(visible);
|
||||
revalidate();
|
||||
repaint();
|
||||
@@ -413,9 +417,8 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener {
|
||||
}
|
||||
|
||||
void adjustMasterVolume(double delta) {
|
||||
settings.outputVolume = Math.max(0, Math.min(2.0, settings.outputVolume + delta));
|
||||
settings.outputVolume.set(Math.max(0, Math.min(2.0, settings.outputVolume.get() + delta)));
|
||||
settings.save();
|
||||
applyOutputSettingsToAllTabs();
|
||||
updateStatusLabel();
|
||||
}
|
||||
|
||||
@@ -510,9 +513,9 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener {
|
||||
|
||||
private void startConnection(String address, int port, String nickname, String password, String identityId,
|
||||
String channel, String channelPassword, boolean replaceCurrent, boolean mytsFeatures) {
|
||||
settings.lastAddress = address + ":" + port;
|
||||
if (!nickname.isBlank()) settings.nickname = nickname;
|
||||
settings.serverPassword = password;
|
||||
settings.lastAddress.set(address + ":" + port);
|
||||
if (!nickname.isBlank()) settings.nickname.set(nickname);
|
||||
settings.serverPassword.set(password);
|
||||
settings.save();
|
||||
|
||||
ServerTab tab = (replaceCurrent && selected != null) ? selected : tabForNewConnection();
|
||||
@@ -626,10 +629,7 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener {
|
||||
sounds, hotkeys,
|
||||
new MyTeamSpeakPanel(myTeamSpeak, new TeamSpeakImporter(identities, bookmarks, settings, contacts),
|
||||
this::bookmarksChanged, this::myTeamSpeakChanged),
|
||||
() -> {
|
||||
applyOutputSettingsToAllTabs();
|
||||
contactsChanged();
|
||||
});
|
||||
this::contactsChanged);
|
||||
dlg.setVisible(true);
|
||||
}
|
||||
|
||||
@@ -661,14 +661,14 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener {
|
||||
}
|
||||
|
||||
/** Master volume, output device and receive buffer are global, so push them to every open connection. */
|
||||
void applyOutputSettingsToAllTabs() {
|
||||
soundPlayer.setOutputDevice(settings.outputDevice);
|
||||
private void applyOutputSettingsToAllTabs() {
|
||||
soundPlayer.setOutputDevice(settings.outputDevice.get());
|
||||
for (ServerTab tab : tabs) {
|
||||
VoiceOutput playback = tab.session().playback();
|
||||
if (playback == null) continue;
|
||||
playback.setMasterVolume(settings.effectiveOutputVolume());
|
||||
playback.setOutputDevice(settings.outputDevice);
|
||||
playback.setReceiveBuffer(settings.receiveBuffer);
|
||||
playback.setOutputDevice(settings.outputDevice.get());
|
||||
playback.setReceiveBuffer(settings.receiveBuffer.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,6 @@ import javax.swing.JPopupMenu;
|
||||
import javax.swing.JSlider;
|
||||
import javax.swing.JToggleButton;
|
||||
import javax.swing.JToolBar;
|
||||
import javax.swing.event.PopupMenuEvent;
|
||||
import javax.swing.event.PopupMenuListener;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.FlowLayout;
|
||||
@@ -96,7 +94,7 @@ final class MainToolbar extends JToolBar {
|
||||
add(settingsButton);
|
||||
add(Box.createHorizontalGlue());
|
||||
masterVolumePanel = buildMasterVolumeControl();
|
||||
masterVolumePanel.setVisible(settings.showMasterVolumeSlider);
|
||||
masterVolumePanel.setVisible(settings.showMasterVolumeSlider.get());
|
||||
add(masterVolumePanel);
|
||||
hostButton = new HostButtonView(pictures);
|
||||
add(hostButton);
|
||||
@@ -136,14 +134,13 @@ final class MainToolbar extends JToolBar {
|
||||
icon.setToolTipText("Master volume (voice + notifications)");
|
||||
icon.setAlignmentY(Component.CENTER_ALIGNMENT);
|
||||
|
||||
JSlider slider = new JSlider(0, 200, (int) Math.round(settings.masterVolume * 100));
|
||||
JSlider slider = new JSlider(0, 200, (int) Math.round(settings.masterVolume.get() * 100));
|
||||
slider.setOpaque(false);
|
||||
slider.setToolTipText("Master volume (voice + notifications) — scroll to adjust");
|
||||
slider.setAlignmentY(Component.CENTER_ALIGNMENT);
|
||||
slider.setPreferredSize(new Dimension(UIScale.scale(135), slider.getPreferredSize().height));
|
||||
slider.addChangeListener(e -> {
|
||||
settings.masterVolume = slider.getValue() / 100.0;
|
||||
commands.applyOutputSettings();
|
||||
settings.masterVolume.set(slider.getValue() / 100.0);
|
||||
// Only touch the disk once the drag (or a wheel step) has settled.
|
||||
if (!slider.getValueIsAdjusting()) settings.save();
|
||||
});
|
||||
@@ -162,41 +159,27 @@ final class MainToolbar extends JToolBar {
|
||||
private JPopupMenu buildContextMenu() {
|
||||
JPopupMenu menu = new JPopupMenu();
|
||||
|
||||
JCheckBoxMenuItem statusBarItem = new JCheckBoxMenuItem("Show Status Bar", settings.showStatusBar);
|
||||
JCheckBoxMenuItem statusBarItem = new JCheckBoxMenuItem("Show Status Bar", settings.showStatusBar.get());
|
||||
statusBarItem.addActionListener(e -> {
|
||||
settings.showStatusBar = statusBarItem.isSelected();
|
||||
settings.showStatusBar.set(statusBarItem.isSelected());
|
||||
settings.save();
|
||||
commands.showStatusBar(settings.showStatusBar);
|
||||
});
|
||||
settings.showStatusBar.addListener(statusBarItem::setSelected);
|
||||
|
||||
JCheckBoxMenuItem volumeItem = new JCheckBoxMenuItem("Show Master Volume Slider", settings.showMasterVolumeSlider);
|
||||
JCheckBoxMenuItem volumeItem = new JCheckBoxMenuItem("Show Master Volume Slider", settings.showMasterVolumeSlider.get());
|
||||
volumeItem.addActionListener(e -> {
|
||||
settings.showMasterVolumeSlider = volumeItem.isSelected();
|
||||
settings.showMasterVolumeSlider.set(volumeItem.isSelected());
|
||||
settings.save();
|
||||
masterVolumePanel.setVisible(settings.showMasterVolumeSlider);
|
||||
});
|
||||
settings.showMasterVolumeSlider.addListener(shown -> {
|
||||
volumeItem.setSelected(shown);
|
||||
masterVolumePanel.setVisible(shown);
|
||||
revalidate();
|
||||
repaint();
|
||||
});
|
||||
|
||||
menu.add(statusBarItem);
|
||||
menu.add(volumeItem);
|
||||
// Either toggle can also be flipped elsewhere (or via settings.properties), so
|
||||
// re-sync the ticks each time the menu is about to be shown.
|
||||
menu.addPopupMenuListener(new PopupMenuListener() {
|
||||
@Override
|
||||
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
|
||||
statusBarItem.setSelected(settings.showStatusBar);
|
||||
volumeItem.setSelected(settings.showMasterVolumeSlider);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void popupMenuCanceled(PopupMenuEvent e) {
|
||||
}
|
||||
});
|
||||
return menu;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ final class MicrophoneTest {
|
||||
input.setLevelListener(db -> SwingUtilities.invokeLater(() -> onLevel.accept(db)));
|
||||
input.setTalkListener(talking -> SwingUtilities.invokeLater(() -> onTransmitting.accept(talking)));
|
||||
input.setMonitorListener(this::enqueueForLoopback);
|
||||
this.outputDevice = settings.outputDevice;
|
||||
this.outputDevice = settings.outputDevice.get();
|
||||
try {
|
||||
input.start();
|
||||
} catch (RuntimeException e) {
|
||||
|
||||
@@ -34,7 +34,7 @@ final class NetworkPanel extends FormPanel {
|
||||
this.liveMic = liveMic;
|
||||
GridBagConstraints c = gbc();
|
||||
|
||||
int kbits = Math.max(MIN_BITRATE_KBITS, Math.min(MAX_BITRATE_KBITS, settings.bitrate / 1000));
|
||||
int kbits = Math.max(MIN_BITRATE_KBITS, Math.min(MAX_BITRATE_KBITS, settings.bitrate.get() / 1000));
|
||||
bitrateSlider = new JSlider(MIN_BITRATE_KBITS, MAX_BITRATE_KBITS, kbits);
|
||||
JLabel bitrateLabel = new JLabel(kbits + " kbit/s");
|
||||
bitrateSlider.addChangeListener(e -> {
|
||||
@@ -42,28 +42,28 @@ final class NetworkPanel extends FormPanel {
|
||||
pushEncoder.run();
|
||||
});
|
||||
|
||||
vbrCheck = new JCheckBox("Variable bitrate (VBR)", settings.vbr);
|
||||
fecCheck = new JCheckBox("Forward error correction (FEC)", settings.fec);
|
||||
vbrCheck = new JCheckBox("Variable bitrate (VBR)", settings.vbr.get());
|
||||
fecCheck = new JCheckBox("Forward error correction (FEC)", settings.fec.get());
|
||||
vbrCheck.addActionListener(e -> pushEncoder.run());
|
||||
fecCheck.addActionListener(e -> pushEncoder.run());
|
||||
|
||||
complexitySlider = new JSlider(0, 10, settings.complexity);
|
||||
JLabel complexityLabel = new JLabel(String.valueOf(settings.complexity));
|
||||
complexitySlider = new JSlider(0, 10, settings.complexity.get());
|
||||
JLabel complexityLabel = new JLabel(String.valueOf(settings.complexity.get()));
|
||||
complexitySlider.addChangeListener(e -> {
|
||||
complexityLabel.setText(String.valueOf(complexitySlider.getValue()));
|
||||
pushEncoder.run();
|
||||
});
|
||||
|
||||
musicCheck = new JCheckBox("Music codec (stereo, higher fidelity)", settings.music);
|
||||
musicCheck = new JCheckBox("Music codec (stereo, higher fidelity)", settings.music.get());
|
||||
musicCheck.setToolTipText("<html>Transmits <b>OPUS_MUSIC</b>: stereo when the capture "
|
||||
+ "device has two channels, and without the voice pre-processing "
|
||||
+ "(noise removal, typing attenuation, AGC).<br>"
|
||||
+ "Voice mode (<b>OPUS_VOICE</b>) is mono, as in the official client.</html>");
|
||||
musicCheck.addActionListener(e -> pushEncoder.run());
|
||||
|
||||
delaySlider = choiceSlider(Settings.REDUNDANCY_DELAYS, settings.redundancyDelay);
|
||||
delaySlider = choiceSlider(Settings.REDUNDANCY_DELAYS, settings.redundancyDelay.get());
|
||||
JLabel delayLabel = new JLabel(delayLabel(selectedDelay()));
|
||||
int copies = Math.max(1, Math.min(Settings.MAX_REDUNDANCY_COPIES, settings.redundancyCopies));
|
||||
int copies = Math.max(1, Math.min(Settings.MAX_REDUNDANCY_COPIES, settings.redundancyCopies.get()));
|
||||
copiesSlider = new JSlider(1, Settings.MAX_REDUNDANCY_COPIES, copies);
|
||||
copiesSlider.setMajorTickSpacing(1);
|
||||
copiesSlider.setPaintTicks(true);
|
||||
@@ -84,7 +84,7 @@ final class NetworkPanel extends FormPanel {
|
||||
pushRedundancy();
|
||||
});
|
||||
|
||||
receiveBufferSlider = choiceSlider(Settings.RECEIVE_BUFFERS, settings.receiveBuffer);
|
||||
receiveBufferSlider = choiceSlider(Settings.RECEIVE_BUFFERS, settings.receiveBuffer.get());
|
||||
JLabel receiveBufferLabel = new JLabel(delayLabel(selectedReceiveBuffer()));
|
||||
receiveBufferSlider.addChangeListener(e -> receiveBufferLabel.setText(delayLabel(selectedReceiveBuffer())));
|
||||
|
||||
@@ -138,13 +138,13 @@ final class NetworkPanel extends FormPanel {
|
||||
|
||||
/** Copies the page into {@code target}, without touching anything else. */
|
||||
void writeInto(Settings target) {
|
||||
target.bitrate = bitrateSlider.getValue() * 1000;
|
||||
target.vbr = vbrCheck.isSelected();
|
||||
target.fec = fecCheck.isSelected();
|
||||
target.complexity = complexitySlider.getValue();
|
||||
target.music = musicCheck.isSelected();
|
||||
target.redundancyDelay = selectedDelay();
|
||||
target.redundancyCopies = copiesSlider.getValue();
|
||||
target.receiveBuffer = selectedReceiveBuffer();
|
||||
target.bitrate.set(bitrateSlider.getValue() * 1000);
|
||||
target.vbr.set(vbrCheck.isSelected());
|
||||
target.fec.set(fecCheck.isSelected());
|
||||
target.complexity.set(complexitySlider.getValue());
|
||||
target.music.set(musicCheck.isSelected());
|
||||
target.redundancyDelay.set(selectedDelay());
|
||||
target.redundancyCopies.set(copiesSlider.getValue());
|
||||
target.receiveBuffer.set(selectedReceiveBuffer());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,10 +88,10 @@ final class NotificationsPanel extends JPanel {
|
||||
this.settings = settings;
|
||||
this.sounds = sounds;
|
||||
this.working = settings.notifications.copy();
|
||||
this.originalPackId = settings.soundPack;
|
||||
this.originalPackDir = settings.soundPackDir;
|
||||
this.volume = new JSlider(0, 100, (int) Math.round(settings.soundVolume * 100));
|
||||
this.packDirField = new JTextField(settings.soundPackDir, 18);
|
||||
this.originalPackId = settings.soundPack.get();
|
||||
this.originalPackDir = settings.soundPackDir.get();
|
||||
this.volume = new JSlider(0, 100, (int) Math.round(settings.soundVolume.get() * 100));
|
||||
this.packDirField = new JTextField(settings.soundPackDir.get(), 18);
|
||||
|
||||
buildRows();
|
||||
this.table = buildTable();
|
||||
@@ -107,21 +107,21 @@ final class NotificationsPanel extends JPanel {
|
||||
/** Copies the edited state into the settings; the caller saves them. */
|
||||
void apply() {
|
||||
settings.notifications.copyFrom(working);
|
||||
settings.soundVolume = volume.getValue() / 100.0;
|
||||
settings.soundVolume.set(volume.getValue() / 100.0);
|
||||
String directory = packDirField.getText().trim();
|
||||
boolean rescan = !directory.equals(settings.soundPackDir);
|
||||
settings.soundPackDir = directory;
|
||||
settings.desktopNotifications = desktopNotifications.isSelected();
|
||||
boolean rescan = !directory.equals(settings.soundPackDir.get());
|
||||
settings.soundPackDir.set(directory);
|
||||
settings.desktopNotifications.set(desktopNotifications.isSelected());
|
||||
sounds.setPack((SoundPack) packCombo.getSelectedItem());
|
||||
if (rescan) sounds.reload();
|
||||
originalPackId = settings.soundPack;
|
||||
originalPackDir = settings.soundPackDir;
|
||||
originalPackId = settings.soundPack.get();
|
||||
originalPackDir = settings.soundPackDir.get();
|
||||
}
|
||||
|
||||
/** Puts back the pack (and folder) last applied, for a cancelled edit. */
|
||||
void revert() {
|
||||
settings.soundPackDir = originalPackDir;
|
||||
settings.soundPack = originalPackId;
|
||||
settings.soundPackDir.set(originalPackDir);
|
||||
settings.soundPack.set(originalPackId);
|
||||
sounds.reload();
|
||||
}
|
||||
|
||||
@@ -162,7 +162,7 @@ final class NotificationsPanel extends JPanel {
|
||||
packDirField.setToolTipText("Extra folder to look for sound packs in");
|
||||
addRow(p, c, row++, new JLabel("Extra pack folder:"), dirRow);
|
||||
|
||||
desktopNotifications.setSelected(settings.desktopNotifications);
|
||||
desktopNotifications.setSelected(settings.desktopNotifications.get());
|
||||
c.gridx = 0;
|
||||
c.gridy = row;
|
||||
c.gridwidth = 2;
|
||||
@@ -283,7 +283,7 @@ final class NotificationsPanel extends JPanel {
|
||||
if (!current.isEmpty()) chooser.setCurrentDirectory(new File(current));
|
||||
if (chooser.showOpenDialog(this) != JFileChooser.APPROVE_OPTION) return;
|
||||
packDirField.setText(chooser.getSelectedFile().getAbsolutePath());
|
||||
settings.soundPackDir = packDirField.getText();
|
||||
settings.soundPackDir.set(packDirField.getText());
|
||||
reloadPacks();
|
||||
}
|
||||
|
||||
|
||||
@@ -29,15 +29,17 @@ final class PlaybackPanel extends FormPanel {
|
||||
Consumer<String> onOutputDeviceChanged) {
|
||||
GridBagConstraints c = gbc();
|
||||
|
||||
outputCombo = AudioDevices.combo(io.outputDevices(), settings.outputDevice);
|
||||
outputCombo = AudioDevices.combo(io.outputDevices(), settings.outputDevice.get());
|
||||
limitWidth(outputCombo, FIELD_WIDTH);
|
||||
outputCombo.addActionListener(e -> onOutputDeviceChanged.accept(AudioDevices.selectedId(outputCombo)));
|
||||
|
||||
outputVol = new JSlider(0, 200, (int) Math.round(settings.outputVolume * 100));
|
||||
outputVol = new JSlider(0, 200, (int) Math.round(settings.outputVolume.get() * 100));
|
||||
JLabel volumeLabel = new JLabel(outputVol.getValue() + "%");
|
||||
outputVol.addChangeListener(e -> {
|
||||
volumeLabel.setText(outputVol.getValue() + "%");
|
||||
if (livePlayback != null) livePlayback.setMasterVolume(outputVol.getValue() / 100.0);
|
||||
if (livePlayback != null) {
|
||||
livePlayback.setMasterVolume(outputVol.getValue() / 100.0 * settings.masterVolume.get());
|
||||
}
|
||||
});
|
||||
|
||||
JButton testSound = new JButton("Play Test Sound");
|
||||
@@ -56,7 +58,7 @@ final class PlaybackPanel extends FormPanel {
|
||||
|
||||
/** Copies the form into {@code target}, without touching anything else. */
|
||||
void writeInto(Settings target) {
|
||||
target.outputDevice = AudioDevices.selectedId(outputCombo);
|
||||
target.outputVolume = outputVol.getValue() / 100.0;
|
||||
target.outputDevice.set(AudioDevices.selectedId(outputCombo));
|
||||
target.outputVolume.set(outputVol.getValue() / 100.0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ final class RecordingActions {
|
||||
if (chooser.showSaveDialog(owner) != JFileChooser.APPROVE_OPTION) return;
|
||||
File file = chooser.getSelectedFile();
|
||||
if (!file.getName().toLowerCase().endsWith(".ogg")) file = new File(file.getParentFile(), file.getName() + ".ogg");
|
||||
settings.recordingDir = file.getParentFile().getAbsolutePath();
|
||||
settings.recordingDir.set(file.getParentFile().getAbsolutePath());
|
||||
settings.save();
|
||||
session.startRecording(mode(multitrack), file.toPath());
|
||||
}
|
||||
|
||||
@@ -154,12 +154,11 @@ final class ServerTab {
|
||||
leftColumn = new JSplitPane(JSplitPane.VERTICAL_SPLIT, treePanel, infoPanel);
|
||||
leftColumn.setContinuousLayout(true);
|
||||
normalDividerSize = leftColumn.getDividerSize();
|
||||
SplitRatio.keep(leftColumn, () -> settings.infoSplitRatio, r -> settings.infoSplitRatio = r,
|
||||
infoPanel::isVisible);
|
||||
SplitRatio.keep(leftColumn, settings.infoSplitRatio, infoPanel::isVisible);
|
||||
|
||||
JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftColumn, chatPanel);
|
||||
split.setContinuousLayout(true);
|
||||
SplitRatio.keep(split, () -> settings.chatSplitRatio, r -> settings.chatSplitRatio = r, () -> true);
|
||||
SplitRatio.keep(split, settings.chatSplitRatio, () -> true);
|
||||
this.component = split;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ final class ServerTabConnectionEvents implements ServerSession.Listener {
|
||||
|
||||
@Override
|
||||
public void onOwnChat(ChatScope scope, int peerClientId, String peerName, String text) {
|
||||
String me = settings.nickname + " (you)";
|
||||
String me = settings.nickname.get() + " (you)";
|
||||
int myId = session.selfClientId();
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
switch (scope) {
|
||||
|
||||
@@ -84,7 +84,7 @@ final class ServerTreeCellRenderer extends DefaultTreeCellRenderer {
|
||||
|
||||
/** Friends and blocked clients stand out by colour, as in TeamSpeak, unless turned off. */
|
||||
private Color contactColor(Contact contact) {
|
||||
if (contact == null || !settings.colorContacts) return Theme.treeText();
|
||||
if (contact == null || !settings.colorContacts.get()) return Theme.treeText();
|
||||
switch (contact.type) {
|
||||
case FRIEND:
|
||||
return Theme.friend();
|
||||
|
||||
@@ -37,7 +37,6 @@ public final class SettingsDialog extends JDialog {
|
||||
private static int lastPage;
|
||||
|
||||
private final Settings settings;
|
||||
private final VoiceOutput livePlayback;
|
||||
private final Runnable onApply;
|
||||
|
||||
private final ApplicationPanel applicationPanel;
|
||||
@@ -56,7 +55,6 @@ public final class SettingsDialog extends JDialog {
|
||||
Runnable onApply) {
|
||||
super(owner, "Options", true);
|
||||
this.settings = settings;
|
||||
this.livePlayback = livePlayback;
|
||||
this.onApply = onApply;
|
||||
|
||||
applicationPanel = new ApplicationPanel(settings);
|
||||
@@ -184,10 +182,10 @@ public final class SettingsDialog extends JDialog {
|
||||
*/
|
||||
private Settings audioSnapshot() {
|
||||
Settings snapshot = new Settings();
|
||||
snapshot.packetLoss = settings.packetLoss;
|
||||
snapshot.packetLoss.set(settings.packetLoss.get());
|
||||
writeAudioSettings(snapshot);
|
||||
if (snapshot.inputMode == Settings.InputMode.PUSH_TO_TALK) {
|
||||
snapshot.inputMode = Settings.InputMode.VOICE_ACTIVATION;
|
||||
if (snapshot.inputMode.get() == Settings.InputMode.PUSH_TO_TALK) {
|
||||
snapshot.inputMode.set(Settings.InputMode.VOICE_ACTIVATION);
|
||||
}
|
||||
return snapshot;
|
||||
}
|
||||
@@ -203,10 +201,6 @@ public final class SettingsDialog extends JDialog {
|
||||
settings.save();
|
||||
|
||||
capturePanel.applyLive(m -> m.apply(settings));
|
||||
if (livePlayback != null) {
|
||||
livePlayback.setMasterVolume(settings.outputVolume);
|
||||
livePlayback.setOutputDevice(settings.outputDevice);
|
||||
}
|
||||
if (onApply != null) onApply.run();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package eu.lixko.ts3j.client.ui;
|
||||
|
||||
import eu.lixko.ts3j.client.config.Setting;
|
||||
|
||||
import javax.swing.JSplitPane;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.function.DoubleConsumer;
|
||||
import java.util.function.DoubleSupplier;
|
||||
|
||||
/**
|
||||
* Keeps a split pane's divider at the share of its span the user gave it: restores the saved
|
||||
@@ -15,8 +15,7 @@ import java.util.function.DoubleSupplier;
|
||||
final class SplitRatio {
|
||||
|
||||
private final JSplitPane split;
|
||||
private final DoubleSupplier saved;
|
||||
private final DoubleConsumer save;
|
||||
private final Setting<Double> saved;
|
||||
private final BooleanSupplier tracking;
|
||||
/** The span at the last divider move; another span means a layout moved it, not the user. */
|
||||
private int lastSpan;
|
||||
@@ -26,23 +25,22 @@ final class SplitRatio {
|
||||
* @param tracking whether the divider is the user's to place right now; while it is not
|
||||
* (a side collapsed, say), moves are neither saved nor corrected
|
||||
*/
|
||||
static void keep(JSplitPane split, DoubleSupplier saved, DoubleConsumer save, BooleanSupplier tracking) {
|
||||
new SplitRatio(split, saved, save, tracking);
|
||||
static void keep(JSplitPane split, Setting<Double> saved, BooleanSupplier tracking) {
|
||||
new SplitRatio(split, saved, tracking);
|
||||
}
|
||||
|
||||
private SplitRatio(JSplitPane split, DoubleSupplier saved, DoubleConsumer save, BooleanSupplier tracking) {
|
||||
private SplitRatio(JSplitPane split, Setting<Double> saved, BooleanSupplier tracking) {
|
||||
this.split = split;
|
||||
this.saved = saved;
|
||||
this.save = save;
|
||||
this.tracking = tracking;
|
||||
split.setResizeWeight(saved.getAsDouble());
|
||||
split.setResizeWeight(saved.get());
|
||||
split.addComponentListener(new ComponentAdapter() {
|
||||
@Override
|
||||
public void componentResized(ComponentEvent e) {
|
||||
if (restored || span() <= 0) return;
|
||||
restored = true;
|
||||
lastSpan = span();
|
||||
split.setDividerLocation(saved.getAsDouble());
|
||||
split.setDividerLocation(saved.get());
|
||||
}
|
||||
});
|
||||
split.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, e -> moved());
|
||||
@@ -57,7 +55,7 @@ final class SplitRatio {
|
||||
}
|
||||
double ratio = split.getDividerLocation() / (double) span;
|
||||
if (ratio <= 0.05 || ratio >= 0.98) return;
|
||||
save.accept(ratio);
|
||||
saved.set(ratio);
|
||||
// Space the pane gains or loses is shared out in the same proportion.
|
||||
split.setResizeWeight(ratio);
|
||||
}
|
||||
|
||||
+14
-14
@@ -74,7 +74,7 @@ final class VoiceActivationSection {
|
||||
group.add(pttRadio);
|
||||
group.add(contRadio);
|
||||
group.add(vadRadio);
|
||||
switch (settings.inputMode) {
|
||||
switch (settings.inputMode.get()) {
|
||||
case PUSH_TO_TALK:
|
||||
pttRadio.setSelected(true);
|
||||
break;
|
||||
@@ -89,25 +89,25 @@ final class VoiceActivationSection {
|
||||
pttKeyButton.setToolTipText("Push-to-talk is a global hotkey; this opens its binding");
|
||||
pttKeyButton.addActionListener(e -> editPushToTalkHotkey());
|
||||
|
||||
vadOverPttCheck = new JCheckBox("Add Voice Activity Detection", settings.vadOverPtt);
|
||||
vadOverPttCheck = new JCheckBox("Add Voice Activity Detection", settings.vadOverPtt.get());
|
||||
vadOverPttCheck.addActionListener(e ->
|
||||
micTest.configure(m -> m.setVadOverPtt(vadOverPttCheck.isSelected())));
|
||||
|
||||
vadModeCombo = new JComboBox<>(new String[]{"Automatic", "Volume Gate", "Hybrid"});
|
||||
vadModeCombo.setSelectedIndex(vadModeIndex(settings.vadMode));
|
||||
vadModeCombo.setSelectedIndex(vadModeIndex(settings.vadMode.get()));
|
||||
vadModeCombo.addActionListener(e -> micTest.configure(m -> m.setVadMode(currentVadMode())));
|
||||
vadModeCombo.setToolTipText("<html><b>Automatic</b>: intelligent speech detection.<br>"
|
||||
+ "<b>Volume Gate</b>: transmit when loud enough.<br>"
|
||||
+ "<b>Hybrid</b>: loud enough <i>and</i> detected as speech.</html>");
|
||||
|
||||
thresholdSlider = new JSlider((int) InputLevel.MIN_DB, (int) InputLevel.MAX_DB,
|
||||
(int) Math.round(settings.vadThresholdDb));
|
||||
thresholdLabel = new JLabel(Math.round(settings.vadThresholdDb) + " dB");
|
||||
speechSlider = new JSlider(0, 100, (int) Math.round(settings.speechThreshold * 100));
|
||||
speechLabel = new JLabel(Math.round(settings.speechThreshold * 100) + "%");
|
||||
(int) Math.round(settings.vadThresholdDb.get()));
|
||||
thresholdLabel = new JLabel(Math.round(settings.vadThresholdDb.get()) + " dB");
|
||||
speechSlider = new JSlider(0, 100, (int) Math.round(settings.speechThreshold.get() * 100));
|
||||
speechLabel = new JLabel(Math.round(settings.speechThreshold.get() * 100) + "%");
|
||||
|
||||
meter = new LevelMeter();
|
||||
meter.setThreshold(settings.vadThresholdDb);
|
||||
meter.setThreshold(settings.vadThresholdDb.get());
|
||||
testControls = buildTestControls();
|
||||
|
||||
thresholdSlider.addChangeListener(e -> {
|
||||
@@ -180,13 +180,13 @@ final class VoiceActivationSection {
|
||||
|
||||
/** Copies the form into {@code target}, without touching anything else. */
|
||||
void writeInto(Settings target) {
|
||||
target.inputMode = pttRadio.isSelected() ? Settings.InputMode.PUSH_TO_TALK
|
||||
target.inputMode.set(pttRadio.isSelected() ? Settings.InputMode.PUSH_TO_TALK
|
||||
: contRadio.isSelected() ? Settings.InputMode.CONTINUOUS
|
||||
: Settings.InputMode.VOICE_ACTIVATION;
|
||||
target.vadMode = currentVadMode();
|
||||
target.vadThresholdDb = thresholdSlider.getValue();
|
||||
target.speechThreshold = speechSlider.getValue() / 100.0;
|
||||
target.vadOverPtt = vadOverPttCheck.isSelected();
|
||||
: Settings.InputMode.VOICE_ACTIVATION);
|
||||
target.vadMode.set(currentVadMode());
|
||||
target.vadThresholdDb.set((double) thresholdSlider.getValue());
|
||||
target.speechThreshold.set(speechSlider.getValue() / 100.0);
|
||||
target.vadOverPtt.set(vadOverPttCheck.isSelected());
|
||||
}
|
||||
|
||||
/** Applies a change to the microphone test, if it is running. */
|
||||
|
||||
@@ -30,7 +30,8 @@ final class WindowGeometry {
|
||||
}
|
||||
|
||||
static void restore(JFrame frame, Settings settings, Dimension defaultSize) {
|
||||
Rectangle saved = new Rectangle(settings.windowX, settings.windowY, settings.windowWidth, settings.windowHeight);
|
||||
Rectangle saved = new Rectangle(settings.windowX.get(), settings.windowY.get(),
|
||||
settings.windowWidth.get(), settings.windowHeight.get());
|
||||
if (saved.width > 0 && saved.height > 0 && onScreen(saved)) {
|
||||
Dimension min = frame.getMinimumSize();
|
||||
saved.width = Math.max(saved.width, min.width);
|
||||
@@ -40,7 +41,7 @@ final class WindowGeometry {
|
||||
frame.setSize(UIScale.scale(defaultSize));
|
||||
frame.setLocationRelativeTo(null);
|
||||
}
|
||||
if (settings.windowMaximized) frame.setExtendedState(Frame.MAXIMIZED_BOTH);
|
||||
if (settings.windowMaximized.get()) frame.setExtendedState(Frame.MAXIMIZED_BOTH);
|
||||
track(frame, settings);
|
||||
}
|
||||
|
||||
@@ -48,13 +49,13 @@ final class WindowGeometry {
|
||||
Timer settle = new Timer(SETTLE_MS, e -> {
|
||||
int state = frame.getExtendedState();
|
||||
if ((state & Frame.ICONIFIED) != 0 || !frame.isShowing()) return;
|
||||
settings.windowMaximized = (state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH;
|
||||
settings.windowMaximized.set((state & Frame.MAXIMIZED_BOTH) == Frame.MAXIMIZED_BOTH);
|
||||
if (state != Frame.NORMAL) return;
|
||||
Rectangle r = frame.getBounds();
|
||||
settings.windowX = r.x;
|
||||
settings.windowY = r.y;
|
||||
settings.windowWidth = r.width;
|
||||
settings.windowHeight = r.height;
|
||||
settings.windowX.set(r.x);
|
||||
settings.windowY.set(r.y);
|
||||
settings.windowWidth.set(r.width);
|
||||
settings.windowHeight.set(r.height);
|
||||
});
|
||||
settle.setRepeats(false);
|
||||
frame.addComponentListener(new ComponentAdapter() {
|
||||
|
||||
Reference in New Issue
Block a user