Example #1
0
 def sel_cor_manager(self):
     contextMenu(funcs=[(
         tr(32033),
         self.sel_import_correction), (
             tr(32028),
             self.sel_delete_correction), (tr(32032), self.sel_playsweep)])
     self.sel_correction()
Example #2
0
    def sel_profile(self):
        func_available, eqid, _, is_playing, _, is_dyn = self.check_func_available(
        )
        if not func_available: return

        self.eqid = eqid

        include_switch_off = is_dyn and is_playing

        profiles = SocketCom("server").call_func("get", "eq_profiles")
        profile = SocketCom("server").call_func("get", "eq_base_profile")

        if include_switch_off: profiles = [tr(32011)] + profiles

        funcs = [(tr(32014), self.sel_new_profile),
                 (tr(32015), self.sel_delete_profile),
                 (tr(32016), self.sel_load_defaults)]

        sel = contextMenu(items=profiles, default=profile, funcs=funcs)

        if sel is None: return
        if include_switch_off and sel == 0:
            SocketCom("server").call_func("switch", "eq_off")
        else:
            SocketCom("server").call_func("load", "eq_profile",
                                          [eqid, profiles[sel]])
Example #3
0
	def __init__( self, *args, **_kwargs ):
		self.cwd = args[1]
		self.skin = args[2]

		self.sock = SocketCom("server")

		result = self.sock.call_func("get","eq_channel")
		if result is None: return

		self.eqid, self.name, channel = (result)

		self.channel_id = channel

		ch_index = []
		for ch_name in channel:
			try:
				index = chan_num.index(ch_name)
				ch_index.append(index)
			except Exception as e: opthandle(e)

		self.channel = ch_index

		self.profiles = [tr(32413)] + self.sock.call_func("get","eq_profiles")
		self.save_profile = self.sock.call_func("get","eq_base_profile")
		self.sock.call_func("unload","eq_profile",[self.eqid])

		self.corrections =[tr(32411)] + self.sock.call_func("get","room_corrections")
		self.save_correction = self.sock.call_func("get","room_correction")
		self.sock.call_func("unset","room_correction" , [self.eqid])
Example #4
0
	def on_sel_channel(self):
		sel_list = [tr(32412) + "  (0)"] + [tr(32500 + i)+ "  (%s)"%(i+1) for i in self.channel]

		nsel = contextMenu(items = sel_list, default = sel_list[self.channel_sel])
		if nsel is None: return

		self.channel_sel=nsel
		self.getControl(302).setLabel(sel_list[nsel])
Example #5
0
    def sel_manager(self):
        func_available, eqid, _, _, _, _ = self.check_func_available()
        if not func_available: return

        self.eqid = eqid
        contextMenu(funcs=[(
            tr(32014),
            self.sel_new_profile), (
                tr(32015),
                self.sel_delete_profile), (tr(32016), self.sel_load_defaults)])
Example #6
0
    def onAction(self, action):
        t = time.time()
        aid = action.getId()
        fid = self.getFocusId()
        buc = action.getButtonCode() & 255
        #log("eqdialog: key: %s fid: %s"%(aid,fid))

        #OK pressed
        if aid in [7]:
            self.save_profile()
            self._close()

        if aid in [100]:
            if fid == 1800:
                #self.save_profile()
                self.load_profile()
                self._close()

        #Cancel
        if aid in [92, 10]:
            if self.is_changed:
                contextMenu(funcs=[(tr(32622),
                                    self.sel_cancel), (tr(32623),
                                                       self.sel_save)])
            else:
                self.close()

        self.dyn_step.dynamic_step(buc)

        if aid in [3, 104]:
            ctl = self.getControl(self.controlId)
            new = ctl.getInt() + self.dyn_step.dynstep
            if ctl.getInt() < 50 and new > 50: new = 50
            pos = new
            if pos > 100: pos = 100
            ctl.setInt(pos, 0, 0, 100)

        if aid in [4, 105]:
            ctl = self.getControl(self.controlId)
            new = ctl.getInt() - self.dyn_step.dynstep
            if ctl.getInt() > 50 and new < 50: new = 50
            pos = new
            if pos < 0: pos = 0
            ctl.setInt(pos, 0, 0, 100)

        if aid in [3, 4, 104, 105, 106]:
            self.setFocusId(self.controlId)
            self.setFilter()

        self.last_key = t
Example #7
0
    def sel_delete_correction(self):
        corrections = SocketCom("server").call_func("get", "room_corrections")

        if not corrections: return

        nr = contextMenu(items=corrections)
        if nr is None: return

        del_correction = corrections[nr]
        # sure to delete
        if xbmcgui.Dialog().yesno(
                tr(32030) % del_correction,
                tr(32031) % del_correction) is True:
            SocketCom("server").call_func("remove", "room_correction",
                                          [del_correction])
        self.sel_correction()
Example #8
0
    def sel_delete_profile(self):
        profiles = SocketCom("server").call_func("get", "eq_profiles")

        if not profiles: return

        nr = contextMenu(items=profiles)
        if nr is None: return

        # sure to delete
        del_profile = profiles[nr]
        if xbmcgui.Dialog().yesno(
                tr(32018) % del_profile,
                tr(32019) % del_profile) is True:
            SocketCom("server").call_func("remove", "eq_profile",
                                          [del_profile])
        self.sel_profile()
Example #9
0
	def onAction( self, action ):
		try:
			aid = action.getId()
			fid = self.getFocusId()
			but = action.getButtonCode()

			log("action id {} button {:x}".format(aid,but))

			if aid == 0 and not self.success:
				self.keycount -= 1
				if self.keycount == 0:
					# no direction keyes pressed, maybe not supported device
					xbmcgui.Dialog().notification(tr(32753),tr(32754))
					self.end_gui_cancel()
					return

			if but == 0:
				if aid in [107,203]:
					return
				#mouse click
				if aid == 100 and self.check_end(self.index[fid]):
					return True

				xbmcgui.Dialog().notification(tr(32753),tr(32754))
				self.end_gui_cancel()
				return

			keycode = translate_keycode(but)

			if self.kmf.is_mapped(but):
				xbmcgui.Dialog().notification(tr(32755),self.format_key(but,keycode), time=700)

			log("translated keycode {}".format(str(keycode)))

			if keycode and keycode["mods"]==[]:
				self.kmf.unlock()

				if self.navigate(keycode["keyname"]["name"],fid):
					return
			try:
				if self.index[fid] not in ["CANCEL","SAVE"]:
					self.set_key(fid, but, self.format_key(but,keycode))

			except KeyError: pass
		except Exception as e:
			handle(e)
			self.end_gui_cancel()
Example #10
0
 def sel_new_profile(self):
     # Name for new Profile
     profile = xbmcgui.Dialog().input(tr(32017))
     if profile != '':
         SocketCom("server").call_func("save", "eq_profile", [profile])
         SocketCom("server").call_func("load", "eq_profile",
                                       [self.eqid, profile])
     self.sel_profile()
Example #11
0
 def onInit(self):
     self.header = self.getControl(100)
     self.header.setLabel(tr(32022))
     self.slider = self.getControl(1900)
     self.label = self.getControl(2000)
     self.setFocus(self.slider)
     latency = int(self.latency_info["latency"] / 1000)
     self.slider.setInt(latency, 0, 25, 2000)
     self.label.setLabel("{:d} ms".format(latency))
Example #12
0
	def get_butlab_info(cls, keystruct,ginfo):
		key = keystruct["key"]
		return {
			"bid":ginfo.cid,
			"lid":ginfo.cid + 0x100,
			"btop":ginfo.top,
			"bheight":ginfo.height,
			"align":"left",
			"lbutton":tr(keystruct["name"]),
			"llable":cls.format_key(key, translate_keycode(key), True)
			}
Example #13
0
 def sel_main_menu(self):
     contextMenu(funcs=[(tr(32006),
                         self.sel_profile), (tr(32007), self.sel_equalizer),
                        (tr(32008),
                         self.sel_device), (tr(32027), self.sel_correction),
                        (tr(32010),
                         self.sel_latency), (
                             tr(32036),
                             self.sel_sysvol), (tr(32750),
                                                self.sel_keymap)])
Example #14
0
    def check_func_available(self):
        self.current = SocketCom("server").call_func("get", "eq_current")
        eqid, desc, is_playing, eq_profile, is_dyn = (self.current)

        if eqid == -1:
            # Dialog equalizer not installed
            xbmcgui.Dialog().ok(tr(32004), tr(32035))
            return False, eqid, desc, is_playing, eq_profile, is_dyn

        if is_playing and eq_profile == 'off' and is_dyn:
            # Dialog switch on?
            if not xbmcgui.Dialog().yesno(tr(32000), tr(32003)):
                return False, eqid, desc, is_playing, eq_profile, is_dyn
            else:
                SocketCom("server").call_func("switch", "eq_on")

                count = 10
                while count > 0:
                    count = count - 1
                    self.current = SocketCom("server").call_func(
                        "get", "eq_current")
                    eqid, desc, is_playing, eq_profile, is_dyn = (self.current)
                    if eqid is not None:
                        return True, eqid, desc, is_playing, eq_profile, is_dyn
                    sleep(0.1)
            # Dialog problem switch on
            xbmcgui.Dialog().ok(tr(32004), tr(32005))
            return False, eqid, desc, is_playing, eq_profile, is_dyn
        # all ok
        return True, eqid, desc, is_playing, eq_profile, is_dyn
Example #15
0
    def sel_correction(self):
        func_available, eqid, _, _, _, _ = self.check_func_available()
        if not func_available: return

        corrections = SocketCom("server").call_func("get", "room_corrections")
        correction = SocketCom("server").call_func("get", "room_correction")
        if correction is None: correction = tr(32411)

        corrections = [tr(32411)] + corrections

        funcs = [(tr(32033), self.sel_import_correction),
                 (tr(32028), self.sel_delete_correction),
                 (tr(32032), self.sel_playsweep)]

        sel = contextMenu(items=corrections, default=correction, funcs=funcs)

        if sel is None: return
        if sel == 0:
            SocketCom("server").call_func("unset", "room_correction", [eqid])
            return

        SocketCom("server").call_func("set", "room_correction",
                                      [eqid, corrections[sel]])
Example #16
0
	def format_key(but,keycode, xml=False):
		if but == 0: return "-"
		if keycode and  keycode["keyname"]:
			if keycode["mods"]:
				app = "[{}]".format("".join(x[0] for x in keycode["mods"]))
			else:
				app = ""

			if "char" in keycode["keyname"]:
				kn = keycode["keyname"]["char"]

				if xml:
					try: kn = "$NUMBER[{}]".format(int(kn))
					except ValueError: pass

			elif "tr" in keycode["keyname"]:
				kn = tr(keycode["keyname"]["tr"])
			else:
				kn = keycode["keyname"]["name"]

			return "{} {}".format(app,kn)
		else:
			return "key {}".format(but)
Example #17
0
	def build_dialog(self,**kwargs):
		color = kwargs["color"]
		file_s = kwargs["file_s"]

		header_t, pageformat_t,	group_t, button_t, label_t,	groupclose_t, close_t = get_template(
								file_s,
								["<!-- page format -->",
								"<!-- group template -->",
								"<!-- button template -->",
								"<!-- label template -->",
								"<!-- label template end -->",
								"<!-- group template end -->"]
								)

		butlab_t = button_t + label_t
		groups = parse_xml(pageformat_t)["butgroup"][0]["items"]

		self.kmf = KeyMapFile()
		self.kmf.parse_keymap_file()

		self.index = {}
		self.maxy = []

		final_txt = ""
		glob = {}

		id_iter = iter([0x1000,0x2000, 0x3000])

		for group in groups:
			ginfo = self.group_var(group)
			ginfo.cid = next(id_iter)
			ginfo.top = 0

			group_txt = ""
			# bulid button list
			for item in ginfo.items:
				if item == "GAP":
					ginfo.top += ginfo.gap
					continue

				self.index[ginfo.cid]=item
				keystruct = self.kmf.get_info(item)
				butinfo = self.get_butlab_info(keystruct,ginfo)

				group_txt = group_txt + butlab_t.format(**butinfo,**color)

				ginfo.top += ginfo.height
				ginfo.cid += 1

			ginfo.top += ginfo.height

			#append SAVE, CANCEL
			if ginfo.cid & 0xF000 in [0x1000,0x2000]:
				ipos = ginfo.cid >> 12
				if ipos == 1:
					glob["default"] = ginfo.cid
					glob["gtop"] = (1080 - (ginfo.top + ginfo.height)) / 2
					self.cancel = ginfo.cid

				self.index[ginfo.cid]=["CANCEL","SAVE"][ipos-1]

				butinfo = {
					"bid":ginfo.cid,
					"btop":ginfo.top,
					"bheight":ginfo.height,
					"align":"center",
					"lbutton":[tr(32752),tr(32751)][ipos-1]
					}
				ginfo.cid += 1

				group_txt = group_txt + button_t.format(**butinfo,**color)

			#build final group string
			final_txt = final_txt + group_t.format(gleft = ginfo.left) + group_txt + groupclose_t

			self.maxy.append((ginfo.cid & 0xFF) - 1)

		write_dialog(file_s,
				localize(header_t.format(**glob, **color)) +
				final_txt +
				close_t
				)