mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Migrate catalog and convert actions. And remove layout spec from plugins
This commit is contained in:
parent
206547021d
commit
cb07d093e2
@ -578,11 +578,20 @@ plugins += input_profiles + output_profiles
|
|||||||
from calibre.customize import InterfaceActionBase
|
from calibre.customize import InterfaceActionBase
|
||||||
|
|
||||||
class ActionAdd(InterfaceActionBase):
|
class ActionAdd(InterfaceActionBase):
|
||||||
name = 'action_add'
|
name = 'Add Books'
|
||||||
actual_plugin = 'calibre.gui2.actions.add:AddAction'
|
actual_plugin = 'calibre.gui2.actions.add:AddAction'
|
||||||
|
|
||||||
class ActionFetchAnnotations(InterfaceActionBase):
|
class ActionFetchAnnotations(InterfaceActionBase):
|
||||||
name = 'action_fetch_annotations'
|
name = 'Fetch Annotations'
|
||||||
actual_plugin = 'calibre.gui2.actions.annotate:FetchAnnotationsAction'
|
actual_plugin = 'calibre.gui2.actions.annotate:FetchAnnotationsAction'
|
||||||
|
|
||||||
plugins += [ActionAdd, ActionFetchAnnotations]
|
class ActionGenerateCatalog(InterfaceActionBase):
|
||||||
|
name = 'Generate Catalog'
|
||||||
|
actual_plugin = 'calibre.gui2.actions.catalog:GenerateCatalogAction'
|
||||||
|
|
||||||
|
class ActionConvert(InterfaceActionBase):
|
||||||
|
name = 'Convert Books'
|
||||||
|
actual_plugin = 'calibre.gui2.actions.convert:ConvertAction'
|
||||||
|
|
||||||
|
plugins += [ActionAdd, ActionFetchAnnotations, ActionGenerateCatalog,
|
||||||
|
ActionConvert]
|
||||||
|
@ -16,17 +16,16 @@ class InterfaceAction(QObject):
|
|||||||
name = 'Implement me'
|
name = 'Implement me'
|
||||||
priority = 1
|
priority = 1
|
||||||
positions = frozenset([])
|
positions = frozenset([])
|
||||||
separators = frozenset([])
|
|
||||||
|
|
||||||
popup_type = QToolButton.MenuPopup
|
popup_type = QToolButton.MenuPopup
|
||||||
|
|
||||||
#: Of the form: (text, icon_path, tooltip, keyboard shortcut)
|
#: Of the form: (text, icon_path, tooltip, keyboard shortcut)
|
||||||
#: tooltip and keybard shortcut can be None
|
#: icon, tooltip and keybard shortcut can be None
|
||||||
#: shortcut must be a translated string if not None
|
#: shortcut must be a translated string if not None
|
||||||
action_spec = ('text', 'icon', None, None)
|
action_spec = ('text', 'icon', None, None)
|
||||||
|
|
||||||
def __init__(self, parent, site_customization):
|
def __init__(self, parent, site_customization):
|
||||||
QObject.__init__(self, parent)
|
QObject.__init__(self, parent)
|
||||||
|
self.setObjectName(self.name)
|
||||||
self.gui = parent
|
self.gui = parent
|
||||||
self.site_customization = site_customization
|
self.site_customization = site_customization
|
||||||
|
|
||||||
|
@ -23,9 +23,6 @@ class AddAction(InterfaceAction):
|
|||||||
|
|
||||||
name = 'Add Books'
|
name = 'Add Books'
|
||||||
action_spec = (_('Add books'), 'add_book.svg', None, _('A'))
|
action_spec = (_('Add books'), 'add_book.svg', None, _('A'))
|
||||||
positions = frozenset([
|
|
||||||
('toolbar', 'all', 0),
|
|
||||||
])
|
|
||||||
|
|
||||||
def genesis(self):
|
def genesis(self):
|
||||||
self._add_filesystem_book = self.Dispatcher(self.__add_filesystem_book)
|
self._add_filesystem_book = self.Dispatcher(self.__add_filesystem_book)
|
||||||
|
@ -17,7 +17,7 @@ from calibre.gui2.actions import InterfaceAction
|
|||||||
class FetchAnnotationsAction(InterfaceAction):
|
class FetchAnnotationsAction(InterfaceAction):
|
||||||
|
|
||||||
name = 'Fetch Annotations'
|
name = 'Fetch Annotations'
|
||||||
action_spec = (_('Fetch Annotations'), None, None, None)
|
action_spec = (_('Fetch annotations (experimental)'), None, None, None)
|
||||||
|
|
||||||
def genesis(self):
|
def genesis(self):
|
||||||
pass
|
pass
|
||||||
|
@ -9,58 +9,62 @@ import os, shutil
|
|||||||
|
|
||||||
from PyQt4.Qt import QModelIndex
|
from PyQt4.Qt import QModelIndex
|
||||||
|
|
||||||
from calibre.gui2 import error_dialog, Dispatcher, choose_dir
|
from calibre.gui2 import error_dialog, choose_dir
|
||||||
from calibre.gui2.tools import generate_catalog
|
from calibre.gui2.tools import generate_catalog
|
||||||
from calibre.utils.config import dynamic
|
from calibre.utils.config import dynamic
|
||||||
|
from calibre.gui2.actions import InterfaceAction
|
||||||
|
|
||||||
class GenerateCatalogAction(object):
|
class GenerateCatalogAction(InterfaceAction):
|
||||||
|
|
||||||
|
name = 'Generate Catalog'
|
||||||
|
action_spec = (_('Create catalog of books in your calibre library'), None, None, None)
|
||||||
|
|
||||||
def generate_catalog(self):
|
def generate_catalog(self):
|
||||||
rows = self.library_view.selectionModel().selectedRows()
|
rows = self.gui.library_view.selectionModel().selectedRows()
|
||||||
if not rows or len(rows) < 2:
|
if not rows or len(rows) < 2:
|
||||||
rows = xrange(self.library_view.model().rowCount(QModelIndex()))
|
rows = xrange(self.gui.library_view.model().rowCount(QModelIndex()))
|
||||||
ids = map(self.library_view.model().id, rows)
|
ids = map(self.gui.library_view.model().id, rows)
|
||||||
|
|
||||||
dbspec = None
|
dbspec = None
|
||||||
if not ids:
|
if not ids:
|
||||||
return error_dialog(self, _('No books selected'),
|
return error_dialog(self.gui, _('No books selected'),
|
||||||
_('No books selected to generate catalog for'),
|
_('No books selected to generate catalog for'),
|
||||||
show=True)
|
show=True)
|
||||||
|
|
||||||
# Calling gui2.tools:generate_catalog()
|
# Calling gui2.tools:generate_catalog()
|
||||||
ret = generate_catalog(self, dbspec, ids, self.device_manager.device)
|
ret = generate_catalog(self.gui, dbspec, ids, self.gui.device_manager.device)
|
||||||
if ret is None:
|
if ret is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
func, args, desc, out, sync, title = ret
|
func, args, desc, out, sync, title = ret
|
||||||
|
|
||||||
fmt = os.path.splitext(out)[1][1:].upper()
|
fmt = os.path.splitext(out)[1][1:].upper()
|
||||||
job = self.job_manager.run_job(
|
job = self.gui.job_manager.run_job(
|
||||||
Dispatcher(self.catalog_generated), func, args=args,
|
self.Dispatcher(self.catalog_generated), func, args=args,
|
||||||
description=desc)
|
description=desc)
|
||||||
job.catalog_file_path = out
|
job.catalog_file_path = out
|
||||||
job.fmt = fmt
|
job.fmt = fmt
|
||||||
job.catalog_sync, job.catalog_title = sync, title
|
job.catalog_sync, job.catalog_title = sync, title
|
||||||
self.status_bar.show_message(_('Generating %s catalog...')%fmt)
|
self.gui.status_bar.show_message(_('Generating %s catalog...')%fmt)
|
||||||
|
|
||||||
def catalog_generated(self, job):
|
def catalog_generated(self, job):
|
||||||
if job.result:
|
if job.result:
|
||||||
# Search terms nulled catalog results
|
# Search terms nulled catalog results
|
||||||
return error_dialog(self, _('No books found'),
|
return error_dialog(self.gui, _('No books found'),
|
||||||
_("No books to catalog\nCheck exclude tags"),
|
_("No books to catalog\nCheck exclude tags"),
|
||||||
show=True)
|
show=True)
|
||||||
if job.failed:
|
if job.failed:
|
||||||
return self.job_exception(job)
|
return self.gui.job_exception(job)
|
||||||
id = self.library_view.model().add_catalog(job.catalog_file_path, job.catalog_title)
|
id = self.gui.library_view.model().add_catalog(job.catalog_file_path, job.catalog_title)
|
||||||
self.library_view.model().reset()
|
self.gui.library_view.model().reset()
|
||||||
if job.catalog_sync:
|
if job.catalog_sync:
|
||||||
sync = dynamic.get('catalogs_to_be_synced', set([]))
|
sync = dynamic.get('catalogs_to_be_synced', set([]))
|
||||||
sync.add(id)
|
sync.add(id)
|
||||||
dynamic.set('catalogs_to_be_synced', sync)
|
dynamic.set('catalogs_to_be_synced', sync)
|
||||||
self.status_bar.show_message(_('Catalog generated.'), 3000)
|
self.gui.status_bar.show_message(_('Catalog generated.'), 3000)
|
||||||
self.sync_catalogs()
|
self.gui.sync_catalogs()
|
||||||
if job.fmt not in ['EPUB','MOBI']:
|
if job.fmt not in ['EPUB','MOBI']:
|
||||||
export_dir = choose_dir(self, _('Export Catalog Directory'),
|
export_dir = choose_dir(self.gui, _('Export Catalog Directory'),
|
||||||
_('Select destination for %s.%s') % (job.catalog_title, job.fmt.lower()))
|
_('Select destination for %s.%s') % (job.catalog_title, job.fmt.lower()))
|
||||||
if export_dir:
|
if export_dir:
|
||||||
destination = os.path.join(export_dir, '%s.%s' % (job.catalog_title, job.fmt.lower()))
|
destination = os.path.join(export_dir, '%s.%s' % (job.catalog_title, job.fmt.lower()))
|
||||||
|
@ -6,133 +6,154 @@ __copyright__ = '2010, Kovid Goyal <kovid@kovidgoyal.net>'
|
|||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from functools import partial
|
||||||
|
|
||||||
from PyQt4.Qt import QModelIndex
|
from PyQt4.Qt import QModelIndex, QMenu
|
||||||
|
|
||||||
from calibre.gui2 import error_dialog, Dispatcher
|
from calibre.gui2 import error_dialog, Dispatcher
|
||||||
from calibre.gui2.tools import convert_single_ebook, convert_bulk_ebook
|
from calibre.gui2.tools import convert_single_ebook, convert_bulk_ebook
|
||||||
from calibre.utils.config import prefs
|
from calibre.utils.config import prefs
|
||||||
|
from calibre.gui2.actions import InterfaceAction
|
||||||
|
|
||||||
|
class ConvertAction(InterfaceAction):
|
||||||
|
|
||||||
|
name = 'Convert Books'
|
||||||
|
action_spec = (_('Convert books'), 'convert.svg', None, _('C'))
|
||||||
|
|
||||||
|
def genesis(self):
|
||||||
|
cm = QMenu()
|
||||||
|
cm.addAction(_('Convert individually'), partial(self.convert_ebook,
|
||||||
|
False, bulk=False))
|
||||||
|
cm.addAction(_('Bulk convert'),
|
||||||
|
partial(self.convert_ebook, False, bulk=True))
|
||||||
|
cm.addSeparator()
|
||||||
|
ac = cm.addAction(
|
||||||
|
_('Create catalog of books in your calibre library'))
|
||||||
|
ac.triggered.connect(self.gui.iactions['Generate Catalog'].generate_catalog)
|
||||||
|
self.qaction.setMenu(cm)
|
||||||
|
self.qaction.triggered.connect(self.convert_ebook)
|
||||||
|
self.convert_menu = cm
|
||||||
|
self.conversion_jobs = {}
|
||||||
|
|
||||||
class ConvertAction(object):
|
|
||||||
|
|
||||||
def auto_convert(self, book_ids, on_card, format):
|
def auto_convert(self, book_ids, on_card, format):
|
||||||
previous = self.library_view.currentIndex()
|
previous = self.gui.library_view.currentIndex()
|
||||||
rows = [x.row() for x in \
|
rows = [x.row() for x in \
|
||||||
self.library_view.selectionModel().selectedRows()]
|
self.gui.library_view.selectionModel().selectedRows()]
|
||||||
jobs, changed, bad = convert_single_ebook(self, self.library_view.model().db, book_ids, True, format)
|
jobs, changed, bad = convert_single_ebook(self.gui, self.gui.library_view.model().db, book_ids, True, format)
|
||||||
if jobs == []: return
|
if jobs == []: return
|
||||||
self.queue_convert_jobs(jobs, changed, bad, rows, previous,
|
self.queue_convert_jobs(jobs, changed, bad, rows, previous,
|
||||||
self.book_auto_converted, extra_job_args=[on_card])
|
self.book_auto_converted, extra_job_args=[on_card])
|
||||||
|
|
||||||
def auto_convert_mail(self, to, fmts, delete_from_library, book_ids, format):
|
def auto_convert_mail(self, to, fmts, delete_from_library, book_ids, format):
|
||||||
previous = self.library_view.currentIndex()
|
previous = self.gui.library_view.currentIndex()
|
||||||
rows = [x.row() for x in \
|
rows = [x.row() for x in \
|
||||||
self.library_view.selectionModel().selectedRows()]
|
self.gui.library_view.selectionModel().selectedRows()]
|
||||||
jobs, changed, bad = convert_single_ebook(self, self.library_view.model().db, book_ids, True, format)
|
jobs, changed, bad = convert_single_ebook(self.gui, self.gui.library_view.model().db, book_ids, True, format)
|
||||||
if jobs == []: return
|
if jobs == []: return
|
||||||
self.queue_convert_jobs(jobs, changed, bad, rows, previous,
|
self.queue_convert_jobs(jobs, changed, bad, rows, previous,
|
||||||
self.book_auto_converted_mail,
|
self.book_auto_converted_mail,
|
||||||
extra_job_args=[delete_from_library, to, fmts])
|
extra_job_args=[delete_from_library, to, fmts])
|
||||||
|
|
||||||
def auto_convert_news(self, book_ids, format):
|
def auto_convert_news(self, book_ids, format):
|
||||||
previous = self.library_view.currentIndex()
|
previous = self.gui.library_view.currentIndex()
|
||||||
rows = [x.row() for x in \
|
rows = [x.row() for x in \
|
||||||
self.library_view.selectionModel().selectedRows()]
|
self.gui.library_view.selectionModel().selectedRows()]
|
||||||
jobs, changed, bad = convert_single_ebook(self, self.library_view.model().db, book_ids, True, format)
|
jobs, changed, bad = convert_single_ebook(self.gui, self.gui.library_view.model().db, book_ids, True, format)
|
||||||
if jobs == []: return
|
if jobs == []: return
|
||||||
self.queue_convert_jobs(jobs, changed, bad, rows, previous,
|
self.queue_convert_jobs(jobs, changed, bad, rows, previous,
|
||||||
self.book_auto_converted_news)
|
self.book_auto_converted_news)
|
||||||
|
|
||||||
def auto_convert_catalogs(self, book_ids, format):
|
def auto_convert_catalogs(self, book_ids, format):
|
||||||
previous = self.library_view.currentIndex()
|
previous = self.gui.library_view.currentIndex()
|
||||||
rows = [x.row() for x in \
|
rows = [x.row() for x in \
|
||||||
self.library_view.selectionModel().selectedRows()]
|
self.gui.library_view.selectionModel().selectedRows()]
|
||||||
jobs, changed, bad = convert_single_ebook(self, self.library_view.model().db, book_ids, True, format)
|
jobs, changed, bad = convert_single_ebook(self.gui, self.gui.library_view.model().db, book_ids, True, format)
|
||||||
if jobs == []: return
|
if jobs == []: return
|
||||||
self.queue_convert_jobs(jobs, changed, bad, rows, previous,
|
self.queue_convert_jobs(jobs, changed, bad, rows, previous,
|
||||||
self.book_auto_converted_catalogs)
|
self.book_auto_converted_catalogs)
|
||||||
|
|
||||||
def get_books_for_conversion(self):
|
def get_books_for_conversion(self):
|
||||||
rows = [r.row() for r in \
|
rows = [r.row() for r in \
|
||||||
self.library_view.selectionModel().selectedRows()]
|
self.gui.library_view.selectionModel().selectedRows()]
|
||||||
if not rows or len(rows) == 0:
|
if not rows or len(rows) == 0:
|
||||||
d = error_dialog(self, _('Cannot convert'),
|
d = error_dialog(self.gui, _('Cannot convert'),
|
||||||
_('No books selected'))
|
_('No books selected'))
|
||||||
d.exec_()
|
d.exec_()
|
||||||
return None
|
return None
|
||||||
return [self.library_view.model().db.id(r) for r in rows]
|
return [self.gui.library_view.model().db.id(r) for r in rows]
|
||||||
|
|
||||||
def convert_ebook(self, checked, bulk=None):
|
def convert_ebook(self, checked, bulk=None):
|
||||||
book_ids = self.get_books_for_conversion()
|
book_ids = self.get_books_for_conversion()
|
||||||
if book_ids is None: return
|
if book_ids is None: return
|
||||||
previous = self.library_view.currentIndex()
|
previous = self.gui.library_view.currentIndex()
|
||||||
rows = [x.row() for x in \
|
rows = [x.row() for x in \
|
||||||
self.library_view.selectionModel().selectedRows()]
|
self.gui.library_view.selectionModel().selectedRows()]
|
||||||
num = 0
|
num = 0
|
||||||
if bulk or (bulk is None and len(book_ids) > 1):
|
if bulk or (bulk is None and len(book_ids) > 1):
|
||||||
self.__bulk_queue = convert_bulk_ebook(self, self.queue_convert_jobs,
|
self.__bulk_queue = convert_bulk_ebook(self.gui, self.queue_convert_jobs,
|
||||||
self.library_view.model().db, book_ids,
|
self.gui.library_view.model().db, book_ids,
|
||||||
out_format=prefs['output_format'], args=(rows, previous,
|
out_format=prefs['output_format'], args=(rows, previous,
|
||||||
self.book_converted))
|
self.book_converted))
|
||||||
if self.__bulk_queue is None:
|
if self.__bulk_queue is None:
|
||||||
return
|
return
|
||||||
num = len(self.__bulk_queue.book_ids)
|
num = len(self.__bulk_queue.book_ids)
|
||||||
else:
|
else:
|
||||||
jobs, changed, bad = convert_single_ebook(self,
|
jobs, changed, bad = convert_single_ebook(self.gui,
|
||||||
self.library_view.model().db, book_ids, out_format=prefs['output_format'])
|
self.gui.library_view.model().db, book_ids, out_format=prefs['output_format'])
|
||||||
self.queue_convert_jobs(jobs, changed, bad, rows, previous,
|
self.queue_convert_jobs(jobs, changed, bad, rows, previous,
|
||||||
self.book_converted)
|
self.book_converted)
|
||||||
num = len(jobs)
|
num = len(jobs)
|
||||||
|
|
||||||
if num > 0:
|
if num > 0:
|
||||||
self.status_bar.show_message(_('Starting conversion of %d book(s)') %
|
self.gui.status_bar.show_message(_('Starting conversion of %d book(s)') %
|
||||||
num, 2000)
|
num, 2000)
|
||||||
|
|
||||||
def queue_convert_jobs(self, jobs, changed, bad, rows, previous,
|
def queue_convert_jobs(self, jobs, changed, bad, rows, previous,
|
||||||
converted_func, extra_job_args=[]):
|
converted_func, extra_job_args=[]):
|
||||||
for func, args, desc, fmt, id, temp_files in jobs:
|
for func, args, desc, fmt, id, temp_files in jobs:
|
||||||
if id not in bad:
|
if id not in bad:
|
||||||
job = self.job_manager.run_job(Dispatcher(converted_func),
|
job = self.gui.job_manager.run_job(Dispatcher(converted_func),
|
||||||
func, args=args, description=desc)
|
func, args=args, description=desc)
|
||||||
args = [temp_files, fmt, id]+extra_job_args
|
args = [temp_files, fmt, id]+extra_job_args
|
||||||
self.conversion_jobs[job] = tuple(args)
|
self.conversion_jobs[job] = tuple(args)
|
||||||
|
|
||||||
if changed:
|
if changed:
|
||||||
self.library_view.model().refresh_rows(rows)
|
self.gui.library_view.model().refresh_rows(rows)
|
||||||
current = self.library_view.currentIndex()
|
current = self.gui.library_view.currentIndex()
|
||||||
self.library_view.model().current_changed(current, previous)
|
self.gui.library_view.model().current_changed(current, previous)
|
||||||
|
|
||||||
def book_auto_converted(self, job):
|
def book_auto_converted(self, job):
|
||||||
temp_files, fmt, book_id, on_card = self.conversion_jobs[job]
|
temp_files, fmt, book_id, on_card = self.conversion_jobs[job]
|
||||||
self.book_converted(job)
|
self.book_converted(job)
|
||||||
self.sync_to_device(on_card, False, specific_format=fmt, send_ids=[book_id], do_auto_convert=False)
|
self.gui.sync_to_device(on_card, False, specific_format=fmt, send_ids=[book_id], do_auto_convert=False)
|
||||||
|
|
||||||
def book_auto_converted_mail(self, job):
|
def book_auto_converted_mail(self, job):
|
||||||
temp_files, fmt, book_id, delete_from_library, to, fmts = self.conversion_jobs[job]
|
temp_files, fmt, book_id, delete_from_library, to, fmts = self.conversion_jobs[job]
|
||||||
self.book_converted(job)
|
self.book_converted(job)
|
||||||
self.send_by_mail(to, fmts, delete_from_library, specific_format=fmt, send_ids=[book_id], do_auto_convert=False)
|
self.gui.send_by_mail(to, fmts, delete_from_library, specific_format=fmt, send_ids=[book_id], do_auto_convert=False)
|
||||||
|
|
||||||
def book_auto_converted_news(self, job):
|
def book_auto_converted_news(self, job):
|
||||||
temp_files, fmt, book_id = self.conversion_jobs[job]
|
temp_files, fmt, book_id = self.conversion_jobs[job]
|
||||||
self.book_converted(job)
|
self.book_converted(job)
|
||||||
self.sync_news(send_ids=[book_id], do_auto_convert=False)
|
self.gui.sync_news(send_ids=[book_id], do_auto_convert=False)
|
||||||
|
|
||||||
def book_auto_converted_catalogs(self, job):
|
def book_auto_converted_catalogs(self, job):
|
||||||
temp_files, fmt, book_id = self.conversion_jobs[job]
|
temp_files, fmt, book_id = self.conversion_jobs[job]
|
||||||
self.book_converted(job)
|
self.book_converted(job)
|
||||||
self.sync_catalogs(send_ids=[book_id], do_auto_convert=False)
|
self.gui.sync_catalogs(send_ids=[book_id], do_auto_convert=False)
|
||||||
|
|
||||||
def book_converted(self, job):
|
def book_converted(self, job):
|
||||||
temp_files, fmt, book_id = self.conversion_jobs.pop(job)[:3]
|
temp_files, fmt, book_id = self.conversion_jobs.pop(job)[:3]
|
||||||
try:
|
try:
|
||||||
if job.failed:
|
if job.failed:
|
||||||
self.job_exception(job)
|
self.gui.job_exception(job)
|
||||||
return
|
return
|
||||||
data = open(temp_files[-1].name, 'rb')
|
data = open(temp_files[-1].name, 'rb')
|
||||||
self.library_view.model().db.add_format(book_id, \
|
self.gui.library_view.model().db.add_format(book_id, \
|
||||||
fmt, data, index_is_id=True)
|
fmt, data, index_is_id=True)
|
||||||
data.close()
|
data.close()
|
||||||
self.status_bar.show_message(job.description + \
|
self.gui.status_bar.show_message(job.description + \
|
||||||
(' completed'), 2000)
|
(' completed'), 2000)
|
||||||
finally:
|
finally:
|
||||||
for f in temp_files:
|
for f in temp_files:
|
||||||
@ -141,8 +162,8 @@ class ConvertAction(object):
|
|||||||
os.remove(f.name)
|
os.remove(f.name)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
self.tags_view.recount()
|
self.gui.tags_view.recount()
|
||||||
if self.current_view() is self.library_view:
|
if self.gui.current_view() is self.gui.library_view:
|
||||||
current = self.library_view.currentIndex()
|
current = self.gui.library_view.currentIndex()
|
||||||
self.library_view.model().current_changed(current, QModelIndex())
|
self.gui.library_view.model().current_changed(current, QModelIndex())
|
||||||
|
|
||||||
|
@ -11,6 +11,9 @@ from calibre.utils.config import dynamic
|
|||||||
|
|
||||||
class FetchNewsAction(object):
|
class FetchNewsAction(object):
|
||||||
|
|
||||||
|
def genesis(self):
|
||||||
|
self.conversion_jobs = {}
|
||||||
|
|
||||||
def download_scheduled_recipe(self, arg):
|
def download_scheduled_recipe(self, arg):
|
||||||
func, args, desc, fmt, temp_files = \
|
func, args, desc, fmt, temp_files = \
|
||||||
fetch_scheduled_recipe(arg)
|
fetch_scheduled_recipe(arg)
|
||||||
|
@ -925,7 +925,7 @@ class DeviceMixin(object): # {{{
|
|||||||
_('Auto convert the following books before sending via '
|
_('Auto convert the following books before sending via '
|
||||||
'email?'), det_msg=autos,
|
'email?'), det_msg=autos,
|
||||||
buttons=QMessageBox.Yes|QMessageBox.Cancel):
|
buttons=QMessageBox.Yes|QMessageBox.Cancel):
|
||||||
self.auto_convert_mail(to, fmts, delete_from_library, auto, format)
|
self.iactions['Convert Books'].auto_convert_mail(to, fmts, delete_from_library, auto, format)
|
||||||
|
|
||||||
if bad:
|
if bad:
|
||||||
bad = '\n'.join('%s'%(i,) for i in bad)
|
bad = '\n'.join('%s'%(i,) for i in bad)
|
||||||
@ -1027,7 +1027,7 @@ class DeviceMixin(object): # {{{
|
|||||||
_('Auto convert the following books before uploading to '
|
_('Auto convert the following books before uploading to '
|
||||||
'the device?'), det_msg=autos,
|
'the device?'), det_msg=autos,
|
||||||
buttons=QMessageBox.Yes|QMessageBox.Cancel):
|
buttons=QMessageBox.Yes|QMessageBox.Cancel):
|
||||||
self.auto_convert_catalogs(auto, format)
|
self.iactions['Convert Books'].auto_convert_catalogs(auto, format)
|
||||||
files = [f for f in files if f is not None]
|
files = [f for f in files if f is not None]
|
||||||
if not files:
|
if not files:
|
||||||
dynamic.set('catalogs_to_be_synced', set([]))
|
dynamic.set('catalogs_to_be_synced', set([]))
|
||||||
@ -1089,7 +1089,7 @@ class DeviceMixin(object): # {{{
|
|||||||
_('Auto convert the following books before uploading to '
|
_('Auto convert the following books before uploading to '
|
||||||
'the device?'), det_msg=autos,
|
'the device?'), det_msg=autos,
|
||||||
buttons=QMessageBox.Yes|QMessageBox.Cancel):
|
buttons=QMessageBox.Yes|QMessageBox.Cancel):
|
||||||
self.auto_convert_news(auto, format)
|
self.iactions['Convert Books'].auto_convert_news(auto, format)
|
||||||
files = [f for f in files if f is not None]
|
files = [f for f in files if f is not None]
|
||||||
for f in files:
|
for f in files:
|
||||||
f.deleted_after_upload = del_on_upload
|
f.deleted_after_upload = del_on_upload
|
||||||
@ -1208,7 +1208,7 @@ class DeviceMixin(object): # {{{
|
|||||||
_('Auto convert the following books before uploading to '
|
_('Auto convert the following books before uploading to '
|
||||||
'the device?'), det_msg=autos,
|
'the device?'), det_msg=autos,
|
||||||
buttons=QMessageBox.Yes|QMessageBox.Cancel):
|
buttons=QMessageBox.Yes|QMessageBox.Cancel):
|
||||||
self.auto_convert(auto, on_card, format)
|
self.iactions['Convert Books'].auto_convert(auto, on_card, format)
|
||||||
|
|
||||||
if bad:
|
if bad:
|
||||||
bad = '\n'.join('%s'%(i,) for i in bad)
|
bad = '\n'.join('%s'%(i,) for i in bad)
|
||||||
|
@ -585,18 +585,6 @@ class MainWindowMixin(object):
|
|||||||
self.action_edit.setMenu(md)
|
self.action_edit.setMenu(md)
|
||||||
self.action_save.setMenu(self.save_menu)
|
self.action_save.setMenu(self.save_menu)
|
||||||
|
|
||||||
cm = QMenu()
|
|
||||||
cm.addAction(_('Convert individually'), partial(self.convert_ebook,
|
|
||||||
False, bulk=False))
|
|
||||||
cm.addAction(_('Bulk convert'),
|
|
||||||
partial(self.convert_ebook, False, bulk=True))
|
|
||||||
cm.addSeparator()
|
|
||||||
ac = cm.addAction(
|
|
||||||
_('Create catalog of books in your calibre library'))
|
|
||||||
ac.triggered.connect(self.generate_catalog)
|
|
||||||
self.action_convert.setMenu(cm)
|
|
||||||
self.action_convert.triggered.connect(self.convert_ebook)
|
|
||||||
self.convert_menu = cm
|
|
||||||
|
|
||||||
pm = QMenu()
|
pm = QMenu()
|
||||||
pm.addAction(QIcon(I('config.svg')), _('Preferences'), self.do_config)
|
pm.addAction(QIcon(I('config.svg')), _('Preferences'), self.do_config)
|
||||||
|
@ -150,7 +150,6 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, # {{{
|
|||||||
self.get_metadata = GetMetadata()
|
self.get_metadata = GetMetadata()
|
||||||
self.upload_memory = {}
|
self.upload_memory = {}
|
||||||
self.delete_memory = {}
|
self.delete_memory = {}
|
||||||
self.conversion_jobs = {}
|
|
||||||
self.persistent_files = []
|
self.persistent_files = []
|
||||||
self.metadata_dialogs = []
|
self.metadata_dialogs = []
|
||||||
self.default_thumbnail = None
|
self.default_thumbnail = None
|
||||||
|
Loading…
x
Reference in New Issue
Block a user