forked from j62/ctbrec
Write config immediately after a value changed
This commit is contained in:
parent
9a51cff240
commit
e5ff778d6b
|
@ -29,10 +29,12 @@ public class ColorSettingsPane extends Pane {
|
|||
baseColor.setOnAction(evt -> {
|
||||
Config.getInstance().getSettings().colorBase = toWeb(baseColor.getValue());
|
||||
settingsTab.showRestartRequired();
|
||||
settingsTab.saveConfig();
|
||||
});
|
||||
accentColor.setOnAction(evt -> {
|
||||
Config.getInstance().getSettings().colorAccent = toWeb(accentColor.getValue());
|
||||
settingsTab.showRestartRequired();
|
||||
settingsTab.saveConfig();
|
||||
});
|
||||
reset.setOnAction(evt -> {
|
||||
baseColor.setValue(Color.WHITE);
|
||||
|
@ -40,6 +42,7 @@ public class ColorSettingsPane extends Pane {
|
|||
accentColor.setValue(Color.WHITE);
|
||||
Config.getInstance().getSettings().colorAccent = toWeb(Color.WHITE);
|
||||
settingsTab.showRestartRequired();
|
||||
settingsTab.saveConfig();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -51,18 +51,23 @@ public class ProxySettingsPane extends TitledPane implements EventHandler<Action
|
|||
l = new Label("Host");
|
||||
layout.add(l, 0, 1);
|
||||
layout.add(proxyHost, 1, 1);
|
||||
proxyHost.textProperty().addListener((ob, o, n) -> settingsTab.saveConfig());
|
||||
|
||||
l = new Label("Port");
|
||||
layout.add(l, 0, 2);
|
||||
layout.add(proxyPort, 1, 2);
|
||||
proxyPort.textProperty().addListener((ob, o, n) -> settingsTab.saveConfig());
|
||||
|
||||
l = new Label("Username");
|
||||
layout.add(l, 0, 3);
|
||||
layout.add(proxyUser, 1, 3);
|
||||
proxyUser.textProperty().addListener((ob, o, n) -> settingsTab.saveConfig());
|
||||
|
||||
|
||||
l = new Label("Password");
|
||||
layout.add(l, 0, 4);
|
||||
layout.add(proxyPassword, 1, 4);
|
||||
proxyPassword.textProperty().addListener((ob, o, n) -> settingsTab.saveConfig());
|
||||
}
|
||||
|
||||
private void loadConfig() {
|
||||
|
@ -86,6 +91,7 @@ public class ProxySettingsPane extends TitledPane implements EventHandler<Action
|
|||
public void handle(ActionEvent event) {
|
||||
setComponentDisableState();
|
||||
settingsTab.showRestartRequired();
|
||||
settingsTab.saveConfig();
|
||||
}
|
||||
|
||||
private void setComponentDisableState() {
|
||||
|
|
|
@ -154,6 +154,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
|||
} else {
|
||||
settings.disabledSites.add(site.getName());
|
||||
}
|
||||
saveConfig();
|
||||
showRestartRequired();
|
||||
});
|
||||
GridPane.setMargin(l, new Insets(CHECKBOX_MARGIN, 0, 0, 0));
|
||||
|
@ -183,6 +184,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
|||
Config.getInstance().getSettings().localRecording = recordLocal.isSelected();
|
||||
setRecordingMode(recordLocal.isSelected());
|
||||
showRestartRequired();
|
||||
saveConfig();
|
||||
});
|
||||
GridPane.setMargin(l, new Insets(0, 0, CHECKBOX_MARGIN, 0));
|
||||
GridPane.setMargin(recordLocal, new Insets(0, 0, CHECKBOX_MARGIN, 0));
|
||||
|
@ -190,9 +192,10 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
|||
|
||||
layout.add(new Label("Server"), 0, 1);
|
||||
server = new TextField(Config.getInstance().getSettings().httpServer);
|
||||
server.focusedProperty().addListener((e) -> {
|
||||
server.textProperty().addListener((ob, o, n) -> {
|
||||
if(!server.getText().isEmpty()) {
|
||||
Config.getInstance().getSettings().httpServer = server.getText();
|
||||
saveConfig();
|
||||
}
|
||||
});
|
||||
GridPane.setFillWidth(server, true);
|
||||
|
@ -202,18 +205,27 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
|||
|
||||
layout.add(new Label("Port"), 0, 2);
|
||||
port = new TextField(Integer.toString(Config.getInstance().getSettings().httpPort));
|
||||
port.focusedProperty().addListener((e) -> {
|
||||
port.textProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if (!newValue.matches("\\d*")) {
|
||||
port.setText(newValue.replaceAll("[^\\d]", ""));
|
||||
}
|
||||
if(!port.getText().isEmpty()) {
|
||||
try {
|
||||
Config.getInstance().getSettings().httpPort = Integer.parseInt(port.getText());
|
||||
port.setBorder(Border.EMPTY);
|
||||
port.setTooltip(null);
|
||||
} catch (NumberFormatException e1) {
|
||||
port.setBorder(new Border(new BorderStroke(Color.RED, BorderStrokeStyle.DASHED, new CornerRadii(2), new BorderWidths(2))));
|
||||
port.setTooltip(new Tooltip("Port has to be a number in the range 1 - 65536"));
|
||||
}
|
||||
Config.getInstance().getSettings().httpPort = Integer.parseInt(port.getText());
|
||||
saveConfig();
|
||||
}
|
||||
});
|
||||
// port.focusedProperty().addListener((e) -> {
|
||||
// if(!port.getText().isEmpty()) {
|
||||
// try {
|
||||
// Config.getInstance().getSettings().httpPort = Integer.parseInt(port.getText());
|
||||
// port.setBorder(Border.EMPTY);
|
||||
// port.setTooltip(null);
|
||||
// } catch (NumberFormatException e1) {
|
||||
// port.setBorder(new Border(new BorderStroke(Color.RED, BorderStrokeStyle.DASHED, new CornerRadii(2), new BorderWidths(2))));
|
||||
// port.setTooltip(new Tooltip("Port has to be a number in the range 1 - 65536"));
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
GridPane.setFillWidth(port, true);
|
||||
GridPane.setHgrow(port, Priority.ALWAYS);
|
||||
GridPane.setColumnSpan(port, 2);
|
||||
|
@ -229,6 +241,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
|||
if(key == null) {
|
||||
key = Hmac.generateKey();
|
||||
Config.getInstance().getSettings().key = key;
|
||||
saveConfig();
|
||||
}
|
||||
TextInputDialog keyDialog = new TextInputDialog();
|
||||
keyDialog.setResizable(true);
|
||||
|
@ -273,7 +286,10 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
|||
options.add(ONE_PER_RECORDING);
|
||||
directoryStructure = new ComboBox<>(FXCollections.observableList(options));
|
||||
directoryStructure.setValue(Config.getInstance().getSettings().recordingsDirStructure);
|
||||
directoryStructure.setOnAction((evt) -> Config.getInstance().getSettings().recordingsDirStructure = directoryStructure.getValue());
|
||||
directoryStructure.setOnAction((evt) -> {
|
||||
Config.getInstance().getSettings().recordingsDirStructure = directoryStructure.getValue();
|
||||
saveConfig();
|
||||
});
|
||||
GridPane.setColumnSpan(directoryStructure, 2);
|
||||
GridPane.setMargin(directoryStructure, new Insets(0, 0, 0, CHECKBOX_MARGIN));
|
||||
layout.add(directoryStructure, 1, row++);
|
||||
|
@ -313,6 +329,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
|||
loadResolution.setSelected(Config.getInstance().getSettings().determineResolution);
|
||||
loadResolution.setOnAction((e) -> {
|
||||
Config.getInstance().getSettings().determineResolution = loadResolution.isSelected();
|
||||
saveConfig();
|
||||
if(!loadResolution.isSelected()) {
|
||||
ThumbOverviewTab.queue.clear();
|
||||
}
|
||||
|
@ -324,7 +341,10 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
|||
l = new Label("Allow multiple players");
|
||||
layout.add(l, 0, row);
|
||||
multiplePlayers.setSelected(!Config.getInstance().getSettings().singlePlayer);
|
||||
multiplePlayers.setOnAction((e) -> Config.getInstance().getSettings().singlePlayer = !multiplePlayers.isSelected());
|
||||
multiplePlayers.setOnAction((e) -> {
|
||||
Config.getInstance().getSettings().singlePlayer = !multiplePlayers.isSelected();
|
||||
saveConfig();
|
||||
});
|
||||
GridPane.setMargin(l, new Insets(3, 0, 0, 0));
|
||||
GridPane.setMargin(multiplePlayers, new Insets(CHECKBOX_MARGIN, 0, 0, CHECKBOX_MARGIN));
|
||||
layout.add(multiplePlayers, 1, row++);
|
||||
|
@ -332,7 +352,10 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
|||
l = new Label("Manually select stream quality");
|
||||
layout.add(l, 0, row);
|
||||
chooseStreamQuality.setSelected(Config.getInstance().getSettings().chooseStreamQuality);
|
||||
chooseStreamQuality.setOnAction((e) -> Config.getInstance().getSettings().chooseStreamQuality = chooseStreamQuality.isSelected());
|
||||
chooseStreamQuality.setOnAction((e) -> {
|
||||
Config.getInstance().getSettings().chooseStreamQuality = chooseStreamQuality.isSelected();
|
||||
saveConfig();
|
||||
});
|
||||
GridPane.setMargin(l, new Insets(CHECKBOX_MARGIN, 0, 0, 0));
|
||||
GridPane.setMargin(chooseStreamQuality, new Insets(CHECKBOX_MARGIN, 0, 0, CHECKBOX_MARGIN));
|
||||
layout.add(chooseStreamQuality, 1, row++);
|
||||
|
@ -340,7 +363,10 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
|||
l = new Label("Update thumbnails");
|
||||
layout.add(l, 0, row);
|
||||
updateThumbnails.setSelected(Config.getInstance().getSettings().updateThumbnails);
|
||||
updateThumbnails.setOnAction((e) -> Config.getInstance().getSettings().updateThumbnails = updateThumbnails.isSelected());
|
||||
updateThumbnails.setOnAction((e) -> {
|
||||
Config.getInstance().getSettings().updateThumbnails = updateThumbnails.isSelected();
|
||||
saveConfig();
|
||||
});
|
||||
GridPane.setMargin(l, new Insets(CHECKBOX_MARGIN, 0, 0, 0));
|
||||
GridPane.setMargin(updateThumbnails, new Insets(CHECKBOX_MARGIN, 0, 0, CHECKBOX_MARGIN));
|
||||
layout.add(updateThumbnails, 1, row++);
|
||||
|
@ -355,7 +381,10 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
|||
resolutionOptions.add(0);
|
||||
maxResolution = new ComboBox<>(FXCollections.observableList(resolutionOptions));
|
||||
setMaxResolutionValue();
|
||||
maxResolution.setOnAction((e) -> Config.getInstance().getSettings().maximumResolution = maxResolution.getSelectionModel().getSelectedItem());
|
||||
maxResolution.setOnAction((e) -> {
|
||||
Config.getInstance().getSettings().maximumResolution = maxResolution.getSelectionModel().getSelectedItem();
|
||||
saveConfig();
|
||||
});
|
||||
layout.add(maxResolution, 1, row++);
|
||||
GridPane.setMargin(l, new Insets(CHECKBOX_MARGIN, 0, 0, 0));
|
||||
GridPane.setMargin(maxResolution, new Insets(CHECKBOX_MARGIN, 0, 0, CHECKBOX_MARGIN));
|
||||
|
@ -372,7 +401,10 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
|||
splitAfter = new ComboBox<>(FXCollections.observableList(options));
|
||||
layout.add(splitAfter, 1, row++);
|
||||
setSplitAfterValue();
|
||||
splitAfter.setOnAction((e) -> Config.getInstance().getSettings().splitRecordings = splitAfter.getSelectionModel().getSelectedItem().getValue());
|
||||
splitAfter.setOnAction((e) -> {
|
||||
Config.getInstance().getSettings().splitRecordings = splitAfter.getSelectionModel().getSelectedItem().getValue();
|
||||
saveConfig();
|
||||
});
|
||||
GridPane.setMargin(l, new Insets(0, 0, 0, 0));
|
||||
GridPane.setMargin(splitAfter, new Insets(0, 0, 0, CHECKBOX_MARGIN));
|
||||
|
||||
|
@ -380,7 +412,10 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
|||
layout.add(l, 0, row);
|
||||
startTab = new ComboBox<>();
|
||||
layout.add(startTab, 1, row++);
|
||||
startTab.setOnAction((e) -> Config.getInstance().getSettings().startTab = startTab.getSelectionModel().getSelectedItem());
|
||||
startTab.setOnAction((e) -> {
|
||||
Config.getInstance().getSettings().startTab = startTab.getSelectionModel().getSelectedItem();
|
||||
saveConfig();
|
||||
});
|
||||
GridPane.setMargin(l, new Insets(0, 0, 0, 0));
|
||||
GridPane.setMargin(startTab, new Insets(0, 0, 0, CHECKBOX_MARGIN));
|
||||
|
||||
|
@ -488,6 +523,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
|||
setPostProcessing(program);
|
||||
} else {
|
||||
Config.getInstance().getSettings().postProcessing = "";
|
||||
saveConfig();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -501,6 +537,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
|||
mediaPlayer.setTooltip(new Tooltip(msg));
|
||||
} else {
|
||||
Config.getInstance().getSettings().mediaPlayer = mediaPlayer.getText();
|
||||
saveConfig();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -511,6 +548,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
|||
postProcessing.setTooltip(new Tooltip(msg));
|
||||
} else {
|
||||
Config.getInstance().getSettings().postProcessing = postProcessing.getText();
|
||||
saveConfig();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -587,6 +625,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
|||
String path = dir.getCanonicalPath();
|
||||
Config.getInstance().getSettings().recordingsDir = path;
|
||||
recordingsDirectory.setText(path);
|
||||
saveConfig();
|
||||
} catch (IOException e1) {
|
||||
LOG.error("Couldn't determine directory path", e1);
|
||||
Alert alert = new AutosizeAlert(Alert.AlertType.ERROR);
|
||||
|
@ -625,6 +664,11 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
|||
|
||||
public void saveConfig() {
|
||||
proxySettingsPane.saveConfig();
|
||||
try {
|
||||
Config.getInstance().save();
|
||||
} catch (IOException e) {
|
||||
LOG.error("Couldn't save config", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static class SplitAfterOption {
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package ctbrec.ui.sites;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.sites.ConfigUI;
|
||||
|
||||
public abstract class AbstractConfigUI implements ConfigUI {
|
||||
|
||||
private static final transient Logger LOG = LoggerFactory.getLogger(AbstractConfigUI.class);
|
||||
|
||||
protected void save() {
|
||||
try {
|
||||
Config.getInstance().save();
|
||||
} catch (IOException e) {
|
||||
LOG.error("Couldn't save config");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,10 +1,10 @@
|
|||
package ctbrec.ui.sites.bonga;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.sites.ConfigUI;
|
||||
import ctbrec.sites.bonga.BongaCams;
|
||||
import ctbrec.ui.DesktopIntegration;
|
||||
import ctbrec.ui.SettingsTab;
|
||||
import ctbrec.ui.sites.AbstractConfigUI;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.control.Button;
|
||||
|
@ -14,8 +14,7 @@ import javafx.scene.control.TextField;
|
|||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.Priority;
|
||||
|
||||
public class BongaCamsConfigUI implements ConfigUI {
|
||||
|
||||
public class BongaCamsConfigUI extends AbstractConfigUI {
|
||||
private BongaCams bongaCams;
|
||||
|
||||
public BongaCamsConfigUI(BongaCams bongaCams) {
|
||||
|
@ -27,7 +26,10 @@ public class BongaCamsConfigUI implements ConfigUI {
|
|||
GridPane layout = SettingsTab.createGridLayout();
|
||||
layout.add(new Label("BongaCams User"), 0, 0);
|
||||
TextField username = new TextField(Config.getInstance().getSettings().bongaUsername);
|
||||
username.focusedProperty().addListener((e) -> Config.getInstance().getSettings().bongaUsername = username.getText());
|
||||
username.textProperty().addListener((ob, o, n) -> {
|
||||
Config.getInstance().getSettings().bongaUsername = username.getText();
|
||||
save();
|
||||
});
|
||||
GridPane.setFillWidth(username, true);
|
||||
GridPane.setHgrow(username, Priority.ALWAYS);
|
||||
GridPane.setColumnSpan(username, 2);
|
||||
|
@ -36,7 +38,10 @@ public class BongaCamsConfigUI implements ConfigUI {
|
|||
layout.add(new Label("BongaCams Password"), 0, 1);
|
||||
PasswordField password = new PasswordField();
|
||||
password.setText(Config.getInstance().getSettings().bongaPassword);
|
||||
password.focusedProperty().addListener((e) -> Config.getInstance().getSettings().bongaPassword = password.getText());
|
||||
password.focusedProperty().addListener((e) -> {
|
||||
Config.getInstance().getSettings().bongaPassword = password.getText();
|
||||
save();
|
||||
});
|
||||
GridPane.setFillWidth(password, true);
|
||||
GridPane.setHgrow(password, Priority.ALWAYS);
|
||||
GridPane.setColumnSpan(password, 2);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package ctbrec.ui.sites.cam4;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.sites.ConfigUI;
|
||||
import ctbrec.sites.cam4.Cam4;
|
||||
import ctbrec.ui.DesktopIntegration;
|
||||
import ctbrec.ui.SettingsTab;
|
||||
import ctbrec.ui.sites.AbstractConfigUI;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.control.Button;
|
||||
|
@ -14,14 +14,16 @@ import javafx.scene.control.TextField;
|
|||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.Priority;
|
||||
|
||||
public class Cam4ConfigUI implements ConfigUI {
|
||||
|
||||
public class Cam4ConfigUI extends AbstractConfigUI {
|
||||
@Override
|
||||
public Parent createConfigPanel() {
|
||||
GridPane layout = SettingsTab.createGridLayout();
|
||||
layout.add(new Label("Cam4 User"), 0, 0);
|
||||
TextField username = new TextField(Config.getInstance().getSettings().cam4Username);
|
||||
username.focusedProperty().addListener((e) -> Config.getInstance().getSettings().cam4Username = username.getText());
|
||||
username.textProperty().addListener((ob, o, n) -> {
|
||||
Config.getInstance().getSettings().cam4Username = username.getText();
|
||||
save();
|
||||
});
|
||||
GridPane.setFillWidth(username, true);
|
||||
GridPane.setHgrow(username, Priority.ALWAYS);
|
||||
GridPane.setColumnSpan(username, 2);
|
||||
|
@ -30,7 +32,10 @@ public class Cam4ConfigUI implements ConfigUI {
|
|||
layout.add(new Label("Cam4 Password"), 0, 1);
|
||||
PasswordField password = new PasswordField();
|
||||
password.setText(Config.getInstance().getSettings().cam4Password);
|
||||
password.focusedProperty().addListener((e) -> Config.getInstance().getSettings().cam4Password = password.getText());
|
||||
password.focusedProperty().addListener((e) -> {
|
||||
Config.getInstance().getSettings().cam4Password = password.getText();
|
||||
save();
|
||||
});
|
||||
GridPane.setFillWidth(password, true);
|
||||
GridPane.setHgrow(password, Priority.ALWAYS);
|
||||
GridPane.setColumnSpan(password, 2);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package ctbrec.ui.sites.camsoda;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.sites.ConfigUI;
|
||||
import ctbrec.sites.camsoda.Camsoda;
|
||||
import ctbrec.ui.DesktopIntegration;
|
||||
import ctbrec.ui.SettingsTab;
|
||||
import ctbrec.ui.sites.AbstractConfigUI;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.control.Button;
|
||||
|
@ -14,8 +14,7 @@ import javafx.scene.control.TextField;
|
|||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.Priority;
|
||||
|
||||
public class CamsodaConfigUI implements ConfigUI {
|
||||
|
||||
public class CamsodaConfigUI extends AbstractConfigUI {
|
||||
private Camsoda camsoda;
|
||||
|
||||
public CamsodaConfigUI(Camsoda camsoda) {
|
||||
|
@ -27,7 +26,10 @@ public class CamsodaConfigUI implements ConfigUI {
|
|||
GridPane layout = SettingsTab.createGridLayout();
|
||||
layout.add(new Label("CamSoda User"), 0, 0);
|
||||
TextField username = new TextField(Config.getInstance().getSettings().camsodaUsername);
|
||||
username.focusedProperty().addListener((e) -> Config.getInstance().getSettings().camsodaUsername = username.getText());
|
||||
username.textProperty().addListener((ob, o, n) -> {
|
||||
Config.getInstance().getSettings().camsodaUsername = username.getText();
|
||||
save();
|
||||
});
|
||||
GridPane.setFillWidth(username, true);
|
||||
GridPane.setHgrow(username, Priority.ALWAYS);
|
||||
GridPane.setColumnSpan(username, 2);
|
||||
|
@ -36,7 +38,10 @@ public class CamsodaConfigUI implements ConfigUI {
|
|||
layout.add(new Label("CamSoda Password"), 0, 1);
|
||||
PasswordField password = new PasswordField();
|
||||
password.setText(Config.getInstance().getSettings().camsodaPassword);
|
||||
password.focusedProperty().addListener((e) -> Config.getInstance().getSettings().camsodaPassword = password.getText());
|
||||
password.textProperty().addListener((ob, o, n) -> {
|
||||
Config.getInstance().getSettings().camsodaPassword = password.getText();
|
||||
save();
|
||||
});
|
||||
GridPane.setFillWidth(password, true);
|
||||
GridPane.setHgrow(password, Priority.ALWAYS);
|
||||
GridPane.setColumnSpan(password, 2);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package ctbrec.ui.sites.chaturbate;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.sites.ConfigUI;
|
||||
import ctbrec.sites.chaturbate.Chaturbate;
|
||||
import ctbrec.ui.DesktopIntegration;
|
||||
import ctbrec.ui.SettingsTab;
|
||||
import ctbrec.ui.sites.AbstractConfigUI;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.control.Button;
|
||||
|
@ -14,14 +14,17 @@ import javafx.scene.control.TextField;
|
|||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.Priority;
|
||||
|
||||
public class ChaturbateConfigUi implements ConfigUI {
|
||||
public class ChaturbateConfigUi extends AbstractConfigUI {
|
||||
@Override
|
||||
public Parent createConfigPanel() {
|
||||
GridPane layout = SettingsTab.createGridLayout();
|
||||
|
||||
layout.add(new Label("Chaturbate User"), 0, 0);
|
||||
TextField username = new TextField(Config.getInstance().getSettings().username);
|
||||
username.focusedProperty().addListener((e) -> Config.getInstance().getSettings().username = username.getText());
|
||||
username.textProperty().addListener((ob, o, n) -> {
|
||||
Config.getInstance().getSettings().username = username.getText();
|
||||
save();
|
||||
});
|
||||
GridPane.setFillWidth(username, true);
|
||||
GridPane.setHgrow(username, Priority.ALWAYS);
|
||||
GridPane.setColumnSpan(username, 2);
|
||||
|
@ -30,7 +33,10 @@ public class ChaturbateConfigUi implements ConfigUI {
|
|||
layout.add(new Label("Chaturbate Password"), 0, 1);
|
||||
PasswordField password = new PasswordField();
|
||||
password.setText(Config.getInstance().getSettings().password);
|
||||
password.focusedProperty().addListener((e) -> Config.getInstance().getSettings().password = password.getText());
|
||||
password.textProperty().addListener((ob, o, n) -> {
|
||||
Config.getInstance().getSettings().password = password.getText();
|
||||
save();
|
||||
});
|
||||
GridPane.setFillWidth(password, true);
|
||||
GridPane.setHgrow(password, Priority.ALWAYS);
|
||||
GridPane.setColumnSpan(password, 2);
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package ctbrec.ui.sites.myfreecams;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.sites.ConfigUI;
|
||||
import ctbrec.sites.mfc.MyFreeCams;
|
||||
import ctbrec.ui.DesktopIntegration;
|
||||
import ctbrec.ui.SettingsTab;
|
||||
import ctbrec.ui.sites.AbstractConfigUI;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.scene.Parent;
|
||||
import javafx.scene.control.Button;
|
||||
|
@ -14,8 +14,7 @@ import javafx.scene.control.TextField;
|
|||
import javafx.scene.layout.GridPane;
|
||||
import javafx.scene.layout.Priority;
|
||||
|
||||
public class MyFreeCamsConfigUI implements ConfigUI {
|
||||
|
||||
public class MyFreeCamsConfigUI extends AbstractConfigUI {
|
||||
private MyFreeCams myFreeCams;
|
||||
|
||||
public MyFreeCamsConfigUI(MyFreeCams myFreeCams) {
|
||||
|
@ -27,7 +26,10 @@ public class MyFreeCamsConfigUI implements ConfigUI {
|
|||
GridPane layout = SettingsTab.createGridLayout();
|
||||
layout.add(new Label("MyFreeCams User"), 0, 0);
|
||||
TextField username = new TextField(Config.getInstance().getSettings().mfcUsername);
|
||||
username.focusedProperty().addListener((e) -> Config.getInstance().getSettings().mfcUsername = username.getText());
|
||||
username.textProperty().addListener((ob, o, n) -> {
|
||||
Config.getInstance().getSettings().mfcUsername = username.getText();
|
||||
save();
|
||||
});
|
||||
GridPane.setFillWidth(username, true);
|
||||
GridPane.setHgrow(username, Priority.ALWAYS);
|
||||
GridPane.setColumnSpan(username, 2);
|
||||
|
@ -36,7 +38,10 @@ public class MyFreeCamsConfigUI implements ConfigUI {
|
|||
layout.add(new Label("MyFreeCams Password"), 0, 1);
|
||||
PasswordField password = new PasswordField();
|
||||
password.setText(Config.getInstance().getSettings().mfcPassword);
|
||||
password.focusedProperty().addListener((e) -> Config.getInstance().getSettings().mfcPassword = password.getText());
|
||||
password.textProperty().addListener((ob, o, n) -> {
|
||||
Config.getInstance().getSettings().mfcPassword = password.getText();
|
||||
save();
|
||||
});
|
||||
GridPane.setFillWidth(password, true);
|
||||
GridPane.setHgrow(password, Priority.ALWAYS);
|
||||
GridPane.setColumnSpan(password, 2);
|
||||
|
@ -51,5 +56,4 @@ public class MyFreeCamsConfigUI implements ConfigUI {
|
|||
GridPane.setMargin(createAccount, new Insets(0, 0, 0, SettingsTab.CHECKBOX_MARGIN));
|
||||
return layout;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue