Fix some other small bugs with new signal implementation
This commit is contained in:
parent
a70aa212e0
commit
b91274cfcf
2
TODO
2
TODO
@ -59,8 +59,6 @@ Improvements / minor features
|
|||||||
- configurable warning when closing window with multiple tabs open
|
- configurable warning when closing window with multiple tabs open
|
||||||
- Hide statusbar messages after timeout, not on keypress
|
- Hide statusbar messages after timeout, not on keypress
|
||||||
- Reimplement tabbar to paint it by ourselves to look like dwb
|
- Reimplement tabbar to paint it by ourselves to look like dwb
|
||||||
- We probably should rewrite all the signal cache stuff to save state
|
|
||||||
internally instead. (also see bugs)
|
|
||||||
- Save cookies in Netscape format so it can be used by wget.
|
- Save cookies in Netscape format so it can be used by wget.
|
||||||
http://www.cookiecentral.com/faq/#3.5
|
http://www.cookiecentral.com/faq/#3.5
|
||||||
https://docs.python.org/3.4/library/http.cookies.html
|
https://docs.python.org/3.4/library/http.cookies.html
|
||||||
|
@ -408,7 +408,7 @@ class QuteBrowser(QApplication):
|
|||||||
tabs.cur_statusbar_message.connect(status.txt.on_statusbar_message)
|
tabs.cur_statusbar_message.connect(status.txt.on_statusbar_message)
|
||||||
|
|
||||||
tabs.currentChanged.connect(status.url.on_tab_changed)
|
tabs.currentChanged.connect(status.url.on_tab_changed)
|
||||||
tabs.cur_url_changed.connect(status.url.set_url)
|
tabs.cur_url_text_changed.connect(status.url.set_url)
|
||||||
tabs.cur_link_hovered.connect(status.url.set_hover_url)
|
tabs.cur_link_hovered.connect(status.url.set_hover_url)
|
||||||
|
|
||||||
# command input / completion
|
# command input / completion
|
||||||
|
@ -62,7 +62,7 @@ class TabbedBrowser(TabWidget):
|
|||||||
cur_load_finished: Current tab finished loading (loadFinished)
|
cur_load_finished: Current tab finished loading (loadFinished)
|
||||||
cur_statusbar_message: Current tab got a statusbar message
|
cur_statusbar_message: Current tab got a statusbar message
|
||||||
(statusBarMessage)
|
(statusBarMessage)
|
||||||
cur_url_changed: Current URL changed (urlChanged)
|
cur_url_text_changed: Current URL text changed.
|
||||||
cur_link_hovered: Link hovered in current tab (linkHovered)
|
cur_link_hovered: Link hovered in current tab (linkHovered)
|
||||||
cur_scroll_perc_changed: Scroll percentage of current tab changed.
|
cur_scroll_perc_changed: Scroll percentage of current tab changed.
|
||||||
arg 1: x-position in %.
|
arg 1: x-position in %.
|
||||||
@ -80,7 +80,7 @@ class TabbedBrowser(TabWidget):
|
|||||||
cur_load_started = pyqtSignal()
|
cur_load_started = pyqtSignal()
|
||||||
cur_load_finished = pyqtSignal(bool)
|
cur_load_finished = pyqtSignal(bool)
|
||||||
cur_statusbar_message = pyqtSignal(str)
|
cur_statusbar_message = pyqtSignal(str)
|
||||||
cur_url_changed = pyqtSignal('QUrl')
|
cur_url_text_changed = pyqtSignal(str)
|
||||||
cur_link_hovered = pyqtSignal(str, str, str)
|
cur_link_hovered = pyqtSignal(str, str, str)
|
||||||
cur_scroll_perc_changed = pyqtSignal(int, int)
|
cur_scroll_perc_changed = pyqtSignal(int, int)
|
||||||
hint_strings_updated = pyqtSignal(list)
|
hint_strings_updated = pyqtSignal(list)
|
||||||
@ -144,8 +144,9 @@ class TabbedBrowser(TabWidget):
|
|||||||
self._filter.create(self.cur_statusbar_message))
|
self._filter.create(self.cur_statusbar_message))
|
||||||
tab.scroll_pos_changed.connect(
|
tab.scroll_pos_changed.connect(
|
||||||
self._filter.create(self.cur_scroll_perc_changed))
|
self._filter.create(self.cur_scroll_perc_changed))
|
||||||
tab.urlChanged.connect(self.on_url_changed)
|
tab.url_text_changed.connect(
|
||||||
tab.urlChanged.connect(self._filter.create(self.cur_url_changed))
|
self._filter.create(self.cur_url_text_changed))
|
||||||
|
tab.url_text_changed.connect(self.on_url_text_changed)
|
||||||
# hintmanager
|
# hintmanager
|
||||||
tab.hintmanager.hint_strings_updated.connect(self.hint_strings_updated)
|
tab.hintmanager.hint_strings_updated.connect(self.hint_strings_updated)
|
||||||
tab.hintmanager.openurl.connect(self.cur.openurl_slot)
|
tab.hintmanager.openurl.connect(self.cur.openurl_slot)
|
||||||
@ -234,12 +235,10 @@ class TabbedBrowser(TabWidget):
|
|||||||
tab = WebView(self)
|
tab = WebView(self)
|
||||||
self._connect_tab_signals(tab)
|
self._connect_tab_signals(tab)
|
||||||
self._tabs.append(tab)
|
self._tabs.append(tab)
|
||||||
|
self.addTab(tab, "")
|
||||||
if url is not None:
|
if url is not None:
|
||||||
url = urlutils.qurl(url)
|
url = urlutils.qurl(url)
|
||||||
self.addTab(tab, "")
|
|
||||||
tab.openurl(url)
|
tab.openurl(url)
|
||||||
else:
|
|
||||||
self.addTab(tab, "")
|
|
||||||
if background is None:
|
if background is None:
|
||||||
background = config.get('general', 'background-tabs')
|
background = config.get('general', 'background-tabs')
|
||||||
if not background:
|
if not background:
|
||||||
@ -489,7 +488,7 @@ class TabbedBrowser(TabWidget):
|
|||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def on_load_started(self, tab):
|
def on_load_started(self, tab):
|
||||||
"""Clear signal cache and icon when a tab started loading.
|
"""Clear icon when a tab started loading.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
tab: The tab where the signal belongs to.
|
tab: The tab where the signal belongs to.
|
||||||
@ -511,12 +510,12 @@ class TabbedBrowser(TabWidget):
|
|||||||
else:
|
else:
|
||||||
logging.debug("ignoring title change")
|
logging.debug("ignoring title change")
|
||||||
|
|
||||||
@pyqtSlot('QUrl')
|
@pyqtSlot(str)
|
||||||
def on_url_changed(self, url):
|
def on_url_text_changed(self, url):
|
||||||
"""Set the new URL as title if there's no title yet."""
|
"""Set the new URL as title if there's no title yet."""
|
||||||
idx = self.indexOf(self.sender())
|
idx = self.indexOf(self.sender())
|
||||||
if not self.tabText(idx):
|
if not self.tabText(idx):
|
||||||
self.setTabText(idx, urlutils.urlstring(url))
|
self.setTabText(idx, url)
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def on_icon_changed(self):
|
def on_icon_changed(self):
|
||||||
@ -537,7 +536,7 @@ class TabbedBrowser(TabWidget):
|
|||||||
|
|
||||||
@pyqtSlot(int)
|
@pyqtSlot(int)
|
||||||
def on_current_changed(self, idx):
|
def on_current_changed(self, idx):
|
||||||
"""Set last_focused and replay signal cache if focus changed."""
|
"""Set last_focused when focus changed."""
|
||||||
tab = self.widget(idx)
|
tab = self.widget(idx)
|
||||||
self.last_focused = self.now_focused
|
self.last_focused = self.now_focused
|
||||||
self.now_focused = tab
|
self.now_focused = tab
|
||||||
|
@ -112,9 +112,9 @@ class Url(TextBase):
|
|||||||
"""Setter to be used as a Qt slot.
|
"""Setter to be used as a Qt slot.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
s: The URL to set.
|
s: The URL to set as string.
|
||||||
"""
|
"""
|
||||||
self.setText(urlstring(s))
|
self.setText(s)
|
||||||
self.urltype = 'normal'
|
self.urltype = 'normal'
|
||||||
|
|
||||||
@pyqtSlot(str, str, str)
|
@pyqtSlot(str, str, str)
|
||||||
@ -146,7 +146,7 @@ class Url(TextBase):
|
|||||||
def on_tab_changed(self, idx):
|
def on_tab_changed(self, idx):
|
||||||
"""Update URL if the tab changed."""
|
"""Update URL if the tab changed."""
|
||||||
tab = self.sender().widget(idx)
|
tab = self.sender().widget(idx)
|
||||||
self.setText(urlstring(tab.url()))
|
self.setText(tab.url_text)
|
||||||
status = LoadStatus[tab.load_status]
|
status = LoadStatus[tab.load_status]
|
||||||
if status in ['success', 'error', 'warn']:
|
if status in ['success', 'error', 'warn']:
|
||||||
self.urltype = status
|
self.urltype = status
|
||||||
|
@ -54,7 +54,8 @@ class WebView(QWebView):
|
|||||||
work.
|
work.
|
||||||
progress: loading progress of this page.
|
progress: loading progress of this page.
|
||||||
scroll_pos: The current scroll position as (x%, y%) tuple.
|
scroll_pos: The current scroll position as (x%, y%) tuple.
|
||||||
url: The current URL as QUrl.
|
_url_text: The current URL as string.
|
||||||
|
Accessed via url_text property.
|
||||||
_load_status: loading status of this page (index into LoadStatus)
|
_load_status: loading status of this page (index into LoadStatus)
|
||||||
Accessed via load_status property.
|
Accessed via load_status property.
|
||||||
_has_ssl_errors: Whether SSL errors occured during loading.
|
_has_ssl_errors: Whether SSL errors occured during loading.
|
||||||
@ -72,11 +73,13 @@ class WebView(QWebView):
|
|||||||
arg 2: y-position in %.
|
arg 2: y-position in %.
|
||||||
linkHovered: QWebPages linkHovered signal exposed.
|
linkHovered: QWebPages linkHovered signal exposed.
|
||||||
load_status_changed: The loading status changed
|
load_status_changed: The loading status changed
|
||||||
|
url_text_changed: Current URL string changed.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
scroll_pos_changed = pyqtSignal(int, int)
|
scroll_pos_changed = pyqtSignal(int, int)
|
||||||
linkHovered = pyqtSignal(str, str, str)
|
linkHovered = pyqtSignal(str, str, str)
|
||||||
load_status_changed = pyqtSignal(str)
|
load_status_changed = pyqtSignal(str)
|
||||||
|
url_text_changed = pyqtSignal(str)
|
||||||
|
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
@ -91,6 +94,7 @@ class WebView(QWebView):
|
|||||||
self._zoom = None
|
self._zoom = None
|
||||||
self._has_ssl_errors = False
|
self._has_ssl_errors = False
|
||||||
self._init_neighborlist()
|
self._init_neighborlist()
|
||||||
|
self._url_text = ''
|
||||||
self.progress = 0
|
self.progress = 0
|
||||||
self.page_ = BrowserPage(self)
|
self.page_ = BrowserPage(self)
|
||||||
self.setPage(self.page_)
|
self.setPage(self.page_)
|
||||||
@ -101,6 +105,7 @@ class WebView(QWebView):
|
|||||||
self.page_.linkHovered.connect(self.linkHovered)
|
self.page_.linkHovered.connect(self.linkHovered)
|
||||||
self.linkClicked.connect(self.on_link_clicked)
|
self.linkClicked.connect(self.on_link_clicked)
|
||||||
self.page_.mainFrame().loadStarted.connect(self.on_load_started)
|
self.page_.mainFrame().loadStarted.connect(self.on_load_started)
|
||||||
|
self.urlChanged.connect(self.on_url_changed)
|
||||||
self.loadFinished.connect(self.on_load_finished)
|
self.loadFinished.connect(self.on_load_finished)
|
||||||
self.loadProgress.connect(lambda p: setattr(self, 'progress', p))
|
self.loadProgress.connect(lambda p: setattr(self, 'progress', p))
|
||||||
self.page_.networkAccessManager().sslErrors.connect(
|
self.page_.networkAccessManager().sslErrors.connect(
|
||||||
@ -122,6 +127,21 @@ class WebView(QWebView):
|
|||||||
self._load_status = val
|
self._load_status = val
|
||||||
self.load_status_changed.emit(LoadStatus[val])
|
self.load_status_changed.emit(LoadStatus[val])
|
||||||
|
|
||||||
|
@property
|
||||||
|
def url_text(self):
|
||||||
|
"""Getter for url_text."""
|
||||||
|
return self._url_text
|
||||||
|
|
||||||
|
@url_text.setter
|
||||||
|
def url_text(self, val):
|
||||||
|
"""Setter for url_text.
|
||||||
|
|
||||||
|
Emit:
|
||||||
|
url_text_changed
|
||||||
|
"""
|
||||||
|
self._url_text = val
|
||||||
|
self.url_text_changed.emit(val)
|
||||||
|
|
||||||
def _init_neighborlist(self):
|
def _init_neighborlist(self):
|
||||||
"""Initialize the _zoom neighborlist."""
|
"""Initialize the _zoom neighborlist."""
|
||||||
self._zoom = NeighborList(
|
self._zoom = NeighborList(
|
||||||
@ -256,7 +276,7 @@ class WebView(QWebView):
|
|||||||
Return status of self.load
|
Return status of self.load
|
||||||
|
|
||||||
Emit:
|
Emit:
|
||||||
titleChanged and urlChanged
|
titleChanged
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
u = urlutils.fuzzy_url(url)
|
u = urlutils.fuzzy_url(url)
|
||||||
@ -264,7 +284,7 @@ class WebView(QWebView):
|
|||||||
raise CommandError(e)
|
raise CommandError(e)
|
||||||
logging.debug("New title: {}".format(urlutils.urlstring(u)))
|
logging.debug("New title: {}".format(urlutils.urlstring(u)))
|
||||||
self.titleChanged.emit(urlutils.urlstring(u))
|
self.titleChanged.emit(urlutils.urlstring(u))
|
||||||
self.urlChanged.emit(urlutils.qurl(u))
|
self.url_text = urlutils.urlstring(u)
|
||||||
return self.load(u)
|
return self.load(u)
|
||||||
|
|
||||||
def zoom_perc(self, perc, fuzzyval=True):
|
def zoom_perc(self, perc, fuzzyval=True):
|
||||||
@ -334,6 +354,11 @@ class WebView(QWebView):
|
|||||||
self.deleteLater()
|
self.deleteLater()
|
||||||
logging.debug("Tab shutdown scheduled")
|
logging.debug("Tab shutdown scheduled")
|
||||||
|
|
||||||
|
@pyqtSlot('QUrl')
|
||||||
|
def on_url_changed(self, url):
|
||||||
|
"""Update url_text when URL has changed."""
|
||||||
|
self.url_text = urlutils.urlstring(url)
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def on_link_clicked(self, url):
|
def on_link_clicked(self, url):
|
||||||
"""Handle a link.
|
"""Handle a link.
|
||||||
|
Loading…
Reference in New Issue
Block a user