Some refactoring of the config checkboxes

This commit is contained in:
cyian-1756 2017-11-25 22:35:24 -05:00
parent d3a3e6af03
commit ff6aeeda68

View File

@ -146,6 +146,13 @@ public final class MainWindow implements Runnable, RipStatusHandler {
}
private static JCheckBox addNewCheckbox(String text, String configString, Boolean configBool) {
JCheckBox checkbox = new JCheckBox(text, Utils.getConfigBoolean(configString, configBool));
checkbox.setHorizontalAlignment(JCheckBox.RIGHT);
checkbox.setHorizontalTextPosition(JCheckBox.LEFT);
return checkbox;
}
public MainWindow() {
mainFrame = new JFrame("RipMe v" + UpdateUtils.getThisJarVersion());
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
@ -460,48 +467,23 @@ public final class MainWindow implements Runnable, RipStatusHandler {
configThreadsText = new JTextField(Integer.toString(Utils.getConfigInteger("threads.size", 3)));
configTimeoutText = new JTextField(Integer.toString(Utils.getConfigInteger("download.timeout", 60000)));
configRetriesText = new JTextField(Integer.toString(Utils.getConfigInteger("download.retries", 3)));
configOverwriteCheckbox = new JCheckBox("Overwrite existing files?", Utils.getConfigBoolean("file.overwrite", false));
configOverwriteCheckbox.setHorizontalAlignment(JCheckBox.RIGHT);
configOverwriteCheckbox.setHorizontalTextPosition(JCheckBox.LEFT);
configAutoupdateCheckbox = new JCheckBox("Auto-update?", Utils.getConfigBoolean("auto.update", true));
configAutoupdateCheckbox.setHorizontalAlignment(JCheckBox.RIGHT);
configAutoupdateCheckbox.setHorizontalTextPosition(JCheckBox.LEFT);
configOverwriteCheckbox = addNewCheckbox("Overwrite existing files?", "file.overwrite", false);
configAutoupdateCheckbox = addNewCheckbox("Auto-update?", "auto.update", true);
configPlaySound = addNewCheckbox("Sound when rip completes", "play.sound", false);
configShowPopup = addNewCheckbox("Notification when rip starts", "download.show_popup", false);
configSaveOrderCheckbox = addNewCheckbox("Preserve order", "download.save_order", true);
configSaveLogs = addNewCheckbox("Save logs", "log.save", false);
configSaveURLsOnly = addNewCheckbox("Save URLs only", "urls_only.save", false);
configSaveAlbumTitles = addNewCheckbox("Save album titles", "album_titles.save", true);
configClipboardAutorip = addNewCheckbox("Autorip from Clipboard", "clipboard.autorip", false);
configSaveDescriptions = addNewCheckbox("Save descriptions", "descriptions.save", true);
configPreferMp4 = addNewCheckbox("Prefer MP4 over GIF","prefer.mp4", false);
configWindowPosition = addNewCheckbox("Restore window position", "window.position", true);
configURLHistoryCheckbox = addNewCheckbox("Remember URL history", "remember.url_history", true);
configLogLevelCombobox = new JComboBox(new String[] {"Log level: Error", "Log level: Warn", "Log level: Info", "Log level: Debug"});
configLogLevelCombobox.setSelectedItem(Utils.getConfigString("log.level", "Log level: Debug"));
setLogLevel(configLogLevelCombobox.getSelectedItem().toString());
configPlaySound = new JCheckBox("Sound when rip completes", Utils.getConfigBoolean("play.sound", false));
configPlaySound.setHorizontalAlignment(JCheckBox.RIGHT);
configPlaySound.setHorizontalTextPosition(JCheckBox.LEFT);
configSaveOrderCheckbox = new JCheckBox("Preserve order", Utils.getConfigBoolean("download.save_order", true));
configSaveOrderCheckbox.setHorizontalAlignment(JCheckBox.RIGHT);
configSaveOrderCheckbox.setHorizontalTextPosition(JCheckBox.LEFT);
configShowPopup = new JCheckBox("Notification when rip starts", Utils.getConfigBoolean("download.show_popup", false));
configShowPopup.setHorizontalAlignment(JCheckBox.RIGHT);
configShowPopup.setHorizontalTextPosition(JCheckBox.LEFT);
configSaveLogs = new JCheckBox("Save logs", Utils.getConfigBoolean("log.save", false));
configSaveLogs.setHorizontalAlignment(JCheckBox.RIGHT);
configSaveLogs.setHorizontalTextPosition(JCheckBox.LEFT);
configSaveURLsOnly = new JCheckBox("Save URLs only", Utils.getConfigBoolean("urls_only.save", false));
configSaveURLsOnly.setHorizontalAlignment(JCheckBox.RIGHT);
configSaveURLsOnly.setHorizontalTextPosition(JCheckBox.LEFT);
configSaveAlbumTitles = new JCheckBox("Save album titles", Utils.getConfigBoolean("album_titles.save", true));
configSaveAlbumTitles.setHorizontalAlignment(JCheckBox.RIGHT);
configSaveAlbumTitles.setHorizontalTextPosition(JCheckBox.LEFT);
configClipboardAutorip = new JCheckBox("Autorip from Clipboard", Utils.getConfigBoolean("clipboard.autorip", false));
configClipboardAutorip.setHorizontalAlignment(JCheckBox.RIGHT);
configClipboardAutorip.setHorizontalTextPosition(JCheckBox.LEFT);
configSaveDescriptions = new JCheckBox("Save descriptions", Utils.getConfigBoolean("descriptions.save", true));
configSaveDescriptions.setHorizontalAlignment(JCheckBox.RIGHT);
configSaveDescriptions.setHorizontalTextPosition(JCheckBox.LEFT);
configPreferMp4 = new JCheckBox("Prefer MP4 over GIF", Utils.getConfigBoolean("prefer.mp4", false));
configPreferMp4.setHorizontalAlignment(JCheckBox.RIGHT);
configPreferMp4.setHorizontalTextPosition(JCheckBox.LEFT);
configWindowPosition = new JCheckBox("Restore window position", Utils.getConfigBoolean("window.position", true));
configWindowPosition.setHorizontalAlignment(JCheckBox.RIGHT);
configWindowPosition.setHorizontalTextPosition(JCheckBox.LEFT);
configURLHistoryCheckbox = new JCheckBox("Remember URL history", Utils.getConfigBoolean("remember.url_history", true));
configURLHistoryCheckbox.setHorizontalAlignment(JCheckBox.RIGHT);
configURLHistoryCheckbox.setHorizontalTextPosition(JCheckBox.LEFT);
configSaveDirLabel = new JLabel();
try {
String workingDir = (Utils.shortenPath(Utils.getWorkingDirectory()));