From 92a495c664c1fc75e11d043c4e1d48f6c6994a58 Mon Sep 17 00:00:00 2001 From: Ziad Ashraf Date: Tue, 20 Aug 2024 19:03:01 +0300 Subject: [PATCH] Fixed the missing darkmode ,and the about menu bug --- GUI/src/main/java/ui/ConfirmationDialog.java | 4 ++- GUI/src/main/java/ui/ManageFolders.java | 23 ++++++++++-- GUI/src/main/java/ui/Settings.java | 2 +- GUI/src/main/java/ui/Theme.java | 2 ++ GUI/src/main/java/ui/UIController.java | 37 ++++++++++++++------ 5 files changed, 53 insertions(+), 15 deletions(-) diff --git a/GUI/src/main/java/ui/ConfirmationDialog.java b/GUI/src/main/java/ui/ConfirmationDialog.java index 52ba5589d..9d3d6d290 100644 --- a/GUI/src/main/java/ui/ConfirmationDialog.java +++ b/GUI/src/main/java/ui/ConfirmationDialog.java @@ -30,6 +30,7 @@ enum State { private final State state; private final String lf = System.lineSeparator(); private static Button btnNo; + private static Button btnOk; private static Button btnYes; private double width = 200; private double height = 150; @@ -113,7 +114,7 @@ private void createControls() { answer.setAnswer(false); stage.close(); }); - Button btnOk = newButton("OK", e -> stage.close()); + btnOk = newButton("OK", e -> stage.close()); TextField tfFilename = new TextField(filename); tfFilename.setMinWidth(width * .4); tfFilename.setMaxWidth(width * .8); @@ -155,6 +156,7 @@ private void showScene() { Theme.applyTheme("Dark", scene); Theme.changeButtonStyle(true, btnYes); Theme.changeButtonStyle(true, btnNo); + Theme.changeButtonStyle(true , btnOk); } else { Theme.applyTheme("Light", scene); } diff --git a/GUI/src/main/java/ui/ManageFolders.java b/GUI/src/main/java/ui/ManageFolders.java index 059afbc41..9d878e719 100644 --- a/GUI/src/main/java/ui/ManageFolders.java +++ b/GUI/src/main/java/ui/ManageFolders.java @@ -7,6 +7,7 @@ import javafx.collections.ObservableList; import javafx.geometry.Pos; import javafx.scene.Scene; +import javafx.scene.control.Button; import javafx.scene.control.ListCell; import javafx.scene.control.ListView; import javafx.scene.layout.HBox; @@ -16,13 +17,24 @@ public class ManageFolders { private Stage stage; + + public static Scene scene; private final double width = 400; private final double height = 550; private final Folders folders; private VBox vBox; private ListView lvFolders; - private javafx.scene.control.Button btnRemove; - private javafx.scene.control.Button btnClose; + + public static Button getBtnRemove() { + return btnRemove; + } + + public static Button getBtnClose() { + return btnClose; + } + + private static javafx.scene.control.Button btnRemove; + private static javafx.scene.control.Button btnClose; public ManageFolders() { this.folders = AppSettings.GET.folders(); @@ -87,7 +99,12 @@ private void setControls() { public void showScene() { stage = new Stage(); - Scene scene = Constants.getScene(vBox); + scene = Constants.getScene(vBox); + if (AppSettings.GET.mainTheme().equals("Dark")) { + Constants.addCSS(scene, Constants.DARK_THEME_CSS); + Theme.changeButtonStyle(true, ManageFolders.getBtnClose()); + Theme.changeButtonStyle(true, ManageFolders.getBtnRemove()); + } stage.setScene(scene); stage.setWidth(width); stage.setHeight(height); diff --git a/GUI/src/main/java/ui/Settings.java b/GUI/src/main/java/ui/Settings.java index 1439b9a8e..af966afab 100644 --- a/GUI/src/main/java/ui/Settings.java +++ b/GUI/src/main/java/ui/Settings.java @@ -130,7 +130,7 @@ private void setupThemeChoice() { themeChoiceBox = new ChoiceBox<>(); themeChoiceBox.getItems().addAll("Dark Theme", "Light Theme"); themeChoiceBox.setValue(AppSettings.GET.mainTheme().equals("Dark") ? "Dark Theme" : "Light Theme"); - themeChoiceBox.setOnAction(e -> Theme.applyTheme(themeChoiceBox.getValue().equals("Dark Theme") ? "Dark" : "Light", settingsScene, Drifty_GUI.getScene(), About.getScene(), UIController.getInfoScene(), ConfirmationDialog.getScene())); + themeChoiceBox.setOnAction(e -> Theme.applyTheme(themeChoiceBox.getValue().equals("Dark Theme") ? "Dark" : "Light", settingsScene, Drifty_GUI.getScene(), About.getScene(), UIController.getInfoScene(), ConfirmationDialog.getScene(), ManageFolders.scene)); } private void createAutoPasteCheck() { diff --git a/GUI/src/main/java/ui/Theme.java b/GUI/src/main/java/ui/Theme.java index 7b5240f0d..341340744 100644 --- a/GUI/src/main/java/ui/Theme.java +++ b/GUI/src/main/java/ui/Theme.java @@ -103,6 +103,8 @@ private static void updateButtonStyles(boolean isDark, String theme) { changeButtonStyle(isDark, Settings.getSelectDirectoryButton()); changeButtonStyle(isDark, ConfirmationDialog.getBtnYes()); changeButtonStyle(isDark, ConfirmationDialog.getBtnNo()); + changeButtonStyle(isDark, ManageFolders.getBtnClose()); + changeButtonStyle(isDark, ManageFolders.getBtnRemove()); setupButtonGraphics(theme); } diff --git a/GUI/src/main/java/ui/UIController.java b/GUI/src/main/java/ui/UIController.java index e9dccc1b8..615fa8b4a 100644 --- a/GUI/src/main/java/ui/UIController.java +++ b/GUI/src/main/java/ui/UIController.java @@ -580,7 +580,7 @@ private ContextMenu getListMenu() { M.msgFilenameInfo(""); M.msgDirInfo(""); }); - miInfo.setOnAction(e -> help()); + miInfo.setOnAction(e -> Helpshow()); return new ContextMenu(miDel, miClear, separator, miInfo); } @@ -781,6 +781,7 @@ private void commitJobListToListView() { }); } + Stage Helpstage; private void help() { Color textColor = AppSettings.GET.mainTheme().equals("Dark") ? Color.WHITE : Color.BLACK; Color headingsColor = AppSettings.GET.mainTheme().equals("Dark") ? Color.LIGHTGREEN : Color.DARKBLUE; @@ -810,12 +811,17 @@ private void help() { INFO_TF.getChildren().add(text("Another thing you can do is grab a YouTube playlist and Drifty will extract all of the videos from the playlist and build a batch from the list (or add to your existing batch).\n\n", false, textColor, n)); INFO_TF.setStyle("-fx-background-color: transparent"); + + Helpstage = Constants.getStage("Help", false); + double width = 500; double height = 700; Button btnOK = new Button("OK"); - Stage stage = Constants.getStage("Help", false); - stage.setWidth(width); - stage.setHeight(height + 100); + + + + Helpstage.setWidth(width); + Helpstage.setHeight(height + 100); VBox vox = new VBox(20, INFO_TF); vox.setPrefWidth(width - 35); vox.setPrefHeight(height - 75); @@ -834,16 +840,27 @@ private void help() { } infoScene.setFill(Color.TRANSPARENT); - stage.setScene(infoScene); - stage.setAlwaysOnTop(true); - stage.setTitle("Help"); - stage.setOnCloseRequest(e -> stage.close()); + Helpstage.setScene(infoScene); + Helpstage.setAlwaysOnTop(true); + Helpstage.setTitle("Help"); + Helpstage.setOnCloseRequest(e -> Helpstage.close()); VBox.setVgrow(vox, Priority.ALWAYS); VBox.setVgrow(INFO_TF, Priority.ALWAYS); - btnOK.setOnAction(e -> stage.close()); + btnOK.setOnAction(e -> Helpstage.close()); scrollPane.setVvalue(0.0); - stage.showAndWait(); + Helpstage.showAndWait(); } + public void Helpshow(){ + if (Helpstage != null && Helpstage.isShowing()) { + Helpstage.toFront(); + } else { + help(); + } + } + private void initializeHelpComponents(){ + + } + private Text text(String string, boolean bold, Color color, double size) { // This is used by the help() method for custom text formatting