def __init__(self, parent=None): super(License_dialog, self).__init__(parent) self.setStyleSheet(cfg.stylesheet) self.layout = QtWidgets.QVBoxLayout(self) self.pipelineUI = self.parent() self.version = pipeline.__version__ self.input_widget = QtWidgets.QWidget(self) self.input_layout = QtWidgets.QVBoxLayout(self.input_widget) self.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) self.input_layout.setContentsMargins(5, 5, 5, 5) self.layout.setContentsMargins(10, 10, 10, 10) self.title = gui.Title( self, label="Please enter your Pipeline {} license key:".format( self.version[0]), seperator=False) self.title.layout.setContentsMargins(5, 0, 5, 0) self.input_layout.addWidget(self.title) self.note = gui.Title(self, label="Activation requires internet connection.") font = QtGui.QFont() font.setItalic(True) self.note.label.setFont(font) self.input_layout.addWidget(self.note) self.key_widget = inputs.GroupInput( self, label="Key", inputWidget=QtWidgets.QLineEdit(self), ic=cfg.lock_icon) self.key_input = self.key_widget.input self.key_widget.label.setMinimumSize(QtCore.QSize(10, 30)) self.key_widget.label.setText("") self.key_input.setMinimumSize(QtCore.QSize(300, 30)) self.input_layout.addWidget(self.key_widget) self.layout.addWidget(self.input_widget) ok = QtWidgets.QPushButton("Activate") ok.setDefault(True) canc = QtWidgets.QPushButton("Cancel") buttons = QtWidgets.QDialogButtonBox(QtCore.Qt.Horizontal) buttons.addButton(ok, QtWidgets.QDialogButtonBox.AcceptRole) buttons.addButton(canc, QtWidgets.QDialogButtonBox.RejectRole) buttons.accepted.connect(self.accept) buttons.rejected.connect(self.reject) self.layout.addWidget(buttons)
def remove(self, node, index): if node.typeInfo() == cfg._node_: self.model().removeRows(0,1,QtCore.QModelIndex(),node) self.edited.emit() else: if not self.dummy: string = "Caution: This is not undoable,\nBranch {} and all of its contants will be deleted!".format(node.name) alert = massage.Prompt_alert(alert_string=string) result = alert.exec_() if result == QtWidgets.QDialog.Accepted: node.delete_me() self.model().removeRows(0, 1, QtCore.QModelIndex(), node) self.edited.emit()
def __init__(self, parent=None, preset_file=None, **kwargs): super(Preset_generation_dialog, self).__init__(parent, **kwargs) self.setWindowTitle("Preset generation") self.hierarchy_label.setMaximumHeight(30) self.components_label.setMaximumHeight(30) self.hierarchy_help_label.setHidden(True) self.components_help_label.setHidden(True) self.save_preset_btn.setHidden(True) self.load_preset_btn.setHidden(True) self.generate_preset_btn = QtWidgets.QPushButton("Generate tree") self.generate_preset_btn.setIcon(QtGui.QIcon(cfg.creation_icon)) self.generate_preset_btn.setIconSize(QtCore.QSize(20, 20)) self.actions_widget_layout.addWidget(self.generate_preset_btn) self.generate_preset_btn.clicked.connect(self.generate_preset) if preset_file: self.set_preset(preset_file) self.show() else: if self.load_preset(): self.show() else: pass
def remove_script(self, *args): rows = self.scripts_table_view.selectionModel().selectedRows() # logger.info(rows) if rows: # index = rows[0].row() self.scripts_table_view.model().removeRows( rows[0].row(), 1, parent=QtCore.QModelIndex())
class AlphaButton(QtWidgets.QWidget): alphaClick = QtCore.Signal() ''' custom QLbael the can send clicked signal, only from the pixmap are that has 100% alpha used for the thumbnail transperent icon button ''' def __init__(self, parent, alpha): QtWidgets.QWidget.__init__(self, parent) self.pixmap = alpha self.button = QLabelButton(self) # self.solid = QtGui.QPixmap(96,96) # self.solid.fill(QtGui.QColor(cfg.colors.LIGHT_PURPLE)) self.button.setPixmap(self.pixmap) # self.button.setStyleSheet('''QLabel { # color: ''' + cfg.colors.LIGHT_PURPLE + '''; # }''') self.button.setScaledContents(True) self.button.setMask(self.pixmap.mask()) self.button.clicked.connect(self.onClick) # self.connect(self.button, QtCore.SIGNAL('clicked()'), self.onClick) def onClick(self): self.alphaClick.emit() # self.emit(QtCore.SIGNAL('clicked()')) def set_pixmap(self, pixmap): self.button.setPixmap(pixmap) self.button.setScaledContents(True) self.button.setMask(pixmap.mask())
def __init__(self,parent_layout=None,parent=None): QtWidgets.QWidget.__init__(self, parent) # super(ComboWidget, self).__init__(parent) self.setHidden(True) self._parent_layout = parent_layout # UI self.setMaximumHeight(60) self.setMinimumHeight(60) self.layout = QtWidgets.QVBoxLayout(self) self.layout.setAlignment(QtCore.Qt.AlignLeft) self.label = QtWidgets.QLabel() self.comboBox = QtWidgets.QComboBox(parent) self.comboBox.setIconSize(QtCore.QSize(24, 24)) self.comboBox.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) # self.comboBox.setStyleSheet(cfg.stylesheet) self.layout.addWidget(self.label) self.layout.addWidget(self.comboBox) self.layout.setContentsMargins(0, 0, 0, 0) self.setLayout(self.layout) self._parent_layout.addWidget(self) self.setStyleSheet(''' QComboBox::down-arrow { image:url(''' + cfg.light_down_arrow + '''); margin-right: 10px; } ''')
def add(self, node): branch = outliner.New_branch_dialog(self) result = branch.exec_() res = branch.result() if result == QtWidgets.QDialog.Accepted: name = res["name"] branches = [b.name for b in self.model().items] if not name in branches: if self.dummy: new_branch = dt.Node(name) if not self.dummy and self.project: new_branch = elements.BranchNode(name, path=os.path.join(self.project.path, name), project = self).create(path=os.path.join(self.project.path, name)) self.model().insertRows(0, 1, parent=QtCore.QModelIndex(), node=new_branch) self.edited.emit() else: logger.info("A branch called {} exsists.".format(name))
def keyPressEvent(self, event): # logger.info(event.key()) # # logger.info(QtCore.Qt.Key_Left) # logger.info(QtCore.Qt.Key_Right) # logger.info(QtCore.Qt.Key_Up) # logger.info(QtCore.Qt.Key_Down) super(FolderView, self).keyPressEvent(event) try: self.parent().update( self.selectionModel().selection().indexes()[0]) except: pass if event.key() == QtCore.Qt.Key_Right: # logger.info("RIGHT") if self.parent()._child: self.parent()._child.folder_view.setFocus() index = self.parent()._child.folder_view.model().index( 0, 0, QtCore.QModelIndex()) self.parent()._child.folder_view.setCurrentIndex(index) self.parent()._child.update(index) event.accept() if event.key() == QtCore.Qt.Key_Left: # logger.info("LEFT") if self.parent()._parent_box: self.parent()._parent_box.folder_view.setFocus() # self.parent()._parent_box.update(self.parent()._parent_box.folder_view.selectionModel().selection().indexes()[0]) event.accept()
def __init__(self, parent, label=None, ic=None): super(RangeInput, self).__init__(parent) self.layout = QtWidgets.QHBoxLayout(self) self.layout.setContentsMargins(5, 5, 5, 5) self.layout.setAlignment(QtCore.Qt.AlignLeft) if ic: self.icon = QtWidgets.QLabel() self.icon.setPixmap(ic) self.icon.setMinimumSize(QtCore.QSize(24, 24)) self.layout.addWidget(self.icon) if label: self.label = QtWidgets.QLabel(label) self.label.setMinimumSize(QtCore.QSize(100, 30)) self.layout.addWidget(self.label) self.from_label = QtWidgets.QLabel("From") # self.from_label.setMinimumSize(QtCore.QSize(100, 30)) self.layout.addWidget(self.from_label) self.start_input = QtWidgets.QSpinBox(self) self.start_input.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) self.start_input.setMinimumSize(QtCore.QSize(0, 30)) self.layout.addWidget(self.start_input) self.to_label = QtWidgets.QLabel("To") # self.to_label.setMinimumSize(QtCore.QSize(100, 30)) self.layout.addWidget(self.to_label) self.end_input = QtWidgets.QSpinBox(self) self.end_input.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) self.end_input.setMinimumSize(QtCore.QSize(0, 30)) self.layout.addWidget(self.end_input) self.step_label = QtWidgets.QLabel("Step") # self.to_label.setMinimumSize(QtCore.QSize(100, 30)) self.layout.addWidget(self.to_label) self.step_input = QtWidgets.QSpinBox(self) self.step_input.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) self.step_input.setMinimumSize(QtCore.QSize(0, 30)) self.layout.addWidget(self.step_input)
def __init__(self, parent=None): super(LoginWindow, self).__init__(parent) self.setStyleSheet(cfg.stylesheet) self.setMaximumWidth(200) self.setMinimumWidth(200) self.setMaximumHeight(50) self.label = QtWidgets.QLabel() self.label.setPixmap(cfg.users_icon) self.label_user = QtWidgets.QLabel("Username:"******"Password:"******"Login") log.setDefault(True) canc = QtWidgets.QPushButton("Cancel") buttons = QtWidgets.QDialogButtonBox(QtCore.Qt.Horizontal) buttons.addButton(log, QtWidgets.QDialogButtonBox.AcceptRole) buttons.addButton(canc, QtWidgets.QDialogButtonBox.RejectRole) buttons.accepted.connect(self.accept) buttons.rejected.connect(self.reject) layout.addWidget(buttons)
def __init__(self, parent, label=None, options=None, ic=None): super(GroupRadioInput, self).__init__(parent) self.options = [option for option in options] self.option = self.options[0] self.layout = QtWidgets.QHBoxLayout(self) self.layout.setContentsMargins(5, 5, 5, 5) self.layout.setAlignment(QtCore.Qt.AlignLeft) if ic: self.icon = QtWidgets.QLabel() self.icon.setPixmap(ic) self.icon.setMinimumSize(QtCore.QSize(24, 24)) self.layout.addWidget(self.icon) self.icon.setAlignment(QtCore.Qt.AlignTop) if label: self.label = QtWidgets.QLabel(label) self.label.setMinimumSize(QtCore.QSize(100, 30)) self.layout.addWidget(self.label) self.label.setAlignment(QtCore.Qt.AlignTop) self.options_widget = QtWidgets.QWidget() self.layout.addWidget(self.options_widget) self.options_widget_layout = QtWidgets.QVBoxLayout(self.options_widget) self.options_radio_widgets = [] for option in self.options: option_widget = QtWidgets.QRadioButton(option) self.options_radio_widgets.append( option_widget ) self.options_widget_layout.addWidget(option_widget) option_widget.clicked.connect(self.selection) self.options_radio_widgets[0].setChecked(True)
class Click_label(QtWidgets.QLabel): clicked = QtCore.Signal() def __init__(self): super(Click_label, self).__init__() def mouseReleaseEvent(self, e): logger.info(e) self.clicked.emit() e.accept()
def move_down(self, *args): rows = self.scripts_table_view.selectionModel().selectedRows() # logger.info(rows) if rows: # row = rows[0].row() self.scripts_table_view.model().move_down(rows[0].row()) ind = self.scripts_table_view.model().index( rows[0].row() + 1, 0, QtCore.QModelIndex()) self.scripts_table_view.selectionModel().setCurrentIndex( ind, QtCore.QItemSelectionModel.ClearAndSelect | QtCore.QItemSelectionModel.Rows)
def __init__(self, parent=None): super(Update_window, self).__init__(parent) # self.pipelineUI = self.parent() self.setWindowFlags(QtCore.Qt.Tool) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.main_widget = QtWidgets.QWidget(self) self.setCentralWidget(self.main_widget) self.setStyleSheet(cfg.stylesheet) self.layout = QtWidgets.QVBoxLayout(self.main_widget) self.layout.setContentsMargins(10, 5, 10, 10) self.setMinimumHeight(120) self.setMaximumHeight(120) self.setMinimumWidth(600) self.setMaximumWidth(600) self.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) # self.center_to_maya_window() # self.current_version = current_version self.caption = gui.Title(self, label="", seperator=False) self.link_label = Click_label() self.link_label.setHidden(True) self.layout.addWidget(self.link_label) self.layout.addWidget(self.caption) self.startup_switch = inputs.GroupInput( self, label="Check for updates on startup", inputWidget=QtWidgets.QCheckBox()) self.startup_switch_input = self.startup_switch.input if settings.settings_node().check_for_updates: self.startup_switch_input.setCheckState(QtCore.Qt.Checked) self.startup_switch_input.stateChanged.connect( self.start_updates_toggle) self.layout.addWidget(self.startup_switch) self.ok = QtWidgets.QPushButton("Abort") self.ok.setIconSize(QtCore.QSize(20, 20)) self.ok.setIcon(QtGui.QIcon(cfg.no_icon)) self.ok.clicked.connect(self.close) self.layout.addWidget(self.ok)
def __init__(self, parent, height, buttons = dict()): super(Toolbar, self).__init__(parent) self.layout = QtWidgets.QHBoxLayout(self) self.layout.setContentsMargins(1, 1, 1, 1) self.layout.setSpacing(2) self.layout.setAlignment(QtCore.Qt.AlignLeft) _buttons = dict() for k in buttons: button = QtWidgets.QPushButton(buttons[k]['label']) button.setIconSize(QtCore.QSize(height-2, height-2)) button.setIcon(QtGui.QIcon(buttons[k]['icon'])) self.layout.addWidget(button) _buttons[k] = button
def delete(self, node, index): if node: alert = massage.Prompt_alert( None, alert_string= "This will send {} and all it's children to the trash. Procced?" .format(node.name)) result = alert.exec_() if result == QtWidgets.QDialog.Accepted: # if massage.Prompt_alert(None, alert_string="This will send {} and all it's children to the trash. Procced?".format(node.name)):#"warning", "Delete {}".format(node.name), "This will send {} and all it's children to the trash. Procced?".format(node.name)): node.delete_me() self.model().sourceModel().removeRows(0, 0, node=node) self._proxyModel.invalidate() self.parent().update(self.model().index( 0, 0, QtCore.QModelIndex()))
def add_script(self, *args): path = QtWidgets.QFileDialog.getOpenFileName(None, "Select script file", filter="*.*") if path[0]: typ = files.extension(files.file_name(path[0])) if typ == ".py" or typ == ".mel": item = dt.ScriptFileNode(name='script', path=path[0]) else: return else: return scripts_model = self.scripts_table_view.model() scripts_model.insertRows(0, 1, QtCore.QModelIndex(), node=item) return
def populate(self, items=None): # root = self.parent.project.path self.comps = list() self.comp_hints = list() self.comps_model = None self.search_line.set_suggestions_model(None) self.library_view.setModel_(None) if not items: self.hide_loader() if self.scan: self.scan.kill() self.scan = None return for item in items: node = stages.ComponentNode(item['name'], path=item['path'], project=self.project) self.comps.append(node) # self.comp_hints.append(node.name) self.comp_hints.extend(node.full_path_elements) comp_hints_no_duplicates = sorted(list(set(self.comp_hints))) self.search_line.set_suggestions_model( QtCore.QStringListModel(comp_hints_no_duplicates)) self.comps_model = models.Library_Model(self.comps) self.library_view.setModel_(self.comps_model) self.hide_loader() if self.scan: self.scan.kill() return True
class QLabelButton(QtWidgets.QLabel): clicked = QtCore.Signal() ''' custom QLbael the can send clicked signal ''' def __init__(self, parent): QtWidgets.QLabel.__init__(self, parent) # color = cfg.colors.LIGHT_GRAY # "#ccc" # # # self.setStyleSheet('''QLabel{ # # color: #ccc; # # background-color: ''' + color + '''; # # border-radius: 12px; # # padding: 4px; # # } # # ''') def mouseReleaseEvent(self, ev): click = ev.pos() if self.mask().contains(click): self.clicked.emit()
def __init__(self, parent, label=None, inputWidget=None, ic=None): super(GroupInput, self).__init__(parent) self.layout = QtWidgets.QHBoxLayout(self) self.layout.setContentsMargins(2,2,2,2) self.layout.setSpacing(2) self.layout.setAlignment(QtCore.Qt.AlignLeft) if isinstance(inputWidget, QtWidgets.QCheckBox): self.input = inputWidget self.input.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) self.input.setMinimumSize(QtCore.QSize(20, 0)) self.layout.addWidget(self.input) ic = None if label: self.label = QtWidgets.QLabel(label) self.label.setMinimumSize(QtCore.QSize(100, 24)) self.layout.addWidget(self.label) return else: if ic: self.icon = QtWidgets.QLabel() self.icon.setPixmap(ic) self.icon.setMaximumSize(QtCore.QSize(24, 24)) self.icon.setMinimumSize(QtCore.QSize(24, 24)) self.layout.addWidget(self.icon) if label: self.label = QtWidgets.QLabel(label) self.label.setMinimumSize(QtCore.QSize(100, 24)) self.layout.addWidget(self.label) if inputWidget: self.input = inputWidget self.input.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) self.input.setMinimumSize(QtCore.QSize(0, 24)) self.layout.addWidget(self.input)
class Library(QtWidgets.QWidget): component_changed = QtCore.Signal() def __init__(self, parent=None, settings=None): super(Library, self).__init__(parent) self.setMinimumHeight(100) self.parent = parent self.layout = QtWidgets.QVBoxLayout(self) self.layout.setContentsMargins(0, 5, 0, 0) self.library_view = views.Library_View(self, settings=settings) self.layout.addWidget(self.library_view) self.progressBar = QtWidgets.QProgressBar(self) self.progressBar.setMaximum(100) self.progressBar.setMinimum(0) self.progressBar.setValue(0) self.progressBar.setMaximumHeight(5) self.progressBar.setTextVisible(False) self.progressBar.setStyleSheet(''' QProgressBar { border: 1px solid ''' + cfg.colors.DARK_GRAY_MINUS + '''; } QProgressBar::chunk { background-color: ''' + cfg.colors.DARK_PURPLE + '''; }''') self.layout.addWidget(self.progressBar) self.address_widget = QtWidgets.QWidget(self) self.address_widget_layout = QtWidgets.QHBoxLayout(self.address_widget) self.address_widget_layout.setAlignment(QtCore.Qt.AlignLeft) self.address_widget_layout.setContentsMargins(0, 3, 0, 0) self.layout.addWidget(self.address_widget) self.search_line = inputs.SuggestionSearchBar( self, label="Search public components...") self.search_line.setMinimumHeight(30) self.address_widget_layout.addWidget(self.search_line) # self.comps = list() self.comp_hints = list() self.comps_model = None self.project = None self.scan = None # # self.search_line.set_suggestions_model(None) # self.library_view.setModel_(None) # self.populate() self.search_line.textChanged.connect(self.search_changed) def set_project(self, project): # logger.info(self.parent) self.project = None if project: self.project = project # self.root_path = os.path.join(self.project.path, "assets") # self.populate() def set_root(self, path): if self.scan: try: self.scan.kill() except: print traceback.print_exc() self.search_line.set_suggestions_model(None) self.library_view.setModel_(None) if path: if os.path.exists(path): self.root_path = path self.scan = Scan_masters_thread(path_to_dir=self.root_path, project=self.project) self.scan.update.connect(self.populate) self.scan.percent.connect(self.progressBar.setValue) self.scan.start() self.show_loader() # self.populate() def populate(self, items=None): # root = self.parent.project.path self.comps = list() self.comp_hints = list() self.comps_model = None self.search_line.set_suggestions_model(None) self.library_view.setModel_(None) if not items: self.hide_loader() if self.scan: self.scan.kill() self.scan = None return for item in items: node = stages.ComponentNode(item['name'], path=item['path'], project=self.project) self.comps.append(node) # self.comp_hints.append(node.name) self.comp_hints.extend(node.full_path_elements) comp_hints_no_duplicates = sorted(list(set(self.comp_hints))) self.search_line.set_suggestions_model( QtCore.QStringListModel(comp_hints_no_duplicates)) self.comps_model = models.Library_Model(self.comps) self.library_view.setModel_(self.comps_model) self.hide_loader() if self.scan: self.scan.kill() return True def search_changed(self, str): if (self.search_line.text() != "") and (self.search_line.text() != self.search_line.label): self.filter(str) # logger.info("searching...") return else: self.library_view.setModel_(self.comps_model) # if self.rootFolder and (self.search_line.text() == ""): # if isinstance(self.results_folder, FolderStaticWidget): # self.results_folder.remove() # self.results_folder = None # # if isinstance(self.rootFolder, FolderDynamicWidget): # self.rootFolder.hide(False) # logger.info("Not searching") # return def filter(self, string): filterd_comps = list() for comp in self.comps: f = None try: f = re.search(string, comp.nice_full_name) # os.path.split(folder)[1]) except: logger.info("This search pattern {} is invalid".format(string)) # logger.info(search_in) if f: filterd_comps.append(comp) self.library_view.setModel_(models.Library_Model(filterd_comps)) def hide_loader(self): # self.folder_view.setHidden(False) self.progressBar.setHidden(True) def show_loader(self): # self.folder_view.setHidden(False) self.progressBar.setHidden(False) self.progressBar.setValue(0)
class ProjectNode(RootNode): loaded = QtCore.Signal(dict) def __init__(self, name, parent=None, **kwargs): super(ProjectNode, self).__init__(name, parent, **kwargs) self.project_file = None if self.data_file: self.project_file = self.data_file.read() self.pipelineUI = None for key in kwargs: if key == "pipelineUI": self.pipelineUI = kwargs[key] self.loaded.connect(self.pipelineUI.updateCurrentProject) def create(self, nice_name=None, path=None, padding=3, fps=25, file_type="ma", users={"0": ["Admin", "1234", "admin"]}, branches=["scenes", "assets"], playblasts_root=cfg.playblast_save_options.PROJECT_ROOT, prefix=None): file_type = "ma" project_key = serializer.id_generator() project_data = {} project_data["nice_name"] = nice_name if nice_name else self.name project_data["project_name"] = self.name project_data["project_key"] = project_key project_data["padding"] = padding project_data["fps"] = fps project_data["defult_file_type"] = file_type project_data["users"] = users project_data["playblasts_root"] = playblasts_root # project_data["prefix"] = prefix # project_data["playblast_outside"] = playblast_outside folders = [ "scenes", "assets", "images", "sourceimages", "data", "autosave", "movies", "scripts", "sound", "clips", "renderData", "cache" ] for folder in folders: # project_data[folder] = folder files.create_directory(os.path.join(path, folder)) # render folders: r_folders = ["renderData", "depth", "iprimages", "shaders"] for r_folder in r_folders[1:]: files.create_directory(os.path.join(path, r_folders[0], r_folder)) fur_folders = [ "renderData", "fur", "furFiles", "furImages", "furEqualMap", "furAttrMap", "furShadowMap" ] for f_folder in fur_folders[2:]: files.create_directory( os.path.join(path, fur_folders[0], fur_folders[1], f_folder)) # cache folders: c_folders = ["cache", "particles", "nCache", "bifrost"] for c_folder in c_folders[1:]: files.create_directory(os.path.join(path, c_folders[0], c_folder)) fl_folders = ["cache", "nCache", "fluid"] for fl_folder in fl_folders[2:]: files.create_directory( os.path.join(path, fl_folders[0], fl_folders[1], fl_folder)) self.path = path data_path = os.path.join(path, "%s.%s" % (self.name, "json")) self.data_file_path = data_path self.data_file = serializer.JSONSerializer().create( self.data_file_path, project_data) self.project_file = self.data_file.read() for branch in branches: elements.BranchNode( branch, path=os.path.join(path, branch), project=self).create(path=os.path.join(path, branch)) # elements.BranchNode("assets", path=os.path.join(path, "assets"), project = self).create(path=os.path.join(path, "assets")) if playblasts_root == cfg.playblast_save_options.PROJECT_ROOT: files.create_directory(os.path.join(path, "playblasts")) if playblasts_root == cfg.playblast_save_options.PROJECT_SISTER: try: files.create_directory( os.path.join(os.path.dirname(path), "{}_playblasts".format(self.name))) except: logger.info("Could not create Playblasts folder at: {}".format( os.path.dirname(path))) return self def online(self): if os.path.isdir(self.path): if os.path.isfile(self.data_file_path): return True return False def edit(self): logger.info(self.edit.__name__) # _users = True if self.project_users else False user = self.pipelineUI.settings.user[0] password = self.pipelineUI.settings.user[1] projectDlg = project_editor.Project_edit_Dialog( project=self, user_data=[user, password]) result = projectDlg.exec_() res = projectDlg.result() if result == QtWidgets.QDialog.Accepted: # logger.info(res) self.nice_name = res["nice_name"] if res["users_mode"]: self.users = res["users"] else: self.users = None if res["playblasts_root"] != self.project_playblasts_root: self.set_playblasts_root(res["playblasts_root"]) self.set(user=[user, password]) self.pipelineUI.navigate_to_current_file() def validate_user(self, username=None, password=None): for key in self.users: if self.users[key][0] == username and self.users[key][ 1] == password: role = self.users[key][2] if role == 'admin': role = 'administrator' return role return '' def link(self): path = QtWidgets.QFileDialog.getOpenFileName( None, "Select Pipeline project file", filter="*.*") if path[0]: project_path = os.path.dirname(path[0]) self.path = project_path self.data_file_path = path[0] self.set_data_file(self.data_file_path) self.project_file = self.data_file.read() self.pipelineUI.link_project(self) def set(self, **kwargs): user = '' password = '' role = '' if 'user' in kwargs: user = kwargs['user'][0] password = kwargs['user'][1] if self.data_file: _users = True if self.project_users else False if self.project_users: # the project is permission based if user == '': # no user was called with the function, need to prompt for credentials login = users.LoginWindow() result = login.exec_() user, password = login.result() if result == QtWidgets.QDialog.Accepted: # user entered credentials role = self.validate_user(user, password) # from user+password, return the role if role == '': # if no role was return there is no such user logger.info("invalid username or password") return False else: # recived valid role, set the user as current in the settings self.pipelineUI.settings.user = [user, password] else: # user aborted, exit return False else: # the function was called with a user+password, let's get their role role = self.validate_user(user, password) self.pipelineUI.settings.user = [user, password] if role == '': # if no role was return there is no such user logger.info("invalid username or password") return False import pymel.core as pm import maya.mel as mel pm.workspace.open(self.path) pm.workspace.chdir(self.path) raw_project_path = self.path.replace("\\", "\\\\") melCmd = "setProject \"" + raw_project_path + "\";" try: mel.eval(melCmd) except: pass logger.info("Project changed to: {} ({})".format( self.nice_name, self.name)) self.loaded.emit({'users': _users, 'user': user, 'role': role}) return True def project_file_key(self, key=None): if self.project_file: return self.project_file[key] else: return None def set_playblasts_root(self, new_root): project_root = cfg.playblast_save_options.PROJECT_ROOT project_sister = cfg.playblast_save_options.PROJECT_SISTER component_root = cfg.playblast_save_options.COMPONENT def get_fullpath_if_is_component(dir): if os.path.exists(dir): if os.path.isfile( os.path.join(dir, "%s.%s" % (os.path.split(dir)[1], "json"))): j = serializer.Metadata_file(path=os.path.join( dir, "%s.%s" % (os.path.split(dir)[1], "json"))) info = j.data_file.read() if info: if info["typeInfo"] == cfg._component_: return "_".join(info["fullpath"]) return False def move_playblasts_into_components(move_from): # logger.info("move_playblasts_into_components from {}, to {}".format(move_from, "components")) for branch in self.branches: for root, subFolders, _files in os.walk(branch): for s in subFolders: p = os.path.join(root, s) fullpath = get_fullpath_if_is_component(p) if fullpath: b = os.path.split(branch)[1] master_avi = os.path.join( move_from, b, "{}_MASTER.avi".format(fullpath)) master_mov = os.path.join( move_from, b, "{}_MASTER.mov".format(fullpath)) versions_dir = os.path.join( move_from, b, "versions", fullpath) if os.path.isfile(master_avi): logger.info( "*.avi master from: {}".format(master_avi)) target_master_avi = os.path.join( p, "{}_MASTER.avi".format(fullpath)) logger.info("will move to: {}".format( target_master_avi)) files.dir_move(master_avi, target_master_avi) if os.path.isfile(master_mov): logger.info( "*.mov master from: {}".format(master_mov)) target_master_mov = os.path.join( p, "{}_MASTER.mov".format(fullpath)) logger.info("will move to: {}".format( target_master_mov)) files.dir_move(master_mov, target_master_mov) if os.path.isdir(versions_dir): logger.info( "playblasts versions folder from: {}". format(versions_dir)) target_dir = os.path.join(p, "playblasts") logger.info( "will move to: {}".format(target_dir)) files.dir_move(versions_dir, target_dir) logger.info("<>") logger.info(os.listdir(os.path.join(move_from, b, "versions"))) if not os.listdir(os.path.join(move_from, b, "versions")): files.delete(os.path.join(move_from, b, "versions")) if not os.listdir(os.path.join(move_from, b)): files.delete(os.path.join(move_from, b)) if not os.listdir(move_from): files.delete(move_from) def move_playblasts_to_single_folder(move_to): # logger.info("move_playblasts_to_single_folde from {}, to {}".format(current_root, move_to)) for branch in self.branches: b = os.path.split(branch)[1] for root, subFolders, _files in os.walk(branch): for s in subFolders: p = os.path.join(root, s) fullpath = get_fullpath_if_is_component(p) if fullpath: master_avi = os.path.join( p, "{}_MASTER.avi".format(fullpath)) master_mov = os.path.join( p, "{}_MASTER.mov".format(fullpath)) versions_dir = os.path.join(p, "playblasts") if os.path.isfile(master_mov): target_master_mov = os.path.join( move_to, b, "{}_MASTER.mov".format(fullpath)) files.assure_folder_exists( os.path.join(move_to, b)) files.dir_move(master_mov, target_master_mov) if os.path.isfile(master_avi): target_master_avi = os.path.join( move_to, b, "{}_MASTER.avi".format(fullpath)) files.assure_folder_exists( os.path.join(move_to, b)) files.dir_move(master_avi, target_master_avi) if os.path.isdir(versions_dir): target_dir = os.path.join( move_to, b, "versions", fullpath) files.assure_folder_exists( os.path.join(move_to, b, "versions")) files.dir_move(versions_dir, target_dir) current_root = self.project_playblasts_root msg = "You are about to move your playblasts folder from {0}, to {1}.\n" \ "This may take a few minutes.".format(current_root, new_root) prompt = massage.PromptUser(self.pipelineUI, prompt=msg, override_yes_text="Proceed", override_no_label="Don't move", cancel_button=False) result = prompt.exec_() if result == 0: if (current_root == project_root) or (current_root == project_sister): if (new_root == project_root) or (new_root == project_sister): current_playblasts_folder = self.playblasts_path self.project_playblasts_root = new_root files.dir_move(current_playblasts_folder, self.playblasts_path) return else: move_playblasts_into_components(self.playblasts_path) self.project_playblasts_root = new_root return else: if (new_root == project_root) or (new_root == project_sister): self.project_playblasts_root = new_root move_playblasts_to_single_folder(self.playblasts_path) return def explore(self): files.explore(self.path) @property def branches(self): branches = list() for dir in files.list_dir_folders(self.path): if misc.branch_dir(os.path.join(self.path, dir)): branches.append(os.path.join(self.path, dir)) return branches @property def nice_name(self): if self.project_file: try: return self.project_file["nice_name"] except: return self.name else: return self.name @nice_name.setter def nice_name(self, nice_name): if self.data_file: data = {} data["nice_name"] = nice_name self.data_file.edit(data) self.project_file = self.data_file.read() @property def project_name(self): if self.project_file: return self.project_file["project_name"] else: return None @property def project_fps(self): if self.project_file: if "fps" in self.project_file.keys(): return self.project_file["fps"] else: return None else: return None @project_fps.setter def project_fps(self, fps): if self.data_file: data = {} data["fps"] = fps self.data_file.edit(data) self.project_file = self.data_file.read() @property def project_key(self): if self.project_file: return self.project_file["project_key"] else: return None @property def project_padding(self): if self.project_file: return self.project_file["padding"] else: return None @property def project_file_type(self): if self.project_file: return self.project_file["defult_file_type"] else: return None @project_file_type.setter def project_file_type(self, type): if self.data_file: data = {} data["defult_file_type"] = type self.data_file.edit(data) self.project_file = self.data_file.read() @property def project_playblasts_root(self): if self.project_file: if "playblasts_root" in self.project_file: return self.project_file["playblasts_root"] return cfg.playblast_save_options.PROJECT_ROOT @project_playblasts_root.setter def project_playblasts_root(self, root_type): if self.data_file: data = {} data["playblasts_root"] = root_type self.data_file.edit(data) self.project_file = self.data_file.read() # # @property # def movie_file_type(self): # if self.project_file: # return "mov" # else: # return None @property def project_users(self): if self.project_file: if "users" in self.project_file.keys(): return self.project_file["users"] else: return None else: return None @project_users.setter def project_users(self, users): if self.data_file: data = {} data["users"] = users self.data_file.edit(data) self.project_file = self.data_file.read() # @property # def playblast_outside(self): # if self.project_file: # if "playblast_outside" in self.project_file.keys(): # return self.project_file["playblast_outside"] # else: # return False # else: # return None # # @playblast_outside.setter # def playblast_outside(self, playblast_outside): # # old_path = self.playblasts_path # # if self.data_file: # data = {} # data["playblast_outside"] = playblast_outside # self.data_file.edit(data) # self.project_file = self.data_file.read() # # files.dir_move(old_path, self.playblasts_path) @property def playblasts_path(self): if self.project_file: if self.project_playblasts_root == cfg.playblast_save_options.PROJECT_ROOT: return os.path.join(self.path, "playblasts") if self.project_playblasts_root == cfg.playblast_save_options.PROJECT_SISTER: return os.path.join(os.path.dirname(self.path), "{}_playblasts".format(self.name)) return "" @property def users(self): if self.project_file: return self.project_file["users"] else: return None @users.setter def users(self, dict): if self.data_file: data = {} data["users"] = dict self.data_file.edit(data) self.project_file = self.data_file.read()
def __init__(self, parent=None): super(ProjectsDialog, self).__init__(parent) css = loadCSS.loadCSS( os.path.join(os.path.dirname(pipeline.CSS.__file__), 'mainWindow.css')) self.setStyleSheet(css) self.setWindowFlags(QtCore.Qt.Tool) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.pipeline_window = self.parent() self.setMinimumHeight(600) self.setMinimumWidth(600) self.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) self.center_to_maya_window() self.main_widget = QtWidgets.QWidget(self) self.setCentralWidget(self.main_widget) # self.setStyleSheet(cfg.stylesheet) self.layout = QtWidgets.QVBoxLayout(self.main_widget) self.layout.setContentsMargins(5, 5, 5, 5) # self.setLayout(self.layout) self.setWindowTitle("Projects") self.header = gui.Title(self, label="Current Projects") self.header.setMaximumHeight(40) self.layout.addWidget(self.header) self.project_table_widget = QtWidgets.QWidget(self) self.projects_table_widget_layout = QtWidgets.QVBoxLayout( self.project_table_widget) self.projects_table_widget_layout.setContentsMargins(5, 5, 5, 5) self.layout.addWidget(self.project_table_widget) self.projects_table_view = views.Projects_View( parent=self, parentWidget=self.project_table_widget) self.project_table_widget.layout().addWidget(self.projects_table_view) self.projects_table_view.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) self.projects_table_view.setModel_(self.pipeline_window.projects) self.actions_widget = QtWidgets.QWidget(self) self.actions_widget_layout = QtWidgets.QHBoxLayout(self.actions_widget) self.actions_widget_layout.setContentsMargins(5, 5, 5, 5) self.layout.addWidget(self.actions_widget) self.create_project_btn = QtWidgets.QPushButton( "Create Project") #inputs.NiceQLabelButton("Create new Project")# self.create_project_btn.setIcon(QtGui.QIcon(cfg.new_icon)) self.create_project_btn.setIconSize(QtCore.QSize(20, 20)) self.load_project_btn = QtWidgets.QPushButton("Load Project") self.load_project_btn.setIcon(QtGui.QIcon(cfg.load_icon)) self.load_project_btn.setIconSize(QtCore.QSize(20, 20)) self.unload_project_btn = QtWidgets.QPushButton("Unload Project") self.unload_project_btn.setIcon(QtGui.QIcon(cfg.unload_icon)) self.unload_project_btn.setIconSize(QtCore.QSize(20, 20)) self.actions_widget_layout.addWidget(self.create_project_btn) self.actions_widget_layout.addWidget(self.load_project_btn) self.actions_widget_layout.addWidget(self.unload_project_btn) self.create_project_btn.clicked.connect(self.create_project) self.load_project_btn.clicked.connect(self.load_project) self.unload_project_btn.clicked.connect(self.unload_project)
def __init__(self, parent=None, origin='', settings={}, **kwargs): super(Publish_Dialog, self).__init__(parent) css = loadCSS.loadCSS( os.path.join(os.path.dirname(pipeline.CSS.__file__), 'mainWindow.css')) self.setStyleSheet(css) self.layout = QtWidgets.QVBoxLayout(self) self.layout.setSpacing(5) self.layout.setContentsMargins(5, 5, 5, 5) self.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) self.setMinimumWidth(400) self.setWindowTitle('Save master') # self.title = gui.Title(self, label="Save master") # self.layout.addWidget(self.title) self.center_to_maya_window() self.main_widget = QtWidgets.QWidget(self) self.main_widget_layout = QtWidgets.QVBoxLayout(self.main_widget) self.main_widget_layout.setSpacing(2) self.main_widget_layout.setContentsMargins(5, 5, 5, 5) self.layout.addWidget(self.main_widget) self.options_widget = QtWidgets.QWidget() self.options_widget_layout = QtWidgets.QVBoxLayout(self.options_widget) self.options_widget_layout.setSpacing(2) self.options_widget_layout.setContentsMargins(2, 2, 2, 2) self.options_widget_layout.setAlignment(QtCore.Qt.AlignTop) self.scripts_table_label = QtWidgets.QLabel('Execute scripts') self.scripts_table_view = views.Run_scripts_View(parent=self) self.scripts_table_view.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) self.scripts_table_toolbar = QtWidgets.QToolBar(self.main_widget) self.scripts_table_toolbar.setIconSize(QtCore.QSize(20, 20)) add = self.scripts_table_toolbar.addAction( QtGui.QIcon(cfg.simple_add_icon), '', self.add_script) add.setToolTip('Add script') rm = self.scripts_table_toolbar.addAction( QtGui.QIcon(cfg.simple_rm_icon), '', self.remove_script) rm.setToolTip('Remove script') self.scripts_table_toolbar.addAction(QtGui.QIcon(cfg.simple_up_icon), '', self.move_up) self.scripts_table_toolbar.addAction(QtGui.QIcon(cfg.simple_dn_icon), '', self.move_down) self.scripts_table_toolbar.setStyleSheet(''' QToolButton{ border: none; } QToolButton::hover { background-color: ''' + cfg.colors.LIGHT_GRAY_plus + '''; border none; } ''') self.label_Note = QtWidgets.QLabel('Note') self.textNote = QtWidgets.QTextEdit(self) self.textNote.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) self.textNote.setMaximumHeight(100) self.remember = inputs.GroupInput( self.options_widget, "Remember these settings for {}".format(origin), QtWidgets.QCheckBox(), ic=cfg.save_icon) self.remember_input = self.remember.input self.remember_input.setCheckState(QtCore.Qt.Checked) self.open_after = inputs.GroupInput(self.options_widget, "Open master after save", QtWidgets.QCheckBox(), ic=cfg.save_icon) self.open_after_input = self.open_after.input self.open_after_input.setCheckState(QtCore.Qt.Checked) self.main_widget_layout.addWidget(self.options_widget) space1 = gui.HLine() space1.setMinimumHeight(20) self.main_widget_layout.addWidget(space1) self.main_widget_layout.addWidget(self.scripts_table_label) self.main_widget_layout.addWidget(self.scripts_table_toolbar) self.main_widget_layout.addWidget(self.scripts_table_view) space2 = gui.HLine() space2.setMinimumHeight(20) self.main_widget_layout.addWidget(space2) self.main_widget_layout.addWidget(self.label_Note) self.main_widget_layout.addWidget(self.textNote) self.main_widget_layout.addWidget(self.remember) self.main_widget_layout.addWidget(self.open_after) self.import_references = inputs.GroupInput(self.options_widget, "Import references", QtWidgets.QCheckBox(), ic=cfg.creation_icon) self.import_references_input = self.import_references.input self.import_references_input.setCheckState(QtCore.Qt.Checked) self.options_widget_layout.addWidget(self.import_references) self.delete_namespaces = inputs.GroupInput(self.options_widget, "Delete namespaces", QtWidgets.QCheckBox(), ic=cfg.creation_icon) self.delete_namespaces_input = self.delete_namespaces.input self.delete_namespaces_input.setCheckState(QtCore.Qt.Checked) self.options_widget_layout.addWidget(self.delete_namespaces) self.clean_up = inputs.GroupInput(self.options_widget, "Optimize scene", QtWidgets.QCheckBox(), ic=cfg.creation_icon) self.clean_up_input = self.clean_up.input self.clean_up_input.setCheckState(QtCore.Qt.Checked) self.options_widget_layout.addWidget(self.clean_up) self.delete_ng = inputs.GroupInput(self.options_widget, "Delete ngSkinTools nodes", QtWidgets.QCheckBox(), ic=cfg.creation_icon) self.delete_ng_input = self.delete_ng.input self.delete_ng_input.setCheckState(QtCore.Qt.Checked) self.options_widget_layout.addWidget(self.delete_ng) # buttons = QtWidgets.QDialogButtonBox( # QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel, # QtCore.Qt.Horizontal, self) # # buttons.accepted.setText('Save') # buttons.accepted.connect(self.accept) # buttons.rejected.connect(self.reject) save = QtWidgets.QPushButton("Save") canc = QtWidgets.QPushButton("Cancel") canc.setDefault(True) buttons = QtWidgets.QDialogButtonBox(QtCore.Qt.Horizontal) buttons.addButton(save, QtWidgets.QDialogButtonBox.AcceptRole) buttons.addButton(canc, QtWidgets.QDialogButtonBox.RejectRole) buttons.accepted.connect(self.accept) buttons.rejected.connect(self.reject) self.main_widget_layout.addWidget(buttons) model = models.Script_files_Model(list()) self.scripts_table_view.setModel(model) # logger.info(settings) stat = QtCore.Qt.Checked if settings[ 'import_ref'] else QtCore.Qt.Unchecked self.import_references_input.setCheckState(stat) stat = QtCore.Qt.Checked if settings[ 'delete_ns'] else QtCore.Qt.Unchecked self.delete_namespaces_input.setCheckState(stat) stat = QtCore.Qt.Checked if settings[ 'optimize'] else QtCore.Qt.Unchecked self.clean_up_input.setCheckState(stat) if settings['scripts']: items = list() for s in settings['scripts']: items.append(dt.ScriptFileNode(name='script', path=s)) model = models.Script_files_Model(items) else: model = models.Script_files_Model(list()) self.scripts_table_view.setModel(model) stat = QtCore.Qt.Checked if settings[ 'remember_settings'] else QtCore.Qt.Unchecked self.remember_input.setCheckState(stat) stat = QtCore.Qt.Checked if settings[ 'open_after'] else QtCore.Qt.Unchecked self.open_after_input.setCheckState(stat)
def getIndex(model, item, column): return model.index(model.items.index(item), column, QtCore.QModelIndex())
class FilterComboWidget(comboBox.ComboWidget): changed = QtCore.Signal(str) def __init__(self, items=None, path=None, parent_layout=None, parent=None): super(FilterComboWidget, self).__init__(parent_layout, parent) self.setMaximumHeight(30) self.setMinimumHeight(30) self.setMaximumWidth(150) self.setMinimumWidth(150) self.label.setParent(None) self.label.deleteLater() self.parent = parent self.setHidden(False) # self.comboBox.currentIndexChanged.connect(self.update) # logger.info("connecting to {}".format(self.parent)) # self.changed.connect(self.parent.set_view_root) def update(self): return # logger.info("updating with {}".format(self.comboBox.currentText())) # path = os.path.join(self._path,self.comboBox.currentText()) if self._path else self.comboBox.currentText() # self.changed.emit(path) # self.parent.address_label.setText(self.comboBox.currentText()) def set_branch(self, string): return if comboBox.setComboValue(self.comboBox, string): # logger.info("branch set to {}".format(string)) self.update() def set_root(self, path): return if path: self._path = path self.listDirectory() self.createModel() # self.update() else: self.comboBox.clear() def createModel(self): return self.comboBox.clear() # dt.CatagoryNode(name, path=path, project = self.parent.parent.project) li = [] # p = self._parent_box.folderView.selectionModel() if self._subdirectories: # p = self._parent_box.selected_node if self._parent_box else None for dir in sorted(self._subdirectories): n = os.path.split(dir)[1] path = os.path.join(self._path, dir) if misc.branch_dir(path): li.append( pipeline.libs.nodes.stages.BranchNode( n, path=path, project=self.project)) if li: self.comboBox.setModel(models.List_Model(li)) return True return False
class Scan_masters_thread(QtCore.QObject, threading.Thread): update = QtCore.Signal(object) percent = QtCore.Signal(int) def __init__(self, path_to_dir='.', project=None): QtCore.QObject.__init__(self) threading.Thread.__init__(self) self._path = path_to_dir self.project = project self.daemon = True self.killed = False def run(self): li = [] try: li = self.createModel() except SystemExit: pass # print 'system exit at in {}.thread.run():'.format(self.__class__.__name__) except: print 'exceptions in {}.thread.run():'.format( self.__class__.__name__) print traceback.print_exc() finally: self.update.emit(li) return def calculate_total(self): total = 0 for root, subFolders, _files in os.walk(self._path): for s in subFolders: total += 1 return total def createModel(self): li = list() index = 0 max = self.calculate_total() if not self.project: return li for root, subFolders, _files in os.walk(self._path): for s in subFolders: index += 1 folder = os.path.join(root, s) comp = folder if misc.component_dir(folder) else None if comp: node = stages.ComponentNode(os.path.split(comp)[1], path=comp, project=self.project) if node.public: li.append({ "name": os.path.split(comp)[1], "path": comp }) del node val = remap(index, 0, max, 0, 100) self.percent.emit(val) return li def start(self): """Start the thread.""" self.__run_backup = self.run self.run = self.__run # Force the Thread to threading.Thread.start(self) def __run(self): """Hacked run function, which installs the trace.""" sys.settrace(self.globaltrace) self.__run_backup() self.run = self.__run_backup def globaltrace(self, frame, why, arg): if why == 'call': return self.localtrace else: return None def localtrace(self, frame, why, arg): if self.killed: if why == 'line': raise SystemExit() return self.localtrace def kill(self): try: self.update.disconnect() self.percent.disconnect() except: pass self.killed = True
def __init__(self, parent, title='oops!', prompt=None, override_yes_text=None, override_no_label=None, override_cancel_label="Cancel", cancel_button=False, color=None, override_yes_icon=None, override_no_icon=None, cancel_icon=None): super(PromptUser, self).__init__(parent) if not color: color = '#fff' css = loadCSS.loadCSS( os.path.join(os.path.dirname(pipeline.CSS.__file__), 'mainWindow.css')) self.setStyleSheet(css) self.setObjectName('prompt_massage') self.setStyleSheet(self.styleSheet() + ''' QLabel { color: ''' + color + ''' ;} ''') self.setWindowTitle(title) self.setText(prompt) self.setIconPixmap(cfg.simple_warning_icon) if override_yes_icon: self.yes_btn = QtWidgets.QPushButton(self) self.yes_btn.setText(override_yes_text) self.yes_btn.setMinimumHeight(30) self.yes_btn.setIconSize(QtCore.QSize(24, 24)) self.yes_btn.setIcon(QtGui.QIcon(override_yes_icon)) self.addButton(self.yes_btn, QtWidgets.QMessageBox.YesRole) else: self.addButton(override_yes_text, QtWidgets.QMessageBox.YesRole) if override_yes_icon: self.no_btn = QtWidgets.QPushButton(self) self.no_btn.setText(override_no_label) self.no_btn.setIcon(QtGui.QIcon(override_no_icon)) self.addButton(self.no_btn, QtWidgets.QMessageBox.NoRole) self.no_btn.setMinimumHeight(30) self.no_btn.setIconSize(QtCore.QSize(24, 24)) else: self.addButton(override_no_label, QtWidgets.QMessageBox.NoRole) # self.addButton(override_no_label, QtWidgets.QMessageBox.NoRole) if cancel_button: if cancel_icon: self.canc_btn = QtWidgets.QPushButton(self) self.canc_btn.setText(override_cancel_label) self.canc_btn.setIcon(QtGui.QIcon(cancel_icon)) self.addButton(self.canc_btn, QtWidgets.QMessageBox.RejectRole) self.canc_btn.setMinimumHeight(30) self.canc_btn.setIconSize(QtCore.QSize(24, 24)) else: self.addButton(override_cancel_label, QtWidgets.QMessageBox.RejectRole)
def __init__(self, parent=None, **kwargs): super(ProjectDialog, self).__init__(parent) # self.setStyleSheet(cfg.stylesheet) css = loadCSS.loadCSS( os.path.join(os.path.dirname(pipeline.CSS.__file__), 'mainWindow.css')) self.setStyleSheet(css) self.layout = QtWidgets.QVBoxLayout(self) self.layout.setContentsMargins(5, 5, 5, 10) # self.setMaximumHeight(150) self.setWindowTitle('Create new project') self.input_widget = QtWidgets.QWidget(self) self.input_layout = QtWidgets.QVBoxLayout(self.input_widget) self.title = gui.Title(self, label="New project") self.input_layout.addWidget(self.title) self.name_widget = inputs.GroupInput( self, label="Project name", inputWidget=QtWidgets.QLineEdit(self), ic=cfg.text_icon) self.name_input = self.name_widget.input self.input_layout.addWidget(self.name_widget) self.nice_name_widget = inputs.GroupInput( self, label="Nice name", inputWidget=QtWidgets.QLineEdit(self), ic=cfg.text_icon) self.nice_name_input = self.nice_name_widget.input self.input_layout.addWidget(self.nice_name_widget) self.path_widget = inputs.GroupInput( self, label="Project path", inputWidget=QtWidgets.QLineEdit(self), ic=cfg.text_icon) self.path_input = self.path_widget.input self.path_input.setEnabled(False) self.path_set_btn = QtWidgets.QPushButton() self.path_widget.layout.addWidget(self.path_set_btn) self.path_set_btn.setIcon(QtGui.QIcon(cfg.search_icon)) self.path_set_btn.setIconSize(QtCore.QSize(20, 20)) self.path_set_btn.clicked.connect(self.set_project_path) self.input_layout.addWidget(self.path_widget) self.input_padding_widget = inputs.GroupInput( self, label="Padding", inputWidget=QtWidgets.QSpinBox(self), ic=cfg.counter_icon) self.padding_slider = self.input_padding_widget.input self.padding_slider.setMinimum(0) self.padding_slider.setMaximum(6) self.padding_slider.setValue(3) self.input_layout.addWidget(self.input_padding_widget) self.input_fps_widget = inputs.GroupInput( self, label="Default fps", inputWidget=QtWidgets.QComboBox(self), ic=cfg.time_icon) self.fps_input = self.input_fps_widget.input self.fps_input.setEditable(False) rates = ["PAL (25fps)", "Film (24fps)", "NTSC (30fps)"] self.fps_input.addItems(rates) self.input_layout.addWidget(self.input_fps_widget) i = self.fps_input.findText(rates[0], QtCore.Qt.MatchFixedString) if i >= 0: self.fps_input.setCurrentIndex(i) self.input_playblasts_switch_widget = inputs.GroupInput( self, label="Save playblast at", inputWidget=QtWidgets.QComboBox(self), ic=cfg.icons.HDD) self.playblasts_switch_input = self.input_playblasts_switch_widget.input self.playblasts_switch_input.setEditable(False) rates = [ cfg.playblast_save_options.PROJECT_ROOT, cfg.playblast_save_options.PROJECT_SISTER, cfg.playblast_save_options.COMPONENT ] # "Projects root (Recommended)", "Project sister folder", "Component root"] self.playblasts_switch_input.addItems(rates) self.input_layout.addWidget(self.input_playblasts_switch_widget) i = self.playblasts_switch_input.findText(rates[0], QtCore.Qt.MatchFixedString) if i >= 0: self.playblasts_switch_input.setCurrentIndex(i) # self.prefix_widget = inputs.GroupInput(self, label="Project prefix", inputWidget=QtWidgets.QLineEdit(self), # ic=cfg.text_icon) # self.prefix_input = self.prefix_widget.input # self.input_layout.addWidget(self.prefix_widget) # self.playblasts_switch = inputs.GroupInput(self,label="Save playblasts to root folder",inputWidget= QtWidgets.QCheckBox(),ic = cfg.camrea_icon) # self.playblasts_switch_input = self.playblasts_switch.input # self.input_layout.addWidget(self.playblasts_switch) # self.playblasts_switch_input.stateChanged.connect(self.playblasts_switch_toggle) self.var_title = gui.Title(self, label="Project variables") self.input_layout.addWidget(self.var_title) self.layout.addWidget(self.input_widget) self.input_layout.setContentsMargins(0, 0, 0, 0) self.input_widget.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) self.tab_widgets = QtWidgets.QWidget(self) self.tab_widgets_layout = QtWidgets.QVBoxLayout(self.tab_widgets) self.tab_widgets_layout.setContentsMargins(0, 0, 0, 0) self.tab_widgets.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) self.layout.addWidget(self.tab_widgets) self.variable_tabs = gui.Tabs(self) self.tab_widgets_layout.addWidget(self.variable_tabs) self.branches_widget = QtWidgets.QWidget() self.branches_layout = QtWidgets.QVBoxLayout(self.branches_widget) # self.branches_widget.setMinimumHeight(600) self.branches_widget.setMinimumWidth(450) self.variable_tabs.tab_widget.addTab(self.branches_widget, "Branches") self.branches_view = branch_view.Branch_list_view(self) self.branches_layout.addWidget(self.branches_view) # self.branches_view.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) self.users_widget = QtWidgets.QWidget() self.users_layout = QtWidgets.QVBoxLayout(self.users_widget) self.users_widget.setMinimumHeight(400) self.users_widget.setMinimumWidth(450) self.variable_tabs.tab_widget.addTab(self.users_widget, "Users") self.users_switch = inputs.GroupInput( self, label="Enable users", inputWidget=QtWidgets.QCheckBox(), ic=cfg.users_icon) self.users_swith_input = self.users_switch.input self.users_layout.addWidget(self.users_switch) self.users_swith_input.stateChanged.connect(self.users_table_toggle) self.users_tree = views.Project_Users_View(self.users_widget) self.users_layout.addWidget(self.users_tree) # self.users_tree.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) # self.list_view.setModel_(self.list_model) # self.setSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) self.actions_widget = QtWidgets.QWidget(self) self.actions_widget_layout = QtWidgets.QVBoxLayout(self.actions_widget) self.actions_widget_layout.setContentsMargins(0, 0, 0, 0) self.actions_widget.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) self.layout.addWidget(self.actions_widget) buttons = QtWidgets.QDialogButtonBox( QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel, QtCore.Qt.Horizontal, self) buttons.accepted.connect(self.accept) buttons.rejected.connect(self.reject) self.actions_widget_layout.addWidget(buttons) self.populate_brnaches() self.populated_users() # self.name_input.setText(cfg.preset["project_name"]) self.padding_slider.setValue(3) # self.prefix_input.setText(cfg.preset["prefix"]) self.name_input.textChanged.connect(self.name_changed) self.path_input.textChanged.connect(self.path_changed) self.users_swith_input.setCheckState(QtCore.Qt.Checked) self.users_table_toggle(QtCore.Qt.Checked) # self.playblasts_switch_input.setCheckState(QtCore.Qt.Checked) # self.playblasts_switch_toggle(QtCore.Qt.Checked) self.users_mode = True self.playblast_on_root = True
def __init__(self, parent, **kwargs): super(Preset_dialog, self).__init__(parent) self.setWindowFlags(QtCore.Qt.Tool) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.pipeline_window = None if 'pipeline_window' in kwargs: self.pipeline_window = kwargs['pipeline_window'] self.setMinimumHeight(650) self.setMinimumWidth(800) self.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) self.center_to_maya_window() self.main_widget = QtWidgets.QWidget(self) self.setCentralWidget(self.main_widget) # self.setStyleSheet(cfg.stylesheet) css = loadCSS.loadCSS( os.path.join(os.path.dirname(pipeline.CSS.__file__), 'mainWindow.css')) self.setStyleSheet(css) self.layout = QtWidgets.QVBoxLayout(self.main_widget) self.layout.setContentsMargins(5, 5, 5, 5) # self.setLayout(self.layout) self.setWindowTitle("Preset editor") self.header = gui.Title(self, label="Tree construction preset") self.header.setMaximumHeight(40) self.layout.addWidget(self.header) self.editor_tables_widget = QtWidgets.QWidget(self) self.editor_tables_widget_layout = QtWidgets.QVBoxLayout( self.editor_tables_widget) self.editor_tables_widget_layout.setContentsMargins(5, 5, 5, 5) self.editor_tables_widget_layout.setSpacing(10) self.layout.addWidget(self.editor_tables_widget) self.hierarchy_table_view = views.Hierarcy_catagories_view( parent=self, parentWidget=self.editor_tables_widget) self.hierarchy_table_view.setSizePolicy( QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) branches = [ os.path.split(p)[1] for p in self.pipeline_window.project.branches ] if self.pipeline_window else list() self.components_table_view = views.Hierarcy_components_view( parent=self, parentWidget=self.editor_tables_widget, branches=branches) self.components_table_view.setSizePolicy( QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) self.hierarchy_label = gui.Title(self, label="Tree hierarchy", seperator=False) # self.hierarchy_label.setMaximumHeight(30) self.components_label = gui.Title(self, label="Child omponents", seperator=False) # self.components_label.setMaximumHeight(30) self.hierarchy_help_label = QtWidgets.QLabel() self.hierarchy_help_label.setText( "Use right click for options.\n" "Each category will be generated under it's parent category.\n\n" "{} = during creation the user will be prompt to enter a value.". format(cfg.Hierarcy_options.ASK_USER)) italic = QtGui.QFont() italic.setItalic(True) self.hierarchy_help_label.setFont(italic) self.components_help_label = QtWidgets.QLabel() self.components_help_label.setText( "Components and categories will be generated for the defined branch,\n" "under the lower category.\n\n" "Branches will be created if they are not exists in the project.") italic = QtGui.QFont() italic.setItalic(True) self.components_help_label.setFont(italic) self.editor_tables_widget_layout.addWidget(self.hierarchy_label) self.editor_tables_widget_layout.addWidget(self.hierarchy_help_label) self.editor_tables_widget_layout.addWidget(self.hierarchy_table_view) self.editor_tables_widget_layout.addWidget(self.components_label) self.editor_tables_widget_layout.addWidget(self.components_help_label) self.editor_tables_widget_layout.addWidget(self.components_table_view) self.actions_widget = QtWidgets.QWidget(self) self.actions_widget_layout = QtWidgets.QHBoxLayout(self.actions_widget) self.actions_widget_layout.setContentsMargins(5, 5, 5, 5) self.layout.addWidget(self.actions_widget) self.save_preset_btn = QtWidgets.QPushButton("Save preset") self.save_preset_btn.setIcon(QtGui.QIcon(cfg.save_icon)) self.save_preset_btn.setIconSize(QtCore.QSize(20, 20)) self.load_preset_btn = QtWidgets.QPushButton("Load preset") self.load_preset_btn.setIcon(QtGui.QIcon(cfg.folder_open_icon)) self.load_preset_btn.setIconSize(QtCore.QSize(20, 20)) self.load_preset_btn.setStyleSheet(''' QPushButton::menu-indicator{ image: url(none.jpg); } ''') self.set_preset_menu() # self.menu = QtWidgets.QMenu(self.load_preset_btn) # self.menu.addAction(QtWidgets.QAction("Load from file...", self.menu, triggered=self.load_preset)) # self.menu.addSeparator() # # for p in self.list_saved_presets(): # self.menu.addAction(QtWidgets.QAction(p[1], self.menu, triggered=functools.partial(self.set_preset, p[0]))) # # self.menu.addSeparator() # self.menu.addAction(QtWidgets.QAction("Clear", self.menu, triggered=self.clear_preset)) # self.load_preset_btn.setMenu(self.menu) # self.actions_widget_layout.addWidget(self.save_preset_btn) self.actions_widget_layout.addWidget(self.load_preset_btn) self.save_preset_btn.clicked.connect(self.save_preset)