Esempio n. 1
0
    def __init__(self, owner, theme, your_themes):
        super(WNameTheme, self).__init__(owner)

        self.theme = theme
        li_sections = [theme["SECCION"] for theme in your_themes if "SECCION" in theme]
        self.li_sections = list(set(li_sections))
        self.li_sections.sort()

        self.setWindowTitle(_("Theme"))
        self.setWindowIcon(Iconos.Temas())
        self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint)

        lb_name = Controles.LB2P(self, _("Name"))
        self.ed_name = Controles.ED(self, theme.get("NOMBRE", ""))
        ly_name = Colocacion.H().control(lb_name).control(self.ed_name)

        lb_section = Controles.LB2P(self, _("Section"))
        self.ed_section = Controles.ED(self, theme.get("SECCION", ""))
        bt_section = Controles.PB(self, "", self.mira_section).ponIcono(Iconos.BuscarC(), 16).ponToolTip(_("Section lists"))
        ly_section = Colocacion.H().control(lb_section).control(self.ed_section).espacio(-10).control(bt_section).relleno(1)

        self.chb_pieces_set = Controles.CHB(self, _("Change piece set"), theme.get("CHANGE_PIECES", True))

        li_acciones = [(_("Save"), Iconos.Aceptar(), self.aceptar), None, (_("Cancel"), Iconos.Cancelar(), self.reject), None]
        self.tb = QTVarios.LCTB(self, li_acciones)

        layout = Colocacion.V().control(self.tb).espacio(16)
        layout.otro(ly_name).espacio(16)
        layout.otro(ly_section).espacio(16)
        layout.control(self.chb_pieces_set)
        layout.margen(6)
        self.setLayout(layout)

        self.ed_name.setFocus()
        if not self.li_sections:
            bt_section.hide()
Esempio n. 2
0
    def __init__(self, owner, configuracion, dic_data):
        super(WOptionsDatabase, self).__init__(owner)

        self.new = len(dic_data) == 0

        self.dic_data = dic_data
        self.dic_data_resp = None

        def d_str(key):
            return dic_data.get(key, "")

        def d_true(key):
            return dic_data.get(key, True)

        def d_false(key):
            return dic_data.get(key, False)

        title = _("New database") if len(dic_data) == 0 else "%s: %s" % (_("Database"), d_str("NAME"))
        self.setWindowTitle(title)
        self.setWindowIcon(Iconos.DatabaseMas())
        self.setWindowFlags(QtCore.Qt.WindowCloseButtonHint | QtCore.Qt.Dialog | QtCore.Qt.WindowTitleHint)

        self.configuracion = configuracion
        self.resultado = None

        valid_rx = r'^[^<>:;,?"*|/\\]+'

        lb_name = Controles.LB2P(self, _("Name"))
        self.ed_name = Controles.ED(self, d_str("NAME")).controlrx(valid_rx)

        ly_name = Colocacion.H().control(lb_name).control(self.ed_name)

        folder = os.path.dirname(Util.relative_path(d_str("FILEPATH")))
        folder = folder[len(configuracion.folder_databases()):]
        if folder.strip():
            folder = folder.strip(os.sep)
            li = folder.split(os.sep)
            nli = len(li)
            group = li[0]
            subgroup1 = li[1] if nli > 1 else ""
            subgroup2 = li[2] if nli > 2 else ""
        else:
            group = ""
            subgroup1 = ""
            subgroup2 = ""

        lb_group = Controles.LB2P(self, _("Group"))
        self.ed_group = Controles.ED(self, group).controlrx(valid_rx)
        self.bt_group = (
            Controles.PB(self, "", self.mira_group).ponIcono(Iconos.BuscarC(), 16).ponToolTip(_("Group lists"))
        )
        ly_group = (
            Colocacion.H().control(lb_group).control(self.ed_group).espacio(-10).control(self.bt_group).relleno(1)
        )

        lb_subgroup_l1 = Controles.LB2P(self, _("Subgroup"))
        self.ed_subgroup_l1 = Controles.ED(self, subgroup1).controlrx(valid_rx)
        self.bt_subgroup_l1 = (
            Controles.PB(self, "", self.mira_subgroup_l1).ponIcono(Iconos.BuscarC(), 16).ponToolTip(_("Group lists"))
        )
        ly_subgroup_l1 = (
            Colocacion.H()
            .espacio(40)
            .control(lb_subgroup_l1)
            .control(self.ed_subgroup_l1)
            .espacio(-10)
            .control(self.bt_subgroup_l1)
            .relleno(1)
        )

        lb_subgroup_l2 = Controles.LB2P(self, "%s → %s" % (_("Subgroup"), _("Subgroup")))
        self.ed_subgroup_l2 = Controles.ED(self, subgroup2).controlrx(valid_rx)
        self.bt_subgroup_l2 = (
            Controles.PB(self, "", self.mira_subgroup_l2).ponIcono(Iconos.BuscarC(), 16).ponToolTip(_("Group lists"))
        )
        ly_subgroup_l2 = (
            Colocacion.H()
            .espacio(40)
            .control(lb_subgroup_l2)
            .control(self.ed_subgroup_l2)
            .espacio(-10)
            .control(self.bt_subgroup_l2)
            .relleno(1)
        )

        x1 = -8
        ly_group = Colocacion.V().otro(ly_group).espacio(x1).otro(ly_subgroup_l1).espacio(x1).otro(ly_subgroup_l2)

        gb_group = Controles.GB(self, "%s (%s)" % (_("Group"), "optional"), ly_group)

        lb_summary = Controles.LB2P(self, _("Summary depth (0=disable)"))
        self.sb_summary = Controles.SB(self, dic_data.get("SUMMARY_DEPTH", 12), 0, 999)
        ly_summary = Colocacion.H().control(lb_summary).control(self.sb_summary).relleno(1)

        self.external_folder = d_str("EXTERNAL_FOLDER")
        lb_external = Controles.LB2P(self, _("Store in an external folder"))
        self.bt_external = Controles.PB(self, self.external_folder, self.select_external, False)
        self.bt_external.setSizePolicy(
            QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        )
        ly_external = Colocacion.H().control(lb_external).control(self.bt_external)

        self.chb_complete = Controles.CHB(self, _("Allow complete games"), d_true("ALLOWS_COMPLETE_GAMES"))
        self.chb_positions = Controles.CHB(self, _("Allow positions"), d_true("ALLOWS_POSITIONS"))
        self.chb_duplicate = Controles.CHB(self, _("Allow duplicates"), d_false("ALLOWS_DUPLICATES"))
        self.chb_zeromoves = Controles.CHB(self, _("Allow without moves"), d_false("ALLOWS_ZERO_MOVES"))
        ly_res = (
            Colocacion.V()
            .controlc(self.chb_complete)
            .controlc(self.chb_positions)
            .controlc(self.chb_duplicate)
            .controlc(self.chb_zeromoves)
        )

        gb_restrictions = Controles.GB(self, _("Import restrictions"), ly_res)

        li_acciones = [
            (_("Save"), Iconos.Aceptar(), self.save),
            None,
            (_("Cancel"), Iconos.Cancelar(), self.reject),
            None,
        ]
        self.tb = QTVarios.LCTB(self, li_acciones)

        x0 = 16

        layout = Colocacion.V().control(self.tb).espacio(x0)
        layout.otro(ly_name).espacio(x0).control(gb_group).espacio(x0)
        layout.otro(ly_summary).espacio(x0)
        layout.otro(ly_external).espacio(x0)
        layout.control(gb_restrictions)
        layout.margen(9)

        self.setLayout(layout)

        self.ed_name.setFocus()