diff --git a/src/python/classes/mainwindow.py b/src/python/classes/mainwindow.py index 131c774..7f5ce07 100644 --- a/src/python/classes/mainwindow.py +++ b/src/python/classes/mainwindow.py @@ -46,10 +46,14 @@ class MainWindow(QMainWindow, Ui_MainWindow): dialog.setFileMode(QFileDialog.ExistingFile) file_formats = "All Files (*);;JPG (*.jpg);;PNG (*.png)" file, _ = dialog.getOpenFileName(self, "QFileDialog.getOpenFileName()", "", file_formats, options=dialog.options()) + if not file: + msg = F"[!] Nie wybrano żadnego pliku." + dialog = self.create_custom_dialog(title='Ostrzeżenie', msg=msg) + dialog.exec_() - if not file.lower().endswith('.jpg') and not file.lower().endswith('.png'): + if file and not file.lower().endswith('.jpg') and not file.lower().endswith('.png'): msg = F"[!] Plik {file} nie jest plikiem jpg/png." - dialog = self.create_custom_dialog(title='Error', msg=msg) + dialog = self.create_custom_dialog(title='Błąd', msg=msg) dialog.exec_() else: @@ -80,10 +84,14 @@ class MainWindow(QMainWindow, Ui_MainWindow): dialog.setFileMode(QFileDialog.ExistingFile) file_formats = "All Files (*);;mp3 (*.mp3);;wav (*.wav)" file, _ = dialog.getOpenFileName(self, "QFileDialog.getOpenFileName()", "", file_formats, options=dialog.options()) + if not file: + msg = F"[!] Nie wybrano żadnego pliku." + dialog = self.create_custom_dialog(title='Ostrzeżenie', msg=msg) + dialog.exec_() - if not file.lower().endswith('.mp3') and not file.lower().endswith('.wav'): + elif not file.lower().endswith('.mp3') and not file.lower().endswith('.wav'): msg = F"[!] Plik {file} nie jest plikiem mp3/wav." - dialog = self.create_custom_dialog(title='Error', msg=msg) + dialog = self.create_custom_dialog(title='Błąd', msg=msg) dialog.exec_() else: