def _load_tab(self, new_tab, data): """Load yaml data into a newly opened tab.""" entries = [] for histentry in data['history']: user_data = {} if 'zoom' in data: user_data['zoom'] = data['zoom'] if 'scroll-pos' in data: pos = data['scroll-pos'] user_data['scroll-pos'] = QPoint(pos['x'], pos['y']) active = histentry.get('active', False) url = QUrl.fromEncoded(histentry['url'].encode('ascii')) if 'original-url' in histentry: orig_url = QUrl.fromEncoded( histentry['original-url'].encode('ascii')) else: orig_url = url entry = tabhistory.TabHistoryItem( url=url, original_url=orig_url, title=histentry['title'], active=active, user_data=user_data) entries.append(entry) if active: new_tab.titleChanged.emit(histentry['title']) try: new_tab.page().load_history(entries) except ValueError as e: raise SessionError(e)
def _load_tab(self, new_tab, data): """Load yaml data into a newly opened tab.""" entries = [] for histentry in data['history']: user_data = {} if 'zoom' in data: # The zoom was accidentally stored in 'data' instead of per-tab # earlier. # See https://github.com/The-Compiler/qutebrowser/issues/728 user_data['zoom'] = data['zoom'] elif 'zoom' in histentry: user_data['zoom'] = histentry['zoom'] if 'scroll-pos' in data: # The scroll position was accidentally stored in 'data' instead # of per-tab earlier. # See https://github.com/The-Compiler/qutebrowser/issues/728 pos = data['scroll-pos'] user_data['scroll-pos'] = QPoint(pos['x'], pos['y']) elif 'scroll-pos' in histentry: pos = histentry['scroll-pos'] user_data['scroll-pos'] = QPoint(pos['x'], pos['y']) active = histentry.get('active', False) url = QUrl.fromEncoded(histentry['url'].encode('ascii')) if 'original-url' in histentry: orig_url = QUrl.fromEncoded( histentry['original-url'].encode('ascii')) else: orig_url = url entry = tabhistory.TabHistoryItem(url=url, original_url=orig_url, title=histentry['title'], active=active, user_data=user_data) entries.append(entry) if active: new_tab.titleChanged.emit(histentry['title']) try: new_tab.page().load_history(entries) except ValueError as e: raise SessionError(e)