lazy sessions
This commit is contained in:
parent
3a012ca1e3
commit
95f8c07d7f
@ -424,6 +424,13 @@ def qute_settings(url):
|
||||
confget=config.instance.get_str)
|
||||
return 'text/html', html
|
||||
|
||||
@add_handler('back')
|
||||
def qute_back(url):
|
||||
"""Handler for qute://back. Simple page to free ram / lazy load a site,
|
||||
goes back on focusing the tab."""
|
||||
|
||||
html = jinja.render('back.html', title='Suspended')
|
||||
return 'text/html', html
|
||||
|
||||
@add_handler('configdiff')
|
||||
def qute_configdiff(url):
|
||||
|
@ -88,6 +88,14 @@ session_default_name:
|
||||
|
||||
If this is set to null, the session which was last loaded is saved.
|
||||
|
||||
session_lazy_restore:
|
||||
type:
|
||||
name: Bool
|
||||
none_ok: true
|
||||
default: false
|
||||
desc: >-
|
||||
Load a restored tab as soon as it takes focus.
|
||||
|
||||
backend:
|
||||
type:
|
||||
name: String
|
||||
|
@ -347,7 +347,9 @@ class SessionManager(QObject):
|
||||
if 'pinned' in histentry:
|
||||
new_tab.data.pinned = histentry['pinned']
|
||||
|
||||
active = histentry.get('active', False)
|
||||
active = (histentry.get('active', False) and
|
||||
(not config.val.session_lazy_restore or
|
||||
histentry['url'].startswith('qute://')))
|
||||
url = QUrl.fromEncoded(histentry['url'].encode('ascii'))
|
||||
if 'original-url' in histentry:
|
||||
orig_url = QUrl.fromEncoded(
|
||||
@ -360,6 +362,19 @@ class SessionManager(QObject):
|
||||
entries.append(entry)
|
||||
if active:
|
||||
new_tab.title_changed.emit(histentry['title'])
|
||||
|
||||
if config.val.session_lazy_restore and data['history']:
|
||||
last = data['history'][-1]
|
||||
title = last['title']
|
||||
url = 'qute://back#' + title
|
||||
active = last.get('active', False)
|
||||
|
||||
if not last['url'].startswith('qute://'):
|
||||
entries.append(TabHistoryItem(url=QUrl.fromEncoded(url.encode('ascii')),
|
||||
title=title, active=active, user_data={}))
|
||||
if active:
|
||||
new_tab.title_changed.emit(title)
|
||||
|
||||
try:
|
||||
new_tab.history.load_items(entries)
|
||||
except ValueError as e:
|
||||
|
Loading…
Reference in New Issue
Block a user