def mousePressEvent(self, event): siRight = event.button() == QtCore.Qt.RightButton p = event.pos() a1h8 = self.punto2a1h8(p) m = int(event.modifiers()) is_ctrl = (m & QtCore.Qt.ControlModifier) > 0 is_shift = (m & QtCore.Qt.ShiftModifier) > 0 is_alt = (m & QtCore.Qt.AltModifier) > 0 li_tareas = self.guion.tareasPosicion(p) if siRight and is_shift and is_alt: pz_borrar = self.board.dameNomPiezaEn(a1h8) menu = Controles.Menu(self.board) dicPieces = TrListas.dicNomPiezas() icoPiece = self.board.piezas.icono if pz_borrar or len(li_tareas): mrem = menu.submenu(_("Remove"), Iconos.Delete()) if pz_borrar: label = dicPieces[pz_borrar.upper()] mrem.opcion(("rem_pz", None), label, icoPiece(pz_borrar)) mrem.separador() for pos_guion, tarea in li_tareas: label = "%s - %s - %s" % (tarea.txt_tipo(), tarea.name(), tarea.info()) mrem.opcion(("rem_gr", pos_guion), label, Iconos.Delete()) mrem.separador() menu.separador() for pz in "KQRBNPkqrbnp": if pz != pz_borrar: if pz == "k": menu.separador() menu.opcion(("create", pz), dicPieces[pz.upper()], icoPiece(pz)) resp = menu.lanza() if resp is not None: orden, arg = resp if orden == "rem_gr": self.w.g_guion.goto(arg, 0) self.w.borrar_lista() elif orden == "rem_pz": self.w.creaTarea("B", pz_borrar, a1h8, -1) elif orden == "create": self.w.creaTarea("C", arg, a1h8, -1) return True if self.director: return self.mousePressEvent_Drop(event) self.w.boardPress(event, a1h8, siRight, is_shift, is_alt, is_ctrl) return True
def __init__(self, owner, nom_pieces_ori): titulo = _("Blindfold") + " - " + _("Configuration") icono = Iconos.Ojo() extparam = "wblindfold" QTVarios.WDialogo.__init__(self, owner, titulo, icono, extparam) self.config = BlindfoldConfig(nom_pieces_ori) self.nom_pieces_ori = nom_pieces_ori lbWhite = Controles.LB(self, _("White")).ponTipoLetra(peso=75, puntos=10) lbBlack = Controles.LB(self, _("Black")).ponTipoLetra(peso=75, puntos=10) self.dicWidgets = collections.OrderedDict() self.dicImgs = {} li_options = ((_("Hide"), HIDE), (_("Green"), GREY), (_("Checker"), CHECKER), (_("Show"), SHOW)) dicNomPiezas = TrListas.dicNomPiezas() def haz(pz): tpW = self.config.dicPiezas[pz.upper()] tpB = self.config.dicPiezas[pz] lbPZw = Controles.LB(self) cbPZw = Controles.CB(self, li_options, tpW).capture_changes(self.reset) lbPZ = Controles.LB(self, dicNomPiezas[pz.upper()]).ponTipoLetra( peso=75, puntos=10) lbPZb = Controles.LB(self) cbPZb = Controles.CB(self, li_options, tpB).capture_changes(self.reset) self.dicWidgets[pz] = [ lbPZw, cbPZw, lbPZ, lbPZb, cbPZb, None, None ] for pz in "kqrbnp": haz(pz) btAllW = Controles.PB(self, _("All White"), self.allWhite, plano=False) self.cbAll = Controles.CB(self, li_options, HIDE) btAllB = Controles.PB(self, _("All Black"), self.allBlack, plano=False) btSwap = Controles.PB(self, _("Swap"), self.swap, plano=False) li_acciones = ( (_("Save"), Iconos.Grabar(), "grabar"), None, (_("Cancel"), Iconos.Cancelar(), "cancelar"), None, (_("Configurations"), Iconos.Opciones(), "configurations"), None, ) tb = Controles.TB(self, li_acciones) ly = Colocacion.G() ly.controlc(lbWhite, 0, 1).controlc(lbBlack, 0, 3) row = 1 for pz in "kqrbnp": lbPZw, cbPZw, lbPZ, lbPZb, cbPZb, tipoW, tipoB = self.dicWidgets[ pz] ly.control(cbPZw, row, 0) ly.controlc(lbPZw, row, 1) ly.controlc(lbPZ, row, 2) ly.controlc(lbPZb, row, 3) ly.control(cbPZb, row, 4) row += 1 ly.filaVacia(row, 20) row += 1 ly.controld(btAllW, row, 0, 1, 2) ly.control(self.cbAll, row, 2) ly.control(btAllB, row, 3, 1, 2) ly.controlc(btSwap, row + 1, 0, 1, 5) ly.margen(20) layout = Colocacion.V().control(tb).otro(ly) self.setLayout(layout) self.reset()