Add :prompt-open-download --pdfjs

This commit is contained in:
Florian Bruhin 2018-09-27 22:25:29 +02:00
parent bfa7d6a566
commit 36d7dc4853
3 changed files with 17 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -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