mirror of
https://github.com/akissinger/dodo.git
synced 2024-10-04 06:27:25 +03:00
allow custom file picker command (closes #4)
This commit is contained in:
parent
e6ec020eda
commit
f5272dbd0d
@ -196,12 +196,31 @@ class ComposePanel(panel.Panel):
|
|||||||
"""Attach a file
|
"""Attach a file
|
||||||
|
|
||||||
Opens a file browser for selecting a file to attach. If a file is selected, add it using the "A:"
|
Opens a file browser for selecting a file to attach. If a file is selected, add it using the "A:"
|
||||||
pseudo-header. This will be translated into a proper attachment when the message is sent."""
|
pseudo-header. This will be translated into a proper attachment when the message is sent.
|
||||||
f = QFileDialog.getOpenFileName()
|
|
||||||
if f[0]:
|
This command can also use the optional setting file_picker_command to run an external file picker
|
||||||
self.raw_message_string = util.add_header_line(self.raw_message_string, 'A: ' + f[0])
|
instead of Qt's built-in one."""
|
||||||
|
|
||||||
|
if settings.file_picker_command == None:
|
||||||
|
f = QFileDialog.getOpenFileName()
|
||||||
|
if f[0]:
|
||||||
|
self.raw_message_string = util.add_header_line(self.raw_message_string, 'A: ' + f[0])
|
||||||
|
self.refresh()
|
||||||
|
else:
|
||||||
|
fd, file = tempfile.mkstemp()
|
||||||
|
cmd = settings.file_picker_command.format(tempfile=file)
|
||||||
|
subprocess.run(cmd, shell=True)
|
||||||
|
|
||||||
|
with open(file, 'r') as f1:
|
||||||
|
file_list = f1.read().split('\n')
|
||||||
|
os.remove(file)
|
||||||
|
|
||||||
|
for att in file_list:
|
||||||
|
if att != '':
|
||||||
|
self.raw_message_string = util.add_header_line(self.raw_message_string, 'A: ' + att)
|
||||||
self.refresh()
|
self.refresh()
|
||||||
|
|
||||||
|
|
||||||
def toggle_wrap(self) -> None:
|
def toggle_wrap(self) -> None:
|
||||||
"""Toggle message wrapping
|
"""Toggle message wrapping
|
||||||
|
|
||||||
|
@ -70,6 +70,16 @@ command is used when viewing attachments, which first dumps the attachments to a
|
|||||||
temp directory given by `{dir}`, then opens that directory in a file browser.
|
temp directory given by `{dir}`, then opens that directory in a file browser.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
file_picker_command = None
|
||||||
|
"""Command used to launch external file picker
|
||||||
|
|
||||||
|
This is an optional shell command, which additionally takes the `{tempfile}` placeholder.
|
||||||
|
This command is used when picking files to attach to an email. The command should write
|
||||||
|
out the chosen files to {tempfile}, which will then be read and deleted, if it exists.
|
||||||
|
|
||||||
|
By default, this is set to None, in which case the built-in file picker will be used.
|
||||||
|
"""
|
||||||
|
|
||||||
web_browser_command = ''
|
web_browser_command = ''
|
||||||
"""Web browser to use when clicking links in emails
|
"""Web browser to use when clicking links in emails
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user