Add prompt-yank command
add yank_text property to utils.usertypes.Question class Resolves #2591
This commit is contained in:
parent
b1c54f5706
commit
d77c9ae009
@ -166,6 +166,7 @@ def get_filename_question(*, suggested_filename, url, parent=None):
|
||||
q.title = "Save file to:"
|
||||
q.text = "Please enter a location for <b>{}</b>".format(
|
||||
html.escape(url.toDisplayString()))
|
||||
q.yank_text = url.toString()
|
||||
q.mode = usertypes.PromptMode.download
|
||||
q.completed.connect(q.deleteLater)
|
||||
q.default = _path_suggestion(suggested_filename)
|
||||
|
@ -422,6 +422,18 @@ class PromptContainer(QWidget):
|
||||
except UnsupportedOperationError:
|
||||
pass
|
||||
|
||||
@cmdutils.register(instance='prompt-container', scope='window',
|
||||
modes=[usertypes.KeyMode.prompt])
|
||||
def prompt_yank(self):
|
||||
"""Yank URLs or other data in prompts."""
|
||||
question = self._prompt.question
|
||||
s = None
|
||||
if question and hasattr(question, 'yank_text'):
|
||||
s = question.yank_text
|
||||
utils.set_clipboard(s)
|
||||
message.info("Yanked download URL to clipboard: {}".format(s))
|
||||
|
||||
|
||||
|
||||
class LineEdit(QLineEdit):
|
||||
|
||||
@ -721,6 +733,7 @@ class DownloadFilenamePrompt(FilenamePrompt):
|
||||
('prompt-accept', 'Accept'),
|
||||
('leave-mode', 'Abort'),
|
||||
('prompt-open-download', "Open download"),
|
||||
('prompt-yank', "Yank URLs in prompts"),
|
||||
]
|
||||
return cmds
|
||||
|
||||
|
@ -266,6 +266,7 @@ class Question(QObject):
|
||||
For user_pwd, a default username as string.
|
||||
title: The question title to show.
|
||||
text: The prompt text to display to the user.
|
||||
yank_text: The prompt text available to prompt-yank command.
|
||||
answer: The value the user entered (as password for user_pwd).
|
||||
is_aborted: Whether the question was aborted.
|
||||
interrupted: Whether the question was interrupted by another one.
|
||||
@ -296,6 +297,7 @@ class Question(QObject):
|
||||
self.default = None
|
||||
self.title = None
|
||||
self.text = None
|
||||
self.yank_text = None
|
||||
self.answer = None
|
||||
self.is_aborted = False
|
||||
self.interrupted = False
|
||||
|
Loading…
Reference in New Issue
Block a user