mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Sort the entries in the Connect/Share->Email to menu. Fixes #1663545 [Enhancement to sort the Connect/Share address list](https://bugs.launchpad.net/calibre/+bug/1663545)
This commit is contained in:
parent
b64ebfa502
commit
0fd4b2da4b
@ -7,15 +7,16 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
from functools import partial
|
||||
|
||||
from PyQt5.Qt import QToolButton, QMenu, pyqtSignal, QIcon, QTimer
|
||||
from PyQt5.Qt import QIcon, QMenu, QTimer, QToolButton, pyqtSignal
|
||||
|
||||
from calibre.gui2.actions import InterfaceAction
|
||||
from calibre.utils.smtp import config as email_config
|
||||
from calibre.utils.config import tweaks
|
||||
from calibre.constants import iswindows, isosx, get_osx_version
|
||||
from calibre.gui2.dialogs.smartdevice import SmartdeviceDialog
|
||||
from calibre.constants import get_osx_version, isosx, iswindows
|
||||
from calibre.gui2 import info_dialog, question_dialog
|
||||
from calibre.gui2.actions import InterfaceAction
|
||||
from calibre.gui2.dialogs.smartdevice import SmartdeviceDialog
|
||||
from calibre.library.server import server_config as content_server_config
|
||||
from calibre.utils.config import tweaks
|
||||
from calibre.utils.icu import primary_sort_key
|
||||
from calibre.utils.smtp import config as email_config
|
||||
|
||||
|
||||
class ShareConnMenu(QMenu): # {{{
|
||||
@ -105,7 +106,11 @@ class ShareConnMenu(QMenu): # {{{
|
||||
self.email_to_and_delete_menu = QMenu(
|
||||
_('Email to and delete from library')+'...', self)
|
||||
keys = sorted(opts.accounts.keys())
|
||||
for account in keys:
|
||||
|
||||
def sk(account):
|
||||
return primary_sort_key(opts.aliases.get(account) or account)
|
||||
|
||||
for account in sorted(keys, key=sk):
|
||||
formats, auto, default = opts.accounts[account]
|
||||
subject = opts.subjects.get(account, '')
|
||||
alias = opts.aliases.get(account, '')
|
||||
|
@ -26,7 +26,7 @@ from calibre.constants import preferred_encoding
|
||||
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
|
||||
from calibre.utils.icu import primary_sort_key
|
||||
from calibre.gui2.threaded_jobs import ThreadedJob
|
||||
|
||||
|
||||
@ -135,6 +135,7 @@ class Sendmail(object):
|
||||
finally:
|
||||
self.last_send_time = time.time()
|
||||
|
||||
|
||||
gui_sendmail = Sendmail()
|
||||
|
||||
|
||||
@ -179,6 +180,7 @@ def email_news(mi, remove, get_fmts, done, job_manager):
|
||||
sent_mails.append(to_s[0])
|
||||
return sent_mails
|
||||
|
||||
|
||||
plugboard_email_value = 'email'
|
||||
plugboard_email_formats = ['epub', 'mobi', 'azw3']
|
||||
|
||||
@ -266,7 +268,11 @@ class SelectRecipients(QDialog): # {{{
|
||||
def init_list(self):
|
||||
opts = email_config().parse()
|
||||
self.items = []
|
||||
for key in sorted(opts.accounts or (), key=sort_key):
|
||||
|
||||
def sk(account):
|
||||
return primary_sort_key(opts.aliases.get(account) or account)
|
||||
|
||||
for key in sorted(opts.accounts or (), key=sk):
|
||||
self.create_item(opts.aliases.get(key, key), key)
|
||||
|
||||
def accept(self):
|
||||
@ -495,8 +501,8 @@ class EmailMixin(object): # {{{
|
||||
|
||||
# }}}
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
from PyQt5.Qt import QApplication
|
||||
app = QApplication([]) # noqa
|
||||
print (select_recipients())
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user