Some refactoring of the config checkboxes
This commit is contained in:
parent
d3a3e6af03
commit
ff6aeeda68
@ -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() {
|
public MainWindow() {
|
||||||
mainFrame = new JFrame("RipMe v" + UpdateUtils.getThisJarVersion());
|
mainFrame = new JFrame("RipMe v" + UpdateUtils.getThisJarVersion());
|
||||||
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
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)));
|
configThreadsText = new JTextField(Integer.toString(Utils.getConfigInteger("threads.size", 3)));
|
||||||
configTimeoutText = new JTextField(Integer.toString(Utils.getConfigInteger("download.timeout", 60000)));
|
configTimeoutText = new JTextField(Integer.toString(Utils.getConfigInteger("download.timeout", 60000)));
|
||||||
configRetriesText = new JTextField(Integer.toString(Utils.getConfigInteger("download.retries", 3)));
|
configRetriesText = new JTextField(Integer.toString(Utils.getConfigInteger("download.retries", 3)));
|
||||||
configOverwriteCheckbox = new JCheckBox("Overwrite existing files?", Utils.getConfigBoolean("file.overwrite", false));
|
configOverwriteCheckbox = addNewCheckbox("Overwrite existing files?", "file.overwrite", false);
|
||||||
configOverwriteCheckbox.setHorizontalAlignment(JCheckBox.RIGHT);
|
configAutoupdateCheckbox = addNewCheckbox("Auto-update?", "auto.update", true);
|
||||||
configOverwriteCheckbox.setHorizontalTextPosition(JCheckBox.LEFT);
|
configPlaySound = addNewCheckbox("Sound when rip completes", "play.sound", false);
|
||||||
configAutoupdateCheckbox = new JCheckBox("Auto-update?", Utils.getConfigBoolean("auto.update", true));
|
configShowPopup = addNewCheckbox("Notification when rip starts", "download.show_popup", false);
|
||||||
configAutoupdateCheckbox.setHorizontalAlignment(JCheckBox.RIGHT);
|
configSaveOrderCheckbox = addNewCheckbox("Preserve order", "download.save_order", true);
|
||||||
configAutoupdateCheckbox.setHorizontalTextPosition(JCheckBox.LEFT);
|
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 = 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"));
|
configLogLevelCombobox.setSelectedItem(Utils.getConfigString("log.level", "Log level: Debug"));
|
||||||
setLogLevel(configLogLevelCombobox.getSelectedItem().toString());
|
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();
|
configSaveDirLabel = new JLabel();
|
||||||
try {
|
try {
|
||||||
String workingDir = (Utils.shortenPath(Utils.getWorkingDirectory()));
|
String workingDir = (Utils.shortenPath(Utils.getWorkingDirectory()));
|
||||||
|
Loading…
Reference in New Issue
Block a user