本文整理汇总了Python中qutebrowser.utils.qtutils.deserialize函数的典型用法代码示例。如果您正苦于以下问题:Python deserialize函数的具体用法?Python deserialize怎么用?Python deserialize使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了deserialize函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: undo
def undo(self):
"""Undo removing of a tab."""
# Remove unused tab which may be created after the last tab is closed
last_close = config.get('tabs', 'last-close')
use_current_tab = False
if last_close in ['blank', 'startpage', 'default-page']:
only_one_tab_open = self.count() == 1
no_history = self.widget(0).history().count() == 1
urls = {
'blank': QUrl('about:blank'),
'startpage': QUrl(config.get('general', 'startpage')[0]),
'default-page': config.get('general', 'default-page'),
}
first_tab_url = self.widget(0).page().mainFrame().requestedUrl()
last_close_urlstr = urls[last_close].toString().rstrip('/')
first_tab_urlstr = first_tab_url.toString().rstrip('/')
last_close_url_used = first_tab_urlstr == last_close_urlstr
use_current_tab = (only_one_tab_open and no_history and
last_close_url_used)
url, history_data = self._undo_stack.pop()
if use_current_tab:
self.openurl(url, newtab=False)
newtab = self.widget(0)
else:
newtab = self.tabopen(url, background=False)
qtutils.deserialize(history_data, newtab.history())
示例2: tab_clone
def tab_clone(self, bg=False, window=False):
"""Duplicate the current tab.
Args:
bg: Open in a background tab.
window: Open in a new window.
Return:
The new QWebView.
"""
if bg and window:
raise cmdexc.CommandError("Only one of -b/-w can be given!")
cur_tabbed_browser = self._tabbed_browser()
curtab = self._current_widget()
cur_title = cur_tabbed_browser.page_title(self._current_index())
# The new tab could be in a new tabbed_browser (e.g. because of
# tabs-are-windows being set)
new_tabbed_browser = self._tabbed_browser(window)
newtab = new_tabbed_browser.tabopen(background=bg, explicit=True)
new_tabbed_browser = objreg.get('tabbed-browser', scope='window',
window=newtab.win_id)
idx = new_tabbed_browser.indexOf(newtab)
new_tabbed_browser.set_page_title(idx, cur_title)
new_tabbed_browser.setTabIcon(idx, curtab.icon())
newtab.keep_icon = True
newtab.setZoomFactor(curtab.zoomFactor())
history = qtutils.serialize(curtab.history())
qtutils.deserialize(history, newtab.history())
return newtab
示例3: undo
def undo(self):
"""Undo removing of a tab."""
# Remove unused tab which may be created after the last tab is closed
last_close = config.get("tabs", "last-close")
use_current_tab = False
if last_close in ["blank", "startpage", "default-page"]:
only_one_tab_open = self.count() == 1
no_history = self.widget(0).history().count() == 1
urls = {
"blank": QUrl("about:blank"),
"startpage": QUrl(config.get("general", "startpage")[0]),
"default-page": config.get("general", "default-page"),
}
first_tab_url = self.widget(0).page().mainFrame().requestedUrl()
last_close_urlstr = urls[last_close].toString().rstrip("/")
first_tab_urlstr = first_tab_url.toString().rstrip("/")
last_close_url_used = first_tab_urlstr == last_close_urlstr
use_current_tab = only_one_tab_open and no_history and last_close_url_used
url, history_data = self._undo_stack.pop()
if use_current_tab:
self.openurl(url, newtab=False)
newtab = self.widget(0)
else:
newtab = self.tabopen(url, background=False)
qtutils.deserialize(history_data, newtab.history())
示例4: test_serialize
def test_serialize(obj):
"""Test a serialize/deserialize round trip.
Args:
obj: The object to test with.
"""
new_obj = type(obj)()
qtutils.deserialize(qtutils.serialize(obj), new_obj)
assert new_obj == obj
示例5: tab_clone
def tab_clone(self, bg=False):
"""Duplicate the current tab.
Args:
bg: Open in a background tab.
Return:
The new QWebView.
"""
curtab = self._current_widget()
tabbed_browser = objreg.get('tabbed-browser')
newtab = tabbed_browser.tabopen(background=bg, explicit=True)
history = qtutils.serialize(curtab.history())
qtutils.deserialize(history, newtab.history())
return newtab
示例6: tab_clone
def tab_clone(self, bg=False, window=False):
"""Duplicate the current tab.
Args:
bg: Open in a background tab.
window: Open in a new window.
Return:
The new QWebView.
"""
if bg and window:
raise cmdexc.CommandError("Only one of -b/-w can be given!")
curtab = self._current_widget()
tabbed_browser = self._tabbed_browser(window)
newtab = tabbed_browser.tabopen(background=bg, explicit=True)
history = qtutils.serialize(curtab.history())
qtutils.deserialize(history, newtab.history())
return newtab
示例7: deserialize
def deserialize(self, data):
return qtutils.deserialize(data, self._history)
示例8: undo
def undo(self):
"""Undo removing of a tab."""
url, history_data = self._undo_stack.pop()
newtab = self.tabopen(url)
qtutils.deserialize(history_data, newtab.history())