Added ability to remove users from quick select list

This commit is contained in:
Maximilian P. Käfer 2020-10-01 22:59:07 +02:00
parent 8592839156
commit 8543e94040
Signed by: mpk
GPG Key ID: 035869C949377C5C
3 changed files with 21 additions and 4 deletions

View File

@ -1,11 +1,12 @@
package envoy.client.ui.control; package envoy.client.ui.control;
import javafx.geometry.Pos; import javafx.geometry.Pos;
import javafx.scene.control.Label; import javafx.scene.control.*;
import javafx.scene.image.ImageView; import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import javafx.scene.shape.Rectangle; import javafx.scene.shape.Rectangle;
import envoy.client.ui.controller.GroupCreationTab;
import envoy.client.util.IconUtil; import envoy.client.util.IconUtil;
import envoy.data.User; import envoy.data.User;
@ -15,7 +16,17 @@ import envoy.data.User;
*/ */
public class QuickSelectControl extends VBox { public class QuickSelectControl extends VBox {
public QuickSelectControl(User user) { public QuickSelectControl(User user, GroupCreationTab tab) {
Button removeBtn = new Button();
removeBtn.setPrefSize(10, 10);
removeBtn.setMaxSize(10, 10);
removeBtn.setMinSize(10, 10);
removeBtn.setAlignment(Pos.TOP_RIGHT);
removeBtn.setOnMouseClicked(evt -> {
tab.removeFromQuickSelection(this);
});
removeBtn.setId("remove-button");
getChildren().add(removeBtn);
// Profile picture // Profile picture
ImageView contactProfilePic = new ImageView(IconUtil.loadIconThemeSensitive("user_icon", 32)); ImageView contactProfilePic = new ImageView(IconUtil.loadIconThemeSensitive("user_icon", 32));
@ -38,5 +49,4 @@ public class QuickSelectControl extends VBox {
getStyleClass().add("quick-select"); getStyleClass().add("quick-select");
} }
} }

View File

@ -91,7 +91,7 @@ public class GroupCreationTab implements EventListener {
@FXML @FXML
private void userListClicked() { private void userListClicked() {
createButton.setDisable(userList.getSelectionModel().isEmpty() || groupNameField.getText().isBlank()); createButton.setDisable(userList.getSelectionModel().isEmpty() || groupNameField.getText().isBlank());
quickSelectList.getItems().add(new QuickSelectControl(userList.getSelectionModel().getSelectedItem())); quickSelectList.getItems().add(new QuickSelectControl(userList.getSelectionModel().getSelectedItem(), this));
} }
/** /**
@ -157,6 +157,8 @@ public class GroupCreationTab implements EventListener {
return localDB.getChats().stream().map(Chat::getRecipient).filter(Group.class::isInstance).map(Contact::getName).anyMatch(newName::equals); return localDB.getChats().stream().map(Chat::getRecipient).filter(Group.class::isInstance).map(Contact::getName).anyMatch(newName::equals);
} }
public void removeFromQuickSelection(QuickSelectControl element) { quickSelectList.getItems().remove(element); }
@FXML @FXML
private void backButtonClicked() { private void backButtonClicked() {
eventBus.dispatch(new BackEvent()); eventBus.dispatch(new BackEvent());

View File

@ -83,3 +83,8 @@
-fx-text-fill: white; -fx-text-fill: white;
-fx-background-color: transparent; -fx-background-color: transparent;
} }
#remove-button {
-fx-background-color: red;
-fx-background-radius: 1em;
}