Add a warning dialog if no file is selected.
This commit is contained in:
parent
ccfe8f09ba
commit
7c417b7298
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user