Let chat logs be turned off or kept elsewhere
Chat logs always went into the TeamSpeak 3 client's own folder. A new Chat page in Options can turn them off, or point them at another folder; left empty, they are still shared with the TeamSpeak 3 client. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
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…");
|
||||
|
||||
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());
|
||||
c.gridx = 0;
|
||||
c.gridy = 0;
|
||||
c.gridwidth = 2;
|
||||
add(enabled, c);
|
||||
|
||||
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 row = new JPanel(new BorderLayout(UIScale.scale(6), 0));
|
||||
row.add(folder, BorderLayout.CENTER);
|
||||
row.add(browse, BorderLayout.EAST);
|
||||
addRow(this, c, 1, new JLabel("Folder:"), row);
|
||||
|
||||
c.gridy = 2;
|
||||
c.gridx = 1;
|
||||
c.weighty = 1;
|
||||
c.anchor = GridBagConstraints.NORTHWEST;
|
||||
add(new JLabel("Takes effect on the next connect."), c);
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user