@@ -416,6 +416,8 @@ def enterUserbouquet(self, root, save_root=True):
416416 if self .bouquet_root :
417417 self .enterPath (self .bouquet_root )
418418 self .enterPath (root )
419+ if self .isSubservices (root ):
420+ self .enterSubservices ()
419421 self .startRoot = None
420422 if save_root :
421423 self .saveRoot ()
@@ -2578,7 +2580,7 @@ def togglePipzap(self):
25782580 self .showPipzapMessage ()
25792581 self .dopipzap = True
25802582 self .__evServiceStart ()
2581- # Move to service playing in pip (will not work with sub-services) .
2583+ # Move to service playing in pip.
25822584 self .setCurrentSelection (self .session .pip .getCurrentService ())
25832585 title = f"{ title } { _ ('(PiP)' )} "
25842586 self .setTitle (title )
@@ -2665,28 +2667,30 @@ def newServicePlayed(self):
26652667 return ret
26662668
26672669 def addToHistory (self , ref ):
2668- if not self .isSubservices () or not self .history :
2669- if self .delhistpoint is not None :
2670- x = self .delhistpoint
2671- while x <= len (self .history ) - 1 :
2670+ if self .history and self .isSubservices (self .history [self .history_pos ][0 ]) and self .isSubservices (self .servicePath [0 ]): # Only replace subservice
2671+ self .history [self .history_pos ] = self .servicePath [:] + [ref ]
2672+ return
2673+ if self .delhistpoint is not None :
2674+ x = self .delhistpoint
2675+ while x <= len (self .history ) - 1 :
2676+ del self .history [x ]
2677+ self .delhistpoint = None
2678+ if self .servicePath is not None :
2679+ tmp = self .servicePath [:]
2680+ tmp .append (ref )
2681+ self .history .append (tmp )
2682+ hlen = len (self .history )
2683+ x = 0
2684+ while x < hlen - 1 :
2685+ if self .history [x ][- 1 ] == ref and not self .isSubservices () or self .isSubservices (self .history [x ][0 ]):
26722686 del self .history [x ]
2673- self .delhistpoint = None
2674- if self .servicePath is not None :
2675- tmp = self .servicePath [:]
2676- tmp .append (ref )
2677- self .history .append (tmp )
2678- hlen = len (self .history )
2679- x = 0
2680- while x < hlen - 1 :
2681- if self .history [x ][- 1 ] == ref :
2682- del self .history [x ]
2683- hlen -= 1
2684- else :
2685- x += 1
2686- if hlen > HISTORY_SIZE :
2687- del self .history [0 ]
26882687 hlen -= 1
2689- self .history_pos = hlen - 1
2688+ else :
2689+ x += 1
2690+ if hlen > HISTORY_SIZE :
2691+ del self .history [0 ]
2692+ hlen -= 1
2693+ self .history_pos = hlen - 1
26902694
26912695 def historyBack (self ):
26922696 hlen = len (self .history )
@@ -2709,8 +2713,11 @@ def historyNext(self):
27092713 def setHistoryPath (self , doZap = True ):
27102714 path = self .history [self .history_pos ][:]
27112715 ref = path .pop ()
2712- del self .servicePath [:]
2713- self .servicePath += path
2716+ if self .isSubservices (path [0 ]):
2717+ self .enterSubservices (ref )
2718+ else :
2719+ del self .servicePath [:]
2720+ self .servicePath += path
27142721 self .saveRoot ()
27152722 root = path [- 1 ]
27162723 cur_root = self .getRoot ()
@@ -2754,7 +2761,7 @@ def historyMenuClosed(self, retval):
27542761 pos += 1
27552762 self .delhistpoint = pos + 1
27562763 if pos < hlen and pos != self .history_pos :
2757- tmp = self .history [pos ] # noqa F841
2764+ # tmp = self.history[pos]
27582765 # self.history.append(tmp)
27592766 # del self.history[pos]
27602767 self .history_pos = pos
@@ -2832,7 +2839,11 @@ def recallPrevService(self):
28322839 self .addToHistory (currentPlayedRef )
28332840 hlen = len (self .history )
28342841 if hlen > 1 :
2835- if self .history_pos == hlen - 1 :
2842+ if self .isSubservices (self .history [self .history_pos ][0 ]): # Exit subservice!
2843+ del self .history [self .history_pos ]
2844+ if self .history_pos > 0 :
2845+ self .history_pos -= 1
2846+ elif self .history_pos == hlen - 1 :
28362847 tmp = self .history [self .history_pos ]
28372848 self .history [self .history_pos ] = self .history [self .history_pos - 1 ]
28382849 self .history [self .history_pos - 1 ] = tmp
@@ -2848,7 +2859,6 @@ def cancel(self):
28482859 if self .revertMode is None :
28492860 self .restoreRoot ()
28502861 if self .dopipzap :
2851- # This unfortunately won't work with sub-services.
28522862 self .setCurrentSelection (self .session .pip .getCurrentService ())
28532863 else :
28542864 lastservice = eServiceReference (self .lastservice .value )
@@ -2879,7 +2889,6 @@ def zapBack(self):
28792889 self .startServiceRef = None
28802890 self .startRoot = None
28812891 if self .dopipzap :
2882- # This unfortunately won't work with sub-services.
28832892 self .setCurrentSelection (self .session .pip .getCurrentService ())
28842893 else :
28852894 lastservice = eServiceReference (self .lastservice .value )
0 commit comments