@@ -58,6 +58,7 @@ public class SettingsManager {
58
58
private TextField workingDirPath ; // Value injected by FXMLLoader
59
59
60
60
private static MainController mc ;
61
+ private static boolean changedDir =false ;
61
62
62
63
@ FXML
63
64
void onAdvancedMode (ActionEvent event ) {
@@ -121,9 +122,13 @@ void onBrowse(ActionEvent event) {
121
122
File selectedDirectory = directoryChooser .showDialog (stage );
122
123
123
124
if (selectedDirectory != null ) {
124
- System .out .println ("Selected directory: " + selectedDirectory .getAbsolutePath ());
125
- ConfigurationDatabase .put ("CaDoodle" , "CaDoodleWorkspace" , selectedDirectory .getAbsolutePath ());
126
- workingDirPath .setText (selectedDirectory .getAbsolutePath ());
125
+ String absolutePath = selectedDirectory .getAbsolutePath ();
126
+ System .out .println ("Selected directory: " + absolutePath );
127
+ ConfigurationDatabase .put ("CaDoodle" , "CaDoodleWorkspace" , absolutePath );
128
+ if (!absolutePath .contentEquals (workingDirPath .getText ())) {
129
+ changedDir =true ;
130
+ }
131
+ workingDirPath .setText (absolutePath );
127
132
ConfigurationDatabase .save ();
128
133
}
129
134
}
@@ -152,6 +157,7 @@ void initialize() {
152
157
boolean advanced = Boolean .parseBoolean (ConfigurationDatabase .get ("CaDoodle" , "CaDoodleAdvancedMode" , "" +true ).toString ());
153
158
mc .setAdvancedMode (advanced );
154
159
advancedSelector .setSelected (advanced );
160
+ changedDir =false ;
155
161
}
156
162
157
163
public static void main (String [] args ) {
@@ -176,6 +182,11 @@ public static void launch(MainController mc) {
176
182
// Set the scene
177
183
Scene scene = new Scene (root );
178
184
stage .setScene (scene );
185
+ stage .setOnCloseRequest (event -> {
186
+ if (changedDir ) {
187
+ mc .onHome (null );
188
+ }
189
+ });
179
190
// Show the new window
180
191
stage .show ();
181
192
} catch (IOException e ) {
0 commit comments