Skip to content

Commit

Permalink
Updated to v0.14-b4.
Browse files Browse the repository at this point in the history
  • Loading branch information
23rd committed Jan 13, 2021
2 parents 081ac6b + b5f30c3 commit e8a13be
Show file tree
Hide file tree
Showing 37 changed files with 712 additions and 151 deletions.
Binary file not shown.
Binary file removed assets/lib/src/JTattoo-1.6.12-1-sources.zip
Binary file not shown.
Binary file added assets/lib/src/JTattoo-1.6.12-2-sources.zip
Binary file not shown.
5 changes: 4 additions & 1 deletion src/chatty/SettingsManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ public void defineSettings() {
settings.addBoolean("popoutSaveAttributes", true);
settings.addBoolean("popoutCloseLastChannel", false);
settings.addList("popoutAttributes", new ArrayList(), Setting.STRING);
settings.addString("popoutClose", "ask");

// Titlebar
settings.addBoolean("simpleTitle", false);
Expand All @@ -438,6 +439,7 @@ public void defineSettings() {

// Tabs
settings.addString("tabOrder", "normal");
settings.addString("tabsOpen", "active2");
settings.addBoolean("tabsMwheelScrolling", false);
settings.addBoolean("tabsMwheelScrollingAnywhere", true);
settings.addString("tabsPlacement", "top");
Expand All @@ -448,7 +450,7 @@ public void defineSettings() {
settings.addLong("tabsStatus", 32);
settings.addLong("tabsActive", 128);
settings.addLong("tabsPopoutDrag", 2);

// Chat Window
settings.addBoolean("chatScrollbarAlways", false);
settings.addLong("userlistWidth", 120);
Expand Down Expand Up @@ -586,6 +588,7 @@ public void defineSettings() {
settings.addList("ignoredUsers", new ArrayList(), Setting.STRING);
settings.addList("ignoredUsersWhisper", new ArrayList(), Setting.STRING);
settings.addBoolean("ignoredUsersHideInGUI", true);
settings.addList("ignoreBlacklist", new ArrayList(), Setting.STRING);

// Filter
settings.addList("filter", new ArrayList(), Setting.STRING);
Expand Down
10 changes: 9 additions & 1 deletion src/chatty/TwitchConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -1209,8 +1209,15 @@ void onQueryMessage(String nick, String from, String text) {
*
* @param channel
* @param text
* @param tags The associated tags, may be empty (never null)
*/
private void infoMessage(String channel, String text, MsgTags tags) {
if (tags.isValue("msg-id", "host_on")) {
String hostedChannel = channelStates.getState(channel).getHosting();
if (!StringUtil.isNullOrEmpty(hostedChannel)) {
tags = MsgTags.addTag(tags, "chatty-hosted", hostedChannel);
}
}
if (text.startsWith("The moderators of")) {
parseModeratorsList(text, channel);
} else {
Expand Down Expand Up @@ -1399,7 +1406,8 @@ public void onChannelCommand(MsgTags tags, String nick,
String[] parameters = trailing.split(" ");
if (parameters.length == 2) {
String target = parameters[0];
if (target.equals("-")) {
// Unhosting should be "-", but just to be safe
if (!Helper.isRegularChannel(target)) {
listener.onHost(rooms.getRoom(channel), null);
channelStates.setHosting(channel, null);
} else {
Expand Down
159 changes: 155 additions & 4 deletions src/chatty/gui/Channels.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
import chatty.gui.components.Channel;
import chatty.gui.components.menus.ContextMenuListener;
import chatty.gui.components.menus.TabContextMenu;
import chatty.lang.Language;
import chatty.util.Debugging;
import chatty.util.IconManager;
import chatty.util.KeyChecker;
import chatty.util.dnd.DockContent;
import chatty.util.dnd.DockListener;
import chatty.util.dnd.DockManager;
Expand All @@ -27,6 +29,16 @@
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import chatty.util.dnd.DockPopout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.KeyEvent;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JOptionPane;

import chatty.util.ForkUtil;

Expand Down Expand Up @@ -126,6 +138,38 @@ public void activeContentChanged(DockPopout window, DockContent content, boolean
public void popoutOpened(DockPopout popout, DockContent content) {
dockPopoutOpened(popout);
}

@Override
public void popoutClosing(DockPopout popout) {
if (KeyChecker.isPressed(KeyEvent.VK_SHIFT)) {
dock.closePopout(popout);
}
else if (KeyChecker.isPressed(KeyEvent.VK_CONTROL)) {
removeContents(dock.getContents(popout));
}
else {
switch (gui.getSettings().getString("popoutClose")) {
case "close":
removeContents(dock.getContents(popout));
break;
case "move":
dock.closePopout(popout);
break;
default:
ClosingDialog d = new ClosingDialog(popout);
if (d.getChoice().equals("close")) {
removeContents(dock.getContents(popout));
}
else if (d.getChoice().equals("move")) {
dock.closePopout(popout);
}

if (d.shouldSaveChoice()) {
gui.getSettings().setString("popoutClose", d.getChoice());
}
}
}
}

@Override
public void popoutClosed(DockPopout popout, List<DockContent> contents) {
Expand All @@ -141,7 +185,7 @@ public void contentAdded(DockContent content) {
public void contentRemoved(DockContent content) {
checkDefaultChannel();
}

});
// One-time settings
dock.setSetting(DockSetting.Type.POPOUT_ICONS, IconManager.getMainIcons());
Expand All @@ -158,6 +202,8 @@ public void contentRemoved(DockContent content) {
});
}
});
KeyChecker.watch(KeyEvent.VK_SHIFT);
KeyChecker.watch(KeyEvent.VK_CONTROL);
}

public DockManager getDock() {
Expand Down Expand Up @@ -386,12 +432,40 @@ private void addDefaultChannel() {

private void addDefaultChannelToDock() {
// Ensure that it's being added in main window
DockPath path = new DockPath(defaultChannel.getDockContent());
path.addParent(DockPathEntry.createPopout(null));
defaultChannel.getDockContent().setTargetPath(path);
setTargetPath(defaultChannel.getDockContent(), "main");
dock.addContent(defaultChannel.getDockContent());
}

private void setTargetPath(DockContent content) {
setTargetPath(content, gui.getSettings().getString("tabsOpen"));
}

private void setTargetPath(DockContent content, String target) {
content.setTargetPath(null);
if (target.equals("active")) {
DockContent active = dock.getActiveContent();
if (active != null) {
content.setTargetPath(active.getPath());
}
}
else if (target.equals("active2")) {
DockContent active = getActiveContent();
if (active != null) {
DockPopout popout = dock.getPopoutFromContent(active);
if ((popout == null && gui.isActive())
|| (popout != null && popout.getWindow().isActive())) {
content.setTargetPath(active.getPath());
}
}
}
// Main in default location
if (content.getTargetPath() == null) {
DockPath path = new DockPath(content);
path.addParent(DockPathEntry.createPopout(null));
content.setTargetPath(path);
}
}

/**
* Adds a channel with the given name. If the default channel is still there
* it is used for this channel and renamed.
Expand All @@ -418,6 +492,7 @@ public Channel addChannel(Room room, Channel.Type type) {
panel = createChannel(room, type);
// Add to channels first so it's already known as "existing"
channels.put(room.getChannel(), panel);
setTargetPath(panel.getDockContent());
dock.addContent(panel.getDockContent());
if (type != Channel.Type.WHISPER) {
dock.setActiveContent(panel.getDockContent());
Expand Down Expand Up @@ -466,6 +541,12 @@ public void removeChannel(final String channelName) {
channel.cleanUp();
}

private void removeContents(Collection<DockContent> contents) {
for (DockContent c : contents) {
c.remove();
}
}

/**
* Add/remove/move default channel depending on whether the main window is
* empty and any other channels are presently added.
Expand Down Expand Up @@ -1069,4 +1150,74 @@ public void setTitle(String title) {

}

private class ClosingDialog extends JDialog {

private final JCheckBox rememberChoice;

private String result = "";

ClosingDialog(DockPopout popout) {
super(popout.getWindow());
setTitle(Language.getString("popoutClose.title"));
setModal(true);
setResizable(false);

setLayout(new GridBagLayout());

JButton closeChannels = new JButton(Language.getString("settings.string.popoutClose.option.close"));
closeChannels.addActionListener(e -> {
result = "close";
setVisible(false);
});

JButton moveChannels = new JButton(Language.getString("settings.string.popoutClose.option.move"));
moveChannels.addActionListener(e -> {
result = "move";
setVisible(false);
});

rememberChoice = new JCheckBox(Language.getString("popoutClose.rememberChoice"));

GridBagConstraints gbc = GuiUtil.makeGbc(1, 0, 1, 1);

Icon icon = UIManager.getIcon("OptionPane.questionIcon");
if (icon != null) {
gbc = GuiUtil.makeGbc(0, 0, 1, 1);
gbc.insets = new Insets(10, 10, 10, 10);
add(new JLabel(icon), gbc);
}

gbc = GuiUtil.makeGbc(1, 0, 2, 1, GridBagConstraints.EAST);
add(new JLabel("<html><body width='250px'><p>"+Language.getString("popoutClose.question")+"</p>"
+ "<p style='margin-top:5px;'>"+Language.getString("popoutClose.keyTip")+"</p>"), gbc);

gbc = GuiUtil.makeGbc(1, 1, 1, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 0.5;
add(closeChannels, gbc);

gbc = GuiUtil.makeGbc(2, 1, 1, 1);
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weightx = 0.5;
gbc.insets = new Insets(5, 5, 5, 10);
add(moveChannels, gbc);

gbc = GuiUtil.makeGbc(1, 2, 2, 1, GridBagConstraints.EAST);
gbc.insets = new Insets(0, 5, 5, 10);
add(rememberChoice, gbc);
pack();
setLocationRelativeTo(popout.getWindow());
setVisible(true);
}

public String getChoice() {
return result;
}

public boolean shouldSaveChoice() {
return rememberChoice.isSelected();
}

}

}
Loading

0 comments on commit e8a13be

Please sign in to comment.