Skip to content

Commit

Permalink
Revert "Add quick subtitle toggle feature (OpenViX#490)"
Browse files Browse the repository at this point in the history
This reverts commit 2a406df.
  • Loading branch information
AbuBaniaz authored and prl committed Jul 6, 2020
1 parent 9f4c553 commit 7e593ab
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 89 deletions.
5 changes: 1 addition & 4 deletions data/keymap.xml
Expand Up @@ -315,8 +315,7 @@
</map>

<map context="InfobarSubtitleSelectionActions">
<key id="KEY_SUBTITLE" mapto="subtitleSelection" flags="b"/>
<key id="KEY_SUBTITLE" mapto="toggleDefaultSubtitles" flags="l"/>
<key id="KEY_SUBTITLE" mapto="subtitleSelection" flags="m"/>
</map>

<map context="InfobarSubserviceSelectionActions">
Expand Down Expand Up @@ -967,7 +966,6 @@
<key id="KEY_HELP" mapto="displayHelp" flags="b"/>
<key id="KEY_HELP" mapto="displayHelp_long" flags="l"/>
<key id="KEY_SUBTITLE" mapto="subtitle" flags="b"/>
<key id="KEY_SUBTITLE" mapto="subtitle_long" flags="l"/>
<key id="KEY_MENU" mapto="mainMenu" flags="b"/>
<key id="KEY_INFO" mapto="info" flags="b"/>
<key id="KEY_INFO" mapto="info_long" flags="l"/>
Expand Down Expand Up @@ -997,7 +995,6 @@
<key id="KEY_PREVIOUSSONG" mapto="rewind" flags="b"/>
<key id="KEY_NEXTSONG" mapto="fastforward" flags="b"/>
<key id="KEY_SCREEN" mapto="activatePiP" flags="b"/>
<key id="KEY_SCREEN" mapto="activatePiP_long" flags="l"/>
<key id="KEY_PROGRAM" mapto="timer" flags="b"/>
<key id="KEY_PLAYPAUSE" mapto="playpause" flags="m"/>
<key id="KEY_LIST" mapto="playlist" flags="b"/>
Expand Down
3 changes: 0 additions & 3 deletions lib/python/Screens/ButtonSetup.py
Expand Up @@ -42,7 +42,6 @@
(_("Help"), "displayHelp", ""),
(_("Help long"), "displayHelp_long", ""),
(_("Subtitle"), "subtitle", ""),
(_("Subtitle Long"), "subtitle_long", ""),
(_("Menu"), "mainMenu", ""),
(_("List/Fav/PVR"), "list", ""),
(_("List/Fav/PVR") + " " + _("long"), "list_long", ""),
Expand All @@ -62,7 +61,6 @@
(_("Skip back"), "skip_back", ""),
(_("Skip forward"), "skip_forward", ""),
(_("activatePiP"), "activatePiP", ""),
(_("activatePiP long"), "activatePiP_long", ""),
(_("Timer"), "timer", ""),
(_("Playlist"), "playlist", ""),
(_("Timeshift"), "timeshift", ""),
Expand Down Expand Up @@ -129,7 +127,6 @@ def getButtonSetupFunctions():
ButtonSetupFunctions.append((_("Show multi EPG"), "Infobar/openMultiServiceEPG", "EPG"))
ButtonSetupFunctions.append((_("Show select audio track"), "Infobar/audioSelection", "InfoBar"))
ButtonSetupFunctions.append((_("Show subtitle selection"), "Infobar/subtitleSelection", "InfoBar"))
ButtonSetupFunctions.append((_("Toggle default subtitles"), "Infobar/toggleDefaultSubtitles", "InfoBar"))
ButtonSetupFunctions.append((_("Switch to radio mode"), "Infobar/showRadio", "InfoBar"))
ButtonSetupFunctions.append((_("Switch to TV mode"), "Infobar/showTv", "InfoBar"))
ButtonSetupFunctions.append((_("Instant record"), "Infobar/instantRecord", "InfoBar"))
Expand Down
33 changes: 9 additions & 24 deletions lib/python/Screens/InfoBarGenerics.py
Expand Up @@ -4027,7 +4027,6 @@ def __init__(self):
self["SubtitleSelectionAction"] = HelpableActionMap(self, "InfobarSubtitleSelectionActions",
{
"subtitleSelection": (self.subtitleSelection, _("Subtitle selection...")),
"toggleDefaultSubtitles": (self.toggleDefaultSubtitles, _("Toggle the default subtitles"))
})

self.selected_subtitle = None
Expand Down Expand Up @@ -4088,31 +4087,17 @@ def __updatedInfo(self):
self.enableSubtitle(cachedsubtitle)
self.doCenterDVBSubs()

def toggleDefaultSubtitles(self):
def enableSubtitle(self, selectedSubtitle):
subtitle = self.getCurrentServiceSubtitle()
subtitlelist = subtitle and subtitle.getSubtitleList()
if subtitlelist is None or len(subtitlelist) == 0:
self.subtitle_window.showMessage(_("No subtitles available"), True)
elif self.selected_subtitle:
self.enableSubtitle(None)
self.subtitle_window.showMessage(_("Subtitles off"), True)
self.selected_subtitle = None
self.selected_subtitle = selectedSubtitle
if subtitle and self.selected_subtitle:
subtitle.enableSubtitles(self.subtitle_window.instance, self.selected_subtitle)
self.subtitle_window.show()
self.doCenterDVBSubs()
else:
self.enableSubtitle(subtitlelist[0])
self.subtitle_window.showMessage(_("Subtitles on"), False)

def enableSubtitle(self, newSubtitle):
if self.selected_subtitle != newSubtitle:
subtitle = self.getCurrentServiceSubtitle()
self.selected_subtitle = newSubtitle
if subtitle and newSubtitle:
subtitle.enableSubtitles(self.subtitle_window.instance, newSubtitle)
self.subtitle_window.show()
self.doCenterDVBSubs()
else:
if subtitle:
subtitle.disableSubtitles(self.subtitle_window.instance)
self.subtitle_window.hide()
if subtitle:
subtitle.disableSubtitles(self.subtitle_window.instance)
self.subtitle_window.hide()

def restartSubtitle(self):
if self.selected_subtitle:
Expand Down
60 changes: 2 additions & 58 deletions lib/python/Screens/SubtitleDisplay.py
@@ -1,62 +1,6 @@
from Screens.Screen import Screen
from Components.Label import Label
from enigma import eTimer, getDesktop, eActionMap, gFont
from Components.ActionMap import ActionMap
from sys import maxint
import skin

class SubtitleDisplay(Screen):
def __init__(self, session):
Screen.__init__(self, session)
eActionMap.getInstance().bindAction('', -maxint - 1, self.keypress)
pass

self.messageShown = False
self['message'] = Label()
self['message'].hide()

if self.layoutFinished not in self.onLayoutFinish:
self.onLayoutFinish.append(self.layoutFinished)

def __removeAction(self):
eActionMap.getInstance().unbindAction('', self.keypress)

def layoutFinished(self):
# Not expecting skins to contain this element
label = self['message']
label.instance.setFont(gFont("Regular", 50))
label.instance.setZPosition(1)
label.instance.setNoWrap(1)
label.instance.setHAlign(1)
label.instance.setVAlign(1)

def showMessage(self, message, hideScreen):
padding = (40,10)
label = self['message']
label.setText(message)
size = label.getSize()
label.resize(size[0]+padding[0]*2, size[1]+padding[1]*2)
label.move((getDesktop(0).size().width()-size[0]-padding[0]) // 2, getDesktop(0).size().height()-size[1]-padding[1]*2-30)
label.show()
self.messageShown = True
self.show()
self.hideTimer = eTimer()
self.hideTimer.callback.append(self.hideScreen if hideScreen else self.hideMessage)
self.hideTimer.start(2000, True)

def keypress(self, key, flag):
# Releasing the subtitle button after a long press unintentionally pops up the subtitle dialog,
# This blocks it without causing issues for anyone that sets the buttons up the other way round
if self.messageShown:
# whilst the notification is shown any keydown event dismisses the notification
if flag == 0:
self.hideMessage()
else: # any key repeat or keyup event is discarded
return 1

def hideMessage(self):
self.messageShown = False
self['message'].hide()

def hideScreen(self):
self.hideMessage()
self.hide()
# not really much to do...

0 comments on commit 7e593ab

Please sign in to comment.