A sidebar of pages with large icons replaces the tabs, and each page opens under a banner with its title, subtitle and icon. OK, Cancel and Apply sit below, and the dialog reopens on the last page used. The pages follow TS3's: Application (muted-microphone warning, reported client version), myTeamSpeak, Playback, Capture, Design, Hotkeys, Contacts, Chat and Notifications. Capture now holds everything from the microphone to the server: the device and gain, activation with the microphone test, signal processing and the encoder, laid out in one grid so its columns line up. Forms are grouped under section headings. Cancel now goes back to what was last applied, and closing the window cancels too, so a theme or icon pack being tried out is put back. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
89 lines
3.4 KiB
Java
89 lines
3.4 KiB
Java
package com.ts3client.ui;
|
|
|
|
import com.formdev.flatlaf.util.UIScale;
|
|
import com.ts3client.config.AppDirs;
|
|
import com.ts3client.config.Settings;
|
|
|
|
import javax.swing.JButton;
|
|
import javax.swing.JCheckBox;
|
|
import javax.swing.JFileChooser;
|
|
import javax.swing.JLabel;
|
|
import javax.swing.JPanel;
|
|
import javax.swing.JTextField;
|
|
import java.awt.BorderLayout;
|
|
import java.awt.GridBagConstraints;
|
|
import java.io.File;
|
|
|
|
/**
|
|
* Options page for chat logs: whether they are kept, and where. By default they go into the
|
|
* TeamSpeak 3 client's own folder, so both clients show the same history.
|
|
*/
|
|
final class ChatLogsPanel extends FormPanel {
|
|
|
|
private final Settings settings;
|
|
private final JCheckBox enabled = new JCheckBox("Keep chat logs");
|
|
private final JTextField folder = new JTextField(18);
|
|
private final JButton browse = new JButton("Browse…");
|
|
private final JCheckBox pictures = new JCheckBox("Show pictures in descriptions");
|
|
|
|
ChatLogsPanel(Settings settings) {
|
|
this.settings = settings;
|
|
GridBagConstraints c = gbc();
|
|
|
|
enabled.setSelected(settings.chatLogs);
|
|
enabled.setToolTipText("Write every chat to disk and show its history when it opens again");
|
|
enabled.addActionListener(e -> updateEnabled());
|
|
|
|
folder.setText(settings.chatLogDir);
|
|
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>");
|
|
limitWidth(folder, FIELD_WIDTH);
|
|
browse.addActionListener(e -> browseForFolder());
|
|
JPanel folderRow = new JPanel(new BorderLayout(UIScale.scale(6), 0));
|
|
folderRow.add(folder, BorderLayout.CENTER);
|
|
folderRow.add(browse, BorderLayout.EAST);
|
|
|
|
JLabel nextConnect = new JLabel("Takes effect on the next connect.");
|
|
nextConnect.setEnabled(false);
|
|
|
|
pictures.setSelected(settings.descriptionPictures);
|
|
pictures.setToolTipText("Off: only links to them, nothing fetched");
|
|
|
|
int row = 0;
|
|
addSection(this, c, row++, "Logging");
|
|
addWide(this, c, row++, enabled);
|
|
addRow(this, c, row++, new JLabel("Folder:"), folderRow);
|
|
c.gridx = 1;
|
|
c.gridy = row++;
|
|
add(nextConnect, c);
|
|
addSection(this, c, row++, "Descriptions");
|
|
addWide(this, c, row++, pictures);
|
|
addFiller(this, c, row);
|
|
updateEnabled();
|
|
}
|
|
|
|
private void updateEnabled() {
|
|
folder.setEnabled(enabled.isSelected());
|
|
browse.setEnabled(enabled.isSelected());
|
|
}
|
|
|
|
private void browseForFolder() {
|
|
JFileChooser chooser = new JFileChooser();
|
|
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
|
chooser.setDialogTitle("Folder for chat logs");
|
|
String current = folder.getText().trim();
|
|
chooser.setCurrentDirectory(current.isEmpty() ? AppDirs.chatLogs().toFile() : new File(current));
|
|
if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) {
|
|
folder.setText(chooser.getSelectedFile().getAbsolutePath());
|
|
}
|
|
}
|
|
|
|
/** 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();
|
|
}
|
|
}
|