Added ThemeChangeEvent, improved EventHandler declaration
This commit is contained in:
@ -30,6 +30,8 @@ import envoy.client.Client;
|
||||
import envoy.client.Config;
|
||||
import envoy.client.LocalDB;
|
||||
import envoy.client.Settings;
|
||||
import envoy.client.event.EventBus;
|
||||
import envoy.client.event.ThemeChangeEvent;
|
||||
import envoy.schema.Message;
|
||||
import envoy.schema.User;
|
||||
|
||||
@ -166,7 +168,6 @@ public class ChatWindow extends JFrame {
|
||||
settingsButton.addActionListener((evt) -> {
|
||||
try {
|
||||
SettingsScreen.open();
|
||||
changeChatWindowColors(Settings.getInstance().getCurrentTheme());
|
||||
} catch (Exception e) {
|
||||
SettingsScreen.open();
|
||||
logger.log(Level.WARNING, "An error occured while opening the settings screen", e);
|
||||
@ -220,11 +221,13 @@ public class ChatWindow extends JFrame {
|
||||
gbc_userList.anchor = GridBagConstraints.PAGE_START;
|
||||
gbc_userList.insets = new Insets(space, space, space, space);
|
||||
|
||||
changeChatWindowColors(Settings.getInstance().getCurrentTheme());
|
||||
changeChatWindowColors(Settings.getInstance().getThemes().get(Settings.getInstance().getCurrentTheme()));
|
||||
|
||||
contentPane.add(userList, gbc_userList);
|
||||
contentPane.revalidate();
|
||||
|
||||
EventBus.getInstance().register(ThemeChangeEvent.class, (evt) -> changeChatWindowColors((Theme) evt.get()));
|
||||
|
||||
loadUsersAndChats();
|
||||
|
||||
if (client.isOnline()) startSyncThread(Config.getInstance().getSyncTimeout());
|
||||
@ -237,9 +240,7 @@ public class ChatWindow extends JFrame {
|
||||
*
|
||||
* @since Envoy v0.1-alpha
|
||||
*/
|
||||
public void changeChatWindowColors(String key) {
|
||||
Theme theme = Settings.getInstance().getThemes().get(key);
|
||||
|
||||
private void changeChatWindowColors(Theme theme) {
|
||||
// contentPane
|
||||
contentPane.setBackground(theme.getBackgroundColor());
|
||||
contentPane.setForeground(theme.getUserNameColor());
|
||||
|
Reference in New Issue
Block a user