Some style fixes.

This commit is contained in:
Joel Torstensson 2015-02-09 12:06:49 +01:00
parent 6bbb655a54
commit 767ca42e46
2 changed files with 19 additions and 3 deletions

View File

@ -912,7 +912,7 @@ class CommandDispatcher:
@cmdutils.register(instance='command-dispatcher', scope='window') @cmdutils.register(instance='command-dispatcher', scope='window')
def download(self, url=None, dest=None): def download(self, url=None, dest=None):
"""Download a given URL, or current page if none given. """Download a given URL, or current page if no URL given.
Args: Args:
url: The URL to download, or None to download current page. url: The URL to download, or None to download current page.
@ -920,7 +920,7 @@ class CommandDispatcher:
""" """
download_manager = objreg.get('download-manager', scope='window', download_manager = objreg.get('download-manager', scope='window',
window=self._win_id) window=self._win_id)
if (url): if url:
url = urlutils.qurl_from_user_input(url) url = urlutils.qurl_from_user_input(url)
urlutils.raise_cmdexc_if_invalid(url) urlutils.raise_cmdexc_if_invalid(url)
download_manager.get(url, filename=dest) download_manager.get(url, filename=dest)
@ -928,6 +928,12 @@ class CommandDispatcher:
page = self._current_widget().page() page = self._current_widget().page()
download_manager.get(self._current_url(), page) download_manager.get(self._current_url(), page)
@cmdutils.register(instance='command-dispatcher', scope='window',
deprecated="Use :download instead.")
def download_page(self):
"""Download the current page."""
self.download()
@cmdutils.register(instance='command-dispatcher', scope='window') @cmdutils.register(instance='command-dispatcher', scope='window')
def view_source(self): def view_source(self):
"""Show the source of the current page.""" """Show the source of the current page."""

View File

@ -745,6 +745,16 @@ class DownloadManager(QAbstractListModel):
raise cmdexc.CommandError("There's no download {}!".format(count)) raise cmdexc.CommandError("There's no download {}!".format(count))
download.cancel() download.cancel()
@cmdutils.register(instance='download-manager', scope='window',
deprecated="Use :download instead.")
def cancel_download(self, count: {'special': 'count'}=1):
"""Cancel the first/[count]th download.
Args:
count: The index of the download to cancel.
"""
self.download_cancel(count)
@cmdutils.register(instance='download-manager', scope='window') @cmdutils.register(instance='download-manager', scope='window')
def download_open(self, count: {'special': 'count'}=0): def download_open(self, count: {'special': 'count'}=0):
"""Open the last/[count]th download. """Open the last/[count]th download.
@ -820,7 +830,7 @@ class DownloadManager(QAbstractListModel):
return False return False
@cmdutils.register(instance='download-manager', name='downloads-clear', @cmdutils.register(instance='download-manager', name='downloads-clear',
scope='window') scope='window')
def clear(self): def clear(self):
"""Remove all finished downloads.""" """Remove all finished downloads."""
self.remove_items(d for d in self.downloads if d.done) self.remove_items(d for d in self.downloads if d.done)