From d6e7df6b6f0697d8ceed2fd74517438ff86bd36e Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 30 Apr 2014 08:47:43 +0530 Subject: [PATCH] Add a copy to clipboard action to the context menu for the spell check dialog --- src/calibre/gui2/tweak_book/spell.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/calibre/gui2/tweak_book/spell.py b/src/calibre/gui2/tweak_book/spell.py index f25575a04f..23f009e986 100644 --- a/src/calibre/gui2/tweak_book/spell.py +++ b/src/calibre/gui2/tweak_book/spell.py @@ -794,9 +794,19 @@ class WordsView(QTableView): a.setMenu(am) for dic in sorted(dictionaries.active_user_dictionaries, key=lambda x:sort_key(x.name)): am.addAction(dic.name, partial(self.add_all.emit, dic.name)) + m.addSeparator() + m.addAction(_('Copy selected words to clipboard'), self.copy_to_clipboard) m.exec_(ev.globalPos()) + def copy_to_clipboard(self): + rows = {i.row() for i in self.selectedIndexes()} + words = {self.model().word_for_row(r) for r in rows} + words.discard(None) + words = sorted({w[0] for w in words}, key=sort_key) + if words: + QApplication.clipboard().setText('\n'.join(words)) + class SpellCheck(Dialog): work_finished = pyqtSignal(object, object)