Removed ON OFF Text

This commit is contained in:
DieGurke 2019-12-23 15:20:20 +01:00
parent 91880424d3
commit 3020125334
2 changed files with 14 additions and 85 deletions

View File

@ -57,12 +57,7 @@ public class PrimaryToggleSwitch extends JPanel {
setState(settingsItem.get()); setState(settingsItem.get());
b.addActionListener((evt) -> { b.addActionListener((evt) -> { settingsItem.set(!currentState); setState(!currentState); revalidate(); repaint(); });
settingsItem.set(!currentState);
setState(!currentState);
revalidate();
repaint();
});
repaint(); repaint();
} }

View File

@ -29,8 +29,6 @@ import envoy.client.util.EnvoyLog;
public class General extends SettingsPanel { public class General extends SettingsPanel {
private Theme theme; private Theme theme;
private boolean onCloseState = Settings.getInstance().getCurrentOnCloseMode();
private boolean enterToSend = Settings.getInstance().isEnterToSend();
private static final Logger logger = EnvoyLog.getLogger(General.class.getSimpleName()); private static final Logger logger = EnvoyLog.getLogger(General.class.getSimpleName());
private static final long serialVersionUID = -7470848775130754239L; private static final long serialVersionUID = -7470848775130754239L;
@ -48,53 +46,18 @@ public class General extends SettingsPanel {
GridBagLayout gbl_general = new GridBagLayout(); GridBagLayout gbl_general = new GridBagLayout();
gbl_general.columnWidths = new int[] { 1, 1 }; gbl_general.columnWidths = new int[] { 1, 1 };
gbl_general.rowHeights = new int[] { 1, 1, 1, 1, 1 }; gbl_general.rowHeights = new int[] { 1, 1, 1 };
gbl_general.columnWeights = new double[] { 1.0, 0.1 }; gbl_general.columnWeights = new double[] { 1.0, 0.1 };
gbl_general.rowWeights = new double[] { 0.02, 0.0005, 0.02, 0.0005, 1.0 }; gbl_general.rowWeights = new double[] { 0.02, 0.02, 1.0 };
setLayout(gbl_general); setLayout(gbl_general);
createSettingElement(0, createSettingElement(0, (SettingsItem<Boolean>) Settings.getInstance().getItems().get("onCloseMode"));
(SettingsItem<Boolean>) Settings.getInstance().getItems().get("onCloseMode"));
createSettingElement(2, createSettingElement(1, (SettingsItem<Boolean>) Settings.getInstance().getItems().get("enterToSend"));
(SettingsItem<Boolean>) Settings.getInstance().getItems().get("enterToSend"));
}
// TODO: Move ON / OFF text to PrimaryToggleswitch
/**
* This method changes the on close mode of the client.
*
* @param state This is the integer that defines weather the toggleSwitch is on
* or off.
* @since Envoy v0.3-alpha
*/
public void changeOnClose(boolean state) {
this.onCloseState = state;
//onCloseModeStatePane.setText(state ? "ON" : "OFF");
revalidate();
repaint();
}
/**
* This method changes the enter to send a message setting.
*
* @param state This is the integer that defines weather the toggleSwitch is on
* or off.
* @since Envoy v0.3-alpha
*/
public void changeEnterToSend(boolean state) {
this.enterToSend = state;
//enterToSendStatePane.setText(state ? "ON" : "OFF");
revalidate();
repaint();
} }
private void createSettingElement(int gridy, SettingsItem<Boolean> settingsItem) { private void createSettingElement(int gridy, SettingsItem<Boolean> settingsItem) {
JTextPane stateText = new JTextPane();
JTextPane descriptionText = new JTextPane(); JTextPane descriptionText = new JTextPane();
PrimaryToggleSwitch toggleSwitch = new PrimaryToggleSwitch(settingsItem); PrimaryToggleSwitch toggleSwitch = new PrimaryToggleSwitch(settingsItem);
@ -105,18 +68,6 @@ public class General extends SettingsPanel {
add(toggleSwitch, gbc_toggleSwitch); add(toggleSwitch, gbc_toggleSwitch);
stateText.setText(settingsItem.get() ? "ON" : "OFF");
stateText.setBackground(theme.getCellColor());
stateText.setForeground(theme.getUserNameColor());
stateText.setEditable(false);
GridBagConstraints gbc_stateText = new GridBagConstraints();
gbc_stateText.anchor = GridBagConstraints.NORTH;
gbc_stateText.gridx = 1;
gbc_stateText.gridy = gridy + 1;
add(stateText, gbc_stateText);
descriptionText.setText(settingsItem.getDescription()); descriptionText.setText(settingsItem.getDescription());
descriptionText.setBackground(theme.getBackgroundColor()); descriptionText.setBackground(theme.getBackgroundColor());
descriptionText.setForeground(theme.getBackgroundColor().invert()); descriptionText.setForeground(theme.getBackgroundColor().invert());
@ -126,28 +77,11 @@ public class General extends SettingsPanel {
gbc_descriptionText.fill = GridBagConstraints.BOTH; gbc_descriptionText.fill = GridBagConstraints.BOTH;
gbc_descriptionText.gridx = 0; gbc_descriptionText.gridx = 0;
gbc_descriptionText.gridy = gridy; gbc_descriptionText.gridy = gridy;
gbc_descriptionText.gridheight = 2;
gbc_descriptionText.insets = new Insets(5, 5, 5, 5); gbc_descriptionText.insets = new Insets(5, 5, 5, 5);
add(descriptionText, gbc_descriptionText); add(descriptionText, gbc_descriptionText);
} }
@Override @Override
public ActionListener getOkButtonAction() { public ActionListener getOkButtonAction() { return null; }
return (evt) -> {
if (onCloseState != Settings.getInstance().getCurrentOnCloseMode()) try {
Settings.getInstance().setCurrentOnCloseMode(onCloseState);
JOptionPane.showMessageDialog(null, "The changes will take effect the next time the program is started.");
} catch (Exception e) {
logger.log(Level.WARNING, "Close mode could not be changed! ", e);
}
if (enterToSend != Settings.getInstance().isEnterToSend()) try {
Settings.getInstance().setEnterToSend(enterToSend);
JOptionPane.showMessageDialog(null, "The changes will take effect the next time the program is started.");
} catch (Exception e) {
logger.log(Level.WARNING, "Enter to send mode could not be changed! ", e);
}
};
}
} }