Add key listener to unfollow by pressing the delete key
This commit is contained in:
parent
e6c38081d9
commit
b206a6caf7
|
@ -83,9 +83,9 @@ public class CtbrecApplication extends Application {
|
|||
tabPane.getTabs().add(createTab("Male", BASE_URI + "/male-cams/"));
|
||||
tabPane.getTabs().add(createTab("Couples", BASE_URI + "/couple-cams/"));
|
||||
tabPane.getTabs().add(createTab("Trans", BASE_URI + "/trans-cams/"));
|
||||
FollowedTab tab = new FollowedTab("Followed", BASE_URI + "/followed-cams/");
|
||||
tab.setRecorder(recorder);
|
||||
tabPane.getTabs().add(tab);
|
||||
FollowedTab followedTab = new FollowedTab("Followed", BASE_URI + "/followed-cams/");
|
||||
followedTab.setRecorder(recorder);
|
||||
tabPane.getTabs().add(followedTab);
|
||||
RecordedModelsTab modelsTab = new RecordedModelsTab("Recording", recorder);
|
||||
tabPane.getTabs().add(modelsTab);
|
||||
RecordingsTab recordingsTab = new RecordingsTab("Recordings", recorder, config);
|
||||
|
@ -97,6 +97,7 @@ public class CtbrecApplication extends Application {
|
|||
int windowWidth = Config.getInstance().getSettings().windowWidth;
|
||||
int windowHeight = Config.getInstance().getSettings().windowHeight;
|
||||
primaryStage.setScene(new Scene(tabPane, windowWidth, windowHeight));
|
||||
followedTab.setScene(primaryStage.getScene());
|
||||
primaryStage.getScene().getStylesheets().add("/ctbrec/ui/ThumbCell.css");
|
||||
primaryStage.getScene().widthProperty().addListener((observable, oldVal, newVal) -> Config.getInstance().getSettings().windowWidth = newVal.intValue());
|
||||
primaryStage.getScene().heightProperty().addListener((observable, oldVal, newVal) -> Config.getInstance().getSettings().windowHeight = newVal.intValue());
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package ctbrec.ui;
|
||||
|
||||
import javafx.concurrent.WorkerStateEvent;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.input.KeyEvent;
|
||||
|
||||
public class FollowedTab extends ThumbOverviewTab {
|
||||
private Label status;
|
||||
|
@ -29,4 +32,14 @@ public class FollowedTab extends ThumbOverviewTab {
|
|||
status.setText("Logging in...");
|
||||
super.selected();
|
||||
}
|
||||
|
||||
public void setScene(Scene scene) {
|
||||
scene.addEventFilter(KeyEvent.KEY_PRESSED, event -> {
|
||||
if(this.isSelected()) {
|
||||
if(event.getCode() == KeyCode.DELETE) {
|
||||
follow(selectedThumbCells, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -270,7 +270,7 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
|
|||
|
||||
}
|
||||
|
||||
private ThumbCell createThumbCell(ThumbOverviewTab thumbOverviewTab, Model model, Recorder recorder2, HttpClient client2) {
|
||||
ThumbCell createThumbCell(ThumbOverviewTab thumbOverviewTab, Model model, Recorder recorder2, HttpClient client2) {
|
||||
ThumbCell newCell = new ThumbCell(this, model, recorder, client);
|
||||
newCell.addEventHandler(ContextMenuEvent.CONTEXT_MENU_REQUESTED, event -> {
|
||||
suspendUpdates(true);
|
||||
|
@ -299,18 +299,18 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
|
|||
|
||||
private ContextMenu createContextMenu(ThumbCell cell) {
|
||||
MenuItem openInPlayer = new MenuItem("Open in Player");
|
||||
openInPlayer.setOnAction((e) -> startPlayer(cell));
|
||||
openInPlayer.setOnAction((e) -> startPlayer(getSelectedThumbCells(cell)));
|
||||
|
||||
MenuItem start = new MenuItem("Start Recording");
|
||||
start.setOnAction((e) -> startStopAction(cell, true));
|
||||
start.setOnAction((e) -> startStopAction(getSelectedThumbCells(cell), true));
|
||||
MenuItem stop = new MenuItem("Stop Recording");
|
||||
stop.setOnAction((e) -> startStopAction(cell, false));
|
||||
stop.setOnAction((e) -> startStopAction(getSelectedThumbCells(cell), false));
|
||||
MenuItem startStop = recorder.isRecording(cell.getModel()) ? stop : start;
|
||||
|
||||
MenuItem follow = new MenuItem("Follow");
|
||||
follow.setOnAction((e) -> follow(cell, true));
|
||||
follow.setOnAction((e) -> follow(getSelectedThumbCells(cell), true));
|
||||
MenuItem unfollow = new MenuItem("Unfollow");
|
||||
unfollow.setOnAction((e) -> follow(cell, false));
|
||||
unfollow.setOnAction((e) -> follow(getSelectedThumbCells(cell), false));
|
||||
|
||||
MenuItem copyUrl = new MenuItem("Copy URL");
|
||||
copyUrl.setOnAction((e) -> {
|
||||
|
@ -343,33 +343,32 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
|
|||
return contextMenu;
|
||||
}
|
||||
|
||||
private void follow(ThumbCell cell, boolean follow) {
|
||||
private List<ThumbCell> getSelectedThumbCells(ThumbCell cell) {
|
||||
if(selectedThumbCells.isEmpty()) {
|
||||
cell.follow(follow);
|
||||
return Collections.singletonList(cell);
|
||||
} else {
|
||||
for (ThumbCell thumbCell : selectedThumbCells) {
|
||||
thumbCell.follow(follow);
|
||||
}
|
||||
return selectedThumbCells;
|
||||
}
|
||||
}
|
||||
|
||||
private void startStopAction(ThumbCell cell, boolean start) {
|
||||
if(selectedThumbCells.isEmpty()) {
|
||||
cell.startStopAction(start);
|
||||
} else {
|
||||
for (ThumbCell thumbCell : selectedThumbCells) {
|
||||
thumbCell.startStopAction(start);
|
||||
}
|
||||
void follow(List<ThumbCell> selection, boolean follow) {
|
||||
for (ThumbCell thumbCell : selection) {
|
||||
thumbCell.follow(follow);
|
||||
}
|
||||
if(!follow) {
|
||||
selectedThumbCells.clear();
|
||||
}
|
||||
}
|
||||
|
||||
private void startPlayer(ThumbCell cell) {
|
||||
if(selectedThumbCells.isEmpty()) {
|
||||
cell.startPlayer();
|
||||
} else {
|
||||
for (ThumbCell thumbCell : selectedThumbCells) {
|
||||
thumbCell.startPlayer();
|
||||
}
|
||||
private void startStopAction(List<ThumbCell> selection, boolean start) {
|
||||
for (ThumbCell thumbCell : selection) {
|
||||
thumbCell.startStopAction(start);
|
||||
}
|
||||
}
|
||||
|
||||
private void startPlayer(List<ThumbCell> selection) {
|
||||
for (ThumbCell thumbCell : selection) {
|
||||
thumbCell.startPlayer();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue