gui: show the loaded Sud's name in the window caption and forecast title

Window caption becomes "BrewPi - <name>" once a schedule is loaded
(back to plain "BrewPi" when empty/disconnected); the Automatic tab's
forecast title is now "<name> - N min total", replacing the generic
"Estimated course..." text while keeping the time estimate.
This commit is contained in:
2026-06-21 10:47:26 +02:00
parent b51d802b31
commit e855076f55
+6 -5
View File
@@ -148,15 +148,14 @@ class SudForecastPlot(FigureCanvasQTAgg):
theta.append(theta[-1])
return t, theta
def show_schedule(self, schedule, start_theta):
def show_schedule(self, schedule, start_theta, name):
t, theta = self._estimate_course(schedule, start_theta)
t_min = [seconds / 60.0 for seconds in t]
self.line.set_data(t_min, theta)
self.ax.relim()
self.ax.autoscale_view()
self.ax.set_title("Estimated course (nominal rates, no plant model) "
"- {:.0f} min total".format(t_min[-1] if t_min else 0.0), fontsize='small')
self.ax.set_title("{} - {:.0f} min total".format(name, t_min[-1] if t_min else 0.0), fontsize='small')
self.figure.tight_layout()
self.draw_idle()
@@ -367,6 +366,7 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow):
self.set_sud_cooling(False)
self.update_sud_actions()
self.update_status_env_label()
self.setWindowTitle("BrewPi")
def update_sud_actions(self):
can_run = self.sud_loaded and not self.sud_empty
@@ -589,6 +589,7 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow):
self.update_sud_forecast(msg['Json'])
elif "Name" in key:
self.statusBar().showMessage("Sud schedule updated: {}".format(msg['Name']), 5000)
self.setWindowTitle("BrewPi - {}".format(msg['Name']) if msg['Name'] else "BrewPi")
elif "State" in key:
prev_state = self.sud_state
self.sud_state = msg['State']
@@ -622,7 +623,7 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow):
def update_sud_forecast(self, doc):
try:
_, _, schedule, _, _ = Sud._parse_data(doc)
name, _, schedule, _, _ = Sud._parse_data(doc)
except (KeyError, TypeError):
return
self.sud_empty = len(schedule) == 0
@@ -633,7 +634,7 @@ class Window(QtWidgets.QMainWindow, Ui_MainWindow):
# No measured starting temperature is available before a brew has
# started; fall back to a plausible ambient guess.
start_theta = self.plot_temp_ist if self.plot_temp_ist else 20.0
self.forecast_plot.show_schedule(schedule, start_theta)
self.forecast_plot.show_schedule(schedule, start_theta, name)
def closeEvent(self, event):
print("Exitting gracefully!")