Add setting to show total model count in title bar

This commit is contained in:
0xb00bface 2021-01-02 14:49:56 +01:00
parent 7b65ab44f1
commit b0eb6e4411
6 changed files with 37 additions and 5 deletions

View File

@ -1,6 +1,8 @@
package ctbrec.ui;
import static ctbrec.event.Event.Type.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
@ -349,11 +351,12 @@ public class CamrecApplication extends Application {
EventBusHolder.BUS.register(new Object() {
@Subscribe
public void handleEvent(Event evt) {
if(evt.getType() == Event.Type.MODEL_ONLINE || evt.getType() == Event.Type.MODEL_STATUS_CHANGED || evt.getType() == Event.Type.RECORDING_STATUS_CHANGED) {
if (evt.getType() == MODEL_ONLINE || evt.getType() == MODEL_STATUS_CHANGED || evt.getType() == RECORDING_STATUS_CHANGED) {
try {
List<Model> models = recorder.getCurrentlyRecording();
activeRecordings = models.size();
String windowTitle = activeRecordings > 0 ? "(" + activeRecordings + ") " + title : title;
int modelCount = recorder.getModelCount();
List<Model> currentlyRecording = recorder.getCurrentlyRecording();
activeRecordings = currentlyRecording.size();
String windowTitle = getActiveRecordings(activeRecordings, modelCount) + title;
Platform.runLater(() -> primaryStage.setTitle(windowTitle));
updateStatus();
} catch (Exception e) {
@ -361,6 +364,19 @@ public class CamrecApplication extends Application {
}
}
}
private String getActiveRecordings(int activeRecordings, int modelCount) {
if (activeRecordings > 0) {
StringBuilder s = new StringBuilder("(").append(activeRecordings);
if (config.getSettings().totalModelCountInTitle) {
s.append("/").append(modelCount);
}
s.append(") ");
return s.toString();
} else {
return "";
}
}
});
}
@ -377,7 +393,7 @@ public class CamrecApplication extends Application {
bytesPerSecond = 0;
}
String humanReadable = ByteUnitFormatter.format(bytesPerSecond);
String status = String.format("Recording %s / %s models @ %s/s", activeRecordings, recorder.getModels().size(), humanReadable);
String status = String.format("Recording %s / %s models @ %s/s", activeRecordings, recorder.getModelCount(), humanReadable);
Platform.runLater(() -> statusLabel.setText(status));
}

View File

@ -123,6 +123,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
private SimpleStringProperty path;
private SimpleStringProperty downloadFilename;
private SimpleBooleanProperty requireAuthentication;
private SimpleBooleanProperty totalModelCountInTitle;
private SimpleBooleanProperty transportLayerSecurity;
private SimpleBooleanProperty fastScrollSpeed;
private ExclusiveSelectionProperty recordLocal;
@ -176,6 +177,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
downloadFilename = new SimpleStringProperty(null, "downloadFilename", settings.downloadFilename);
requireAuthentication = new SimpleBooleanProperty(null, "requireAuthentication", settings.requireAuthentication);
requireAuthentication.addListener(this::requireAuthenticationChanged);
totalModelCountInTitle = new SimpleBooleanProperty(null, "totalModelCountInTitle", settings.totalModelCountInTitle);
transportLayerSecurity = new SimpleBooleanProperty(null, "transportLayerSecurity", settings.transportLayerSecurity);
recordLocal = new ExclusiveSelectionProperty(null, "localRecording", settings.localRecording, "Local", "Remote");
postProcessingThreads = new SimpleIntegerProperty(null, "postProcessingThreads", settings.postProcessingThreads);
@ -208,6 +210,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
Setting.of("Add models from clipboard", monitorClipboard, "Monitor clipboard for model URLs and automatically add them to the recorder").needsRestart(),
Setting.of("Fast scroll speed", fastScrollSpeed, "Makes the thumbnail overviews scroll faster with the mouse wheel").needsRestart(),
Setting.of("Show confirmation dialogs", confirmationDialogs, "Show confirmation dialogs for irreversible actions"),
Setting.of("Total model count in title", totalModelCountInTitle, "Show the total number of models in the title bar"),
Setting.of("Start Tab", startTab),
Setting.of("Colors (Base / Accent)", new ColorSettingsPane(Config.getInstance())).needsRestart()
),

View File

@ -147,6 +147,7 @@ public class Settings {
public String stripchatUsername = "";
public String stripchatPassword = "";
public boolean stripchatUseXhamster = false;
public boolean totalModelCountInTitle = false;
public boolean transportLayerSecurity = true;
public int thumbWidth = 180;
public boolean updateThumbnails = true;

View File

@ -722,4 +722,9 @@ public class NextGenLocalRecorder implements Recorder {
LOG.info("Resuming recorder");
recording = true;
}
@Override
public int getModelCount() {
return models.size();
}
}

View File

@ -140,4 +140,6 @@ public interface Recorder {
* @throws InvalidKeyException
*/
public void resume() throws InvalidKeyException, NoSuchAlgorithmException, IOException;
public int getModelCount();
}

View File

@ -591,4 +591,9 @@ public class RemoteRecorder implements Recorder {
public void resume() throws InvalidKeyException, NoSuchAlgorithmException, IOException {
sendRequest("resumeRecorder");
}
@Override
public int getModelCount() {
return models.size();
}
}