Merge branch 'fix/ui-dialog' into 'master'

Fix: when there an empty queue, display a better exit dialog

See merge request sheepitrenderfarm/client!235
This commit is contained in:
Sheepit Renderfarm
2023-09-16 06:55:08 +00:00

View File

@@ -559,8 +559,14 @@ public class Working implements Activity {
} }
int jobsQueueSize = getJobsQueueSize(client); int jobsQueueSize = getJobsQueueSize(client);
if (jobsQueueSize == 0) {
int userDecision = showCloseDialogNoFrame();
if (userDecision == 0) {
exitImmediately(client);
}
}
else {
int userDecision = showCloseDialog(jobsQueueSize); int userDecision = showCloseDialog(jobsQueueSize);
if (userDecision == 0) { if (userDecision == 0) {
finishJobBeforeExit(client, jobsQueueSize); finishJobBeforeExit(client, jobsQueueSize);
} }
@@ -569,6 +575,13 @@ public class Working implements Activity {
} }
} }
} }
}
public int showCloseDialogNoFrame() {
String[] exitJobOptions = {"Exit Immediately", "Do Nothing" };
return JOptionPane.showOptionDialog(null, "Exit Now or Later", "Exit Now or Later",
JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, exitJobOptions, exitJobOptions[1]); // Make the "Do nothing" button the default one to avoid mistakes
}
public int showCloseDialog(int jobsQueueSize) { public int showCloseDialog(int jobsQueueSize) {
String[] exitJobOptions = { "Exit after current Jobs", "Exit Immediately", "Do Nothing" }; String[] exitJobOptions = { "Exit after current Jobs", "Exit Immediately", "Do Nothing" };