def headerData(self, section, orientation, role): if role == QtCore.Qt.DisplayRole: if section == self.Columns.index(SIDE_A): return "Name" if section == self.Columns.index(SIDE_B): return "Name" if section == self.Columns.index("diff"): return "Diff" if role == QtCore.Qt.ForegroundRole: if section == self.Columns.index(SIDE_A): return QtGui.QColor(SIDE_COLOR[SIDE_A]) if section == self.Columns.index(SIDE_B): return QtGui.QColor(SIDE_COLOR[SIDE_B]) if role == QtCore.Qt.TextAlignmentRole: return QtCore.Qt.AlignCenter if role == QtCore.Qt.FontRole: font = QtGui.QFont() font.setBold(True) return font return super(ComparerModel, self).headerData(section, orientation, role)
def paintEvent(self, event): painter = QtGui.QPainter() painter.begin(self) color = QtGui.QColor(self.colors[self.previous]) painter.setPen(color) painter.setBrush(QtGui.QBrush(color)) painter.drawEllipse(0, 1, 4, 4) painter.drawPixmap(3, 0, self.icons[self.level]) painter.end()
def data(self, index, role): if not index.isValid(): return item = index.internalPointer() if role == QtCore.Qt.DecorationRole: # icon column = index.column() if column == self.Name: # Allow a custom icon and custom icon color to be defined data = item.get("_document", {}).get("data", {}) icon = data.get("icon", None) if icon is None and item.get("type") == "silo": icon = "database" color = data.get("color", style.colors.default) if icon is None: # Use default icons if no custom one is specified. # If it has children show a full folder, otherwise # show an open folder has_children = self.rowCount(index) > 0 icon = "folder" if has_children else "folder-o" # Make the color darker when the asset is deprecated if item.get("deprecated", False): color = QtGui.QColor(color).darker(250) try: key = "fa.{0}".format(icon) # font-awesome key icon = qtawesome.icon(key, color=color) return icon except Exception as exception: # Log an error message instead of erroring out completely # when the icon couldn't be created (e.g. invalid name) log.error(exception) return if role == QtCore.Qt.ForegroundRole: # font color if "deprecated" in item.get("tags", []): return QtGui.QColor(style.colors.light).darker(250) if role == self.ObjectIdRole: return item.get("_id", None) if role == self.DocumentRole: return item.get("_document", None) return super(AssetModel, self).data(index, role)
def data(self, index, role): if not index.isValid(): return if role == QtCore.Qt.DisplayRole: if self.Columns[index.column()] == "value": item = index.internalPointer() value = item.get(self._feature, "") if value and self._feature == "avalonId": time = lib.avalon_id_pretty_time(value) value = "%s [%s]" % (time, value) return value else: return "" if role == QtCore.Qt.DecorationRole: if self.Columns[index.column()] == "side": if index.row(): return self._side_icons[1] else: return self._side_icons[0] if role == QtCore.Qt.FontRole: font = QtGui.QFont("Monospace") font.setStyleHint(QtGui.QFont.TypeWriter) return font return super(FocusModel, self).data(index, role)
def popup(): """Pop-up the existing menu near the mouse cursor""" menu = _get_menu() cursor = QtGui.QCursor() point = cursor.pos() menu.exec_(point)
def process(self, containers): """Color all selected tools the selected colors""" result = [] comp = avalon.fusion.get_current_comp() # Get tool color first = containers[0] tool = first["_tool"] color = tool.TileColor if color is not None: qcolor = QtGui.QColor().fromRgbF(color["R"], color["G"], color["B"]) else: qcolor = self._fallback_color # Launch pick color picked_color = self.get_color_picker(qcolor) if not picked_color: return with avalon.fusion.comp_lock_and_undo_chunk(comp): for container in containers: # Convert color to RGB 0-1 floats rgb_f = picked_color.getRgbF() rgb_f_table = {"R": rgb_f[0], "G": rgb_f[1], "B": rgb_f[2]} # Update tool tool = container["_tool"] tool.TileColor = rgb_f_table result.append(container) return result
def __init__(self, data, parent=None): super(CustomListModel, self).__init__(parent) self.items = data index = QtCore.QModelIndex() self.beginInsertRows(index, 0, len(data)) for item in data: self.beginInsertRows(index, 0, 0) pass self.endInsertRows() self.icons = [] app_path = os.path.dirname(os.path.realpath(__file__)) self.icons.append( QtGui.QIcon(os.path.join(app_path, 'res/not_converted.png'))) self.icons.append(QtGui.QIcon(os.path.join(app_path, 'res/source.png'))) self.icons.append(QtGui.QIcon(os.path.join(app_path, 'res/exr.png')))
def data(self, index, role): if not index.isValid(): return if role == QtCore.Qt.FontRole: if index.column() in ( self.Columns.index("namespace"), self.Columns.index("name"), ): node = index.internalPointer() font = QtGui.QFont("Monospace") font.setStyleHint(QtGui.QFont.TypeWriter) font.setBold(node["isLatest"]) font.setItalic(not node["isLatest"]) return font if role == QtCore.Qt.ForegroundRole: if index.column() in ( self.Columns.index("namespace"), self.Columns.index("name"), ): node = index.internalPointer() if not node["isLatest"]: return QtGui.QColor(120, 120, 120) if role == QtCore.Qt.DecorationRole: if index.column() == self.Columns.index("name"): node = index.internalPointer() if "isLocked" in node: is_locked = node["isLocked"] set_locked = node["setLocked"] if set_locked is None or set_locked == is_locked: return self.status_icon[is_locked] else: return self.status_icon[set_locked + 2] return super(SelectionModel, self).data(index, role)
def data(self, index, role): if not index.isValid(): return if role == QtCore.Qt.FontRole: if index.column() in ( self.Columns.index("Id"), self.Columns.index("name"), ): font = QtGui.QFont("Monospace") font.setStyleHint(QtGui.QFont.TypeWriter) font.setBold(True) return font if role == QtCore.Qt.DecorationRole: if index.column() == self.Columns.index("Id"): node = index.internalPointer() status = node["status"] if (status == utils.Identifier.Clean and node["Id"] in self._duplicated_id): # Is duplicate source status = 3 elif node["isReferenced"]: if status == utils.Identifier.Untracked: # Is referenced but untracked status = 5 elif status == utils.Identifier.Duplicated: # Is referenced but duplicated status = 4 return self.status_icon[status] if index.column() == self.Columns.index("name"): node = index.internalPointer() is_referenced = node["isReferenced"] return self.reference_icon[is_referenced] if role == self.NodeNameDataRole: node = index.internalPointer() return (node["name"], node["namespace"], node["isReferenced"]) return super(SelectionModel, self).data(index, role)
def main(launch_args): # Be sure server won't crash at any moment but just print traceback sys.excepthook = safe_excepthook # Create QtApplication for tools # - QApplicaiton is also main thread/event loop of the server qt_app = QtWidgets.QApplication([]) # Execute pipeline installation api.install(tvpaint) # Create Communicator object and trigger launch # - this must be done before anything is processed communicator = CommunicationWrapper.create_communicator(qt_app) communicator.launch(launch_args) def process_in_main_thread(): """Execution of `MainThreadItem`.""" item = communicator.main_thread_listen() if item: item.execute() timer = QtCore.QTimer() timer.setInterval(100) timer.timeout.connect(process_in_main_thread) timer.start() # Register terminal signal handler def signal_handler(*_args): print("You pressed Ctrl+C. Process ended.") communicator.stop() signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGTERM, signal_handler) qt_app.setQuitOnLastWindowClosed(False) qt_app.setStyleSheet(style.load_stylesheet()) # Load avalon icon icon_path = get_icon_path() if icon_path: icon = QtGui.QIcon(icon_path) qt_app.setWindowIcon(icon) # Set application name to be able show application icon in task bar if platform.system().lower() == "windows": ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID( u"WebsocketServer") # Run Qt application event processing sys.exit(qt_app.exec_())
def __init__(self, parent=None): super(ResolutionEditor, self).__init__(parent) weditor = QtWidgets.QLineEdit() heditor = QtWidgets.QLineEdit() weditor.setValidator(QtGui.QIntValidator()) heditor.setValidator(QtGui.QIntValidator()) layout = QtWidgets.QHBoxLayout(self) layout.addWidget(weditor) layout.addWidget(heditor) # This is important to make those QLineEdit widgets to have # proper hight in column. layout.setContentsMargins(2, 0, 2, 0) weditor.editingFinished.connect(self.on_editingFinished) heditor.editingFinished.connect(self.on_editingFinished) self.data = { "w": weditor, "h": heditor, }
def __init__(self, level, parent=None): super(DatabaseDocumentModel, self).__init__(parent=parent) self.lister = { "silo": self.list_silos, "asset": self.list_assets, "subset": self.list_subsets, "version": self.list_versions, }[level] self.placeholder = "< Select %s.. >" % level.capitalize() self.placeholder_item = QtGui.QStandardItem( qtawesome.icon("fa.hand-o-right", color="white"), self.placeholder) self.reset(None)
def data(self, index, role): # Set the connected item in italics if role == QtCore.Qt.FontRole: font = QtGui.QFont() node = index.internalPointer() if not self._linked_index: return font is_connected = self._linked_index in node.get("linkedIndex", []) if is_connected: font.setItalic(True) font.setBold(True) return font return super(MatchModel, self).data(index, role)
def reset(self, parent): self.blockSignals(True) self.clear() self.blockSignals(False) self.beginResetModel() self.appendRow(self.placeholder_item) for document in self.lister(parent): item = QtGui.QStandardItem(document["name"]) item.setData(document["_id"], QtCore.Qt.UserRole) self.appendRow(item) self.endResetModel()
def data(self, index, role): if not index.isValid(): return if role == QtCore.Qt.FontRole: font = QtGui.QFont("Monospace") font.setStyleHint(QtGui.QFont.TypeWriter) return font if role == self.HTMLTextRole: node = index.internalPointer() return node["fpatternHTML"] if role == QtCore.Qt.DecorationRole: if index.column() == self.Columns.index("name"): if self._stereo: node = index.internalPointer() side = node.get("stereoSide") return self._stereo_icons[side] return super(SequenceModel, self).data(index, role)
def reset(self): self.blockSignals(True) self.clear() self.blockSignals(False) host = api.registered_host() if host is None: return self.beginResetModel() self.appendRow(self.placeholder_item) for container in host.ls(): if lib.is_supported_loader(container["loader"]): item = QtGui.QStandardItem(container["namespace"][1:]) item.setData(container, QtCore.Qt.UserRole) self.appendRow(item) self.endResetModel()
def get_additional_data(container): """Get Nuke's related data for the container Args: container(dict): the container found by the ls() function Returns: dict """ node = container["_tool"] tile_color = node['tile_color'].value() if tile_color is None: return {} hex = '%08x' % tile_color rgba = [ float(int(hex[0:2], 16)) / 255.0, float(int(hex[2:4], 16)) / 255.0, float(int(hex[4:6], 16)) / 255.0 ] return {"color": QtGui.QColor().fromRgbF(rgba[0], rgba[1], rgba[2])}
def paint(self, painter, option, index): index = self.proxy.mapToSource(index) text = index.data(self.role) doc = QtGui.QTextDocument() doc.setHtml(text) doc_layout = doc.documentLayout() self.style.drawControl(QtWidgets.QStyle.CE_ItemViewItem, option, painter) rect = option.rect rect.setTop(rect.top() + 5) painter.save() painter.translate(rect.topLeft()) painter.setClipRect(rect.translated(-rect.topLeft())) ctx = doc_layout.PaintContext() doc_layout.draw(painter, ctx) painter.restore()
def __init__(self, parent=None): super(Project_name_getUI, self).__init__(parent) self.platform = platform.system() self.new_index = 0 # get projects from ftrack self.session = ftrack_api.Session() self.projects_from_ft = self.session.query( 'Project where status is active') self.disks_from_ft = self.session.query('Disk') self.schemas_from_ft = self.session.query('ProjectSchema') self.projects = self._get_projects_ftrack() # define window geometry self.setWindowTitle('Set project attributes') self.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint) self.resize(550, 340) self.setStyleSheet(style.load_stylesheet()) # define disk combobox widget self.disks = self._get_all_disks() self.disk_combobox_label = QtWidgets.QLabel('Destination storage:') self.disk_combobox = QtWidgets.QComboBox() # define schema combobox widget self.schemas = self._get_all_schemas() self.schema_combobox_label = QtWidgets.QLabel('Project schema:') self.schema_combobox = QtWidgets.QComboBox() # define fps widget self.fps_label = QtWidgets.QLabel('Fps:') self.fps_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.fps = QtWidgets.QLineEdit() # define project dir widget self.project_dir_label = QtWidgets.QLabel('Project dir:') self.project_dir_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.project_dir = QtWidgets.QLineEdit() self.project_path_label = QtWidgets.QLabel( 'Project_path (if not then created):') self.project_path_label.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) project_path_font = QtGui.QFont("Helvetica [Cronyx]", 12, QtGui.QFont.Bold) self.project_path = QtWidgets.QLabel() self.project_path.setObjectName('nom_plan_label') self.project_path.setStyleSheet( 'QtWidgets.QLabel#nom_plan_label {color: red}') self.project_path.setAlignment(QtCore.Qt.AlignHCenter | QtCore.Qt.AlignVCenter) self.project_path.setFont(project_path_font) # define handles widget self.handles_label = QtWidgets.QLabel('Handles:') self.handles_label.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.handles = QtWidgets.QLineEdit() # define resolution widget self.resolution_w_label = QtWidgets.QLabel('W:') self.resolution_w = QtWidgets.QLineEdit() self.resolution_h_label = QtWidgets.QLabel('H:') self.resolution_h = QtWidgets.QLineEdit() devider = QtWidgets.QFrame() # devider.Shape(QFrame.HLine) devider.setFrameShape(QtWidgets.QFrame.HLine) devider.setFrameShadow(QtWidgets.QFrame.Sunken) self.generate_lines() # define push buttons self.set_pushbutton = QtWidgets.QPushButton('Set project') self.cancel_pushbutton = QtWidgets.QPushButton('Cancel') # definition of layouts ############################################ action_layout = QtWidgets.QHBoxLayout() action_layout.addWidget(self.set_pushbutton) action_layout.addWidget(self.cancel_pushbutton) # schema property schema_layout = QtWidgets.QGridLayout() schema_layout.addWidget(self.schema_combobox, 0, 1) schema_layout.addWidget(self.schema_combobox_label, 0, 0) # storage property storage_layout = QtWidgets.QGridLayout() storage_layout.addWidget(self.disk_combobox, 0, 1) storage_layout.addWidget(self.disk_combobox_label, 0, 0) # fps property fps_layout = QtWidgets.QGridLayout() fps_layout.addWidget(self.fps, 1, 1) fps_layout.addWidget(self.fps_label, 1, 0) # project dir property project_dir_layout = QtWidgets.QGridLayout() project_dir_layout.addWidget(self.project_dir, 1, 1) project_dir_layout.addWidget(self.project_dir_label, 1, 0) # project path property project_path_layout = QtWidgets.QGridLayout() spacer_1_item = QtWidgets.QSpacerItem(10, 10) project_path_layout.addItem(spacer_1_item, 0, 1) project_path_layout.addWidget(self.project_path_label, 1, 1) project_path_layout.addWidget(self.project_path, 2, 1) spacer_2_item = QtWidgets.QSpacerItem(20, 20) project_path_layout.addItem(spacer_2_item, 3, 1) # handles property handles_layout = QtWidgets.QGridLayout() handles_layout.addWidget(self.handles, 1, 1) handles_layout.addWidget(self.handles_label, 1, 0) # resolution property resolution_layout = QtWidgets.QGridLayout() resolution_layout.addWidget(self.resolution_w_label, 1, 1) resolution_layout.addWidget(self.resolution_w, 2, 1) resolution_layout.addWidget(self.resolution_h_label, 1, 2) resolution_layout.addWidget(self.resolution_h, 2, 2) # form project property layout p_layout = QtWidgets.QGridLayout() p_layout.addLayout(storage_layout, 1, 0) p_layout.addLayout(schema_layout, 2, 0) p_layout.addLayout(project_dir_layout, 3, 0) p_layout.addLayout(fps_layout, 4, 0) p_layout.addLayout(handles_layout, 5, 0) p_layout.addLayout(resolution_layout, 6, 0) p_layout.addWidget(devider, 7, 0) spacer_item = QtWidgets.QSpacerItem(150, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) p_layout.addItem(spacer_item, 8, 0) # form with list to one layout with project property list_layout = QtWidgets.QGridLayout() list_layout.addLayout(p_layout, 1, 0) list_layout.addWidget(self.listWidget, 1, 1) root_layout = QtWidgets.QVBoxLayout() root_layout.addLayout(project_path_layout) root_layout.addWidget(devider) root_layout.addLayout(list_layout) root_layout.addLayout(action_layout) self.setLayout(root_layout)
def install(): """ Installing menu into Nukestudio """ # here is the best place to add menu from avalon.tools import publish, cbloader from avalon.vendor.Qt import QtGui menu_name = os.environ['AVALON_LABEL'] context_label = "{0}, {1}".format(Session["AVALON_ASSET"], Session["AVALON_TASK"]) self._change_context_menu = context_label try: check_made_menu = findMenuAction(menu_name) except Exception: check_made_menu = None if not check_made_menu: # Grab Hiero's MenuBar menu = hiero.ui.menuBar().addMenu(menu_name) else: menu = check_made_menu.menu() context_label_action = menu.addAction(context_label) context_label_action.setEnabled(False) menu.addSeparator() workfiles_action = menu.addAction("Work Files...") workfiles_action.setIcon(QtGui.QIcon("icons:Position.png")) workfiles_action.triggered.connect(set_workfiles) default_tags_action = menu.addAction("Create Default Tags...") default_tags_action.setIcon(QtGui.QIcon("icons:Position.png")) default_tags_action.triggered.connect(add_tags_from_presets) menu.addSeparator() publish_action = menu.addAction("Publish...") publish_action.setIcon(QtGui.QIcon("icons:Output.png")) publish_action.triggered.connect( lambda *args: publish.show(hiero.ui.mainWindow())) loader_action = menu.addAction("Load...") loader_action.setIcon(QtGui.QIcon("icons:CopyRectangle.png")) loader_action.triggered.connect(cbloader.show) menu.addSeparator() reload_action = menu.addAction("Reload pipeline...") reload_action.setIcon(QtGui.QIcon("icons:ColorAdd.png")) reload_action.triggered.connect(reload_config) # Is this required? # hiero.ui.registerAction(context_label_action) # hiero.ui.registerAction(workfiles_action) # hiero.ui.registerAction(default_tags_action) # hiero.ui.registerAction(publish_action) # hiero.ui.registerAction(loader_action) # hiero.ui.registerAction(reload_action) self.context_label_action = context_label_action self.workfile_actions = workfiles_action self.default_tags_action = default_tags_action self.publish_action = publish_action self.reload_action = reload_action
def _show_no_gui(): """ Popup with information about how to register a new GUI In the event of no GUI being registered or available, this information dialog will appear to guide the user through how to get set up with one. """ messagebox = QtWidgets.QMessageBox() messagebox.setIcon(messagebox.Warning) messagebox.setWindowIcon( QtGui.QIcon( os.path.join(os.path.dirname(pyblish.__file__), "icons", "logo-32x32.svg"))) spacer = QtWidgets.QWidget() spacer.setMinimumSize(400, 0) spacer.setSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) layout = messagebox.layout() layout.addWidget(spacer, layout.rowCount(), 0, 1, layout.columnCount()) messagebox.setWindowTitle("Uh oh") messagebox.setText("No registered GUI found.") if not pyblish.api.registered_guis(): messagebox.setInformativeText( "In order to show you a GUI, one must first be registered. " "Press \"Show details...\" below for information on how to " "do that.") messagebox.setDetailedText( "Pyblish supports one or more graphical user interfaces " "to be registered at once, the next acting as a fallback to " "the previous." "\n" "\n" "For example, to use Pyblish Lite, first install it:" "\n" "\n" "$ pip install pyblish-lite" "\n" "\n" "Then register it, like so:" "\n" "\n" ">>> import pyblish.api\n" ">>> pyblish.api.register_gui(\"pyblish_lite\")" "\n" "\n" "The next time you try running this, Lite will appear." "\n" "See http://api.pyblish.com/register_gui.html for " "more information.") else: messagebox.setInformativeText( "None of the registered graphical user interfaces " "could be found." "\n" "\n" "Press \"Show details\" for more information.") messagebox.setDetailedText("These interfaces are currently registered." "\n" "%s" % "\n".join(pyblish.api.registered_guis())) messagebox.setStandardButtons(messagebox.Ok) messagebox.exec_()
def data(self, index, role): if not index.isValid(): return if role == QtCore.Qt.DisplayRole: column = index.column() if self.Columns[column] == SIDE_A: item = index.internalPointer() if not item.get(SIDE_A_DATA): return if self._use_long_name: return item[SIDE_A_DATA]["longName"] else: return item[SIDE_A_DATA]["shortName"] if self.Columns[column] == SIDE_B: item = index.internalPointer() if not item.get(SIDE_B_DATA): return if self._use_long_name: return item[SIDE_B_DATA]["longName"] else: return item[SIDE_B_DATA]["shortName"] if role == QtCore.Qt.ForegroundRole: column = index.column() if self.Columns[column] == SIDE_A: item = index.internalPointer() if not item.get(SIDE_A_DATA): return if not item[SIDE_A_DATA]["fromHost"]: return QtGui.QColor("gray") if self.Columns[column] == SIDE_B: item = index.internalPointer() if not item.get(SIDE_B_DATA): return if not item[SIDE_B_DATA]["fromHost"]: return QtGui.QColor("gray") if role == QtCore.Qt.FontRole: column = index.column() if self.Columns[column] == SIDE_A: item = index.internalPointer() if not item.get(SIDE_A_DATA): return if item[SIDE_A_DATA]["fromHost"]: bold = QtGui.QFont() bold.setBold(True) return bold else: return if self.Columns[column] == SIDE_B: item = index.internalPointer() if not item.get(SIDE_B_DATA): return if item[SIDE_B_DATA]["fromHost"]: bold = QtGui.QFont() bold.setBold(True) return bold else: return if role == self.HostSelectRole: column = index.column() if self.Columns[column] == SIDE_A: item = index.internalPointer() if not item.get(SIDE_A_DATA): return if item[SIDE_A_DATA]["fromHost"]: return item[SIDE_A_DATA]["longName"] else: return if self.Columns[column] == SIDE_B: item = index.internalPointer() if not item.get(SIDE_B_DATA): return if item[SIDE_B_DATA]["fromHost"]: return item[SIDE_B_DATA]["longName"] else: return if role == self.DiffStateRole: column = index.column() if self.Columns[column] == "diff": item = index.internalPointer() name_state = item["matchMethod"] points_state = item["points"] uvmap_state = item["uvmap"] return name_state, points_state, uvmap_state return super(ComparerModel, self).data(index, role)
def menu_install(): """ Installing menu into Hiero """ from . import (publish, launch_workfiles_app, reload_config, apply_colorspace_project, apply_colorspace_clips) # here is the best place to add menu from avalon.tools import cbloader, creator, sceneinventory from avalon.vendor.Qt import QtGui menu_name = os.environ['AVALON_LABEL'] context_label = "{0}, {1}".format(Session["AVALON_ASSET"], Session["AVALON_TASK"]) self._change_context_menu = context_label try: check_made_menu = findMenuAction(menu_name) except Exception: check_made_menu = None if not check_made_menu: # Grab Hiero's MenuBar menu = hiero.ui.menuBar().addMenu(menu_name) else: menu = check_made_menu.menu() context_label_action = menu.addAction(context_label) context_label_action.setEnabled(False) menu.addSeparator() workfiles_action = menu.addAction("Work Files...") workfiles_action.setIcon(QtGui.QIcon("icons:Position.png")) workfiles_action.triggered.connect(launch_workfiles_app) default_tags_action = menu.addAction("Create Default Tags...") default_tags_action.setIcon(QtGui.QIcon("icons:Position.png")) default_tags_action.triggered.connect(tags.add_tags_to_workfile) menu.addSeparator() publish_action = menu.addAction("Publish...") publish_action.setIcon(QtGui.QIcon("icons:Output.png")) publish_action.triggered.connect( lambda *args: publish(hiero.ui.mainWindow())) creator_action = menu.addAction("Create...") creator_action.setIcon(QtGui.QIcon("icons:CopyRectangle.png")) creator_action.triggered.connect(creator.show) loader_action = menu.addAction("Load...") loader_action.setIcon(QtGui.QIcon("icons:CopyRectangle.png")) loader_action.triggered.connect(cbloader.show) sceneinventory_action = menu.addAction("Manage...") sceneinventory_action.setIcon(QtGui.QIcon("icons:CopyRectangle.png")) sceneinventory_action.triggered.connect(sceneinventory.show) menu.addSeparator() reload_action = menu.addAction("Reload pipeline...") reload_action.setIcon(QtGui.QIcon("icons:ColorAdd.png")) reload_action.triggered.connect(reload_config) menu.addSeparator() apply_colorspace_p_action = menu.addAction("Apply Colorspace Project...") apply_colorspace_p_action.setIcon(QtGui.QIcon("icons:ColorAdd.png")) apply_colorspace_p_action.triggered.connect(apply_colorspace_project) apply_colorspace_c_action = menu.addAction("Apply Colorspace Clips...") apply_colorspace_c_action.setIcon(QtGui.QIcon("icons:ColorAdd.png")) apply_colorspace_c_action.triggered.connect(apply_colorspace_clips) self.context_label_action = context_label_action self.workfile_actions = workfiles_action self.default_tags_action = default_tags_action self.publish_action = publish_action self.reload_action = reload_action
class FusionSetToolColor(api.InventoryAction): """Update the color of the selected tools""" label = "Set Tool Color" icon = "plus" color = "#d8d8d8" _fallback_color = QtGui.QColor(1.0, 1.0, 1.0) def process(self, containers): """Color all selected tools the selected colors""" result = [] comp = avalon.fusion.get_current_comp() # Get tool color first = containers[0] tool = first["_tool"] color = tool.TileColor if color is not None: qcolor = QtGui.QColor().fromRgbF(color["R"], color["G"], color["B"]) else: qcolor = self._fallback_color # Launch pick color picked_color = self.get_color_picker(qcolor) if not picked_color: return with avalon.fusion.comp_lock_and_undo_chunk(comp): for container in containers: # Convert color to RGB 0-1 floats rgb_f = picked_color.getRgbF() rgb_f_table = {"R": rgb_f[0], "G": rgb_f[1], "B": rgb_f[2]} # Update tool tool = container["_tool"] tool.TileColor = rgb_f_table result.append(container) return result def get_color_picker(self, color): """Launch color picker and return chosen color Args: color(QtGui.QColor): Start color to display Returns: QtGui.QColor """ color_dialog = QtWidgets.QColorDialog(color) color_dialog.setStyleSheet(style.load_stylesheet()) accepted = color_dialog.exec_() if not accepted: return return color_dialog.selectedColor()
def __init__(self, parent=None): super(HostContainerListModel, self).__init__(parent=parent) self.placeholder_item = QtGui.QStandardItem( lib.icon("hand-o-right", color="white"), "< Select Container.. >" )
def data(self, index, role): if not index.isValid(): return if role == QtCore.Qt.DisplayRole: column = index.column() if self.Columns[column] == SIDE_A: item = index.internalPointer() if not item.get(SIDE_A_DATA): return "" return item[SIDE_A_DATA]["shortName"] if self.Columns[column] == SIDE_B: item = index.internalPointer() if not item.get(SIDE_B_DATA): return "" return item[SIDE_B_DATA]["shortName"] if role == QtCore.Qt.DecorationRole: column = index.column() if self.Columns[column] == SIDE_A: if index == self._focused_indexes[SIDE_A]: return self._focused_icons[0] elif self.Columns[column] == SIDE_B: if index == self._focused_indexes[SIDE_B]: return self._focused_icons[1] if role == QtCore.Qt.ForegroundRole: column = index.column() if self.Columns[column] == SIDE_A: item = index.internalPointer() if not item.get(SIDE_A_DATA): return if not item[SIDE_A_DATA]["fromHost"]: return QtGui.QColor("gray") if self.Columns[column] == SIDE_B: item = index.internalPointer() if not item.get(SIDE_B_DATA): return if not item[SIDE_B_DATA]["fromHost"]: return QtGui.QColor("gray") if role == QtCore.Qt.TextAlignmentRole: return QtCore.Qt.AlignCenter if role == QtCore.Qt.FontRole: column = index.column() if self.Columns[column] == SIDE_A: item = index.internalPointer() if not item.get(SIDE_A_DATA): return if item[SIDE_A_DATA]["fromHost"]: bold = QtGui.QFont() bold.setBold(True) return bold else: return if self.Columns[column] == SIDE_B: item = index.internalPointer() if not item.get(SIDE_B_DATA): return if item[SIDE_B_DATA]["fromHost"]: bold = QtGui.QFont() bold.setBold(True) return bold else: return if role == self.HostSelectRole: column = index.column() if self.Columns[column] == SIDE_A: item = index.internalPointer() if not item.get(SIDE_A_DATA): return if item[SIDE_A_DATA]["fromHost"]: return item[SIDE_A_DATA]["fullPath"] else: return if self.Columns[column] == SIDE_B: item = index.internalPointer() if not item.get(SIDE_B_DATA): return if item[SIDE_B_DATA]["fromHost"]: return item[SIDE_B_DATA]["fullPath"] else: return if role == self.DiffStateRole: column = index.column() if self.Columns[column] == "diff": item = index.internalPointer() name_state = item["matchMethod"] points_state = item["points"] uvmap_state = item["uvmap"] if not item.get(SIDE_A_DATA) or item[SIDE_A_DATA]["fromHost"]: protected_A = -1 else: protected_A = item[SIDE_A_DATA]["protected"] if not item.get(SIDE_B_DATA) or item[SIDE_B_DATA]["fromHost"]: protected_B = -1 else: protected_B = item[SIDE_B_DATA]["protected"] protected = (protected_A, protected_B) return name_state, points_state, uvmap_state, protected return super(ComparerModel, self).data(index, role)