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.title = "Save file to:"
|
||||||
q.text = "Please enter a location for <b>{}</b>".format(
|
q.text = "Please enter a location for <b>{}</b>".format(
|
||||||
html.escape(url.toDisplayString()))
|
html.escape(url.toDisplayString()))
|
||||||
|
q.yank_text = url.toString()
|
||||||
q.mode = usertypes.PromptMode.download
|
q.mode = usertypes.PromptMode.download
|
||||||
q.completed.connect(q.deleteLater)
|
q.completed.connect(q.deleteLater)
|
||||||
q.default = _path_suggestion(suggested_filename)
|
q.default = _path_suggestion(suggested_filename)
|
||||||
|
@ -422,6 +422,18 @@ class PromptContainer(QWidget):
|
|||||||
except UnsupportedOperationError:
|
except UnsupportedOperationError:
|
||||||
pass
|
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):
|
class LineEdit(QLineEdit):
|
||||||
|
|
||||||
@ -721,6 +733,7 @@ class DownloadFilenamePrompt(FilenamePrompt):
|
|||||||
('prompt-accept', 'Accept'),
|
('prompt-accept', 'Accept'),
|
||||||
('leave-mode', 'Abort'),
|
('leave-mode', 'Abort'),
|
||||||
('prompt-open-download', "Open download"),
|
('prompt-open-download', "Open download"),
|
||||||
|
('prompt-yank', "Yank URLs in prompts"),
|
||||||
]
|
]
|
||||||
return cmds
|
return cmds
|
||||||
|
|
||||||
|
@ -266,6 +266,7 @@ class Question(QObject):
|
|||||||
For user_pwd, a default username as string.
|
For user_pwd, a default username as string.
|
||||||
title: The question title to show.
|
title: The question title to show.
|
||||||
text: The prompt text to display to the user.
|
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).
|
answer: The value the user entered (as password for user_pwd).
|
||||||
is_aborted: Whether the question was aborted.
|
is_aborted: Whether the question was aborted.
|
||||||
interrupted: Whether the question was interrupted by another one.
|
interrupted: Whether the question was interrupted by another one.
|
||||||
@ -296,6 +297,7 @@ class Question(QObject):
|
|||||||
self.default = None
|
self.default = None
|
||||||
self.title = None
|
self.title = None
|
||||||
self.text = None
|
self.text = None
|
||||||
|
self.yank_text = None
|
||||||
self.answer = None
|
self.answer = None
|
||||||
self.is_aborted = False
|
self.is_aborted = False
|
||||||
self.interrupted = False
|
self.interrupted = False
|
||||||
|
Loading…
Reference in New Issue
Block a user