def __init__(self): DBG('Init module') self.grab_key_func = None # set up default bindings section = 'keyboard' if not ini.has_section(section): ini.add_section(section) defs = EmcGui.instance().default_keymap_get() for key, event in defs.items(): ini.set(section, key, event) # read mapping from config self.keys = dict() for key, event in ini.get_options(section): DBG('Map key "%s" to event %s' % (key, event)) self.keys[key] = event # add an entry in the config gui section config_gui.root_item_add('keyb', 50, _('Keyboard'), icon='icon/keyboard', callback=self.config_panel_cb) # ask the gui to forward key events to us EmcGui.instance().key_down_connect(self._key_down_cb)
def page_add(self, url, title, styles, populate_cb, *args, **kwargs): """ When you create a page you need to give at least the url, the title and the populate callback. Every other arguments will be passed back in the callback. style can be None to use the default page style, usually the plain list. Args: url: A unique string id for the page title: Readable text for the user styles: A tuple with all the style that the page can show. Available styles: 'List', 'PosterGrid', 'CoverGrid' If set to None it default to the default style given at the Browser instance creation. The first item is the default one. populate_cb: Function to call when the page need to be populated. Signature: func(browser, url, *args, **kwargs) """ # choose the style of the new page if styles is None: styles = (self.default_style, ) if _memorydb and _memorydb.id_exists(url): style = _memorydb.get_data(url) else: style = self._search_style_in_parent() if not style: style = styles[0] if ini.get_bool('general', 'ignore_views_restrictions') is False: if style not in styles: style = styles[0] # get the correct view instance view = self._create_or_get_view(style) # TODO REMOVE ME ?? # append the new page in the pages list page = { 'view': view, 'url': url, 'title': title, 'styles': styles, 'cb': populate_cb, 'args': args, 'kwargs': kwargs } self.pages.append(page) # first time, we don't have a current_view, set it if not self.current_view: self.current_view = view # TODO is this the correct place for this??? EmcGui.instance().model_set('browser', self._model) # TODO needed every time ?? # switch to the new page self._populate_page(page)
def _populate_page(self, page, is_back=False, is_refresh=False, is_unfreeze=False): full = ' > '.join([p['title'] for p in self.pages]) EmcGui.instance().page_title_set(full) # clear the items list self.items = [] view = page['view'] """ if view == self.current_view: # same style for the 2 pages, ask the view to perform the correct anim if is_refresh or is_unfreeze: view.page_show(page['title'], ANIM_NONE) elif is_back: view.page_show(page['title'], ANIM_BACK) elif len(self.pages) < 2: view.page_show(page['title'], ANIM_NONE) else: view.page_show(page['title'], ANIM_FORWARD) else: # different style...hide one view and show the other self.current_view.clear() self.current_view.hide() view.page_show(page['title'], ANIM_NONE) view.show() """ # update state self.current_view = view # back item (optional) if ini.get_bool('general', 'back_in_lists'): self.item_add(BackItemClass(), 'emc://back', self) # use this for extra debug # print(self) # populate the page calling the page user callback url = page['url'] cb = page['cb'] args = page['args'] kwargs = page['kwargs'] cb(self, url, *args, **kwargs) # tell the view that data has been resetted self._model.view_reset() self._model.select_item(0)
def volume_set(vol: float) -> None: """ Set linear volume. Float, always between 0 and 100 """ global _volume vol = utils.clamp(vol, 0, 100) vol = vol / 100.0 * ini.get_int('mediaplayer', 'volume_maximum') if vol == _volume: return _volume = vol EmcGui.instance().volume_set(vol) ini.set('mediaplayer', 'volume', _volume) # events.event_emit('VOLUME_CHANGED') if _player: _player.volume_set(volume_adjusted_get())
def __init__(self, *args, **kargs): super().__init__(*args, **kargs) print("INIT VIDEO PLAYER QT") self._gui = EmcGui.instance() self._audio_menu_model = AudioMenuModel() self._video_menu_model = VideoMenuModel() self._subs_menu_model = SubsMenuModel() self._gui.model_set('AudioMenuModel', self._audio_menu_model) self._gui.model_set('VideoMenuModel', self._video_menu_model) self._gui.model_set('SubsMenuModel', self._subs_menu_model) self._qml_obj = self._gui._qml_root.activate_section('videoplayer')
def __init__(self, *args, **kargs): super().__init__(*args, **kargs) print("INIT DIALOG QT") if self._style in self.list_styles: self._list_model = DialogListModel(self) else: self._list_model = None self._buttons = [] self._gui = EmcGui.instance() self._qml_obj = self._gui._qml_root.build_dialog( self._title, self._style, self._text, self._content, self._spinner, self._list_model) self._qml_obj.emcQuitRequested.connect(self._quit_requested_cb) # automatic buttons self._create_auto_buttons()
def __shutdown__(self): DBG('Shutdown module') config_gui.root_item_del('keyb') EmcGui.instance().key_down_connect(None)
def hide(self): """ TODO Function doc """ # input_events.listener_del('browser-' + self.name) EmcGui.instance().hide_section('browser')
def show(self): """ TODO Function doc """ EmcGui.instance().activate_section('browser') EmcGui.instance().page_icon_set(self.icon)
def hide(): # input_events.listener_del('mainmenu') EmcGui.instance().hide_section('mainmenu') raise DeprecationWarning('should not explicitly hide the menu')
def show(): EmcGui.instance().activate_section('mainmenu') # input_events.listener_add('mainmenu', input_event_cb) raise DeprecationWarning('should not explicitly show the menu')
def __init__(self, *args, **kargs): super().__init__(*args, **kargs) self._model = EmcGui.instance()._notify_model self._model.insert_item(self)