From 76b6fed6a7fec021be19f0ae104f1499781b8f5e Mon Sep 17 00:00:00 2001 From: Alexey Bogomolov Date: Mon, 3 Jul 2023 03:41:37 +0300 Subject: [PATCH 1/3] disable delivery button if no representations checked fix macos combobox layout add error message if no delivery templates found --- openpype/plugins/load/delivery.py | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/openpype/plugins/load/delivery.py b/openpype/plugins/load/delivery.py index d1d5659118..9509cf3b8c 100644 --- a/openpype/plugins/load/delivery.py +++ b/openpype/plugins/load/delivery.py @@ -1,4 +1,5 @@ import copy +import platform from collections import defaultdict from qtpy import QtWidgets, QtCore, QtGui @@ -83,6 +84,12 @@ class DeliveryOptionsDialog(QtWidgets.QDialog): self.templates = self._get_templates(self.anatomy) for name, _ in self.templates.items(): dropdown.addItem(name) + if self.templates and platform.system() == "Darwin": + # fix macos QCombobox Style + dropdown.setItemDelegate(QtWidgets.QStyledItemDelegate()) + # update combo box length to longest entry + longest_key = max(self.templates.keys(), key=len) + dropdown.setMinimumContentsLength(len(longest_key)) template_label = QtWidgets.QLabel() template_label.setCursor(QtGui.QCursor(QtCore.Qt.IBeamCursor)) @@ -115,7 +122,7 @@ class DeliveryOptionsDialog(QtWidgets.QDialog): input_layout.addRow("Representations", repre_checkboxes_layout) btn_delivery = QtWidgets.QPushButton("Deliver") - btn_delivery.setEnabled(bool(dropdown.currentText())) + btn_delivery.setEnabled(False) progress_bar = QtWidgets.QProgressBar(self) progress_bar.setMinimum = 0 @@ -148,9 +155,17 @@ class DeliveryOptionsDialog(QtWidgets.QDialog): self._update_selected_label() self._update_template_value() - - btn_delivery.clicked.connect(self.deliver) - dropdown.currentIndexChanged.connect(self._update_template_value) + if not self.dropdown.count(): + self.text_area.setVisible(True) + error_message = ( + "No Delivery Templates found!\n" + "Add Template in [project_anatomy/templates/delivery]" + ) + self.text_area.setText(error_message) + self.log.error(error_message.replace("\n", " ")) + else: + btn_delivery.clicked.connect(self.deliver) + dropdown.currentIndexChanged.connect(self._update_template_value) def deliver(self): """Main method to loop through all selected representations""" @@ -287,14 +302,17 @@ class DeliveryOptionsDialog(QtWidgets.QDialog): self.files_selected, self.size_selected = \ self._get_counts(selected_repres) self.selected_label.setText(self._prepare_label()) + # update delivery button state if any templates found + if self.dropdown.count(): + self.btn_delivery.setEnabled(bool(selected_repres)) def _update_template_value(self, _index=None): """Sets template value to label after selection in dropdown.""" name = self.dropdown.currentText() template_value = self.templates.get(name) if template_value: - self.btn_delivery.setEnabled(True) self.template_label.setText(template_value) + self.btn_delivery.setEnabled(bool(self._get_selected_repres())) def _update_progress(self, uploaded): """Update progress bar after each repre copied.""" From 5f8a07aa8fb6c5931165e6a60772d8a1d5537665 Mon Sep 17 00:00:00 2001 From: Alexey Bogomolov Date: Mon, 3 Jul 2023 12:30:43 +0300 Subject: [PATCH 2/3] remove unnecessary else statement --- openpype/plugins/load/delivery.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/openpype/plugins/load/delivery.py b/openpype/plugins/load/delivery.py index 9509cf3b8c..90e734973b 100644 --- a/openpype/plugins/load/delivery.py +++ b/openpype/plugins/load/delivery.py @@ -155,6 +155,10 @@ class DeliveryOptionsDialog(QtWidgets.QDialog): self._update_selected_label() self._update_template_value() + + btn_delivery.clicked.connect(self.deliver) + dropdown.currentIndexChanged.connect(self._update_template_value) + if not self.dropdown.count(): self.text_area.setVisible(True) error_message = ( @@ -163,9 +167,6 @@ class DeliveryOptionsDialog(QtWidgets.QDialog): ) self.text_area.setText(error_message) self.log.error(error_message.replace("\n", " ")) - else: - btn_delivery.clicked.connect(self.deliver) - dropdown.currentIndexChanged.connect(self._update_template_value) def deliver(self): """Main method to loop through all selected representations""" From 09f0d183d8915efe72ad00056eee4955ced4cd09 Mon Sep 17 00:00:00 2001 From: Alexey Bogomolov Date: Mon, 3 Jul 2023 15:40:16 +0300 Subject: [PATCH 3/3] hound remove whitespace --- openpype/plugins/load/delivery.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/plugins/load/delivery.py b/openpype/plugins/load/delivery.py index 90e734973b..4bd4f6e9cf 100644 --- a/openpype/plugins/load/delivery.py +++ b/openpype/plugins/load/delivery.py @@ -155,7 +155,7 @@ class DeliveryOptionsDialog(QtWidgets.QDialog): self._update_selected_label() self._update_template_value() - + btn_delivery.clicked.connect(self.deliver) dropdown.currentIndexChanged.connect(self._update_template_value)