Improve the pause button screen workflow (#216)
This commit is contained in:
@@ -138,6 +138,9 @@ public class Client {
|
||||
while (this.running == true) {
|
||||
this.renderingJob = null;
|
||||
synchronized (this) {
|
||||
if (this.suspended) {
|
||||
this.gui.status("Client paused", true);
|
||||
}
|
||||
while (this.suspended) {
|
||||
wait();
|
||||
}
|
||||
@@ -431,6 +434,7 @@ public class Client {
|
||||
|
||||
public void suspend() {
|
||||
suspended = true;
|
||||
this.gui.status("Client will pause when the current job finishes", true);
|
||||
}
|
||||
|
||||
public synchronized void resume() {
|
||||
|
||||
@@ -26,6 +26,8 @@ public interface Gui {
|
||||
|
||||
public void status(String msg_);
|
||||
|
||||
public void status(String msg_, boolean overwriteSuspendedMsg);
|
||||
|
||||
public void updateTrayIcon(Integer percentage_);
|
||||
|
||||
public void setRenderingProjectName(String name_);
|
||||
|
||||
@@ -187,8 +187,13 @@ public class GuiSwing extends JFrame implements Gui {
|
||||
|
||||
@Override
|
||||
public void status(String msg_) {
|
||||
status(msg_, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void status(String msg_, boolean overwriteSuspendedMsg) {
|
||||
if (activityWorking != null) {
|
||||
this.activityWorking.setStatus(msg_);
|
||||
this.activityWorking.setStatus(msg_, overwriteSuspendedMsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -95,8 +95,21 @@ public class GuiText implements Gui {
|
||||
|
||||
@Override
|
||||
public void status(String msg_) {
|
||||
System.out.println(msg_);
|
||||
status(msg_, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void status(String msg_, boolean overwriteSuspendedMsg) {
|
||||
log.debug("GUI " + msg_);
|
||||
|
||||
if (client != null && client.isSuspended()) {
|
||||
if (overwriteSuspendedMsg) {
|
||||
System.out.println(msg_);
|
||||
}
|
||||
}
|
||||
else {
|
||||
System.out.println(msg_);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -106,9 +106,22 @@ public class GuiTextOneLine implements Gui {
|
||||
|
||||
@Override
|
||||
public void status(String msg_) {
|
||||
status(msg_, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void status(String msg_, boolean overwriteSuspendedMsg) {
|
||||
if (client != null && client.isSuspended()) {
|
||||
if (overwriteSuspendedMsg) {
|
||||
status = msg_;
|
||||
updateLine();
|
||||
}
|
||||
}
|
||||
else {
|
||||
status = msg_;
|
||||
updateLine();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRenderingProjectName(String name_) {
|
||||
|
||||
@@ -55,6 +55,7 @@ public class Working implements Activity {
|
||||
private GuiSwing parent;
|
||||
|
||||
private JLabel statusContent;
|
||||
private String previousStatus;
|
||||
private JLabel renderedFrameContent;
|
||||
private JLabel remainingFrameContent;
|
||||
private JLabel lastRenderTime;
|
||||
@@ -94,6 +95,7 @@ public class Working implements Activity {
|
||||
lastRender = new JLabel("");
|
||||
userInfoQueuedUploadsAndSizeValue = new JLabel("0");
|
||||
currentTheme = UIManager.getLookAndFeel().getName(); // Capture the theme on component instantiation
|
||||
previousStatus = "";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -217,10 +219,10 @@ public class Working implements Activity {
|
||||
JButton settingsButton = new JButton("Settings");
|
||||
settingsButton.addActionListener(new SettingsAction());
|
||||
|
||||
pauseButton = new JButton("Pause");
|
||||
pauseButton = new JButton("Pause getting new jobs");
|
||||
Client client = parent.getClient();
|
||||
if (client != null && client.isSuspended()) {
|
||||
pauseButton.setText("Resume");
|
||||
pauseButton.setText("Resume getting jobs");
|
||||
}
|
||||
|
||||
pauseButton.addActionListener(new PauseAction());
|
||||
@@ -259,8 +261,25 @@ public class Working implements Activity {
|
||||
}
|
||||
|
||||
public void setStatus(String msg_) {
|
||||
setStatus(msg_, false);
|
||||
}
|
||||
|
||||
public void setStatus(String msg_, boolean overwriteSuspendedMsg) {
|
||||
Client client = parent.getClient();
|
||||
|
||||
if (!msg_.equals("")) {
|
||||
this.previousStatus = msg_;
|
||||
}
|
||||
|
||||
if (client != null && client.isSuspended()) {
|
||||
if (overwriteSuspendedMsg) {
|
||||
statusContent.setText("<html>" + msg_ + "</html>");
|
||||
}
|
||||
}
|
||||
else {
|
||||
statusContent.setText("<html>" + msg_ + "</html>");
|
||||
}
|
||||
}
|
||||
|
||||
public void setRenderingProjectName(String msg_) {
|
||||
current_project_name_value.setText("<html>" + (msg_.length() > 26 ? msg_.substring(0, 26) : msg_) + "</html>");
|
||||
@@ -428,12 +447,14 @@ public class Working implements Activity {
|
||||
Client client = parent.getClient();
|
||||
if (client != null) {
|
||||
if (client.isSuspended()) {
|
||||
pauseButton.setText("Pause");
|
||||
pauseButton.setText("Pause getting new jobs");
|
||||
client.resume();
|
||||
setStatus(previousStatus);
|
||||
}
|
||||
else {
|
||||
pauseButton.setText("Resume");
|
||||
pauseButton.setText("Resume getting jobs");
|
||||
client.suspend();
|
||||
setStatus("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user