mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Migrated Fetch News
This commit is contained in:
parent
d9ac3a0e0a
commit
5c9ec13a29
@ -605,5 +605,10 @@ class ActionView(InterfaceActionBase):
|
||||
name = 'View'
|
||||
actual_plugin = 'calibre.gui2.actions.view:ViewAction'
|
||||
|
||||
class ActionFetchNews(InterfaceActionBase):
|
||||
name = 'Fetch News'
|
||||
actual_plugin = 'calibre.gui2.actions.fetch_news:FetchNewsAction'
|
||||
|
||||
plugins += [ActionAdd, ActionFetchAnnotations, ActionGenerateCatalog,
|
||||
ActionConvert, ActionDelete, ActionEditMetadata, ActionView]
|
||||
ActionConvert, ActionDelete, ActionEditMetadata, ActionView,
|
||||
ActionFetchNews]
|
||||
|
@ -8,8 +8,12 @@ __docformat__ = 'restructuredtext en'
|
||||
from calibre.gui2 import Dispatcher
|
||||
from calibre.gui2.tools import fetch_scheduled_recipe
|
||||
from calibre.utils.config import dynamic
|
||||
from calibre.gui2.actions import InterfaceAction
|
||||
|
||||
class FetchNewsAction(object):
|
||||
class FetchNewsAction(InterfaceAction):
|
||||
|
||||
name = 'Fetch News'
|
||||
action_spec = (_('Fetch news'), 'news.svg', None, _('F'))
|
||||
|
||||
def location_selected(self, loc):
|
||||
enabled = loc == 'library'
|
||||
@ -18,10 +22,15 @@ class FetchNewsAction(object):
|
||||
def genesis(self):
|
||||
self.conversion_jobs = {}
|
||||
|
||||
def connect_scheduler(self, scheduler):
|
||||
self.qaction.setMenu(scheduler.news_menu)
|
||||
self.qaction.triggered.connect(
|
||||
scheduler.show_dialog)
|
||||
|
||||
def download_scheduled_recipe(self, arg):
|
||||
func, args, desc, fmt, temp_files = \
|
||||
fetch_scheduled_recipe(arg)
|
||||
job = self.job_manager.run_job(
|
||||
job = self.gui.job_manager.run_job(
|
||||
Dispatcher(self.scheduled_recipe_fetched), func, args=args,
|
||||
description=desc)
|
||||
self.conversion_jobs[job] = (temp_files, fmt, arg)
|
||||
@ -31,16 +40,16 @@ class FetchNewsAction(object):
|
||||
temp_files, fmt, arg = self.conversion_jobs.pop(job)
|
||||
pt = temp_files[0]
|
||||
if job.failed:
|
||||
self.scheduler.recipe_download_failed(arg)
|
||||
return self.job_exception(job)
|
||||
self.gui.scheduler.recipe_download_failed(arg)
|
||||
return self.gui.job_exception(job)
|
||||
id = self.gui.library_view.model().add_news(pt.name, arg)
|
||||
self.gui.library_view.model().reset()
|
||||
sync = dynamic.get('news_to_be_synced', set([]))
|
||||
sync.add(id)
|
||||
dynamic.set('news_to_be_synced', sync)
|
||||
self.scheduler.recipe_downloaded(arg)
|
||||
self.gui.scheduler.recipe_downloaded(arg)
|
||||
self.gui.status_bar.show_message(arg['title'] + _(' fetched.'), 3000)
|
||||
self.email_news(id)
|
||||
self.sync_news()
|
||||
self.gui.email_news(id)
|
||||
self.gui.sync_news()
|
||||
|
||||
|
||||
|
@ -427,7 +427,8 @@ class MainWindowMixin(object):
|
||||
def init_scheduler(self, db):
|
||||
self.scheduler = Scheduler(self, db)
|
||||
self.scheduler.start_recipe_fetch.connect(
|
||||
self.download_scheduled_recipe, type=Qt.QueuedConnection)
|
||||
self.iactions['Fetch News'].download_scheduled_recipe, type=Qt.QueuedConnection)
|
||||
self.iactions['Fetch News'].connect_scheduler(self.scheduler)
|
||||
|
||||
def read_toolbar_settings(self):
|
||||
pass
|
||||
@ -462,7 +463,6 @@ class MainWindowMixin(object):
|
||||
ac(-1, 4, 0, 'sync', _('Send to device'), 'sync.svg')
|
||||
ac(5, 5, 3, 'choose_library', _('%d books')%0, 'lt.png',
|
||||
tooltip=_('Choose calibre library to work with'))
|
||||
ac(6, 6, 3, 'news', _('Fetch news'), 'news.svg', _('F'))
|
||||
ac(7, 7, 0, 'save', _('Save to disk'), 'save.svg', _('S'))
|
||||
ac(8, 8, 0, 'conn_share', _('Connect/share'), 'connect_share.svg')
|
||||
ac(9, 9, 3, 'del', _('Remove books'), 'trash.svg', _('Del'))
|
||||
@ -482,9 +482,6 @@ class MainWindowMixin(object):
|
||||
ac(-1, -1, 0, 'books_with_the_same_tags', _('Books with the same tags'),
|
||||
'tags.svg')
|
||||
|
||||
self.action_news.setMenu(self.scheduler.news_menu)
|
||||
self.action_news.triggered.connect(
|
||||
self.scheduler.show_dialog)
|
||||
self.share_conn_menu = ShareConnMenu(self)
|
||||
self.share_conn_menu.toggle_server.connect(self.toggle_content_server)
|
||||
self.share_conn_menu.config_email.connect(partial(self.do_config,
|
||||
|
@ -256,6 +256,7 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, # {{{
|
||||
|
||||
self.keyboard_interrupt.connect(self.quit, type=Qt.QueuedConnection)
|
||||
|
||||
|
||||
self.read_settings()
|
||||
self.finalize_layout()
|
||||
self.donate_button.start_animation()
|
||||
|
Loading…
x
Reference in New Issue
Block a user