diff --git a/openpype/tools/project_manager/project_manager/widgets.py b/openpype/tools/project_manager/project_manager/widgets.py
index 20a6955d81..45599ab747 100644
--- a/openpype/tools/project_manager/project_manager/widgets.py
+++ b/openpype/tools/project_manager/project_manager/widgets.py
@@ -4,6 +4,7 @@ from .constants import (
NAME_ALLOWED_SYMBOLS,
NAME_REGEX
)
+from .style import ResourceCache
from openpype.lib import (
create_project,
PROJECT_NAME_ALLOWED_SYMBOLS,
@@ -13,7 +14,7 @@ from openpype.style import load_stylesheet
from openpype.tools.utils import PlaceholderLineEdit
from avalon.api import AvalonMongoDB
-from Qt import QtWidgets, QtCore
+from Qt import QtWidgets, QtCore, QtGui
class NameTextEdit(QtWidgets.QLineEdit):
@@ -291,42 +292,41 @@ class CreateProjectDialog(QtWidgets.QDialog):
return project_names, project_codes
-class _SameSizeBtns(QtWidgets.QPushButton):
- """Button that keep width of all button added as related.
+# TODO PixmapLabel should be moved to 'utils' in other future PR so should be
+# imported from there
+class PixmapLabel(QtWidgets.QLabel):
+ """Label resizing image to height of font."""
+ def __init__(self, pixmap, parent):
+ super(PixmapLabel, self).__init__(parent)
+ self._empty_pixmap = QtGui.QPixmap(0, 0)
+ self._source_pixmap = pixmap
- This happens without changing min/max/fix size of button. Which is
- welcomed for multidisplay desktops with different resolution.
- """
- def __init__(self, *args, **kwargs):
- super(_SameSizeBtns, self).__init__(*args, **kwargs)
- self._related_btns = []
+ def set_source_pixmap(self, pixmap):
+ """Change source image."""
+ self._source_pixmap = pixmap
+ self._set_resized_pix()
- def add_related_btn(self, btn):
- """Add related button which should be checked for width.
+ def _get_pix_size(self):
+ size = self.fontMetrics().height() * 4
+ return size, size
- Args:
- btn (_SameSizeBtns): Other object of _SameSizeBtns.
- """
- self._related_btns.append(btn)
+ def _set_resized_pix(self):
+ if self._source_pixmap is None:
+ self.setPixmap(self._empty_pixmap)
+ return
+ width, height = self._get_pix_size()
+ self.setPixmap(
+ self._source_pixmap.scaled(
+ width,
+ height,
+ QtCore.Qt.KeepAspectRatio,
+ QtCore.Qt.SmoothTransformation
+ )
+ )
- def hint_width(self):
- """Get size hint of button not related to others."""
- return super(_SameSizeBtns, self).sizeHint().width()
-
- def sizeHint(self):
- """Calculate size hint based on size hint of this button and related.
-
- If width is lower than any other button it is changed to higher.
- """
- result = super(_SameSizeBtns, self).sizeHint()
- width = result.width()
- for btn in self._related_btns:
- btn_width = btn.hint_width()
- if btn_width > width:
- width = btn_width
-
- result.setWidth(width)
- return result
+ def resizeEvent(self, event):
+ self._set_resized_pix()
+ super(PixmapLabel, self).resizeEvent(event)
class ConfirmProjectDeletion(QtWidgets.QDialog):
@@ -336,15 +336,29 @@ class ConfirmProjectDeletion(QtWidgets.QDialog):
self.setWindowTitle("Delete project?")
- message_label = QtWidgets.QLabel(self)
+ top_widget = QtWidgets.QWidget(self)
+
+ warning_pixmap = ResourceCache.get_warning_pixmap()
+ warning_icon_label = PixmapLabel(warning_pixmap, top_widget)
+
+ message_label = QtWidgets.QLabel(top_widget)
message_label.setWordWrap(True)
message_label.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
message_label.setText((
+ "WARNING: This cannot be undone.
"
"Project \"{}\" with all related data will be"
" permanently removed from the database (This actions won't remove"
" any files on disk)."
).format(project_name))
+ top_layout = QtWidgets.QHBoxLayout(top_widget)
+ top_layout.setContentsMargins(0, 0, 0, 0)
+ top_layout.addWidget(
+ warning_icon_label, 0,
+ QtCore.Qt.AlignTop | QtCore.Qt.AlignHCenter
+ )
+ top_layout.addWidget(message_label, 1)
+
question_label = QtWidgets.QLabel("Are you sure?", self)
confirm_input = PlaceholderLineEdit(self)
@@ -359,16 +373,13 @@ class ConfirmProjectDeletion(QtWidgets.QDialog):
confirm_btn.setEnabled(False)
confirm_btn.setToolTip("Confirm deletion")
- cancel_btn.add_related_btn(confirm_btn)
- confirm_btn.add_related_btn(cancel_btn)
-
btns_layout = QtWidgets.QHBoxLayout()
btns_layout.addStretch(1)
btns_layout.addWidget(cancel_btn, 0)
btns_layout.addWidget(confirm_btn, 0)
layout = QtWidgets.QVBoxLayout(self)
- layout.addWidget(message_label, 0)
+ layout.addWidget(top_widget, 0)
layout.addStretch(1)
layout.addWidget(question_label, 0)
layout.addWidget(confirm_input, 0)