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
1 changed files with 13 additions and 0 deletions

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.