From bcdad62e8ae3fe8020554aef14a303fadd0c18ad Mon Sep 17 00:00:00 2001 From: CodeByMrFinchum Date: Thu, 23 Jan 2025 16:33:05 +0100 Subject: [PATCH] patch: Added check if any exif options are empty --- src/OptimaLab35/gui.py | 26 ++++++++++++++++++++++++-- src/OptimaLab35/ui/main_window.py | 3 +-- src/OptimaLab35/ui/main_window.ui | 18 +----------------- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/src/OptimaLab35/gui.py b/src/OptimaLab35/gui.py index df94cfc..5aac4c1 100644 --- a/src/OptimaLab35/gui.py +++ b/src/OptimaLab35/gui.py @@ -295,7 +295,13 @@ class OptimaLab35(QMainWindow, Ui_MainWindow): def start_process(self): self.toggle_buttons(False) - self.update_settings() # Get all user selected data + u = self.update_settings() + print(f"u in startinset_xif: {u}") + if u != None: # Get all user selected data + QMessageBox.warning(self, "Warning", f"Error: {u}") + self.toggle_buttons(True) + return + if self.control_before_start("image") == False: self.toggle_buttons(True) return @@ -327,7 +333,13 @@ class OptimaLab35(QMainWindow, Ui_MainWindow): def startinsert_exif(self): self.toggle_buttons(False) - self.update_settings() # Get all user selected data + u = self.update_settings() + print(f"u in startinset_xif: {u}") + if u != None: # Get all user selected data + QMessageBox.warning(self, "Warning", f"Error: {u}") + self.toggle_buttons(True) + return + if self.control_before_start("exif") == False: self.toggle_buttons(True) return @@ -384,6 +396,12 @@ class OptimaLab35(QMainWindow, Ui_MainWindow): self.settings["gps"] = None return selected_exif + def check_selected_exif(self, exif): + for key in exif: + if len(exif[key]) == 0: + return f"{key} is empty" + return True + def update_settings(self): """Update .settings from all GUI elements.""" # Basic @@ -417,6 +435,10 @@ class OptimaLab35(QMainWindow, Ui_MainWindow): self.settings["user_selected_exif"] = None self.settings["gps"] = None + u = self.check_selected_exif(self.settings["user_selected_exif"]) + if u != True: + return u + # Helper functions, low level def handle_exif_file(self, do): # TODO: add check if data is missing. diff --git a/src/OptimaLab35/ui/main_window.py b/src/OptimaLab35/ui/main_window.py index 8749b23..c0e4990 100644 --- a/src/OptimaLab35/ui/main_window.py +++ b/src/OptimaLab35/ui/main_window.py @@ -344,7 +344,7 @@ class Ui_MainWindow(object): self.edit_exif_button = QPushButton(self.exif_group) self.edit_exif_button.setObjectName(u"edit_exif_button") - self.edit_exif_button.setEnabled(False) + self.edit_exif_button.setEnabled(True) self.horizontalLayout.addWidget(self.edit_exif_button) @@ -584,7 +584,6 @@ class Ui_MainWindow(object): self.resize_Slider.valueChanged.connect(self.resize_spinBox.setValue) self.exif_checkbox.toggled.connect(self.gps_groupBox.setEnabled) self.contrast_spinBox.valueChanged.connect(self.contrast_horizontalSlider.setValue) - self.exif_checkbox.toggled.connect(self.edit_exif_button.setEnabled) self.add_date_checkBox.toggled.connect(self.dateEdit.setEnabled) self.jpg_quality_spinBox.valueChanged.connect(self.jpg_quality_Slider.setValue) self.rename_checkbox.toggled.connect(self.revert_checkbox.setEnabled) diff --git a/src/OptimaLab35/ui/main_window.ui b/src/OptimaLab35/ui/main_window.ui index 0f89e52..59d707a 100644 --- a/src/OptimaLab35/ui/main_window.ui +++ b/src/OptimaLab35/ui/main_window.ui @@ -575,7 +575,7 @@ - false + true Edit Exif @@ -1172,22 +1172,6 @@ - - exif_checkbox - toggled(bool) - edit_exif_button - setEnabled(bool) - - - 134 - 107 - - - 79 - 170 - - - add_date_checkBox toggled(bool)