Show current recipe name in window title

This commit is contained in:
Marcel Kapfer 2020-04-30 19:05:44 +02:00
parent 33615d54fa
commit 09ce159d36
Signed by: mmk2410
GPG key ID: CADE6F0C09F21B09

13
init.py
View file

@ -22,8 +22,21 @@ class MainWindow(QMainWindow, Ui_MainWindow):
self.b_cancel.clicked.connect(self.close)
self.ma_close.triggered.connect(self.close)
# Conncect recipe name typing
self.e_recipe_name.textChanged.connect(self.updateTitle)
self.show()
def updateTitle(self):
"""
Update the window title so it contains the name of the current recipe.
"""
current_recipe_name = self.e_recipe_name.text()
if current_recipe_name:
self.setWindowTitle(f"{current_recipe_name} - WikiCookBook")
else:
self.setWindowTitle("WikiCookBook")
def close(self):
"""
Close the application. A warning is shown before.