def _call_unlink(self): index = self.shared_view.get_selected_row() if index is None: return warning('Hotbox designer', 'No hotbox selected') self.shared_model.remove_link(index) self.save_hotboxes() clear_loaded_hotboxes()
def _call_remove(self): hotbox = self.get_selected_hotbox() if hotbox is None: return warning('Hotbox designer', 'No hotbox selected') areyousure = QtWidgets.QMessageBox.question( self, 'remove', 'remove a hotbox is definitive, are you sure to continue', buttons=QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, defaultButton=QtWidgets.QMessageBox.No) if areyousure == QtWidgets.QMessageBox.No: return self.personnal_model.layoutAboutToBeChanged.emit() self.personnal_model.hotboxes.remove(hotbox) self.personnal_model.layoutChanged.emit() self.save_hotboxes() # self.toolbar.reload.setEnabled(True) # get the amount of hotboxes and get the new hotbox index hotbox_count = len(self.personnal_model.hotboxes) - 1 # select newly created hotbox if hotbox_count > -1: self.personnal_view.selectRow(hotbox_count) # reload hotboxes automatically after a hotbox is removed self.toolbar.reloadRequested.emit()
def _call_unlink(self): index = self.shared_view.get_selected_row() if index is None: return warning('Hotbox designer', 'No hotbox selected') self.shared_model.remove_link(index) self.save_hotboxes() self.toolbar.reload.setEnabled(True)
def _get_switch_command(self): hotbox = self.get_selected_hotbox() if not hotbox: return warning('Hotbox designer', 'No hotbox selected') return SWITCH_COMMAND.format( application=self.application.name, name=hotbox['general']['name'])
def set_hotkey(self, name, mode, sequence, open_cmd, close_cmd, switch_cmd): from maya import cmds, mel current_hotkey_set = cmds.hotkeySet(current=True, query=True) if current_hotkey_set == 'Maya_Default': msg = 'The current hotkey set is locked, change in the hotkey editor' warning('Hotbox designer', msg) return mel.eval('hotkeyEditorWindow;') use_alt = 'Alt' in sequence use_ctrl = 'Ctrl' in sequence use_shift = 'Shift' in sequence touch = sequence.split('+')[-1] show_name = 'showHotbox_{n}'.format(n=name) hide_name = 'hideHotbox_{n}'.format(n=name) switch_name = 'switchHotbox_{n}'.format(n=name) if mode == SETMODE_PRESS_RELEASE: cmds.nameCommand(show_name, annotation='show {n} hotbox'.format(n=name), command=format_command_for_mel(open_cmd), sourceType='python') cmds.nameCommand(hide_name, annotation='hide {n} hotbox'.format(n=name), command=format_command_for_mel(close_cmd), sourceType='python') cmds.hotkey(keyShortcut=touch, altModifier=use_alt, ctrlModifier=use_ctrl, shiftModifier=use_shift, name=show_name, releaseName=hide_name) else: cmds.nameCommand(switch_name, annotation='switch {n} hotbox'.format(n=name), command=format_command_for_mel(switch_cmd), sourceType='python') cmds.hotkey(keyShortcut=touch, altModifier=use_alt, ctrlModifier=use_ctrl, shiftModifier=use_shift, name=switch_name)
def _call_unlink(self): index = self.shared_view.get_selected_row() if index is None: return warning('Hotbox designer', 'No hotbox selected') self.shared_model.remove_link(index) self.save_hotboxes() # reload hotboxes automatically after a hotbox is created self.toolbar.reloadRequested.emit()
def _call_import(self): hotbox = import_hotbox() if not hotbox: return warning('Hotbox designer', 'No hotbox selected') hotboxes = self.personnal_model.hotboxes name = get_valid_name(hotboxes, hotbox['general']['name']) hotbox['general']['name'] = name self.personnal_model.layoutAboutToBeChanged.emit() self.personnal_model.hotboxes.append(hotbox) self.personnal_model.layoutChanged.emit() self.save_hotboxes() self.toolbar.reload.setEnabled(True)
def _call_edit(self): if self.tabwidget.currentIndex(): return hotbox_data = self.get_selected_hotbox() if hotbox_data is None: return warning('Hotbox designer', 'No hotbox selected') if self.hotbox_designer is not None: self.hotbox_designer.close() self.hotbox_designer = HotboxEditor( hotbox_data, self.application, parent=self.application.main_window) method = self.hotbox_data_modified self.hotbox_designer.hotboxDataModified.connect(method) self.hotbox_designer.show()
def _call_set_hotkey(self): hotbox = self.get_selected_hotbox() if not hotbox: return warning('Hotbox designer', 'No hotbox selected') modes = self.application.available_set_hotkey_modes dialog = HotkeySetter(modes) result = dialog.exec_() name = hotbox['general']['name'] open_cmd = OPEN_COMMAND.format(name=name, application=self.application.name) switch_cmd = SWITCH_COMMAND.format(name=name, application=self.application.name) if result == QtWidgets.QDialog.Rejected: return self.application.set_hotkey(name=name, mode=dialog.mode(), sequence=dialog.get_key_sequence(), open_cmd=open_cmd, close_cmd=CLOSE_COMMAND.format(name=name), switch_cmd=switch_cmd)
def _call_remove(self): hotbox = self.get_selected_hotbox() if hotbox is None: return warning('Hotbox designer', 'No hotbox selected') areyousure = QtWidgets.QMessageBox.question( self, 'remove', 'remove a hotbox is definitive, are you sure to continue', buttons=QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No, defaultButton=QtWidgets.QMessageBox.No) if areyousure == QtWidgets.QMessageBox.No: return self.personnal_model.layoutAboutToBeChanged.emit() self.personnal_model.hotboxes.remove(hotbox) self.personnal_model.layoutChanged.emit() self.save_hotboxes() clear_loaded_hotboxes()
def _call_export(self): hotbox = self.get_selected_hotbox() if not hotbox: return warning('Hotbox designer', 'No hotbox selected') export_hotbox(hotbox)
def _get_close_command(self): hotbox = self.get_selected_hotbox() if not hotbox: return warning('Hotbox designer', 'No hotbox selected') return CLOSE_COMMAND.format(name=hotbox['general']['name'])