Пример #1
0
    def __init__(self, owner, procesador):
        QtWidgets.QTreeWidget.__init__(self)
        self.owner = owner
        self.dbCache = owner.dbCache
        self.setAlternatingRowColors(True)
        self.listaMoves = owner.listaMoves
        self.procesador = procesador
        self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self.menuContexto)

        self.setHeaderLabels(
            (_("Moves"), _("Points"), _("Comments"), _("Variations"), "", ""))
        self.setColumnHidden(4, True)

        dic_nags = TrListas.dic_nags()
        self.dicValoracion = collections.OrderedDict()
        self.dicValoracion["1"] = (VERY_GOOD_MOVE, dic_nags[3])
        self.dicValoracion["2"] = (GOOD_MOVE, dic_nags[1])
        self.dicValoracion["3"] = (BAD_MOVE, dic_nags[2])
        self.dicValoracion["4"] = (VERY_POOR_MOVE, dic_nags[4])
        self.dicValoracion["5"] = (SPECULATIVE_MOVE, dic_nags[5])
        self.dicValoracion["6"] = (QUESTIONABLE_MOVE, dic_nags[6])
        self.dicValoracion["0"] = (NO_RATING, _("No rating"))

        ftxt = Controles.TipoLetra(puntos=9)

        self.setFont(ftxt)

        self.currentItemChanged.connect(self.seleccionado)
        self.itemDoubleClicked.connect(self.edited)

        hitem = self.header()
        hitem.setSectionsClickable(True)
        hitem.sectionDoubleClicked.connect(self.editedH)

        self.dicItemMoves = {}
        self.ponMoves(self.listaMoves)

        self.sortItems(4, QtCore.Qt.AscendingOrder)
Пример #2
0
    def muestraInformacion(self):
        li = []
        li.append("%s: %d" % (_("Errors"), self.errores))
        if self.siAyuda:
            li.append(_("Help activated"))
        self.set_label1("\n".join(li))

        tgm = 0
        for tr in self.game_info["TRIES"]:
            tgm += tr["TIME"]

        mens = "\n" + "\n".join(self.liMensBasic)
        mens += "\n%s:\n    %s %s\n    %s %s" % (
            _("Working time"),
            time.strftime("%H:%M:%S", time.gmtime(tgm)),
            _("Current"),
            time.strftime("%H:%M:%S", time.gmtime(self.tm)),
            _("Total"),
        )

        self.set_label2(mens)

        if self.siAyuda:
            dic_nags = TrListas.dic_nags()
            mens3 = ""
            fenm2 = self.game.last_position.fenm2()
            reg = self.dbop.getfenvalue(fenm2)
            if reg:
                mens3 = reg.get("COMENTARIO", "")
                ventaja = reg.get("VENTAJA", 0)
                valoracion = reg.get("VALORACION", 0)
                if ventaja:
                    mens3 += "\n %s" % dic_nags[ventaja]
                if valoracion:
                    mens3 += "\n %s" % dic_nags[valoracion]
            self.set_label3(mens3 if mens3 else None)
    def __init__(self, w_parent):
        QtWidgets.QWidget.__init__(self, w_parent)

        self.w_parent = w_parent

        self.move = None
        self.game = None

        configuration = Code.configuration

        puntos = configuration.x_pgn_fontpoints

        f = Controles.TipoLetra(puntos=puntos, peso=75)
        f9 = Controles.TipoLetra(puntos=puntos)
        ftxt = f9

        # Opening
        self.lb_opening = (Controles.LB(
            self, "").ponFuente(f).align_center().set_foreground_backgound(
                "#eeeeee", "#474d59").set_wrap())
        self.lb_opening.hide()

        # Valoracion
        li_options = [("-", None)]
        dic_nags = TrListas.dic_nags()

        nags_folder = Code.path_resource("IntFiles", "NAGs")

        ico_vacio = QTVarios.fsvg2ico("%s/$0.svg" % (nags_folder, ), 16)

        for x in dic_nags:
            if x:
                fsvg = "%s/$%d.svg" % (nags_folder, x)
                if os.path.isfile(fsvg):
                    li_options.append(("$%d : %s" % (x, dic_nags[x]), x,
                                       QTVarios.fsvg2ico(fsvg, 16)))
                else:
                    li_options.append(
                        ("$%d : %s" % (x, dic_nags[x]), x, ico_vacio))
        self.max_nags = 10
        self.li_nags = []
        for x in range(self.max_nags):
            cb = (Controles.CB(self, li_options,
                               "").set_widthMinimo().capture_changes(
                                   self.valoration_changed).ponFuente(f9))
            if x:
                cb.hide()
            self.li_nags.append(cb)

        bt_nags = Controles.PB(self, "", self.more_nags).ponIcono(
            Iconos.Mas()).anchoFijo(22)

        ly_h = Colocacion.H().control(self.li_nags[0]).control(bt_nags)
        ly = Colocacion.V().otro(ly_h)
        for x in range(1, self.max_nags):
            ly.control(self.li_nags[x])

        self.gbValoracion = Controles.GB(self, _("Rating"), ly).ponFuente(f)

        # Comentarios
        self.comment = (Controles.EM(self, siHTML=False).capturaCambios(
            self.comment_changed).ponFuente(ftxt).anchoMinimo(200))
        ly = Colocacion.H().control(self.comment).margen(3)
        self.gb_comments = Controles.GB(self, _("Comments"), ly).ponFuente(f)

        # Variations
        self.variantes = WVariations(self)

        self.splitter = splitter = QtWidgets.QSplitter(self)
        self.splitter.setOrientation(QtCore.Qt.Vertical)
        splitter.addWidget(self.gb_comments)
        splitter.addWidget(self.variantes)
        splitter.setSizes([1, 1])

        layout = Colocacion.V()
        layout.control(self.lb_opening)
        layout.control(self.gbValoracion)
        layout.control(self.splitter)
        layout.margen(1)

        self.setLayout(layout)

        self.setMinimumWidth(220)
Пример #4
0
def cambiaColores(parent, configuration):
    separador = (None, None)

    liColor = []
    liColor.append(separador)
    liColor.append((_("Reset to default") + ":", False))
    liColor.append(separador)

    palette = configuration.palette
    palette_std = QtWidgets.QApplication.style().standardPalette()

    liPalette = []

    def xcolor(txt, tipo):
        config = FormLayout.Colorbox(txt, 40, 20, siSTR=True)
        color = QtGui.QColor(palette[tipo]) if palette else palette_std.color(getattr(QtGui.QPalette, tipo))
        liColor.append((config, color))
        liPalette.append(tipo)

    xcolor(_("General background"), "Window")
    xcolor(_("General foreground"), "WindowText")
    liColor.append(separador)
    xcolor(_("Text entry background"), "Base")
    xcolor(_("Text entry foreground"), "Text")
    xcolor(_("Alternate background"), "AlternateBase")
    liColor.append(separador)
    xcolor(_("Tool tip background"), "ToolTipBase")
    xcolor(_("Tool tip foreground"), "ToolTipText")
    liColor.append(separador)
    xcolor(_("Button background"), "Button")
    xcolor(_("Button foreground"), "ButtonText")
    xcolor(_("Bright text"), "BrightText")
    liColor.append(separador)
    xcolor(_("Links"), "Link")

    # QtGui.QPalette.Window	10	A general background color.
    # QtGui.QPalette.WindowText	0	A general foreground color.
    # QtGui.QPalette.Base	9	Used mostly as the background color for text entry widgets, but can also be used for other painting - such as the background of combobox drop down lists and toolbar handles. It is usually white or another light color.
    # QtGui.QPalette.AlternateBase	16	Used as the alternate background color in views with alternating row colors (see QAbstractItemView::setAlternatingRowColors()).
    # QtGui.QPalette.ToolTipBase	18	Used as the background color for QToolTip and QWhatsThis. Tool tips use the Inactive color group of QPalette, because tool tips are not active windows.
    # QtGui.QPalette.ToolTipText	19	Used as the foreground color for QToolTip and QWhatsThis. Tool tips use the Inactive color group of QPalette, because tool tips are not active windows.
    # QtGui.QPalette.Text	6	The foreground color used with Base. This is usually the same as the WindowText, in which case it must provide good contrast with Window and Base.
    # QtGui.QPalette.Button	1	The general button background color. This background can be different from Window as some styles require a different background color for buttons.
    # QtGui.QPalette.ButtonText	8	A foreground color used with the Button color.
    # QtGui.QPalette.BrightText	7	A text color that is very different from WindowText, and contrasts well with e.g. Dark. Typically used for text that needs to be drawn where Text or WindowText would give poor contrast, such as on pressed push buttons. Note that text colors can be used for things other than just words; text colors are usually used for text, but it's quite common to use the text color roles for lines, icons, etc.

    liPGN = []
    liPGN.append(separador)
    liPGN.append((_("Reset to default") + ":", False))
    liPGN.append(separador)

    dic_nags = TrListas.dic_nags()
    config = FormLayout.Colorbox(dic_nags[1], 40, 20, siSTR=True)
    liPGN.append((config, configuration.x_color_nag1))

    config = FormLayout.Colorbox(dic_nags[2], 40, 20, siSTR=True)
    liPGN.append((config, configuration.x_color_nag2))

    config = FormLayout.Colorbox(dic_nags[3], 40, 20, siSTR=True)
    liPGN.append((config, configuration.x_color_nag3))

    config = FormLayout.Colorbox(dic_nags[4], 40, 20, siSTR=True)
    liPGN.append((config, configuration.x_color_nag4))

    config = FormLayout.Colorbox(dic_nags[5], 40, 20, siSTR=True)
    liPGN.append((config, configuration.x_color_nag5))

    config = FormLayout.Colorbox(dic_nags[6], 40, 20, siSTR=True)
    liPGN.append((config, configuration.x_color_nag6))

    li_others = []
    li_others.append(separador)
    li_others.append((_("Reset to default") + ":", False))
    li_others.append(separador)

    li_others.append((None, _("Tables")))
    config = FormLayout.Colorbox(_("Background of selected row"), 40, 20, siSTR=True)
    color = configuration.pgn_selbackground()
    li_others.append((config, color))
    config = FormLayout.Colorbox(_("Background of header"), 40, 20, siSTR=True)
    color = configuration.x_pgn_headerbackground
    li_others.append((config, color))

    lista = []
    lista.append((liColor, _("Windows"), ""))
    lista.append((liPGN, _("PGN"), ""))
    lista.append((li_others, _("Others"), ""))

    # Editamos
    resultado = FormLayout.fedit(lista, title=_("Colors"), parent=parent, anchoMinimo=240, icon=Iconos.Opciones())

    if resultado:
        accion, resp = resultado

        liColor, liPGN, li_others = resp

        if liColor[0]:
            palette = None
        else:
            palette = {}
            for n, tipo in enumerate(liPalette):
                color = liColor[n + 1]
                if type(color) != str:
                    color = color.name()
                palette[tipo] = color
        configuration.palette = palette

        if liPGN[0]:
            configuration.colores_nags_defecto()
        else:
            (
                configuration.x_color_nag1,
                configuration.x_color_nag2,
                configuration.x_color_nag3,
                configuration.x_color_nag4,
                configuration.x_color_nag5,
                configuration.x_color_nag6,
            ) = liPGN[1:]

        if li_others[0]:
            configuration.x_pgn_selbackground = None
            configuration.x_pgn_headerbackground = None
        else:
            configuration.x_pgn_selbackground = li_others[1]
            configuration.x_pgn_headerbackground = li_others[2]

        configuration.graba()

        return True
    else:
        return False
Пример #5
0
    def __init__(self, panelOpening, configuration):
        QtWidgets.QWidget.__init__(self)

        self.panelOpening = panelOpening
        self.dbop = panelOpening.dbop

        self.configuration = configuration

        self.gamebase = panelOpening.gamebase
        self.num_jg_inicial = len(self.gamebase)
        self.pos_move = self.num_jg_inicial

        config_board = configuration.config_board("POSLINES", 32)
        self.board = Board.Board(self, config_board)
        self.board.crea()
        self.board.ponerPiezasAbajo(True)
        self.board.set_dispatcher(self.player_has_moved)
        self.board.dispatchSize(self.ajustaAncho)
        self.board.dbvisual_set_file(self.dbop.nom_fichero)
        self.board.dbvisual_set_show_allways(True)
        self.board.dbVisual_setSaveAllways(True)

        self.board.ponerPiezasAbajo(self.dbop.getconfig("WHITEBOTTOM", True))

        self.dbop.setdbVisual_Board(self.board)  # To close

        self.intervalo = configuration.x_interval_replay

        tipoLetra = Controles.TipoLetra(puntos=configuration.x_pgn_fontpoints)

        lybt, bt = QTVarios.lyBotonesMovimiento(self,
                                                "",
                                                siTiempo=True,
                                                siLibre=False,
                                                icon_size=24)

        self.lbPGN = LBKey(self).set_wrap()
        self.lbPGN.setStyleSheet(
            "QLabel{ border-style: groove; border-width: 2px; border-color: LightSlateGray; padding: 8px;}"
        )
        self.lbPGN.ponFuente(tipoLetra)
        self.lbPGN.setOpenExternalLinks(False)

        def muestraPos(txt):
            self.colocatePartida(int(txt))

        self.lbPGN.linkActivated.connect(muestraPos)

        self.with_figurines = configuration.x_pgn_withfigurines

        dic_nags = TrListas.dic_nags()
        self.dicValoracion = collections.OrderedDict()
        self.dicValoracion[GOOD_MOVE] = (dic_nags[1],
                                         WindowColors.nag2ico(1, 16))
        self.dicValoracion[BAD_MOVE] = (dic_nags[2],
                                        WindowColors.nag2ico(2, 16))
        self.dicValoracion[VERY_GOOD_MOVE] = (dic_nags[3],
                                              WindowColors.nag2ico(3, 16))
        self.dicValoracion[VERY_POOR_MOVE] = (dic_nags[4],
                                              WindowColors.nag2ico(4, 16))
        self.dicValoracion[SPECULATIVE_MOVE] = (dic_nags[5],
                                                WindowColors.nag2ico(5, 16))
        self.dicValoracion[QUESTIONABLE_MOVE] = (dic_nags[6],
                                                 WindowColors.nag2ico(6, 16))
        self.dicValoracion[NO_RATING] = (_("No rating"), QtGui.QIcon())

        self.dicVentaja = collections.OrderedDict()
        self.dicVentaja[V_SIN] = (_("Undefined"), QtGui.QIcon())
        self.dicVentaja[V_IGUAL] = (dic_nags[11],
                                    Iconos.V_Blancas_Igual_Negras())
        self.dicVentaja[V_BLANCAS] = (dic_nags[14], Iconos.V_Blancas())
        self.dicVentaja[V_BLANCAS_MAS] = (dic_nags[16], Iconos.V_Blancas_Mas())
        self.dicVentaja[V_BLANCAS_MAS_MAS] = (dic_nags[18],
                                              Iconos.V_Blancas_Mas_Mas())
        self.dicVentaja[V_NEGRAS] = (dic_nags[15], Iconos.V_Negras())
        self.dicVentaja[V_NEGRAS_MAS] = (dic_nags[17], Iconos.V_Negras_Mas())
        self.dicVentaja[V_NEGRAS_MAS_MAS] = (dic_nags[19],
                                             Iconos.V_Negras_Mas_Mas())

        # Valoracion
        li_options = [(tit[0], k, tit[1])
                      for k, tit in self.dicValoracion.items()]
        self.cbValoracion = Controles.CB(self, li_options, 0).capture_changes(
            self.cambiadoValoracion)
        self.cbValoracion.ponFuente(tipoLetra)

        # Ventaja
        li_options = [(tit, k, icon)
                      for k, (tit, icon) in self.dicVentaja.items()]
        self.cbVentaja = Controles.CB(self, li_options,
                                      0).capture_changes(self.cambiadoVentaja)
        self.cbVentaja.ponFuente(tipoLetra)

        # Comentario
        self.emComentario = Controles.EM(self, siHTML=False).capturaCambios(
            self.cambiadoComentario)
        self.emComentario.ponFuente(tipoLetra)
        self.emComentario.altoFijo(5 * configuration.x_pgn_rowheight)
        lyVal = Colocacion.H().control(self.cbValoracion).control(
            self.cbVentaja)
        lyEd = Colocacion.V().otro(lyVal).control(self.emComentario)

        # Opening
        self.lb_opening = Controles.LB(self).align_center().ponFuente(
            tipoLetra).set_wrap()

        lyt = Colocacion.H().relleno().control(self.board).relleno()

        lya = Colocacion.H().relleno().control(self.lbPGN).relleno()

        layout = Colocacion.V()
        layout.otro(lyt)
        layout.otro(lybt)
        layout.otro(lya)
        layout.otro(lyEd)
        layout.control(self.lb_opening)
        layout.relleno().margen(0)
        self.setLayout(layout)

        self.ajustaAncho()

        self.siReloj = False

        self.ponPartida(self.gamebase)