diff --git a/ts3-client/AUDIT-STRUCTURE.md b/ts3-client/AUDIT-STRUCTURE.md index 687bfe8..ca7acca 100644 --- a/ts3-client/AUDIT-STRUCTURE.md +++ b/ts3-client/AUDIT-STRUCTURE.md @@ -16,8 +16,8 @@ Items are worked through in the order below. Status: open, done (commit), or clo | 4b | … request plumbing into its own class; `*Admin` helpers on narrow dependencies instead of the whole connection | done (`da908f7`; renamed `Uplink` in 4c, as `session.ServerLink` is the `ts3server://` link): `ServerLink` owns the socket, event and request threads and file transfers, and runs requests; the helpers take it (plus the model, permissions or avatars where they need them) | | 4c | … frontends reach the admin helpers directly instead of ~40 one-line forwarders | done (`959f7ed`): the helpers are public with non-blocking methods, reached through `ServerSession`/`TeamspeakConnection` getters; 30 forwarders gone, and what they added (stop-at-first-refusal loops, log lines, description refresh, own avatar flag) moved into the helpers. Swing dialogs still take the whole connection for the model and our ids (item 5) | | 4d | … our own state (mic, speakers, away, talk request, recording) out of the connection | done (`9107bdd`): `OwnClient` owns the devices and our flags, and publishes them; `Recording` the recorder. `ServerSession` no longer keeps its own copy of the flags, and they are cleared when a connect starts rather than once it is done | -| 5 | Two front doors: frontends use both `ServerSession` and `session.connection()` with no rule for which | done (uncommitted): `connection()` is gone; frontends reach the model, our ids, devices and the helpers through `ServerSession`. New helpers took the remaining actions off the connection: `ClientAdmin` (move, kick, ban, groups, talk power, poke, details), `ChannelFiles`, `ClientContacts`; `ChannelAdmin` also joins, moves and subscribes. Dialogs take the session, or only the helper they use | -| 6 | Menu bar, toolbar and hotkeys each implement the same commands: `MainMenuBar.Listener` (~50 methods, ~210 lines of forwarding in `MainFrame`), `MainToolbar.Listener`, `HotkeyActions` | open | +| 5 | Two front doors: frontends use both `ServerSession` and `session.connection()` with no rule for which | done (`de42429`): `connection()` is gone; frontends reach the model, our ids, devices and the helpers through `ServerSession`. New helpers took the remaining actions off the connection: `ClientAdmin` (move, kick, ban, groups, talk power, poke, details), `ChannelFiles`, `ClientContacts`; `ChannelAdmin` also joins, moves and subscribes. Dialogs take the session, or only the helper they use | +| 6 | Menu bar, toolbar and hotkeys each implement the same commands: `MainMenuBar.Listener` (~50 methods, ~210 lines of forwarding in `MainFrame`), `MainToolbar.Listener`, `HotkeyActions` | done (uncommitted): `MainCommands` holds each command once, acting on the server on screen or, for hotkeys, on a list of sessions; the menu, toolbar and hotkeys call it directly and both `Listener` interfaces are gone. The menu's mute items no longer click the toolbar's buttons, and the menu's commander toggle now repaints the toolbar and tray | | 7 | The admin list dialogs (bans, complaints, offline messages, privilege keys, server log) repeat the load/status/table-model scaffolding | open | | 8 | `Settings`: 58 public fields, each key spelled twice (load and save), no change notification, so callers fan changes out by hand | open | | 9 | Duplicates: three byte-size formatters (`FileBrowserDialog`, `ChatHtml`, `ConnectionStatsFormat`); four "which chat" enums (`ChatScope`, `ChatLogScope`, `ChatPanel.Target`, Android `ChatKey`); the conversation model lives in each frontend | open | diff --git a/ts3-client/README.md b/ts3-client/README.md index c452326..1a9a600 100644 --- a/ts3-client/README.md +++ b/ts3-client/README.md @@ -296,6 +296,7 @@ swing/ eu.lixko.ts3j.client ├── Main entry point (look & feel, settings, backend injection) └── ui ├── MainFrame window: menu, toolbar, tree | chat, status bar + ├── MainCommands what the menu, toolbar and hotkeys do, each command once ├── ServerTreePanel TS3-style channel/client tree (group badges, spacers) ├── Spacers TS3 spacer-channel name parsing/rendering ├── InfoPanel channel description / client group + details view @@ -304,7 +305,7 @@ swing/ eu.lixko.ts3j.client ├── HotkeysPanel hotkey list (Options → Hotkeys) ├── HotkeyDialog add/edit one hotkey: action, combination, trigger, scope ├── HotkeyService bindings + engine + input hook, for the dialogs - ├── HotkeyActions carries a fired hotkey out on the client + ├── HotkeyActions maps a fired hotkey to its command ├── NotificationsPanel sound pack + per-action sound/important configuration ├── IconPackPanel icon pack chooser + icon viewer (Options → Design) ├── DisplayScale interface scale on Linux (fractional, via FlatLaf) diff --git a/ts3-client/swing/src/main/java/eu/lixko/ts3j/client/ui/HotkeyActions.java b/ts3-client/swing/src/main/java/eu/lixko/ts3j/client/ui/HotkeyActions.java index ff3a8f1..a561174 100644 --- a/ts3-client/swing/src/main/java/eu/lixko/ts3j/client/ui/HotkeyActions.java +++ b/ts3-client/swing/src/main/java/eu/lixko/ts3j/client/ui/HotkeyActions.java @@ -2,9 +2,11 @@ package eu.lixko.ts3j.client.ui; import eu.lixko.ts3j.client.hotkey.Hotkey; import eu.lixko.ts3j.client.hotkey.HotkeyEngine; +import eu.lixko.ts3j.client.session.ServerSession; import javax.swing.SwingUtilities; import java.util.List; +import java.util.function.Predicate; /** * Carries a fired hotkey out on the client. @@ -19,11 +21,13 @@ final class HotkeyActions implements HotkeyEngine.Handler { private static final double VOLUME_STEP = 0.05; private final MainFrame frame; + private final MainCommands commands; /** Latched push-to-talk, driven by the "Toggle Push-to-Talk" action. */ private boolean pttLatched; - HotkeyActions(MainFrame frame) { + HotkeyActions(MainFrame frame, MainCommands commands) { this.frame = frame; + this.commands = commands; } @Override @@ -32,39 +36,34 @@ final class HotkeyActions implements HotkeyEngine.Handler { } private void perform(Hotkey hotkey, boolean active) { - List targets = frame.hotkeyTargets(hotkey.activeServerOnly); + List targets = commands.targets(hotkey.activeServerOnly); switch (hotkey.action) { - case CONNECT_CURRENT_TAB -> frame.connectBookmark(hotkey.argument, false); - case CONNECT_NEW_TAB -> frame.connectBookmark(hotkey.argument, true); - case DISCONNECT_CURRENT -> { - ServerTab tab = frame.selectedTab(); - if (tab != null) tab.session().disconnect(); - } - case DISCONNECT_ALL -> { - for (ServerTab tab : frame.allTabs()) tab.session().disconnect(); - } + case CONNECT_CURRENT_TAB -> commands.connectBookmark(hotkey.argument, false); + case CONNECT_NEW_TAB -> commands.connectBookmark(hotkey.argument, true); + case DISCONNECT_CURRENT -> commands.disconnect(); + case DISCONNECT_ALL -> commands.disconnectAll(); - case MIC_ACTIVATE -> frame.moveMicrophoneToSelectedTab(); - case MIC_MUTE -> setMicMuted(targets, true); - case MIC_UNMUTE -> setMicMuted(targets, false); - case MIC_TOGGLE -> setMicMuted(targets, !anyMicMuted(targets)); + case MIC_ACTIVATE -> commands.activate(); + case MIC_MUTE -> commands.setMicMuted(targets, true); + case MIC_UNMUTE -> commands.setMicMuted(targets, false); + case MIC_TOGGLE -> commands.setMicMuted(targets, !any(targets, ServerSession::isMicMuted)); - case MIC_LOCAL_MUTE -> setMicLocalMuted(targets, true); - case MIC_LOCAL_UNMUTE -> setMicLocalMuted(targets, false); - case MIC_LOCAL_TOGGLE -> setMicLocalMuted(targets, !anyMicLocalMuted(targets)); + case MIC_LOCAL_MUTE -> commands.setMicLocalMuted(targets, true); + case MIC_LOCAL_UNMUTE -> commands.setMicLocalMuted(targets, false); + case MIC_LOCAL_TOGGLE -> commands.setMicLocalMuted(targets, !any(targets, ServerSession::isMicLocalMuted)); - case SPEAKER_MUTE -> setDeafened(targets, true); - case SPEAKER_UNMUTE -> setDeafened(targets, false); - case SPEAKER_TOGGLE -> setDeafened(targets, !anyDeafened(targets)); + case SPEAKER_MUTE -> commands.setDeafened(targets, true); + case SPEAKER_UNMUTE -> commands.setDeafened(targets, false); + case SPEAKER_TOGGLE -> commands.setDeafened(targets, !any(targets, ServerSession::isDeafened)); - case AWAY_SET -> setAway(targets, true, ""); - case AWAY_ONLINE -> setAway(targets, false, ""); - case AWAY_TOGGLE -> setAway(targets, !anyAway(targets), ""); - case AWAY_TOGGLE_WITH_MESSAGE -> setAway(targets, !anyAway(targets), hotkey.argument); + case AWAY_SET -> commands.setAway(targets, true, ""); + case AWAY_ONLINE -> commands.setAway(targets, false, ""); + case AWAY_TOGGLE -> commands.setAway(targets, !any(targets, ServerSession::isAway), ""); + case AWAY_TOGGLE_WITH_MESSAGE -> commands.setAway(targets, !any(targets, ServerSession::isAway), hotkey.argument); - case COMMANDER_ACTIVATE -> setCommander(targets, true); - case COMMANDER_DEACTIVATE -> setCommander(targets, false); - case COMMANDER_TOGGLE -> setCommander(targets, !anyCommander(targets)); + case COMMANDER_ACTIVATE -> commands.setCommander(targets, true); + case COMMANDER_DEACTIVATE -> commands.setCommander(targets, false); + case COMMANDER_TOGGLE -> commands.setCommander(targets, !any(targets, ServerSession::isCommander)); // Momentary: the engine reports the release too, so the key simply holds it open. case PTT_ACTIVATE -> frame.setPushToTalk(active || pttLatched); @@ -77,9 +76,7 @@ final class HotkeyActions implements HotkeyEngine.Handler { frame.setPushToTalk(pttLatched); } - case CHANNEL_SWITCH -> { - for (ServerTab tab : targets) tab.session().joinChannelPath(hotkey.argument); - } + case CHANNEL_SWITCH -> commands.joinChannel(targets, hotkey.argument); case SERVER_TAB_SELECT -> frame.selectTabNumber(parseIndex(hotkey.argument)); case SERVER_TAB_NEXT -> frame.stepTab(1); case SERVER_TAB_PREVIOUS -> frame.stepTab(-1); @@ -91,19 +88,22 @@ final class HotkeyActions implements HotkeyEngine.Handler { case VOLUME_INCREASE -> frame.adjustMasterVolume(VOLUME_STEP); case VOLUME_DECREASE -> frame.adjustMasterVolume(-VOLUME_STEP); - case NICKNAME_CHANGE -> frame.changeNickname(hotkey.argument); - - case RECORDING_START -> startRecording(targets, false); - case RECORDING_START_MULTITRACK -> startRecording(targets, true); - case RECORDING_STOP -> { - for (ServerTab tab : targets) tab.session().stopRecording(); + // Without a nickname to use, it asks for one. + case NICKNAME_CHANGE -> { + if (hotkey.argument == null || hotkey.argument.isBlank()) commands.changeNickname(); + else commands.changeNickname(hotkey.argument); } - case TALK_POWER_REQUEST -> toggleTalkRequest(targets); - case TALK_POWER_GRANT_NEXT -> grantNextTalkPower(targets, false); - case TALK_POWER_REVOKE_ALL_GRANT_NEXT -> grantNextTalkPower(targets, true); + case RECORDING_START -> commands.startRecording(targets, false); + case RECORDING_START_MULTITRACK -> commands.startRecording(targets, true); + case RECORDING_STOP -> commands.stopRecording(targets); - case FILEBROWSER -> frame.browseCurrentChannel(); + // Asks without a reason, as there is nobody to type one. + case TALK_POWER_REQUEST -> commands.toggleTalkRequest(targets); + case TALK_POWER_GRANT_NEXT -> commands.grantNextTalkPower(targets, false); + case TALK_POWER_REVOKE_ALL_GRANT_NEXT -> commands.grantNextTalkPower(targets, true); + + case FILEBROWSER -> commands.browseCurrentChannel(); case SKIN_RELOAD -> frame.reloadSkin(); case BRING_TO_FRONT -> frame.bringToFront(); case SEND_TO_BACK -> frame.sendToBack(); @@ -114,66 +114,8 @@ final class HotkeyActions implements HotkeyEngine.Handler { } } - private void startRecording(List targets, boolean multitrack) { - for (ServerTab tab : targets) frame.recordings().startNow(tab.session(), multitrack); - } - - private void setMicMuted(List targets, boolean muted) { - for (ServerTab tab : targets) tab.session().setMicMuted(muted); - frame.refreshAfterHotkey(); - } - - private void setMicLocalMuted(List targets, boolean muted) { - for (ServerTab tab : targets) tab.session().setMicLocalMuted(muted); - frame.refreshAfterHotkey(); - } - - private void setDeafened(List targets, boolean deaf) { - for (ServerTab tab : targets) tab.session().setDeafened(deaf); - frame.refreshAfterHotkey(); - } - - private void setAway(List targets, boolean away, String message) { - for (ServerTab tab : targets) tab.session().setAway(away, message == null ? "" : message); - frame.refreshAfterHotkey(); - } - - private void setCommander(List targets, boolean commander) { - for (ServerTab tab : targets) tab.session().setCommander(commander); - frame.refreshAfterHotkey(); - } - - /** Asks without a reason, as there is nobody to type one. */ - private void toggleTalkRequest(List targets) { - boolean requested = targets.stream().anyMatch(t -> t.session().isTalkRequested()); - for (ServerTab tab : targets) { - if (requested) tab.session().cancelTalkRequest(); - else tab.session().requestTalkPower(""); - } - } - - private void grantNextTalkPower(List targets, boolean revokeOthers) { - for (ServerTab tab : targets) tab.session().grantNextTalkPower(revokeOthers); - } - - private static boolean anyMicMuted(List tabs) { - return tabs.stream().anyMatch(t -> t.session().isMicMuted()); - } - - private static boolean anyMicLocalMuted(List tabs) { - return tabs.stream().anyMatch(t -> t.session().isMicLocalMuted()); - } - - private static boolean anyDeafened(List tabs) { - return tabs.stream().anyMatch(t -> t.session().isDeafened()); - } - - private static boolean anyAway(List tabs) { - return tabs.stream().anyMatch(t -> t.session().isAway()); - } - - private static boolean anyCommander(List tabs) { - return tabs.stream().anyMatch(t -> t.session().isCommander()); + private static boolean any(List sessions, Predicate state) { + return sessions.stream().anyMatch(state); } /** @return the 1-based tab number in the argument, or 1 when it is not a number */ diff --git a/ts3-client/swing/src/main/java/eu/lixko/ts3j/client/ui/MainCommands.java b/ts3-client/swing/src/main/java/eu/lixko/ts3j/client/ui/MainCommands.java new file mode 100644 index 0000000..97b6249 --- /dev/null +++ b/ts3-client/swing/src/main/java/eu/lixko/ts3j/client/ui/MainCommands.java @@ -0,0 +1,427 @@ +package eu.lixko.ts3j.client.ui; + +import com.formdev.flatlaf.util.UIScale; +import eu.lixko.ts3j.client.config.AwayMessages; +import eu.lixko.ts3j.client.config.BanReasonPresets; +import eu.lixko.ts3j.client.config.Bookmark; +import eu.lixko.ts3j.client.config.Bookmarks; +import eu.lixko.ts3j.client.config.IdentityStore; +import eu.lixko.ts3j.client.config.Settings; +import eu.lixko.ts3j.client.net.ChannelNode; +import eu.lixko.ts3j.client.session.ServerSession; +import eu.lixko.ts3j.client.session.Sessions; + +import javax.swing.JCheckBox; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JLabel; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.JTextField; +import java.awt.GridLayout; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; + +/** + * What the menu bar, the toolbar and the hotkeys can do, each command in one place. + * + *

Plain commands act on the server on screen; the ones taking a list of sessions are + * for hotkeys, which reach the selected server or every connected one. Commands that + * change our own state repaint the window's chrome afterwards. + */ +final class MainCommands { + + private final MainFrame frame; + private final Settings settings; + private final Sessions sessions; + private final Bookmarks bookmarks; + private final AwayMessages awayMessages; + private final IdentityStore identities; + private final RecordingActions recordings; + private BanReasonPresets banReasonPresets; + + MainCommands(MainFrame frame, Settings settings, Sessions sessions, Bookmarks bookmarks, + AwayMessages awayMessages, IdentityStore identities) { + this.frame = frame; + this.settings = settings; + this.sessions = sessions; + this.bookmarks = bookmarks; + this.awayMessages = awayMessages; + this.identities = identities; + this.recordings = new RecordingActions(frame, settings); + } + + /** The server on screen, or {@code null} while no tab is selected. */ + ServerSession current() { + ServerTab tab = frame.selectedTab(); + return tab == null ? null : tab.session(); + } + + /** The server on screen while it is connected, else none. */ + List currentConnected() { + return targets(true); + } + + /** + * Which connections a command reaches: only the server on screen, or every connected + * one. Either way only connected servers. + */ + List targets(boolean currentOnly) { + List out = new ArrayList<>(); + if (currentOnly) { + ServerSession current = current(); + if (current != null && current.isConnected()) out.add(current); + return out; + } + for (ServerTab tab : frame.allTabs()) { + if (tab.session().isConnected()) out.add(tab.session()); + } + return out; + } + + // ---- connections ---- + + void connect() { + frame.showConnectDialog(); + } + + /** @param newTab open the server in a new tab instead of replacing the current one */ + void connect(Bookmark bookmark, boolean newTab) { + frame.connectBookmark(bookmark, newTab); + } + + /** Connects to the bookmark with this label; no label means the first one. */ + void connectBookmark(String label, boolean newTab) { + for (Bookmark b : bookmarks.all()) { + if (label == null || label.isBlank() || label.equalsIgnoreCase(b.label)) { + connect(b, newTab); + return; + } + } + } + + void disconnect() { + ServerSession current = current(); + if (current != null) current.disconnect(); + } + + void disconnectAll() { + for (ServerTab tab : frame.allTabs()) tab.session().disconnect(); + } + + void closeTab() { + frame.closeTab(frame.selectedTab()); + } + + void quit() { + frame.quit(); + } + + // ---- bookmarks ---- + + void addCurrentServerBookmark() { + ServerSession current = current(); + if (current == null || !current.isConnected()) { + JOptionPane.showMessageDialog(frame, "Connect to a server first.", + "Add bookmark", JOptionPane.INFORMATION_MESSAGE); + return; + } + String channelPath = current.currentChannelPath(); + + JTextField labelField = new JTextField(current.title()); + JCheckBox joinChannel = new JCheckBox("Join \"" + channelPath + "\" on connect", !channelPath.isEmpty()); + JPanel form = new JPanel(new GridLayout(0, 1, 0, UIScale.scale(2))); + form.add(new JLabel("Bookmark label:")); + form.add(labelField); + if (!channelPath.isEmpty()) form.add(joinChannel); + if (JOptionPane.showConfirmDialog(frame, form, "Add bookmark", + JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE) != JOptionPane.OK_OPTION) { + return; + } + Bookmark bookmark = current.toBookmark(joinChannel.isSelected() ? channelPath : ""); + bookmark.label = labelField.getText().trim(); + bookmarks.add(bookmark); + bookmarks.save(); + frame.bookmarksChanged(); + } + + void manageBookmarks() { + new BookmarksDialog(frame, bookmarks, identities, settings, sessions, + b -> connect(b, false), frame::bookmarksChanged).setVisible(true); + } + + // ---- microphone and speakers ---- + + /** Moves the microphone to the server on screen. */ + void activate() { + ServerSession current = current(); + if (current != null && current.isConnected()) sessions.giveMicrophoneTo(current); + frame.refreshChrome(); + } + + void toggleMicMuted() { + ServerSession current = current(); + if (current != null) setMicMuted(currentConnected(), !current.isMicMuted()); + } + + void setMicMuted(List targets, boolean muted) { + forEach(targets, s -> s.setMicMuted(muted)); + } + + void setMicLocalMuted(List targets, boolean muted) { + forEach(targets, s -> s.setMicLocalMuted(muted)); + } + + void toggleDeafened() { + ServerSession current = current(); + if (current != null) setDeafened(currentConnected(), !current.isDeafened()); + } + + void setDeafened(List targets, boolean deaf) { + forEach(targets, s -> s.setDeafened(deaf)); + } + + // ---- away ---- + + /** The plain toggle carries no message; "Set away status…" is where messages are chosen. */ + void setAway(boolean away) { + setAway(currentConnected(), away, ""); + } + + void setAway(List targets, boolean away, String message) { + forEach(targets, s -> s.setAway(away, message == null ? "" : message)); + } + + /** Asks for an away message for the server on screen only. */ + void setAwayStatus() { + ServerSession current = current(); + if (current == null) return; + String message = askAwayMessage(current.awayMessage()); + if (message != null) setAway(currentConnected(), true, message); + } + + private void setAwayEverywhere(boolean away, String message) { + sessions.setAwayEverywhere(away, message); + frame.refreshChrome(); + } + + /** The away button's drop-down: the global actions, the presets and their editor. */ + JPopupMenu buildAwayMenu() { + JPopupMenu menu = new JPopupMenu(); + boolean anyConnected = sessions.anyConnected(); + + JCheckBoxMenuItem globally = new JCheckBoxMenuItem("Set Globally Away", Icons.of("AWAY"), + sessions.isAwayEverywhere()); + globally.setEnabled(anyConnected); + globally.addActionListener(e -> setAwayEverywhere(globally.isSelected(), null)); + + JMenuItem globalStatus = new JMenuItem("Set Globally Away Status…", Icons.of("EDIT")); + globalStatus.setEnabled(anyConnected); + globalStatus.addActionListener(e -> { + String message = askAwayMessage(sessions.awayMessage(current())); + if (message != null) setAwayEverywhere(true, message); + }); + + menu.add(globally); + menu.add(globalStatus); + menu.addSeparator(); + + for (String preset : awayMessages.all()) { + JMenuItem item = new JMenuItem(preset); + item.setEnabled(anyConnected); + item.addActionListener(e -> setAwayEverywhere(true, preset)); + menu.add(item); + } + if (!awayMessages.all().isEmpty()) menu.addSeparator(); + + JMenuItem manage = new JMenuItem("Manage away messages…", Icons.of("EDIT")); + manage.addActionListener(e -> new AwayMessagesDialog(frame, awayMessages, null).setVisible(true)); + menu.add(manage); + return menu; + } + + /** @return the entered message (possibly empty), or null when cancelled */ + private String askAwayMessage(String initial) { + return (String) JOptionPane.showInputDialog(frame, "Away message (optional):", "Away status", + JOptionPane.PLAIN_MESSAGE, Icons.of("AWAY"), null, initial); + } + + // ---- ourselves ---- + + void setCommander(boolean commander) { + setCommander(currentConnected(), commander); + } + + void setCommander(List targets, boolean commander) { + forEach(targets, s -> s.setCommander(commander)); + } + + /** Asks for a new nickname, used on every server. */ + void changeNickname() { + String nickname = JOptionPane.showInputDialog(frame, "New nickname:", settings.nickname); + 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.save(); + sessions.setNickname(settings.nickname); + } + + void joinChannel(List targets, String path) { + for (ServerSession s : targets) s.joinChannelPath(path); + } + + void setPhoneticNickname() { + ServerSession current = current(); + if (current == null) return; + String phonetic = (String) JOptionPane.showInputDialog(frame, "Phonetic nickname:", "Set Phonetic Nickname", + JOptionPane.PLAIN_MESSAGE, Icons.of("PHONETICSNICKNAME"), null, current.phoneticNickname()); + if (phonetic != null) current.setPhoneticNickname(phonetic.trim()); + } + + void setAvatar() { + ServerTab tab = frame.selectedTab(); + if (tab != null) tab.avatar().choose(); + } + + void deleteAvatar() { + ServerTab tab = frame.selectedTab(); + if (tab != null) tab.avatar().delete(); + } + + // ---- talk power ---- + + /** Asks for a reason and requests talk power, or withdraws the pending request. */ + void requestTalkPower() { + ServerSession current = current(); + if (current == null) return; + if (current.isTalkRequested()) { + current.cancelTalkRequest(); + return; + } + String message = (String) JOptionPane.showInputDialog(frame, "Reason:", "Request Talk Power", + JOptionPane.PLAIN_MESSAGE, Icons.of("TALK_POWER_REQUEST"), null, ""); + if (message != null) current.requestTalkPower(message.trim()); + } + + /** Requests talk power without a reason, or withdraws pending requests. */ + void toggleTalkRequest(List targets) { + boolean requested = targets.stream().anyMatch(ServerSession::isTalkRequested); + for (ServerSession s : targets) { + if (requested) s.cancelTalkRequest(); + else s.requestTalkPower(""); + } + } + + void grantNextTalkPower(List targets, boolean revokeOthers) { + for (ServerSession s : targets) s.grantNextTalkPower(revokeOthers); + } + + // ---- recording ---- + + /** Asks where to save, then records the server on screen. */ + void startRecording(boolean multitrack) { + ServerSession current = current(); + if (current != null) recordings.choose(current, multitrack); + } + + /** Records into the folder last used, without asking. */ + void startRecording(List targets, boolean multitrack) { + for (ServerSession s : targets) recordings.startNow(s, multitrack); + } + + void stopRecording() { + stopRecording(currentConnected()); + } + + void stopRecording(List targets) { + for (ServerSession s : targets) s.stopRecording(); + } + + // ---- server windows ---- + + void showOfflineMessages() { + onTab(ServerTab::showOfflineMessages); + } + + void showBanList() { + onTab(tab -> tab.showBanList(banReasonPresets())); + } + + void showComplaints() { + onTab(ServerTab::showComplaints); + } + + void showServerLog() { + onTab(ServerTab::showServerLog); + } + + void showPrivilegeKeys() { + onTab(ServerTab::showPrivilegeKeys); + } + + void usePrivilegeKey() { + onTab(ServerTab::usePrivilegeKey); + } + + void browseCurrentChannel() { + ServerTab tab = frame.selectedTab(); + if (tab == null || !tab.session().isConnected()) return; + ChannelNode channel = tab.session().currentChannel(); + if (channel != null) tab.browseFiles(channel); + } + + // ---- 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() { + frame.showGiantPtt(); + } + + void showIdentities() { + new IdentitiesDialog(frame, identities, settings, bookmarks, null).setVisible(true); + } + + void showContacts() { + frame.showContacts(null); + } + + void showSettings() { + frame.showSettings(); + } + + void showAbout() { + frame.showAbout(); + } + + /** Loaded the first time a ban dialog needs them, and shared by every tab from then on. */ + private BanReasonPresets banReasonPresets() { + if (banReasonPresets == null) banReasonPresets = BanReasonPresets.load(); + return banReasonPresets; + } + + private void onTab(Consumer action) { + ServerTab tab = frame.selectedTab(); + if (tab != null) action.accept(tab); + } + + private void forEach(List targets, Consumer change) { + for (ServerSession s : targets) change.accept(s); + frame.refreshChrome(); + } +} diff --git a/ts3-client/swing/src/main/java/eu/lixko/ts3j/client/ui/MainFrame.java b/ts3-client/swing/src/main/java/eu/lixko/ts3j/client/ui/MainFrame.java index e07b8df..d125b38 100644 --- a/ts3-client/swing/src/main/java/eu/lixko/ts3j/client/ui/MainFrame.java +++ b/ts3-client/swing/src/main/java/eu/lixko/ts3j/client/ui/MainFrame.java @@ -6,7 +6,6 @@ import eu.lixko.ts3j.client.audio.AudioBackend; import eu.lixko.ts3j.client.audio.desktop.DesktopAudioBackend; import eu.lixko.ts3j.client.config.AppDirs; import eu.lixko.ts3j.client.config.AwayMessages; -import eu.lixko.ts3j.client.config.BanReasonPresets; import eu.lixko.ts3j.client.config.Bookmark; import eu.lixko.ts3j.client.config.Bookmarks; import eu.lixko.ts3j.client.session.ServerLink; @@ -16,7 +15,6 @@ import eu.lixko.ts3j.client.myts.ChatAttachments; import eu.lixko.ts3j.client.myts.MyTeamSpeakLogin; import eu.lixko.ts3j.client.teamspeak.TeamSpeakImporter; import eu.lixko.ts3j.client.contacts.ContactStore; -import eu.lixko.ts3j.client.net.ChannelNode; import eu.lixko.ts3j.client.net.HostButton; import eu.lixko.ts3j.client.net.PictureDownloads; import eu.lixko.ts3j.client.session.SelfState; @@ -27,22 +25,14 @@ import eu.lixko.ts3j.client.sound.SoundPlayer; import eu.lixko.ts3j.client.ui.tray.TrayBackend; import javax.swing.AbstractAction; -import javax.swing.JCheckBox; -import javax.swing.JCheckBoxMenuItem; import javax.swing.JComponent; import javax.swing.JFrame; -import javax.swing.JLabel; -import javax.swing.JMenuItem; import javax.swing.JOptionPane; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.JTextField; import javax.swing.KeyStroke; import javax.swing.SwingUtilities; import java.io.File; import java.awt.BorderLayout; import java.awt.Dimension; -import java.awt.GridLayout; import java.awt.KeyboardFocusManager; import java.awt.Taskbar; import java.awt.event.ActionEvent; @@ -63,7 +53,7 @@ import java.util.concurrent.atomic.AtomicBoolean; public final class MainFrame extends JFrame implements ServerTabPane.Listener { private final Settings settings; - private final RecordingActions recordings; + private final MainCommands commands; private final Bookmarks bookmarks = Bookmarks.load(); private final AwayMessages awayMessages = AwayMessages.load(); private final IdentityStore identities; @@ -90,7 +80,6 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener { /** The tab whose views are on screen. */ private ServerTab selected; - private BanReasonPresets banReasonPresets; private MainMenuBar menuBar; private javax.swing.Timer statusTimer; @@ -113,7 +102,6 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener { public MainFrame(Settings settings) { super("TeamSpook TS3j"); this.settings = settings; - this.recordings = new RecordingActions(this, settings); this.chatZoom = new TextZoom(settings.chatZoom, z -> { settings.chatZoom = z; settings.save(); @@ -123,6 +111,7 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener { settings.save(); }); this.identities = IdentityStore.load(settings); + this.commands = new MainCommands(this, settings, sessions, bookmarks, awayMessages, identities); new TeamSpeakImporter(identities, bookmarks, settings).seedIfFresh(); this.sounds = new SoundNotifier(settings); this.soundPlayer = audio.createSoundPlayer(settings); @@ -133,7 +122,7 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener { KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener("activeWindow", e -> { if (e.getNewValue() != null) notifier.windowActivated(); }); - this.hotkeys = new HotkeyService(new HotkeyActions(this), this::hotkeyArgumentChoices); + this.hotkeys = new HotkeyService(new HotkeyActions(this, commands), this::hotkeyArgumentChoices); hotkeys.addKeyPressListener(() -> SwingUtilities.invokeLater(sessions::keyPressed)); contacts.addListener(() -> SwingUtilities.invokeLater(this::contactsChanged)); @@ -178,11 +167,7 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener { if (selected != null) selected.chat().openFind(); } }); - statusBar = new StatusBar(() -> { - if (selected != null) selected.session().stopRecording(); - }, () -> { - if (selected != null) selected.showOfflineMessages(); - }, () -> { + statusBar = new StatusBar(commands::stopRecording, commands::showOfflineMessages, () -> { if (selected != null) selected.session().cancelReconnect(); }); statusBar.setVisible(settings.showStatusBar); @@ -213,274 +198,11 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener { // ---- UI construction ---- private MainMenuBar buildMenuBar() { - return new MainMenuBar(bookmarks, new MainMenuBar.Listener() { - @Override - public void onConnect() { - showConnectDialog(); - } - - @Override - public void onDisconnect() { - doDisconnect(); - } - - @Override - public void onCloseTab() { - closeTab(selected); - } - - @Override - public void onQuit() { - quit(); - } - - @Override - public void onActivate() { - moveMicrophoneToSelectedTab(); - } - - @Override - public void onToggleMic() { - toolbar.clickMic(); - } - - @Override - public void onToggleSpeaker() { - toolbar.clickSpeaker(); - } - - @Override - public void onAwayToggle(boolean away) { - toggleAway(away); - } - - @Override - public void onAwayStatus() { - setAwayStatus(); - } - - @Override - public JPopupMenu buildAwayMenu() { - return MainFrame.this.buildAwayMenu(); - } - - @Override - public void onCommanderToggle(boolean commander) { - if (selected != null) selected.session().setCommander(commander); - } - - @Override - public void onChangeNickname() { - changeNickname(); - } - - @Override - public boolean isTalkPowerRequested() { - return selected != null && selected.session().isTalkRequested(); - } - - @Override - public boolean canRequestTalkPower() { - return selected != null && selected.session().canRequestTalkPower(); - } - - @Override - public void onRequestTalkPower() { - requestTalkPower(); - } - - @Override - public void onSetPhoneticNickname() { - setPhoneticNickname(); - } - - @Override - public boolean canSetAvatar() { - return selected != null && selected.session().permissions().canSetAvatar(); - } - - @Override - public void onSetAvatar() { - if (selected != null) selected.avatar().choose(); - } - - @Override - public boolean hasAvatar() { - return selected != null && selected.session().hasAvatar(); - } - - @Override - public void onDeleteAvatar() { - if (selected != null) selected.avatar().delete(); - } - - @Override - public void onGiantPtt() { - showGiantPtt(); - } - - @Override - public void onShowIdentities() { - showIdentities(); - } - - @Override - public void onShowContacts() { - showContacts(null); - } - - @Override - public boolean isRecording() { - return selected != null && selected.session().isRecording(); - } - - @Override - public void onStartRecording(boolean multitrack) { - if (selected != null) recordings.choose(selected.session(), multitrack); - } - - @Override - public void onStopRecording() { - if (selected != null) selected.session().stopRecording(); - } - - @Override - public void onShowOfflineMessages() { - if (selected != null) selected.showOfflineMessages(); - } - - @Override - public boolean canViewBanList() { - return selected != null && selected.session().permissions().canViewBanList(); - } - - @Override - public void onShowBanList() { - if (selected != null) selected.showBanList(banReasonPresets()); - } - - @Override - public boolean canViewComplaints() { - return selected != null && selected.session().permissions().canViewComplaints(); - } - - @Override - public void onShowComplaints() { - if (selected != null) selected.showComplaints(); - } - - @Override - public boolean canViewServerLog() { - return selected != null && selected.session().permissions().canViewServerLog(); - } - - @Override - public void onShowServerLog() { - if (selected != null) selected.showServerLog(); - } - - @Override - public boolean canListPrivilegeKeys() { - return selected != null && selected.session().permissions().canListPrivilegeKeys(); - } - - @Override - public void onShowPrivilegeKeys() { - if (selected != null) selected.showPrivilegeKeys(); - } - - @Override - public void onUsePrivilegeKey() { - if (selected != null) selected.usePrivilegeKey(); - } - - @Override - public void onShowSettings() { - showSettings(); - } - - @Override - public void onShowAbout() { - showAbout(); - } - - @Override - public void onConnectBookmark(Bookmark bookmark, boolean newTab) { - if (newTab) selectTab(newTab()); - connectToBookmark(bookmark); - } - - @Override - public void onAddCurrentServerBookmark() { - addCurrentServerBookmark(); - } - - @Override - public void onManageBookmarks() { - new BookmarksDialog(MainFrame.this, bookmarks, identities, settings, sessions, - MainFrame.this::connectToBookmark, menuBar::rebuildBookmarks).setVisible(true); - } - }); + return new MainMenuBar(bookmarks, commands); } private MainToolbar buildToolbar() { - return new MainToolbar(settings, new MainToolbar.Listener() { - @Override - public void onConnect() { - showConnectDialog(); - } - - @Override - public void onDisconnect() { - doDisconnect(); - } - - @Override - public void onActivate() { - moveMicrophoneToSelectedTab(); - } - - @Override - public void onMicMuteToggle(boolean muted) { - if (selected == null) return; - selected.session().setMicMuted(muted); - updateToolbar(); - } - - @Override - public void onDeafenToggle(boolean deafened) { - if (selected == null) return; - selected.session().setDeafened(deafened); - updateToolbar(); - } - - @Override - public void onAwayToggle(boolean away) { - toggleAway(away); - } - - @Override - public JPopupMenu buildAwayMenu() { - return MainFrame.this.buildAwayMenu(); - } - - @Override - public void onSettings() { - showSettings(); - } - - @Override - public void onMasterVolumeChanged() { - applyOutputSettingsToAllTabs(); - } - - @Override - public void onStatusBarVisibilityChanged(boolean visible) { - statusBar.setVisible(visible); - revalidate(); - repaint(); - } - }, pictures); + return new MainToolbar(settings, commands, pictures); } /** Rebuilds the icon-bearing chrome after the active icon pack changed. */ @@ -581,9 +303,24 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener { void serverIconChanged(ServerTab tab, long iconId) { if (!bookmarks.rememberServerIcon(tab.session().address(), tab.session().port(), iconId)) return; bookmarks.save(); + bookmarksChanged(); + } + + /** The saved bookmarks changed: the menu lists them anew. */ + void bookmarksChanged() { menuBar.rebuildBookmarks(); } + void showStatusBar(boolean visible) { + statusBar.setVisible(visible); + revalidate(); + repaint(); + } + + MainCommands commands() { + return commands; + } + /** The local client on {@code tab} started or stopped talking, muted itself, … */ void selfStateChanged(ServerTab tab) { if (!tabs.contains(tab)) return; @@ -623,27 +360,7 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener { return current == null ? null : current.backend(); } - // ---- hotkeys ---- - - /** - * Which connections a fired hotkey reaches: with "on active server" ticked only the - * selected tab, otherwise every connected one. - */ - List hotkeyTargets(boolean activeServerOnly) { - List out = new ArrayList<>(); - if (activeServerOnly) { - if (selected != null && selected.session().isConnected()) out.add(selected); - return out; - } - for (ServerTab tab : tabs) { - if (tab.session().isConnected()) out.add(tab); - } - return out; - } - - RecordingActions recordings() { - return recordings; - } + // ---- for the commands and hotkeys ---- ServerTab selectedTab() { return selected; @@ -658,7 +375,7 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener { sessions.setPushToTalk(talking); } - private void showGiantPtt() { + void showGiantPtt() { if (giantPtt == null || !giantPtt.isDisplayable()) { giantPtt = new GiantPttWindow(this, sessions::setForceTransmit, () -> { ServerSession owner = sessions.microphoneOwner(); @@ -670,23 +387,10 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener { giantPtt.toFront(); } - void moveMicrophoneToSelectedTab() { - if (selected != null && selected.session().isConnected()) sessions.giveMicrophoneTo(selected.session()); - updateToolbar(); - } - - /** Connects to the bookmark with this label; no label means the first one. */ - void connectBookmark(String label, boolean newTab) { - Bookmark match = null; - for (Bookmark b : bookmarks.all()) { - if (label == null || label.isBlank() || label.equalsIgnoreCase(b.label)) { - match = b; - break; - } - } - if (match == null) return; + /** @param newTab open the server in a new tab instead of replacing the current one */ + void connectBookmark(Bookmark bookmark, boolean newTab) { if (newTab) selectTab(newTab()); - connectToBookmark(match); + connectToBookmark(bookmark); } /** Selects the tab with this 1-based number, as the "Select Server Tab" action names it. */ @@ -715,23 +419,6 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener { updateStatusLabel(); } - /** Applies a new nickname, or asks for one when the hotkey carries none. */ - void changeNickname(String nickname) { - if (nickname == null || nickname.isBlank()) { - changeNickname(); - return; - } - settings.nickname = nickname.trim(); - settings.save(); - sessions.setNickname(settings.nickname); - } - - void browseCurrentChannel() { - if (selected == null || !selected.session().isConnected()) return; - ChannelNode channel = selected.session().currentChannel(); - if (channel != null) selected.browseFiles(channel); - } - void reloadSkin() { IconTheme.get().reload(settings); } @@ -783,8 +470,8 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener { return out; } - /** Repaints the chrome after a hotkey changed the local client's state. */ - void refreshAfterHotkey() { + /** Repaints the chrome after our own state changed. */ + void refreshChrome() { updateToolbar(); updateTray(); refreshTabs(); @@ -792,7 +479,7 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener { // ---- actions ---- - private void showConnectDialog() { + void showConnectDialog() { ConnectDialog dlg = new ConnectDialog(this, settings, identities); dlg.setVisible(true); if (!dlg.isConfirmed()) return; @@ -849,7 +536,7 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener { if (!link.bookmarkLabel.isEmpty()) { bookmarks.add(link.toBookmark()); bookmarks.save(); - menuBar.rebuildBookmarks(); + bookmarksChanged(); } for (ServerTab tab : tabs) { if (tab.session().isOn(link)) { @@ -869,96 +556,6 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener { startConnection(b.address, b.port, b.nickname == null ? "" : b.nickname, b.password, b.identityId, b.channel, b.channelPassword, true, b.myTeamSpeakFeatures); } - private void addCurrentServerBookmark() { - if (selected == null || !selected.session().isConnected()) { - JOptionPane.showMessageDialog(this, "Connect to a server first.", - "Add bookmark", JOptionPane.INFORMATION_MESSAGE); - return; - } - String channelPath = selected.session().currentChannelPath(); - - JTextField labelField = new JTextField(selected.session().title()); - JCheckBox joinChannel = new JCheckBox("Join \"" + channelPath + "\" on connect", !channelPath.isEmpty()); - JPanel form = new JPanel(new GridLayout(0, 1, 0, UIScale.scale(2))); - form.add(new JLabel("Bookmark label:")); - form.add(labelField); - if (!channelPath.isEmpty()) form.add(joinChannel); - if (JOptionPane.showConfirmDialog(this, form, "Add bookmark", - JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE) != JOptionPane.OK_OPTION) { - return; - } - Bookmark bookmark = selected.session().toBookmark(joinChannel.isSelected() ? channelPath : ""); - bookmark.label = labelField.getText().trim(); - bookmarks.add(bookmark); - bookmarks.save(); - menuBar.rebuildBookmarks(); - } - - /** The away button's drop-down: the global actions, the presets and their editor. */ - private JPopupMenu buildAwayMenu() { - JPopupMenu menu = new JPopupMenu(); - boolean anyConnected = sessions.anyConnected(); - - JCheckBoxMenuItem globally = new JCheckBoxMenuItem("Set Globally Away", Icons.of("AWAY"), - sessions.isAwayEverywhere()); - globally.setEnabled(anyConnected); - globally.addActionListener(e -> setAwayEverywhere(globally.isSelected(), null)); - - JMenuItem globalStatus = new JMenuItem("Set Globally Away Status…", Icons.of("EDIT")); - globalStatus.setEnabled(anyConnected); - globalStatus.addActionListener(e -> { - String message = askAwayMessage(sessions.awayMessage(selected == null ? null : selected.session())); - if (message != null) setAwayEverywhere(true, message); - }); - - menu.add(globally); - menu.add(globalStatus); - menu.addSeparator(); - - for (String preset : awayMessages.all()) { - JMenuItem item = new JMenuItem(preset); - item.setEnabled(anyConnected); - item.addActionListener(e -> setAwayEverywhere(true, preset)); - menu.add(item); - } - if (!awayMessages.all().isEmpty()) menu.addSeparator(); - - JMenuItem manage = new JMenuItem("Manage away messages…", Icons.of("EDIT")); - manage.addActionListener(e -> new AwayMessagesDialog(this, awayMessages, null).setVisible(true)); - menu.add(manage); - return menu; - } - - private void toggleAway(boolean away) { - if (selected == null) return; - selected.session().setAway(away, ""); - updateToolbar(); - } - - /** Sets the away message on the selected server only. */ - private void setAwayStatus() { - if (selected == null) return; - String message = askAwayMessage(selected.session().awayMessage()); - if (message == null) return; - selected.session().setAway(true, message); - updateToolbar(); - } - - private void setAwayEverywhere(boolean away, String message) { - sessions.setAwayEverywhere(away, message); - updateToolbar(); - } - - /** @return the entered message (possibly empty), or null when cancelled */ - private String askAwayMessage(String initial) { - return (String) JOptionPane.showInputDialog(this, "Away message (optional):", "Away status", - JOptionPane.PLAIN_MESSAGE, Icons.of("AWAY"), null, initial); - } - - private void doDisconnect() { - if (selected != null) selected.session().disconnect(); - } - /** * Tear everything down before the process exits: disconnect from every server * synchronously (so the "Leaving" notification actually reaches them) and stop @@ -989,21 +586,11 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener { } /** Leaves every server and ends the process. */ - private void quit() { + void quit() { shutdown(); System.exit(0); } - /** Loaded the first time a ban dialog needs them, and shared by every tab from then on. */ - private BanReasonPresets banReasonPresets() { - if (banReasonPresets == null) banReasonPresets = BanReasonPresets.load(); - return banReasonPresets; - } - - private void showIdentities() { - new IdentitiesDialog(this, identities, settings, bookmarks, null).setVisible(true); - } - Settings settings() { return settings; } @@ -1030,7 +617,7 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener { for (ServerTab tab : tabs) tab.contactsChanged(); } - private void showSettings() { + void showSettings() { // Device and voice-gating changes apply to the capturing connection and the // playback of the visible one; the rest pick the new settings up on connect. SettingsDialog dlg = new SettingsDialog(this, settings, audio, @@ -1038,7 +625,7 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener { selected == null ? null : selected.session().playback(), sounds, hotkeys, new MyTeamSpeakPanel(myTeamSpeak, new TeamSpeakImporter(identities, bookmarks, settings, contacts), - menuBar::rebuildBookmarks, this::myTeamSpeakChanged), + this::bookmarksChanged, this::myTeamSpeakChanged), () -> { applyOutputSettingsToAllTabs(); contactsChanged(); @@ -1074,7 +661,7 @@ 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. */ - private void applyOutputSettingsToAllTabs() { + void applyOutputSettingsToAllTabs() { soundPlayer.setOutputDevice(settings.outputDevice); for (ServerTab tab : tabs) { VoiceOutput playback = tab.session().playback(); @@ -1085,36 +672,7 @@ public final class MainFrame extends JFrame implements ServerTabPane.Listener { } } - private void changeNickname() { - String n = JOptionPane.showInputDialog(this, "New nickname:", settings.nickname); - if (n != null && !n.trim().isEmpty()) { - settings.nickname = n.trim(); - settings.save(); - for (ServerTab tab : tabs) tab.session().setNickname(settings.nickname); - } - } - - /** Asks for a reason and requests talk power, or withdraws the pending request. */ - private void requestTalkPower() { - if (selected == null) return; - if (selected.session().isTalkRequested()) { - selected.session().cancelTalkRequest(); - return; - } - String message = (String) JOptionPane.showInputDialog(this, "Reason:", "Request Talk Power", - JOptionPane.PLAIN_MESSAGE, Icons.of("TALK_POWER_REQUEST"), null, ""); - if (message != null) selected.session().requestTalkPower(message.trim()); - } - - private void setPhoneticNickname() { - if (selected == null) return; - String phonetic = (String) JOptionPane.showInputDialog(this, "Phonetic nickname:", "Set Phonetic Nickname", - JOptionPane.PLAIN_MESSAGE, Icons.of("PHONETICSNICKNAME"), null, - selected.session().phoneticNickname()); - if (phonetic != null) selected.session().setPhoneticNickname(phonetic.trim()); - } - - private void showAbout() { + void showAbout() { JOptionPane.showMessageDialog(this, "TeamSpook TS3j\n\n" + "An open-source TeamSpeak 3 desktop client built on the ts3j\n" + diff --git a/ts3-client/swing/src/main/java/eu/lixko/ts3j/client/ui/MainMenuBar.java b/ts3-client/swing/src/main/java/eu/lixko/ts3j/client/ui/MainMenuBar.java index f2bb870..d1a6bd2 100644 --- a/ts3-client/swing/src/main/java/eu/lixko/ts3j/client/ui/MainMenuBar.java +++ b/ts3-client/swing/src/main/java/eu/lixko/ts3j/client/ui/MainMenuBar.java @@ -2,6 +2,8 @@ package eu.lixko.ts3j.client.ui; import eu.lixko.ts3j.client.config.Bookmark; import eu.lixko.ts3j.client.config.Bookmarks; +import eu.lixko.ts3j.client.net.Permissions; +import eu.lixko.ts3j.client.session.ServerSession; import javax.swing.ImageIcon; import javax.swing.JCheckBoxMenuItem; @@ -17,115 +19,17 @@ import javax.swing.event.MenuListener; import java.awt.Component; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.util.function.Predicate; /** * The main window's menu bar: Connections, Bookmarks, Self, Permissions, Tools and Help. - * Talks to {@link MainFrame} only through {@link Listener}; the away/commander - * item states are pushed in by {@link #refresh}, mirroring how {@link MainToolbar} - * is kept in sync. + * Its items run {@link MainCommands}; the away/commander item states are pushed in + * by {@link #refresh}, mirroring how {@link MainToolbar} is kept in sync. */ final class MainMenuBar extends JMenuBar { - interface Listener { - void onConnect(); - - void onDisconnect(); - - void onCloseTab(); - - void onQuit(); - - /** Moves the microphone to the tab on screen. */ - void onActivate(); - - void onToggleMic(); - - void onToggleSpeaker(); - - /** The plain toggle carries no message; "Set away status…" is where messages are chosen. */ - void onAwayToggle(boolean away); - - void onAwayStatus(); - - /** The away button's drop-down, which the "Set Away" submenu mirrors. */ - JPopupMenu buildAwayMenu(); - - void onCommanderToggle(boolean commander); - - void onChangeNickname(); - - /** Whether our talk power request is pending; asked as the Self menu opens. */ - boolean isTalkPowerRequested(); - - /** Whether the current server lets us ask for talk power; asked as the Self menu opens. */ - boolean canRequestTalkPower(); - - /** Requests talk power, or withdraws a pending request. */ - void onRequestTalkPower(); - - void onSetPhoneticNickname(); - - /** Whether the current server lets us upload an avatar; asked as the Self menu opens. */ - boolean canSetAvatar(); - - void onSetAvatar(); - - /** Whether we have an avatar on the current server to delete; asked as the Self menu opens. */ - boolean hasAvatar(); - - void onDeleteAvatar(); - - void onGiantPtt(); - - void onShowIdentities(); - - void onShowContacts(); - - void onShowOfflineMessages(); - - /** Whether the current tab is recording; asked as the Tools menu opens. */ - boolean isRecording(); - - void onStartRecording(boolean multitrack); - - void onStopRecording(); - - /** Whether the current server lets us read its ban list; asked as the Tools menu opens. */ - boolean canViewBanList(); - - void onShowBanList(); - - /** Whether the current server lets us read its complaints; asked as the Tools menu opens. */ - boolean canViewComplaints(); - - void onShowComplaints(); - - /** Whether the current server lets us read its log; asked as the Tools menu opens. */ - boolean canViewServerLog(); - - void onShowServerLog(); - - /** Whether the current server lets us list its privilege keys; asked as the Permissions menu opens. */ - boolean canListPrivilegeKeys(); - - void onShowPrivilegeKeys(); - - void onUsePrivilegeKey(); - - void onShowSettings(); - - void onShowAbout(); - - /** @param newTab open the server in a new tab instead of replacing the current one */ - void onConnectBookmark(Bookmark bookmark, boolean newTab); - - void onAddCurrentServerBookmark(); - - void onManageBookmarks(); - } - private final Bookmarks bookmarks; - private final Listener listener; + private final MainCommands commands; private JMenu bookmarksMenu; private JMenu awayMenu; @@ -149,23 +53,23 @@ final class MainMenuBar extends JMenuBar { private JMenuItem privilegeKeysItem; private JMenuItem usePrivilegeKeyItem; - MainMenuBar(Bookmarks bookmarks, Listener listener) { + MainMenuBar(Bookmarks bookmarks, MainCommands commands) { this.bookmarks = bookmarks; - this.listener = listener; + this.commands = commands; JMenu connections = new JMenu("Connections"); JMenuItem connect = new JMenuItem("Connect…", Icons.of("CONNECT")); connect.setAccelerator(KeyStroke.getKeyStroke("control S")); - connect.addActionListener(e -> listener.onConnect()); + connect.addActionListener(e -> commands.connect()); JMenuItem disconnect = new JMenuItem("Disconnect", Icons.of("DISCONNECT")); disconnect.setAccelerator(KeyStroke.getKeyStroke("control D")); - disconnect.addActionListener(e -> listener.onDisconnect()); + disconnect.addActionListener(e -> commands.disconnect()); JMenuItem closeTab = new JMenuItem("Close tab", Icons.of("CLOSE_BUTTON")); closeTab.setAccelerator(KeyStroke.getKeyStroke("control W")); - closeTab.addActionListener(e -> listener.onCloseTab()); + closeTab.addActionListener(e -> commands.closeTab()); JMenuItem quit = new JMenuItem("Quit", Icons.of("QUIT")); quit.setAccelerator(KeyStroke.getKeyStroke("control Q")); - quit.addActionListener(e -> listener.onQuit()); + quit.addActionListener(e -> commands.quit()); connections.add(connect); connections.add(disconnect); connections.add(closeTab); @@ -208,31 +112,31 @@ final class MainMenuBar extends JMenuBar { } }); activateItem = new JMenuItem("Activate Microphone", Icons.of("ACTIVATE_MICROPHONE")); - activateItem.addActionListener(e -> listener.onActivate()); + activateItem.addActionListener(e -> commands.activate()); muteItem = new JMenuItem(); - muteItem.addActionListener(e -> listener.onToggleMic()); + muteItem.addActionListener(e -> commands.toggleMicMuted()); deafItem = new JMenuItem(); - deafItem.addActionListener(e -> listener.onToggleSpeaker()); + deafItem.addActionListener(e -> commands.toggleDeafened()); showMuted(false, false); awayItem = new JCheckBoxMenuItem("Away", Icons.of("AWAY"), false); - awayItem.addActionListener(e -> listener.onAwayToggle(awayItem.isSelected())); + awayItem.addActionListener(e -> commands.setAway(awayItem.isSelected())); awayStatusItem = new JMenuItem("Set away status…", Icons.of("EDIT")); - awayStatusItem.addActionListener(e -> listener.onAwayStatus()); + awayStatusItem.addActionListener(e -> commands.setAwayStatus()); commanderItem = new JCheckBoxMenuItem("Channel commander", Icons.of("CHANNEL_COMMANDER"), false); - commanderItem.addActionListener(e -> listener.onCommanderToggle(commanderItem.isSelected())); + commanderItem.addActionListener(e -> commands.setCommander(commanderItem.isSelected())); JMenuItem nick = new JMenuItem("Change nickname…", Icons.of("CHANGE_NICKNAME")); - nick.addActionListener(e -> listener.onChangeNickname()); + nick.addActionListener(e -> commands.changeNickname()); talkPowerItem = new JMenuItem(); - talkPowerItem.addActionListener(e -> listener.onRequestTalkPower()); + talkPowerItem.addActionListener(e -> commands.requestTalkPower()); showTalkPowerRequested(false); phoneticItem = new JMenuItem("Set Phonetic Nickname…", Icons.of("PHONETICSNICKNAME")); - phoneticItem.addActionListener(e -> listener.onSetPhoneticNickname()); + phoneticItem.addActionListener(e -> commands.setPhoneticNickname()); avatarItem = new JMenuItem("Set avatar…", Icons.of("UPLOAD_AVATAR")); - avatarItem.addActionListener(e -> listener.onSetAvatar()); + avatarItem.addActionListener(e -> commands.setAvatar()); deleteAvatarItem = new JMenuItem("Delete avatar", Icons.of("DELETE_AVATAR")); - deleteAvatarItem.addActionListener(e -> listener.onDeleteAvatar()); + deleteAvatarItem.addActionListener(e -> commands.deleteAvatar()); JMenuItem giantPtt = new JMenuItem("Giant PTT", Icons.of("CAPTURE")); - giantPtt.addActionListener(e -> listener.onGiantPtt()); + giantPtt.addActionListener(e -> commands.showGiantPtt()); self.add(awayMenu); self.add(activateItem); self.add(muteItem); @@ -249,11 +153,11 @@ final class MainMenuBar extends JMenuBar { self.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { - boolean requested = listener.isTalkPowerRequested(); + boolean requested = is(ServerSession::isTalkRequested); showTalkPowerRequested(requested); - talkPowerItem.setVisible(requested || listener.canRequestTalkPower()); - avatarItem.setVisible(!avatarItem.isEnabled() || listener.canSetAvatar()); - deleteAvatarItem.setVisible(listener.hasAvatar()); + talkPowerItem.setVisible(requested || is(ServerSession::canRequestTalkPower)); + avatarItem.setVisible(!avatarItem.isEnabled() || permitted(Permissions::canSetAvatar)); + deleteAvatarItem.setVisible(is(ServerSession::hasAvatar)); } @Override @@ -267,15 +171,15 @@ final class MainMenuBar extends JMenuBar { JMenu permissions = new JMenu("Permissions"); privilegeKeysItem = new JMenuItem("Privilege Keys", Icons.of("TOKEN")); - privilegeKeysItem.addActionListener(e -> listener.onShowPrivilegeKeys()); + privilegeKeysItem.addActionListener(e -> commands.showPrivilegeKeys()); usePrivilegeKeyItem = new JMenuItem("Use Privilege Key", Icons.of("TOKEN_USE")); - usePrivilegeKeyItem.addActionListener(e -> listener.onUsePrivilegeKey()); + usePrivilegeKeyItem.addActionListener(e -> commands.usePrivilegeKey()); permissions.add(privilegeKeysItem); permissions.add(usePrivilegeKeyItem); permissions.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { - privilegeKeysItem.setVisible(!privilegeKeysItem.isEnabled() || listener.canListPrivilegeKeys()); + privilegeKeysItem.setVisible(!privilegeKeysItem.isEnabled() || permitted(Permissions::canListPrivilegeKeys)); } @Override @@ -290,38 +194,38 @@ final class MainMenuBar extends JMenuBar { JMenu tools = new JMenu("Tools"); JMenuItem identitiesItem = new JMenuItem("Identities…", Icons.of("IDENTITY_MANAGER")); identitiesItem.setAccelerator(KeyStroke.getKeyStroke("control I")); - identitiesItem.addActionListener(e -> listener.onShowIdentities()); + identitiesItem.addActionListener(e -> commands.showIdentities()); JMenuItem contactsItem = new JMenuItem("Contacts…", Icons.ofAny("CONTACT", "EDIT_FRIEND_FOE_STATUS")); contactsItem.setAccelerator(KeyStroke.getKeyStroke("control shift O")); - contactsItem.addActionListener(e -> listener.onShowContacts()); + contactsItem.addActionListener(e -> commands.showContacts()); offlineMessagesItem = new JMenuItem("Offline Messages", Icons.of("OFFLINE_MESSAGES")); offlineMessagesItem.setAccelerator(KeyStroke.getKeyStroke("control O")); - offlineMessagesItem.addActionListener(e -> listener.onShowOfflineMessages()); + offlineMessagesItem.addActionListener(e -> commands.showOfflineMessages()); startRecordingItem = new JMenuItem("Start Recording", Icons.of("RECORDING_START")); - startRecordingItem.addActionListener(e -> listener.onStartRecording(false)); + startRecordingItem.addActionListener(e -> commands.startRecording(false)); startMultitrackItem = new JMenuItem("Start Multitrack Recording", Icons.of("RECORDING_START")); - startMultitrackItem.addActionListener(e -> listener.onStartRecording(true)); + startMultitrackItem.addActionListener(e -> commands.startRecording(true)); stopRecordingItem = new JMenuItem("Stop Recording", Icons.of("RECORDING_STOP")); - stopRecordingItem.addActionListener(e -> listener.onStopRecording()); + stopRecordingItem.addActionListener(e -> commands.stopRecording()); banListItem = new JMenuItem("Ban List", Icons.of("BAN_LIST")); banListItem.setAccelerator(KeyStroke.getKeyStroke("control shift B")); // The shortcut works while the item is hidden, so it asks for itself. banListItem.addActionListener(e -> { - if (listener.canViewBanList()) listener.onShowBanList(); + if (permitted(Permissions::canViewBanList)) commands.showBanList(); }); complaintsItem = new JMenuItem("Complaints List", Icons.of("COMPLAINT_LIST")); complaintsItem.setAccelerator(KeyStroke.getKeyStroke("control shift C")); complaintsItem.addActionListener(e -> { - if (listener.canViewComplaints()) listener.onShowComplaints(); + if (permitted(Permissions::canViewComplaints)) commands.showComplaints(); }); serverLogItem = new JMenuItem("Server Log", Icons.of("SERVER_LOG")); serverLogItem.setAccelerator(KeyStroke.getKeyStroke("control shift L")); serverLogItem.addActionListener(e -> { - if (listener.canViewServerLog()) listener.onShowServerLog(); + if (permitted(Permissions::canViewServerLog)) commands.showServerLog(); }); JMenuItem options = new JMenuItem("Options…", Icons.of("SETTINGS")); options.setAccelerator(KeyStroke.getKeyStroke("alt P")); - options.addActionListener(e -> listener.onShowSettings()); + options.addActionListener(e -> commands.showSettings()); JPopupMenu.Separator adminSeparator = new JPopupMenu.Separator(); tools.add(identitiesItem); tools.add(contactsItem); @@ -341,14 +245,14 @@ final class MainMenuBar extends JMenuBar { tools.addMenuListener(new MenuListener() { @Override public void menuSelected(MenuEvent e) { - boolean bans = banListItem.isEnabled() && listener.canViewBanList(); - boolean complaints = complaintsItem.isEnabled() && listener.canViewComplaints(); - boolean serverLog = serverLogItem.isEnabled() && listener.canViewServerLog(); + boolean bans = banListItem.isEnabled() && permitted(Permissions::canViewBanList); + boolean complaints = complaintsItem.isEnabled() && permitted(Permissions::canViewComplaints); + boolean serverLog = serverLogItem.isEnabled() && permitted(Permissions::canViewServerLog); banListItem.setVisible(bans); complaintsItem.setVisible(complaints); serverLogItem.setVisible(serverLog); adminSeparator.setVisible(bans || complaints || serverLog); - boolean recording = listener.isRecording(); + boolean recording = is(ServerSession::isRecording); startRecordingItem.setVisible(!recording); startMultitrackItem.setVisible(!recording); stopRecordingItem.setVisible(recording); @@ -365,7 +269,7 @@ final class MainMenuBar extends JMenuBar { JMenu help = new JMenu("Help"); JMenuItem about = new JMenuItem("About", Icons.of("ABOUT")); - about.addActionListener(e -> listener.onShowAbout()); + about.addActionListener(e -> commands.showAbout()); help.add(about); add(connections); @@ -376,6 +280,16 @@ final class MainMenuBar extends JMenuBar { add(help); } + /** Asks the server on screen; false while there is none. */ + private boolean is(Predicate question) { + ServerSession current = commands.current(); + return current != null && question.test(current); + } + + private boolean permitted(Predicate question) { + return is(s -> question.test(s.permissions())); + } + /** Reflects the current tab's state on the menu items. */ void refresh(boolean connected, boolean anyConnected, boolean micMuted, boolean deafened, boolean active, boolean away, boolean commander) { @@ -421,17 +335,17 @@ final class MainMenuBar extends JMenuBar { awayMenu.add(awayItem); awayMenu.add(awayStatusItem); awayMenu.addSeparator(); - for (Component c : listener.buildAwayMenu().getComponents()) awayMenu.getPopupMenu().add(c); + for (Component c : commands.buildAwayMenu().getComponents()) awayMenu.getPopupMenu().add(c); } /** Re-lists the saved bookmarks; called after they change (add, remove, manage…). */ void rebuildBookmarks() { bookmarksMenu.removeAll(); JMenuItem addCurrent = new JMenuItem("Add to Bookmarks…", Icons.of("BOOKMARK_ADD")); - addCurrent.addActionListener(e -> listener.onAddCurrentServerBookmark()); + addCurrent.addActionListener(e -> commands.addCurrentServerBookmark()); JMenuItem manage = new JMenuItem("Manage Bookmarks…", Icons.of("BOOKMARK_MANAGER")); manage.setAccelerator(KeyStroke.getKeyStroke("control B")); - manage.addActionListener(e -> listener.onManageBookmarks()); + manage.addActionListener(e -> commands.manageBookmarks()); bookmarksMenu.add(addCurrent); bookmarksMenu.add(manage); if (!bookmarks.all().isEmpty()) bookmarksMenu.addSeparator(); @@ -439,13 +353,13 @@ final class MainMenuBar extends JMenuBar { ImageIcon serverIcon = GroupIcons.cached(b.iconId); JMenuItem item = new JMenuItem(b.displayName(), serverIcon != null ? serverIcon : Icons.of("SERVER_GREEN")); item.setToolTipText("Connect here (middle-click to open a new tab)"); - item.addActionListener(e -> listener.onConnectBookmark(b, false)); + item.addActionListener(e -> commands.connect(b, false)); item.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (!SwingUtilities.isMiddleMouseButton(e)) return; MenuSelectionManager.defaultManager().clearSelectedPath(); - listener.onConnectBookmark(b, true); + commands.connect(b, true); } }); bookmarksMenu.add(item); diff --git a/ts3-client/swing/src/main/java/eu/lixko/ts3j/client/ui/MainToolbar.java b/ts3-client/swing/src/main/java/eu/lixko/ts3j/client/ui/MainToolbar.java index e5c3295..2fc639b 100644 --- a/ts3-client/swing/src/main/java/eu/lixko/ts3j/client/ui/MainToolbar.java +++ b/ts3-client/swing/src/main/java/eu/lixko/ts3j/client/ui/MainToolbar.java @@ -29,39 +29,14 @@ import java.awt.FlowLayout; * window's optional chrome (this toolbar has no say over the status bar's own * visibility beyond reporting the toggle). * - *

Talks to {@link MainFrame} only through {@link Listener}, so it owns no - * connection/tab state itself — {@link #refresh} is handed everything it - * needs to redraw each time the selection changes. + *

Its buttons run {@link MainCommands}, and it owns no connection/tab state + * itself — {@link #refresh} is handed everything it needs to redraw each + * time the selection changes. */ final class MainToolbar extends JToolBar { - interface Listener { - void onConnect(); - - void onDisconnect(); - - /** Moves the microphone to the tab on screen. */ - void onActivate(); - - void onMicMuteToggle(boolean muted); - - void onDeafenToggle(boolean deafened); - - /** The plain toggle carries no message; the drop-down arrow is where messages are chosen. */ - void onAwayToggle(boolean away); - - JPopupMenu buildAwayMenu(); - - void onSettings(); - - /** The slider changed; push the new master volume to every open connection. */ - void onMasterVolumeChanged(); - - void onStatusBarVisibilityChanged(boolean visible); - } - private final Settings settings; - private final Listener listener; + private final MainCommands commands; private final JButton connectButton; private final JButton disconnectButton; @@ -72,9 +47,9 @@ final class MainToolbar extends JToolBar { private final JComponent masterVolumePanel; private final HostButtonView hostButton; - MainToolbar(Settings settings, Listener listener, PictureDownloads pictures) { + MainToolbar(Settings settings, MainCommands commands, PictureDownloads pictures) { this.settings = settings; - this.listener = listener; + this.commands = commands; setFloatable(false); setBackground(Theme.toolbarBg()); @@ -83,32 +58,32 @@ final class MainToolbar extends JToolBar { connectButton = new JButton(Icons.connect()); connectButton.setToolTipText("Connect to a server"); - connectButton.addActionListener(e -> listener.onConnect()); + connectButton.addActionListener(e -> commands.connect()); disconnectButton = new JButton(Icons.disconnect()); disconnectButton.setToolTipText("Disconnect"); - disconnectButton.addActionListener(e -> listener.onDisconnect()); + disconnectButton.addActionListener(e -> commands.disconnect()); activeButton = new JToggleButton(Icons.micActive()); activeButton.setToolTipText("Speak on this server (moves the microphone to this tab)"); - activeButton.addActionListener(e -> listener.onActivate()); + activeButton.addActionListener(e -> commands.activate()); micButton = new JToggleButton(Icons.mic()); micButton.setToolTipText("Mute / unmute microphone on this server"); - micButton.addActionListener(e -> listener.onMicMuteToggle(micButton.isSelected())); + micButton.addActionListener(e -> commands.toggleMicMuted()); speakerButton = new JToggleButton(Icons.speaker()); speakerButton.setToolTipText("Deafen / undeafen (mute speakers) on this server"); - speakerButton.addActionListener(e -> listener.onDeafenToggle(speakerButton.isSelected())); + speakerButton.addActionListener(e -> commands.toggleDeafened()); awayButton = new DropDownToggleButton(Icons.away(), "Away on this server (the arrow offers the global actions and presets)", - listener::buildAwayMenu); - awayButton.addActionListener(e -> listener.onAwayToggle(awayButton.isSelected())); + commands::buildAwayMenu); + awayButton.addActionListener(e -> commands.setAway(awayButton.isSelected())); JButton settingsButton = new JButton(Icons.settings()); settingsButton.setToolTipText("Options"); - settingsButton.addActionListener(e -> listener.onSettings()); + settingsButton.addActionListener(e -> commands.showSettings()); add(connectButton); add(disconnectButton); @@ -151,16 +126,6 @@ final class MainToolbar extends JToolBar { awayButton.setSelected(away); } - /** Simulates a click, for the "Mute Microphone" menu item. */ - void clickMic() { - micButton.doClick(); - } - - /** Simulates a click, for the "Mute Speakers/Headphones" menu item. */ - void clickSpeaker() { - speakerButton.doClick(); - } - /** The Master Volume slider: multiplies both voice and notification volume. */ private JComponent buildMasterVolumeControl() { JPanel panel = new JPanel(new FlowLayout(FlowLayout.RIGHT, UIScale.scale(4), 0)); @@ -178,7 +143,7 @@ final class MainToolbar extends JToolBar { slider.setPreferredSize(new Dimension(UIScale.scale(135), slider.getPreferredSize().height)); slider.addChangeListener(e -> { settings.masterVolume = slider.getValue() / 100.0; - listener.onMasterVolumeChanged(); + commands.applyOutputSettings(); // Only touch the disk once the drag (or a wheel step) has settled. if (!slider.getValueIsAdjusting()) settings.save(); }); @@ -201,7 +166,7 @@ final class MainToolbar extends JToolBar { statusBarItem.addActionListener(e -> { settings.showStatusBar = statusBarItem.isSelected(); settings.save(); - listener.onStatusBarVisibilityChanged(settings.showStatusBar); + commands.showStatusBar(settings.showStatusBar); }); JCheckBoxMenuItem volumeItem = new JCheckBoxMenuItem("Show Master Volume Slider", settings.showMasterVolumeSlider); diff --git a/ts3-client/swing/src/main/java/eu/lixko/ts3j/client/ui/ServerTabTreeActions.java b/ts3-client/swing/src/main/java/eu/lixko/ts3j/client/ui/ServerTabTreeActions.java index c04ee33..8b3ae01 100644 --- a/ts3-client/swing/src/main/java/eu/lixko/ts3j/client/ui/ServerTabTreeActions.java +++ b/ts3-client/swing/src/main/java/eu/lixko/ts3j/client/ui/ServerTabTreeActions.java @@ -291,7 +291,7 @@ final class ServerTabTreeActions implements ServerTreePanel.Actions { @Override public void renameSelf(String nickname) { - host.changeNickname(nickname); + host.commands().changeNickname(nickname); } @Override