def layoutFinished(self): sf = getSkinFactor() font = gFont("Console", int(16 * sf)) if not int(fontRenderClass.getInstance().getLineHeight(font)): font = gFont("Regular", int(16 * sf)) self["list"].instance.setFont(font) fontwidth = getTextBoundarySize(self.instance, font, self["list"].instance.size(), _(" ")).width() listwidth = int(self["list"].instance.size().width() / fontwidth) - 2 if path.exists(self.logfile): for line in file(self.logfile).readlines(): line = line.replace('\t', ' ' * 9) if len(line) > listwidth: pos = 0 offset = 0 readyline = True while readyline: a = " " * offset + line[pos:pos + listwidth - offset] self.log.append(a) if len(line[pos + listwidth - offset:]): pos += listwidth - offset offset = 19 else: readyline = False else: self.log.append(line) else: self.log = [_("file can not displayed - file not found")] self["list"].setList(self.log)
def __init__(self, sublist, enableWrapAround=True): MenuList.__init__(self, sublist, enableWrapAround, eListboxPythonMultiContent) sf = getSkinFactor() self.l.setFont(0, gFont("Regular", int(20 * sf))) self.l.setFont(1, gFont("Regular", int(16 * sf))) self.l.setItemHeight(int(50 * sf))
def QuickMenuEntryComponent(name, description, long_description=None, width=540): pngname = name.replace(" ", "_") png = LoadPixmap( "/usr/lib/enigma2/python/Plugins/Extensions/Infopanel/icons/" + pngname + ".png") if png is None: png = LoadPixmap( "/usr/lib/enigma2/python/Plugins/Extensions/Infopanel/icons/default.png" ) sf = getSkinFactor() return [ _(name), MultiContentEntryText(pos=(60 * sf, 2 * sf), size=((width - 60) * sf, 28 * sf), font=0, text=_(name)), MultiContentEntryText(pos=(60 * sf, 25 * sf), size=((width - 60) * sf, 22 * sf), font=1, text=_(description)), MultiContentEntryPixmapAlphaBlend(pos=(10 * sf, 5 * sf), size=(40 * sf, 40 * sf), flags=BT_SCALE, png=png), MultiContentEntryText(pos=(0, 0), size=(0, 0), font=0, text=_(long_description)) ]
def LoadPixmap(path, desktop=None, cached=None, width=0, height=0): if path[-4:] == ".png": # cache unless caller explicity requests to not cache ptr = loadPNG(path, 0, 0 if cached is False else 1) elif path[-4:] == ".jpg": # don't cache unless caller explicity requests caching ptr = loadJPG(path, 1 if cached is True else 0) elif path[-4:] == ".svg": from skin import parameters, getSkinFactor # imported here to avoid circular import autoscale = int(parameters.get( "AutoscaleSVG", -1)) # skin_default only == -1, disabled == 0 or enabled == 1 scale = height == 0 and (autoscale == -1 and "/skin_default/" in path or autoscale == 1) and getSkinFactor() or 0 ptr = loadSVG(path, 0 if cached is False else 1, width, height, scale) elif path[-1:] == ".": # caching mechanism isn't suitable for multi file images, so it's explicitly disabled alpha = loadPNG(path + "a.png", 0, 0) ptr = loadJPG(path + "rgb.jpg", alpha, 0) else: raise Exception( "Neither .png nor .jpg nor .svg, please fix file extension") if ptr and desktop: desktop.makeCompatiblePixmap(ptr) return ptr
def __init__(self, session, services = None): Screen.__init__(self, session) config.plugins.configurationbackup=BackupRestore_InitConfig() if config.ParentalControl.configured.value: ProtectedScreen.__init__(self) self.session = session self.skin = MENU_SKIN self.onShown.append(self.setWindowTitle) ProtectedScreen.__init__(self) self.service = None global pluginlist global videomode global infook global INFOCONF global menu INFOCONF = 0 pluginlist="False" try: print '[INFO-Panel] SHOW' global inINFOPanel inINFOPanel = self except: print '[INFO-Panel] Error Hide' # global servicelist if services is not None: self.servicelist = services else: self.servicelist = None self.list = [] #// get the remote buttons self["actions"] = ActionMap(["OkCancelActions", "DirectionActions", "ColorActions"], { "cancel": self.Exit, "upUp": self.up, "downUp": self.down, "ok": self.ok, }, 1) self["label1"] = Label(INFO_Panel_Version) self["summary_description"] = StaticText("") self.Mlist = [] if Check_Softcam(): self.Mlist.append(MenuEntryItem((InfoEntryComponent('SoftcamPanel'), _("SoftcamPanel"), 'SoftcamPanel'))) self.Mlist.append(MenuEntryItem((InfoEntryComponent('SoftcamPanelSetup'), _("Softcam-Panel Setup"), 'Softcam-Panel Setup'))) if Check_SysSoftcam() is "oscam": self.Mlist.append(MenuEntryItem((InfoEntryComponent('OScamInfo'), _("OScamInfo"), 'OScamInfo'))) #self.Mlist.append(MenuEntryItem((InfoEntryComponent ("SoftwareManager" ), _("Software update"), ("software-update")))) self.Mlist.append(MenuEntryItem((InfoEntryComponent ("SoftwareManager" ), _("Software Manager"), ("software-manager")))) self.Mlist.append(MenuEntryItem((InfoEntryComponent('KeymapSel'), _("Keymap Selection"), 'KeymapSel'))) self.Mlist.append(MenuEntryItem((InfoEntryComponent('Plugins'), _("Plugins"), 'Plugins'))) self.Mlist.append(MenuEntryItem((InfoEntryComponent('Infos'), _("Infos"), 'Infos'))) self.onChangedEntry = [] if getSkinFactor() == 1: self["Mlist"] = PanelList([]) else: self["Mlist"] = PanelList([], font0=24, font1=15, itemHeight=50) self["Mlist"].l.setList(self.Mlist) menu = 0 self["Mlist"].onSelectionChanged.append(self.selectionChanged)
def QuickSubMenuEntryComponent(name, description, long_description = None, width=540): sf = getSkinFactor() return [ _(name), MultiContentEntryText(pos=(10*sf, 2*sf), size=((width-10)*sf, 28*sf), font=0, text = _(name)), MultiContentEntryText(pos=(10*sf, 25*sf), size=((width-10)*sf, 22*sf), font=1, text = _(description)), MultiContentEntryText(pos=(0, 0), size=(0, 0), font=0, text = _(long_description)) ]
def editLine(self): try: self.findtab = -1 length = 95 self.selLine = self["filedata"].getSelectionIndex() self.oldLine = self.list[self.selLine] my_editableText = self.list[self.selLine][:-1] editableText = my_editableText.partition(": ")[2] # os.system('echo %s %s >> /tmp/test.log' % ("oldline_a :", str(len(editableText)))) if len(editableText) == 0: editableText = "" # self.list[self.selLine][:-1] self.findtab = editableText.find("\t", 0, len(editableText)) if self.findtab != -1: editableText = editableText.replace("\t", " ") firstpos_end = config.plugins.filecommander.editposition_lineend.value if 'MetrixHD/' in config.skin.primary_skin.value: # screen: ... size="1140,30" font="screen_text; 20" # font: ... <alias name="FileList" font="screen_text" size="20" height="30" /> font = skin.fonts.get("FileList", ("Regular", 20, 30)) fieldwidth = int(1140 * skin.getSkinFactor()) #fhd? length = 1 if firstpos_end: while getTextBoundarySize( self.instance, gFont(font[0], font[1]), eSize(fieldwidth, font[2]), editableText[len(editableText) - length:], True).width() <= fieldwidth: length += 1 if length > len(editableText): break else: while getTextBoundarySize( self.instance, gFont(font[0], font[1]), eSize(fieldwidth, font[2]), editableText.replace(' ', '')[:length], True).width() <= fieldwidth: length += 1 if length > len(editableText): break length -= 1 self.session.openWithCallback( self.callbackEditLine, InputBoxWide, title=_(_("original") + ": " + editableText), visible_width=length, overwrite=False, firstpos_end=firstpos_end, allmarked=False, windowTitle=_("Edit line ") + str(self.selLine + 1), text=editableText) except: msg = self.session.open(MessageBox, _("This line is not editable!"), MessageBox.TYPE_ERROR) msg.setTitle(_("Error..."))
def __init__(self, list, font0=24, font1=16, itemHeight=50, enableWrapAround=True): MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent) sf = getSkinFactor() self.l.setFont(0, gFont("Regular", int(font0 * sf))) self.l.setFont(1, gFont("Regular", int(font1 * sf))) self.l.setItemHeight(int(itemHeight * sf))
def MenuEntryItem(entry): res = [entry] sf = getSkinFactor() res.append( MultiContentEntryPixmapAlphaBlend(pos=(10 * sf, 5 * sf), size=(40 * sf, 40 * sf), flags=BT_SCALE, png=entry[0])) # png vorn res.append( MultiContentEntryText(pos=(60 * sf, 10 * sf), size=(540 * sf, 40 * sf), font=0, text=entry[1])) # menupunkt return res
def __init__(self, root, sort_type=None, descr_state=None): GUIComponent.__init__(self) self.list = [] self.descr_state = descr_state or self.HIDE_DESCRIPTION self.sort_type = sort_type or self.SORT_GROUPWISE self.firstFileEntry = 0 self.parentDirectory = 0 self.fontName = "Regular" if skin.getSkinFactor() == 1.5: self.fontSize = 28 else: self.fontSize = 20 self.listHeight = None self.listWidth = None self.reloadDelayTimer = None self.l = eListboxPythonMultiContent() self.tags = set() self.root = None self._playInBackground = None self._playInForeground = None self._char = '' if root is not None: self.reload(root) self.l.setBuildFunc(self.buildMovieListEntry) self.onSelectionChanged = [] self.iconPart = [] for part in list(range(5)): self.iconPart.append( LoadPixmap( resolveFilename(SCOPE_ACTIVE_SKIN, "icons/part_%d_4.png" % part))) self.iconMovieRec = LoadPixmap( resolveFilename(SCOPE_ACTIVE_SKIN, "icons/part_new.png")) self.iconMoviePlay = LoadPixmap( resolveFilename(SCOPE_ACTIVE_SKIN, "icons/movie_play.png")) self.iconMoviePlayRec = LoadPixmap( resolveFilename(SCOPE_ACTIVE_SKIN, "icons/movie_play_rec.png")) self.iconUnwatched = LoadPixmap( resolveFilename(SCOPE_ACTIVE_SKIN, "icons/part_unwatched.png")) self.iconFolder = LoadPixmap( resolveFilename(SCOPE_ACTIVE_SKIN, "icons/folder.png")) self.iconTrash = LoadPixmap( resolveFilename(SCOPE_ACTIVE_SKIN, "icons/trashcan.png")) self.runningTimers = {} self.updateRecordings() self.updatePlayPosCache()
def __init__(self, args): StringList.__init__(self, args) from enigma import BT_SCALE, RT_HALIGN_CENTER, RT_HALIGN_LEFT, RT_HALIGN_RIGHT, RT_VALIGN_BOTTOM, RT_VALIGN_CENTER, RT_VALIGN_TOP, RT_WRAP, eListboxPythonMultiContent, gFont from skin import parseFont, getSkinFactor from Components.MultiContent import MultiContentEntryPixmap, MultiContentEntryPixmapAlphaBlend, MultiContentEntryPixmapAlphaTest, MultiContentEntryProgress, MultiContentEntryProgressPixmap, MultiContentEntryText, MultiContentTemplateColor f = getSkinFactor() loc = locals() del loc["self"] # Cleanup locals a bit. del loc["args"] self.active_style = None self.template = eval(args, {}, loc) assert "fonts" in self.template assert "itemHeight" in self.template assert "template" in self.template or "templates" in self.template assert "template" in self.template or "default" in self.template["templates"] # We need to have a default template. if "template" not in self.template: # Default template can be ["template"] or ["templates"]["default"]. self.template["template"] = self.template["templates"]["default"][1] self.template["itemHeight"] = self.template["template"][0]
def buildMovieListEntry(self, serviceref, info, begin, data): switch = config.usage.show_icons_in_movielist.value ext = config.movielist.useextlist.value width = self.l.getItemSize().width() pathName = serviceref.getPath() res = [None] if ext != '0': ih = self.itemHeight // 2 else: ih = self.itemHeight if skin.getSkinFactor() == 1.5: listBeginX = 3 listEndX = 3 listMarginX = 12 pathIconSize = 29 dataIconSize = 25 progressIconSize = 25 progressBarSize = 72 textPosY = 2 else: listBeginX = 2 listEndX = 2 listMarginX = 8 pathIconSize = 25 dataIconSize = 21 progressIconSize = 21 progressBarSize = 48 textPosY = 1 textPosX = listBeginX + dataIconSize + listMarginX if serviceref.flags & eServiceReference.mustDescent: # Directory iconSize = pathIconSize iconPosX = listBeginX - 1 iconPosY = ih / 2 - iconSize / 2 if iconPosY < iconPosX: iconPosY = iconPosX # Name is full path name if info is None: # Special case: "parent" txt = ".." else: p = os.path.split(pathName) if not p[1]: # if path ends in '/', p is blank. p = os.path.split(p[0]) txt = p[1] if txt == ".Trash": dateSize = getTextBoundarySize(self.instance, self.dateFont, self.l.getItemSize(), _("Trashcan")).width() res.append( MultiContentEntryPixmapAlphaBlend(pos=(iconPosX, iconPosY), size=(iconSize, iconSize), png=self.iconTrash)) res.append( MultiContentEntryText( pos=(textPosX, 0), size=(width - textPosX - dateSize - listMarginX - listEndX, ih), font=0, flags=RT_HALIGN_LEFT | RT_VALIGN_CENTER, text=_("Deleted items"))) res.append( MultiContentEntryText( pos=(width - dateSize - listEndX, textPosY), size=(dateSize, self.itemHeight), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=_("Trashcan"))) return res dateSize = getTextBoundarySize(self.instance, self.dateFont, self.l.getItemSize(), _("Directory")).width() res.append( MultiContentEntryPixmapAlphaBlend(pos=(iconPosX, iconPosY), size=(iconSize, iconSize), png=self.iconFolder)) res.append( MultiContentEntryText(pos=(textPosX, 0), size=(width - textPosX - dateSize - listMarginX - listEndX, ih), font=0, flags=RT_HALIGN_LEFT | RT_VALIGN_CENTER, text=txt)) res.append( MultiContentEntryText(pos=(width - dateSize - listEndX, textPosY), size=(dateSize, self.itemHeight), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=_("Directory"))) return res if (data == -1) or (data is None): data = MovieListData() cur_idx = self.l.getCurrentSelectionIndex() x = self.list[cur_idx] # x = ref,info,begin,... data.len = 0 #dont recalc movielist to speedup loading the list self.list[cur_idx] = ( x[0], x[1], x[2], data ) #update entry in list... so next time we don't need to recalc data.txt = info.getName(serviceref) if config.movielist.hide_extensions.value: fileName, fileExtension = os.path.splitext(data.txt) if fileExtension in KNOWN_EXTENSIONS: data.txt = fileName data.icon = None data.part = None if os.path.split(pathName)[1] in self.runningTimers: if switch == 'i': if (self.playInBackground or self.playInForeground ) and serviceref == (self.playInBackground or self.playInForeground): data.icon = self.iconMoviePlayRec else: data.icon = self.iconMovieRec elif switch == 'p' or switch == 's': data.part = 100 if (self.playInBackground or self.playInForeground ) and serviceref == (self.playInBackground or self.playInForeground): data.partcol = 0xffc71d else: data.partcol = 0xff001d elif (self.playInBackground or self.playInForeground) and serviceref == ( self.playInBackground or self.playInForeground): data.icon = self.iconMoviePlay else: data.part = moviePlayState(pathName + '.cuts', serviceref, data.len) if switch == 'i': if data.part is not None and data.part > 0: data.icon = self.iconPart[data.part // 25] else: if config.usage.movielist_unseen.value: data.icon = self.iconUnwatched elif switch == 'p' or switch == 's': if data.part is not None and data.part > 0: data.partcol = 0xffc71d else: if config.usage.movielist_unseen.value: data.part = 100 data.partcol = 0x206333 len = data.len if len > 0: len = "%d:%02d" % (len // 60, len % 60) else: len = "" iconSize = 0 if switch == 'i': iconSize = dataIconSize iconPosX = listBeginX iconPosY = ih // 2 - iconSize // 2 if iconPosY < iconPosX: iconPosY = iconPosX res.append( MultiContentEntryPixmapAlphaBlend(pos=(iconPosX, iconPosY), size=(iconSize, iconSize), png=data.icon)) elif switch == 'p': if data.part is not None and data.part > 0: iconSize = progressBarSize iconPosX = listBeginX iconPosY = ih // 2 - iconSize // 8 if iconPosY < iconPosX: iconPosY = iconPosX res.append( MultiContentEntryProgress(pos=(iconPosX, iconPosY), size=(iconSize, iconSize // 4), percent=data.part, borderWidth=2, foreColor=data.partcol, foreColorSelected=None, backColor=None, backColorSelected=None)) else: iconSize = dataIconSize iconPosX = listBeginX iconPosY = ih // 2 - iconSize // 2 if iconPosY < iconPosX: iconPosY = iconPosX res.append( MultiContentEntryPixmapAlphaBlend(pos=(iconPosX, iconPosY), size=(iconSize, iconSize), png=data.icon)) elif switch == 's': iconSize = progressIconSize iconPosX = listBeginX iconPosY = ih // 2 - iconSize // 2 if iconPosY < iconPosX: iconPosY = iconPosX if data.part is not None and data.part > 0: res.append( MultiContentEntryProgress(pos=(iconPosX, iconPosY), size=(iconSize, iconSize), percent=data.part, borderWidth=2, foreColor=data.partcol, foreColorSelected=None, backColor=None, backColorSelected=None)) else: res.append( MultiContentEntryPixmapAlphaBlend(pos=(iconPosX, iconPosY), size=(iconSize, iconSize), png=data.icon)) begin_string = "" if begin > 0: begin_string = ', '.join(FuzzyTime(begin, inPast=True)) dateSize = serviceSize = getTextBoundarySize(self.instance, self.dateFont, self.l.getItemSize(), begin_string).width() if iconSize: textPosX = listBeginX + iconSize + listMarginX else: textPosX = listBeginX if ext != '0': getrec = info.getName(serviceref) fileName, fileExtension = os.path.splitext(getrec) desc = None picon = None service = None try: serviceHandler = eServiceCenter.getInstance() info = serviceHandler.info(serviceref) desc = info.getInfoString( serviceref, iServiceInformation.sDescription) # get description ref = info.getInfoString( serviceref, iServiceInformation.sServiceref) # get reference service = ServiceReference( ref).getServiceName() # get service name serviceSize = getTextBoundarySize(self.instance, self.dateFont, self.l.getItemSize(), service).width() except Exception as e: print(('[MovieList] load extended infos get failed: ', e)) if ext == '2': try: picon = getPiconName(ref) picon = loadPNG(picon) except Exception as e: print(('[MovieList] load picon get failed: ', e)) if fileExtension in RECORD_EXTENSIONS: if ext == '1': res.append( MultiContentEntryText( pos=(textPosX, 0), size=(width - textPosX - serviceSize - listMarginX - listEndX, ih), font=0, flags=RT_HALIGN_LEFT | RT_VALIGN_CENTER, text=data.txt)) res.append( MultiContentEntryText( pos=(width - serviceSize - listEndX, textPosY), size=(serviceSize, ih), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=service)) if ext == '2': piconSize = ih * 1.667 res.append( MultiContentEntryText( pos=(textPosX, 0), size=(width - textPosX - dateSize - listMarginX - listEndX, ih), font=0, flags=RT_HALIGN_LEFT | RT_VALIGN_CENTER, text=data.txt)) res.append( MultiContentEntryPixmapAlphaBlend( pos=(width - piconSize - listEndX, listEndX), size=(piconSize, ih), png=picon, flags=BT_SCALE | BT_KEEP_ASPECT_RATIO)) res.append( MultiContentEntryText(pos=(listBeginX, ih + textPosY), size=(width - listBeginX - dateSize - listMarginX - listEndX, ih), font=1, flags=RT_HALIGN_LEFT, text=desc)) res.append( MultiContentEntryText(pos=(width - dateSize - listEndX, ih + textPosY), size=(dateSize, ih), font=1, flags=RT_HALIGN_RIGHT, text=begin_string)) return res else: res.append( MultiContentEntryText(pos=(textPosX, 0), size=(width - textPosX - dateSize - listMarginX - listEndX, ih), font=0, flags=RT_HALIGN_LEFT | RT_VALIGN_CENTER, text=data.txt)) res.append( MultiContentEntryText(pos=(width - dateSize - listEndX, ih), size=(dateSize, ih), font=1, flags=RT_HALIGN_RIGHT, text=begin_string)) return res else: res.append( MultiContentEntryText(pos=(textPosX, 0), size=(width - textPosX - dateSize - listMarginX - listEndX, ih), font=0, flags=RT_HALIGN_LEFT | RT_VALIGN_CENTER, text=data.txt)) res.append( MultiContentEntryText(pos=(width - dateSize - listEndX, textPosY), size=(dateSize, ih), font=1, flags=RT_HALIGN_RIGHT | RT_VALIGN_CENTER, text=begin_string)) return res
from Tools.LoadPixmap import LoadPixmap from Tools.Directories import SCOPE_ACTIVE_SKIN, resolveFilename, fileExists from enigma import eTimer, RT_HALIGN_LEFT, eListboxPythonMultiContent, gFont, getDesktop, eSize, ePoint from xml.etree import ElementTree from operator import itemgetter import os import time import skin from six.moves import urllib from six.moves.urllib.request import HTTPHandler, HTTPDigestAuthHandler ###global sf = skin.getSkinFactor() sizeH = 700 HDSKIN = False screenwidth = getDesktop(0).size().width() if screenwidth and screenwidth == 1920: sizeH = screenwidth - 150 HDSKIN = True elif screenwidth and screenwidth > 1920: HDSKIN = True sizeH = screenwidth - 300 elif screenwidth and screenwidth > 1024: sizeH = screenwidth - 100 HDSKIN = False ###global