mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Sharing by email: Add an option to insert the comments from the book metadata as text into the email. Useful to allow the recipient to see a summary of the book before opening it. The option is in Preferences->Sharing by email
This commit is contained in:
parent
75f7fc5f0a
commit
e95c878293
@ -122,6 +122,7 @@ defs['cover_grid_show_title'] = False
|
||||
defs['cover_grid_texture'] = None
|
||||
defs['show_vl_tabs'] = False
|
||||
defs['show_highlight_toggle_button'] = False
|
||||
defs['add_comments_to_email'] = False
|
||||
del defs
|
||||
# }}}
|
||||
|
||||
|
@ -6,7 +6,7 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import os, socket, time
|
||||
import os, socket, time, textwrap
|
||||
from binascii import unhexlify
|
||||
from functools import partial
|
||||
from threading import Thread
|
||||
@ -23,7 +23,7 @@ from calibre.utils.filenames import ascii_filename
|
||||
from calibre.customize.ui import available_input_formats, available_output_formats
|
||||
from calibre.ebooks.metadata import authors_to_string
|
||||
from calibre.constants import preferred_encoding
|
||||
from calibre.gui2 import config, Dispatcher, warning_dialog, error_dialog
|
||||
from calibre.gui2 import config, Dispatcher, warning_dialog, error_dialog, gprefs
|
||||
from calibre.library.save_to_disk import get_components
|
||||
from calibre.utils.config import tweaks, prefs
|
||||
from calibre.utils.icu import sort_key
|
||||
@ -382,6 +382,9 @@ class EmailMixin(object): # {{{
|
||||
'\n\n' + t + '\n\t' + _('by') + ' ' + a + '\n\n' +
|
||||
_('in the %s format.') %
|
||||
os.path.splitext(f)[1][1:].upper())
|
||||
if mi.comments and gprefs['add_comments_to_email']:
|
||||
from calibre.utils.html2text import html2text
|
||||
texts[-1] += '\n\n' + _('About this book:') + '\n\n' + textwrap.fill(html2text(mi.comments))
|
||||
prefix = ascii_filename(t+' - '+a)
|
||||
if not isinstance(prefix, unicode):
|
||||
prefix = prefix.decode(preferred_encoding, 'replace')
|
||||
|
@ -92,6 +92,18 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="opt_add_comments_to_email">
|
||||
<property name="toolTip">
|
||||
<string>Add the comments from the book metadata to the email.
|
||||
Useful to allow the recipient to see a summary of the
|
||||
book before opening it.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Add &comments metadata as text to the email</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="SendEmail" name="send_email_widget" native="true"/>
|
||||
</item>
|
||||
|
@ -14,7 +14,7 @@ from calibre.gui2.preferences import ConfigWidgetBase, test_widget, \
|
||||
AbortCommit
|
||||
from calibre.gui2.preferences.email_ui import Ui_Form
|
||||
from calibre.utils.config import ConfigProxy
|
||||
from calibre.gui2 import NONE
|
||||
from calibre.gui2 import NONE, gprefs
|
||||
from calibre.utils.smtp import config as smtp_prefs
|
||||
|
||||
class EmailAccounts(QAbstractTableModel): # {{{
|
||||
@ -163,6 +163,8 @@ class ConfigWidget(ConfigWidgetBase, Ui_Form):
|
||||
def genesis(self, gui):
|
||||
self.gui = gui
|
||||
self.proxy = ConfigProxy(smtp_prefs())
|
||||
r = self.register
|
||||
r('add_comments_to_email', gprefs)
|
||||
|
||||
self.send_email_widget.initialize(self.preferred_to_address)
|
||||
self.send_email_widget.changed_signal.connect(self.changed_signal.emit)
|
||||
|
Loading…
x
Reference in New Issue
Block a user