new publisher ui beginning

This commit is contained in:
iLLiCiTiT 2021-06-17 19:32:43 +02:00
parent ccd90bf770
commit b9fa9258d1
4 changed files with 195 additions and 0 deletions

View file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

View file

@ -0,0 +1,98 @@
import os
from Qt import QtWidgets, QtCore, QtGui
def get_default_thumbnail_image_path():
dirpath = os.path.dirname(os.path.abspath(__file__))
return os.path.join(dirpath, "image_file.png")
class SubsetAttributesWidget(QtWidgets.QWidget):
def __init__(self, parent):
super(SubsetAttributesWidget, self).__init__(parent)
"""
_____________________________
| | |
| Global | Thumbnail |
| attributes | | TOP
|_________________|___________|
| | |
| | Publish |
| Family | plugin |
| attributes | attributes | BOTTOM
|______________|______________|
"""
# TOP PART
top_widget = QtWidgets.QWidget(self)
# Global attributes
global_attrs_widget = QtWidgets.QWidget(top_widget)
variant_input = QtWidgets.QLineEdit(global_attrs_widget)
subset_value_widget = QtWidgets.QLabel(global_attrs_widget)
family_value_widget = QtWidgets.QLabel(global_attrs_widget)
asset_value_widget = QtWidgets.QLabel(global_attrs_widget)
task_value_widget = QtWidgets.QLabel(global_attrs_widget)
subset_value_widget.setText("<Subset>")
family_value_widget.setText("<Family>")
asset_value_widget.setText("<Asset>")
task_value_widget.setText("<Task>")
global_attrs_layout = QtWidgets.QFormLayout(global_attrs_widget)
global_attrs_layout.addRow("Name", variant_input)
global_attrs_layout.addRow("Family", family_value_widget)
global_attrs_layout.addRow("Asset", asset_value_widget)
global_attrs_layout.addRow("Task", task_value_widget)
global_attrs_layout.addRow("Subset", subset_value_widget)
thumbnail_widget = ThumbnailWidget(top_widget)
top_layout = QtWidgets.QHBoxLayout(top_widget)
top_layout.setContentsMargins(0, 0, 0, 0)
top_layout.addWidget(global_attrs_widget, 7)
top_layout.addWidget(thumbnail_widget, 3)
# BOTTOM PART
bottom_widget = QtWidgets.QWidget(self)
# TODO they should be scrollable
family_attrs_widget = QtWidgets.QWidget(bottom_widget)
publish_attrs_widget = QtWidgets.QWidget(bottom_widget)
bottom_layout = QtWidgets.QHBoxLayout(bottom_widget)
bottom_layout.setContentsMargins(0, 0, 0, 0)
bottom_layout.addWidget(family_attrs_widget, 1)
bottom_layout.addWidget(publish_attrs_widget, 1)
layout = QtWidgets.QVBoxLayout(self)
layout.addWidget(top_widget, 0)
layout.addWidget(bottom_widget, 1)
self.global_attrs_widget = global_attrs_widget
self.thumbnail_widget = thumbnail_widget
class ThumbnailWidget(QtWidgets.QWidget):
def __init__(self, parent):
super(ThumbnailWidget, self).__init__(parent)
default_pix = QtGui.QPixmap(get_default_thumbnail_image_path())
thumbnail_label = QtWidgets.QLabel(self)
thumbnail_label.setPixmap(
default_pix.scaled(
200, 100,
QtCore.Qt.KeepAspectRatio,
QtCore.Qt.SmoothTransformation
)
)
layout = QtWidgets.QHBoxLayout(self)
layout.setContentsMargins(0, 0, 0, 0)
layout.addWidget(thumbnail_label, alignment=QtCore.Qt.AlignCenter)
self.thumbnail_label = thumbnail_label
self.default_pix = default_pix
self.current_pix = None

View file

@ -0,0 +1,97 @@
import sys
sys.path.append(r"C:\Users\iLLiCiT\PycharmProjects\pype3\.venv\Lib\site-packages")
from Qt import QtWidgets, QtCore
from widgets import SubsetAttributesWidget
class PublisherWindow(QtWidgets.QWidget):
def __init__(self, parent=None):
super(PublisherWindow, self).__init__(parent)
# TODO Title, Icon, Stylesheet
main_frame = QtWidgets.QWidget(self)
# Header
context_label = QtWidgets.QLabel(main_frame)
# Content
content_widget = QtWidgets.QWidget(main_frame)
# Subset widget
subset_widget = QtWidgets.QWidget(content_widget)
subset_view = QtWidgets.QTreeView(subset_widget)
subset_attributes = SubsetAttributesWidget(subset_widget)
subset_layout = QtWidgets.QHBoxLayout(subset_widget)
subset_layout.addWidget(subset_view, 0)
subset_layout.addWidget(subset_attributes, 1)
content_layout = QtWidgets.QVBoxLayout(content_widget)
content_layout.setContentsMargins(0, 0, 0, 0)
content_layout.addWidget(subset_widget)
# Footer
footer_widget = QtWidgets.QWidget(self)
message_input = QtWidgets.QLineEdit(footer_widget)
validate_btn = QtWidgets.QPushButton("Validate", footer_widget)
publish_btn = QtWidgets.QPushButton("Publish", footer_widget)
footer_layout = QtWidgets.QHBoxLayout(footer_widget)
footer_layout.setContentsMargins(0, 0, 0, 0)
footer_layout.addWidget(message_input, 1)
footer_layout.addWidget(validate_btn, 0)
footer_layout.addWidget(publish_btn, 0)
# Main frame
main_frame_layout = QtWidgets.QVBoxLayout(main_frame)
main_frame_layout.addWidget(context_label, 0)
main_frame_layout.addWidget(content_widget, 1)
main_frame_layout.addWidget(footer_widget, 0)
# Add main frame to this window
main_layout = QtWidgets.QHBoxLayout(self)
main_layout.addWidget(main_frame)
validate_btn.clicked.connect(self._on_validate_clicked)
publish_btn.clicked.connect(self._on_publish_clicked)
self.main_frame = main_frame
self.context_label = context_label
self.footer_widget = footer_widget
self.message_input = message_input
self.validate_btn = validate_btn
self.publish_btn = publish_btn
# DEBUGING
self.set_context_label(
"<project>/<hierarchy>/<asset>/<task>/<workfile>"
)
# self.setStyleSheet("border: 1px solid black;")
def set_context_label(self, label):
self.context_label.setText(label)
def _on_validate_clicked(self):
print("Validation!!!")
def _on_publish_clicked(self):
print("Publishing!!!")
def main():
"""Main function for testing purposes."""
app = QtWidgets.QApplication([])
window = PublisherWindow()
window.show()
app.exec_()
if __name__ == "__main__":
main()