Some more objreg fixes for multi-window.
This commit is contained in:
parent
36f7ff6154
commit
895f51083d
@ -315,19 +315,18 @@ class Application(QApplication):
|
|||||||
Return:
|
Return:
|
||||||
A list of open pages, or an empty list.
|
A list of open pages, or an empty list.
|
||||||
"""
|
"""
|
||||||
try:
|
|
||||||
tabbed_browser = objreg.get('tabbed-browser')
|
|
||||||
except KeyError:
|
|
||||||
return []
|
|
||||||
pages = []
|
pages = []
|
||||||
for tab in tabbed_browser.widgets():
|
for win_id in objreg.window_registry:
|
||||||
try:
|
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
||||||
url = tab.cur_url.toString(
|
window=win_id)
|
||||||
QUrl.RemovePassword | QUrl.FullyEncoded)
|
for tab in tabbed_browser.widgets():
|
||||||
if url:
|
try:
|
||||||
pages.append(url)
|
url = tab.cur_url.toString(
|
||||||
except Exception: # pylint: disable=broad-except
|
QUrl.RemovePassword | QUrl.FullyEncoded)
|
||||||
log.destroy.exception("Error while recovering tab")
|
if url:
|
||||||
|
pages.append(url)
|
||||||
|
except Exception: # pylint: disable=broad-except
|
||||||
|
log.destroy.exception("Error while recovering tab")
|
||||||
return pages
|
return pages
|
||||||
|
|
||||||
def _save_geometry(self):
|
def _save_geometry(self):
|
||||||
@ -391,7 +390,7 @@ class Application(QApplication):
|
|||||||
pages = []
|
pages = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
history = objreg.get('status-command').history[-5:]
|
history = objreg.get('command-history')[-5:]
|
||||||
except Exception:
|
except Exception:
|
||||||
log.destroy.exception("Error while getting history: {}")
|
log.destroy.exception("Error while getting history: {}")
|
||||||
history = []
|
history = []
|
||||||
@ -429,13 +428,17 @@ class Application(QApplication):
|
|||||||
"""Restart qutebrowser while keeping existing tabs open."""
|
"""Restart qutebrowser while keeping existing tabs open."""
|
||||||
# We don't use _recover_pages here as it's too forgiving when
|
# We don't use _recover_pages here as it's too forgiving when
|
||||||
# exceptions occur.
|
# exceptions occur.
|
||||||
|
# FIXME handle multiple windows correctly here
|
||||||
if pages is None:
|
if pages is None:
|
||||||
pages = []
|
pages = []
|
||||||
for tab in objreg.get('tabbed-browser').widgets():
|
for win_id in objreg.window_registry:
|
||||||
urlstr = tab.cur_url.toString(
|
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
||||||
QUrl.RemovePassword | QUrl.FullyEncoded)
|
window=win_id)
|
||||||
if urlstr:
|
for tab in tabbed_browser.widgets():
|
||||||
pages.append(urlstr)
|
urlstr = tab.cur_url.toString(
|
||||||
|
QUrl.RemovePassword | QUrl.FullyEncoded)
|
||||||
|
if urlstr:
|
||||||
|
pages.append(urlstr)
|
||||||
log.destroy.debug("sys.executable: {}".format(sys.executable))
|
log.destroy.debug("sys.executable: {}".format(sys.executable))
|
||||||
log.destroy.debug("sys.path: {}".format(sys.path))
|
log.destroy.debug("sys.path: {}".format(sys.path))
|
||||||
log.destroy.debug("sys.argv: {}".format(sys.argv))
|
log.destroy.debug("sys.argv: {}".format(sys.argv))
|
||||||
@ -485,13 +488,15 @@ class Application(QApplication):
|
|||||||
except Exception: # pylint: disable=broad-except
|
except Exception: # pylint: disable=broad-except
|
||||||
out = traceback.format_exc()
|
out = traceback.format_exc()
|
||||||
qutescheme.pyeval_output = out
|
qutescheme.pyeval_output = out
|
||||||
objreg.get('tabbed-browser').openurl(QUrl('qute:pyeval'), newtab=True)
|
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
||||||
|
window='current')
|
||||||
|
tabbed_browser.openurl(QUrl('qute:pyeval'), newtab=True)
|
||||||
|
|
||||||
@cmdutils.register(instance='app')
|
@cmdutils.register(instance='app')
|
||||||
def report(self):
|
def report(self):
|
||||||
"""Report a bug in qutebrowser."""
|
"""Report a bug in qutebrowser."""
|
||||||
pages = self._recover_pages()
|
pages = self._recover_pages()
|
||||||
history = objreg.get('status-command').history[-5:]
|
history = objreg.get('command-history')[-5:]
|
||||||
objects = self.get_all_objects()
|
objects = self.get_all_objects()
|
||||||
self._crashdlg = crash.ReportDialog(pages, history, objects)
|
self._crashdlg = crash.ReportDialog(pages, history, objects)
|
||||||
self._crashdlg.show()
|
self._crashdlg.show()
|
||||||
@ -579,11 +584,11 @@ class Application(QApplication):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
# Close all tabs
|
# Close all tabs
|
||||||
try:
|
for win_id in objreg.window_registry:
|
||||||
log.destroy.debug("Closing tabs...")
|
log.destroy.debug("Closing tabs in window {}...".format(win_id))
|
||||||
objreg.get('tabbed-browser').shutdown()
|
tabbed_browser = objreg.get('tabbed-browser', scope='window',
|
||||||
except KeyError:
|
window=win_id)
|
||||||
pass
|
tabbed_browser.shutdown()
|
||||||
# Save everything
|
# Save everything
|
||||||
try:
|
try:
|
||||||
config_obj = objreg.get('config')
|
config_obj = objreg.get('config')
|
||||||
|
@ -191,7 +191,8 @@ class CommandDispatcher:
|
|||||||
def _tab_focus_last(self):
|
def _tab_focus_last(self):
|
||||||
"""Select the tab which was last focused."""
|
"""Select the tab which was last focused."""
|
||||||
try:
|
try:
|
||||||
tab = objreg.get('last-focused-tab')
|
tab = objreg.get('last-focused-tab', scope='window',
|
||||||
|
window=self._win_id)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise cmdexc.CommandError("No last focused tab!")
|
raise cmdexc.CommandError("No last focused tab!")
|
||||||
idx = self._tabbed_browser().indexOf(tab)
|
idx = self._tabbed_browser().indexOf(tab)
|
||||||
|
@ -402,6 +402,7 @@ class DownloadManager(QObject):
|
|||||||
self.downloads.append(download)
|
self.downloads.append(download)
|
||||||
self.download_added.emit()
|
self.download_added.emit()
|
||||||
|
|
||||||
|
# FIXME display this in right window
|
||||||
q = usertypes.Question(self)
|
q = usertypes.Question(self)
|
||||||
q.text = "Save file to:"
|
q.text = "Save file to:"
|
||||||
q.mode = usertypes.PromptMode.text
|
q.mode = usertypes.PromptMode.text
|
||||||
@ -412,7 +413,9 @@ class DownloadManager(QObject):
|
|||||||
q.destroyed.connect(functools.partial(self.questions.remove, q))
|
q.destroyed.connect(functools.partial(self.questions.remove, q))
|
||||||
self.questions.append(q)
|
self.questions.append(q)
|
||||||
download.cancelled.connect(q.abort)
|
download.cancelled.connect(q.abort)
|
||||||
objreg.get('message-bridge').ask(q, blocking=False)
|
message_bridge = objreg.get('message-bridge', scope='window',
|
||||||
|
window='current')
|
||||||
|
message_bridge.ask(q, blocking=False)
|
||||||
|
|
||||||
@pyqtSlot(DownloadItem)
|
@pyqtSlot(DownloadItem)
|
||||||
def on_finished(self, download):
|
def on_finished(self, download):
|
||||||
|
@ -247,8 +247,10 @@ class TabbedBrowser(tabwidget.TabWidget):
|
|||||||
tab))
|
tab))
|
||||||
if tab is self._now_focused:
|
if tab is self._now_focused:
|
||||||
self._now_focused = None
|
self._now_focused = None
|
||||||
if tab is objreg.get('last-focused-tab', None):
|
if tab is objreg.get('last-focused-tab', None, scope='window',
|
||||||
objreg.delete('last-focused-tab')
|
window=self._win_id):
|
||||||
|
objreg.delete('last-focused-tab', scope='window',
|
||||||
|
window=self._win_id)
|
||||||
if not tab.cur_url.isEmpty():
|
if not tab.cur_url.isEmpty():
|
||||||
qtutils.ensure_valid(tab.cur_url)
|
qtutils.ensure_valid(tab.cur_url)
|
||||||
history_data = qtutils.serialize(tab.history())
|
history_data = qtutils.serialize(tab.history())
|
||||||
@ -503,7 +505,8 @@ class TabbedBrowser(tabwidget.TabWidget):
|
|||||||
modeman.maybe_leave(self._win_id, usertypes.KeyMode.hint,
|
modeman.maybe_leave(self._win_id, usertypes.KeyMode.hint,
|
||||||
'tab changed')
|
'tab changed')
|
||||||
if self._now_focused is not None:
|
if self._now_focused is not None:
|
||||||
objreg.register('last-focused-tab', self._now_focused, update=True)
|
objreg.register('last-focused-tab', self._now_focused, update=True,
|
||||||
|
scope='window', window=self._win_id)
|
||||||
self._now_focused = tab
|
self._now_focused = tab
|
||||||
self.current_tab_changed.emit(tab)
|
self.current_tab_changed.emit(tab)
|
||||||
self._change_app_title(self.tabText(idx))
|
self._change_app_title(self.tabText(idx))
|
||||||
|
Loading…
Reference in New Issue
Block a user