summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2018-09-27 22:25:29 +0200
committerFlorian Bruhin <me@the-compiler.org>2018-09-27 22:25:29 +0200
commit36d7dc4853fed8492abc67a9aad2704f9dbd2d61 (patch)
tree536d27802f0008e96fde65cd794cc5abd82c55f2
parentbfa7d6a566bea1a200aaf77213570a2aefcf60d4 (diff)
downloadqutebrowser-36d7dc4853fed8492abc67a9aad2704f9dbd2d61.tar.gz
qutebrowser-36d7dc4853fed8492abc67a9aad2704f9dbd2d61.zip
Add :prompt-open-download --pdfjs
-rw-r--r--doc/changelog.asciidoc2
-rw-r--r--qutebrowser/config/configdata.yml1
-rw-r--r--qutebrowser/mainwindow/prompt.py19
3 files changed, 17 insertions, 5 deletions
diff --git a/doc/changelog.asciidoc b/doc/changelog.asciidoc
index 094acb9a4..543bb167d 100644
--- a/doc/changelog.asciidoc
+++ b/doc/changelog.asciidoc
@@ -32,6 +32,8 @@ Added
QtWebEngine.
* Opening a PDF file now doesn't start a second request anymore.
* Opening PDFs on https:// sites now works properly.
+ * New `--pdfjs` flag for `prompt-open-download`, so PDFs can be opened in
+ PDF.js with `<Ctrl-P>` in the download prompt.
- New `qt.process_model` setting which can be used to change Chromium's process
model.
- New `qt.low_end_device_mode` setting which turns on Chromium's low-end device
diff --git a/qutebrowser/config/configdata.yml b/qutebrowser/config/configdata.yml
index 88f8f7995..c4a61e203 100644
--- a/qutebrowser/config/configdata.yml
+++ b/qutebrowser/config/configdata.yml
@@ -2610,6 +2610,7 @@ bindings.default:
prompt:
<Return>: prompt-accept
<Ctrl-X>: prompt-open-download
+ <Ctrl-P>: prompt-open-download --pdfjs
<Shift-Tab>: prompt-item-focus prev
<Up>: prompt-item-focus prev
<Tab>: prompt-item-focus next
diff --git a/qutebrowser/mainwindow/prompt.py b/qutebrowser/mainwindow/prompt.py
index 357f63dd7..5eb76c86e 100644
--- a/qutebrowser/mainwindow/prompt.py
+++ b/qutebrowser/mainwindow/prompt.py
@@ -391,7 +391,7 @@ class PromptContainer(QWidget):
@cmdutils.register(instance='prompt-container', scope='window',
modes=[usertypes.KeyMode.prompt], maxsplit=0)
- def prompt_open_download(self, cmdline: str = None):
+ def prompt_open_download(self, cmdline: str = None, pdfjs=False):
"""Immediately open a download.
If no specific command is given, this will use the system's default
@@ -402,9 +402,10 @@ class PromptContainer(QWidget):
is expanded to the temporary file name. If no `{}` is
present, the filename is automatically appended to the
cmdline.
+ pdfjs: Open the download via PDF.js.
"""
try:
- self._prompt.download_open(cmdline)
+ self._prompt.download_open(cmdline, pdfjs=pdfjs)
except UnsupportedOperationError:
pass
@@ -537,8 +538,10 @@ class _BasePrompt(QWidget):
def accept(self, value=None):
raise NotImplementedError
- def download_open(self, _cmdline):
+ def download_open(self, cmdline, pdfjs):
"""Open the download directly if this is a download prompt."""
+ utils.unused(cmdline)
+ utils.unused(pdfjs)
raise UnsupportedOperationError
def item_focus(self, _which):
@@ -757,8 +760,13 @@ class DownloadFilenamePrompt(FilenamePrompt):
self.question.answer = downloads.FileDownloadTarget(answer)
return done
- def download_open(self, cmdline):
- self.question.answer = downloads.OpenFileDownloadTarget(cmdline)
+ def download_open(self, cmdline, pdfjs):
+ if pdfjs:
+ target = downloads.PDFJSDownloadTarget()
+ else:
+ target = downloads.OpenFileDownloadTarget(cmdline)
+
+ self.question.answer = target
self.question.done()
message.global_bridge.prompt_done.emit(self.KEY_MODE)
@@ -767,6 +775,7 @@ class DownloadFilenamePrompt(FilenamePrompt):
('prompt-accept', 'Accept'),
('leave-mode', 'Abort'),
('prompt-open-download', "Open download"),
+ ('prompt-open-download --pdfjs', "Open download via PDF.js"),
('prompt-yank', "Yank URL"),
]
return cmds