diff --git a/imgsrc/polish.svg b/imgsrc/polish.svg new file mode 100644 index 0000000000..7affaaf4bd --- /dev/null +++ b/imgsrc/polish.svg @@ -0,0 +1,366 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + Ulisse Perusin + + + + uli.peru@gmail.com + edit-clear + + + + + + + + + + + + + + + + + + + + + diff --git a/resources/images/polish.png b/resources/images/polish.png new file mode 100644 index 0000000000..7963e91e93 Binary files /dev/null and b/resources/images/polish.png differ diff --git a/src/calibre/customize/builtins.py b/src/calibre/customize/builtins.py index 43a0baa1d8..a61340966d 100644 --- a/src/calibre/customize/builtins.py +++ b/src/calibre/customize/builtins.py @@ -789,6 +789,11 @@ class ActionConvert(InterfaceActionBase): actual_plugin = 'calibre.gui2.actions.convert:ConvertAction' description = _('Convert books to various ebook formats') +# class ActionPolish(InterfaceActionBase): +# name = 'Polish Books' +# actual_plugin = 'calibre.gui2.actions.polish:PolishAction' +# description = _('Fine tune your ebooks') +# class ActionDelete(InterfaceActionBase): name = 'Remove Books' actual_plugin = 'calibre.gui2.actions.delete:DeleteAction' @@ -924,7 +929,7 @@ class ActionPluginUpdater(InterfaceActionBase): plugins += [ActionAdd, ActionFetchAnnotations, ActionGenerateCatalog, ActionConvert, ActionDelete, ActionEditMetadata, ActionView, - ActionFetchNews, ActionSaveToDisk, ActionQuickview, + ActionFetchNews, ActionSaveToDisk, ActionQuickview, #ActionPolish, ActionShowBookDetails,ActionRestart, ActionOpenFolder, ActionConnectShare, ActionSendToDevice, ActionHelp, ActionPreferences, ActionSimilarBooks, ActionAddToLibrary, ActionEditCollections, ActionChooseLibrary, diff --git a/src/calibre/gui2/actions/polish.py b/src/calibre/gui2/actions/polish.py new file mode 100644 index 0000000000..0edd6538b6 --- /dev/null +++ b/src/calibre/gui2/actions/polish.py @@ -0,0 +1,70 @@ +#!/usr/bin/env python +# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:fdm=marker:ai +from __future__ import (unicode_literals, division, absolute_import, + print_function) + +__license__ = 'GPL v3' +__copyright__ = '2013, Kovid Goyal ' +__docformat__ = 'restructuredtext en' + +from PyQt4.Qt import (QDialog) + +from calibre.gui2 import error_dialog +from calibre.gui2.actions import InterfaceAction + +SUPPORTED = {'EPUB', 'AZW3'} + +class Polish(QDialog): + + def __init__(self, db, book_id_map, parent=None): + QDialog.__init__(self, parent) + +class PolishAction(InterfaceAction): + + name = 'Polish Books' + action_spec = (_('Polish books'), 'polish.png', None, None) + dont_add_to = frozenset(['context-menu-device']) + action_type = 'current' + + def genesis(self): + self.qaction.triggered.connect(self.polish_books) + + def location_selected(self, loc): + enabled = loc == 'library' + self.qaction.setEnabled(enabled) + + def get_books_for_polishing(self): + rows = [r.row() for r in + self.gui.library_view.selectionModel().selectedRows()] + if not rows or len(rows) == 0: + d = error_dialog(self.gui, _('Cannot polish'), + _('No books selected')) + d.exec_() + return None + db = self.gui.library_view.model().db + ans = (db.id(r) for r in rows) + supported = set(SUPPORTED) + for x in SUPPORTED: + supported.add('ORIGINAL_'+x) + ans = {x:set( (db.formats(x, index_is_id=True) or '').split(',') ) + .intersection(supported) for x in ans} + ans = {x:fmts for x, fmts in ans.iteritems() if fmts} + if not ans: + error_dialog(self.gui, _('Cannot polish'), + _('Polishing is only supported for books in the %s' + ' formats. Convert to one of those formats before polishing.') + %_(' or ').join(sorted(SUPPORTED)), show=True) + for fmts in ans.itervalues(): + for x in SUPPORTED: + if ('ORIGINAL_'+x) in fmts: + fmts.discard(x) + return ans + + def polish_books(self): + book_id_map = self.get_books_for_polishing() + if not book_id_map: + return + d = Polish(self.gui.library_view.model().db, book_id_map, parent=self.gui) + if d.exec_() == d.Accepted: + pass +