Merge branch 'pretty_url' of https://github.com/forkbong/qutebrowser into forkbong-pretty_url

This commit is contained in:
Florian Bruhin 2016-04-20 22:15:54 +02:00
commit e18b056877
3 changed files with 20 additions and 3 deletions

View File

@ -654,13 +654,14 @@ class CommandDispatcher:
frame.scroll(dx, dy)
@cmdutils.register(instance='command-dispatcher', scope='window')
def yank(self, title=False, sel=False, domain=False):
def yank(self, title=False, sel=False, domain=False, pretty=False):
"""Yank the current URL/title to the clipboard or primary selection.
Args:
sel: Use the primary selection instead of the clipboard.
title: Yank the title instead of the URL.
domain: Yank only the scheme, domain, and port number.
pretty: Yank the URL in pretty decoded form.
"""
if title:
s = self._tabbed_browser.page_title(self._current_index())
@ -672,8 +673,10 @@ class CommandDispatcher:
':' + str(port) if port > -1 else '')
what = 'domain'
else:
s = self._current_url().toString(
QUrl.FullyEncoded | QUrl.RemovePassword)
flags = QUrl.RemovePassword
if not pretty:
flags |= QUrl.FullyEncoded
s = self._current_url().toString(flags)
what = 'URL'
if sel and QApplication.clipboard().supportsSelection():

View File

@ -1448,6 +1448,8 @@ KEY_DATA = collections.OrderedDict([
('yank -ts', ['yT']),
('yank -d', ['yd']),
('yank -ds', ['yD']),
('yank -p', ['yp']),
('yank -ps', ['yP']),
('paste', ['pp']),
('paste -s', ['pP']),
('paste -t', ['Pp']),

View File

@ -33,6 +33,18 @@ Feature: Yanking and pasting.
Then the message "Yanked domain to clipboard: http://localhost:(port)" should be shown
And the clipboard should contain "http://localhost:(port)"
Scenario: Yanking fully encoded URL
When I open data/title with spaces.html
And I run :yank
Then the message "Yanked URL to clipboard: http://localhost:(port)/data/title%20with%20spaces.html" should be shown
And the clipboard should contain "http://localhost:(port)/data/title%20with%20spaces.html"
Scenario: Yanking pretty decoded URL
When I open data/title with spaces.html
And I run :yank --pretty
Then the message "Yanked URL to clipboard: http://localhost:(port)/data/title with spaces.html" should be shown
And the clipboard should contain "http://localhost:(port)/data/title with spaces.html"
#### :paste
Scenario: Pasting an URL