From 7c417b7298b5222cecfed41811d3659b3c3e7437 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20Wieczorek?= Date: Sun, 20 Dec 2020 12:16:09 +0100 Subject: [PATCH] Add a warning dialog if no file is selected. --- src/python/classes/mainwindow.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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: