Revert "Merge branch 'fix/exit-dialog' into 'master'"

This commit is contained in:
harlekin
2023-03-07 08:50:45 +00:00
parent 7d6d69c109
commit 5c99acf04d

View File

@@ -33,7 +33,6 @@ import java.awt.Image;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.Objects; import java.util.Objects;
@@ -520,7 +519,7 @@ public class Working implements Activity {
} }
private int getJobsQueueSize(Client client) { private int getJobsQueueSize(Client client) {
return client.getUploadQueueSize() + (client.getRenderingJob() != null ? 1 : 0); return client.getUploadQueueSize() + (client.isRunning() ? 1 : 0);
} }
class PauseAction implements ActionListener { class PauseAction implements ActionListener {
@@ -572,17 +571,13 @@ public class Working implements Activity {
} }
public int showCloseDialog(int jobsQueueSize) { public int showCloseDialog(int jobsQueueSize) {
ArrayList<String> exitJobOptions = new ArrayList<String>(); String[] exitJobOptions = { "Exit after current Jobs", "Exit Immediately", "Do Nothing" };
if (jobsQueueSize > 0) { return JOptionPane.showOptionDialog(null, String.format(
exitJobOptions.add("Exit after current Jobs"); "<html>You have <strong>%d frame%s</strong> being uploaded or rendered. Do you want to finish the jobs or exit now?.\n\n",
} jobsQueueSize, // Add the current frame to the total count ONLY if the client is running
exitJobOptions.add("Exit Immediately"); (jobsQueueSize > 1 ? "s" : ""), (jobsQueueSize > 1 ? (jobsQueueSize + " ") : ""), (jobsQueueSize > 1 ? "s" : "")),
exitJobOptions.add("Do Nothing"); "Exit Now or Later", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, exitJobOptions,
exitJobOptions[2]); // Make the "Do nothing" button the default one to avoid mistakes
String message = jobsQueueSize == 0 ? "Do you want to exit now?" : String.format("<html>You have <strong>%d frame%s</strong> being uploaded or rendered. Do you want to finish the jobs or exit now?.\n\n", jobsQueueSize, (jobsQueueSize > 1 ? "s" : ""));
return JOptionPane.showOptionDialog(null, message, "Exit Now or Later?",
JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, exitJobOptions.toArray(), exitJobOptions.size() - 1); // Make the "Do nothing" button the default one to avoid mistakes
} }
public void finishJobBeforeExit(Client client, int jobsQueueSize) { public void finishJobBeforeExit(Client client, int jobsQueueSize) {