Пример #1
0
    def genesis(self):
        icon_resources = self.load_resources(PLUGIN_ICONS)
        set_plugin_icon_resources(self.name, icon_resources)

        self.qaction.setIcon(get_icon(PLUGIN_ICONS[0]))
        self.old_actions_unique_map = {}

        base_plugin_object = self.interface_action_base_plugin
        do_user_config = base_plugin_object.do_user_config

        self.menu = QMenu(self.gui)
        self.qaction.setMenu(self.menu)
Пример #2
0
    def capture_cover(self):
        from calibre.gui2.ui import get_gui
        self.qaction.setIcon(get_icon('images/camera_working.png'))
        rows = self.gui.library_view.selectionModel().selectedRows()
        if not rows or len(rows) == 0:
            return error_dialog(self.gui,
                                'Cannot update metadata',
                                'No books selected',
                                show=True)
        
        # Map the rows to book ids
        ids = list(map(self.gui.library_view.model().id, rows))
        get_gui().library_view.model().books_added(len(ids))
        local_cover = '/tmp/kvr.jpg'
        urllib.urlretrieve("{0}/capture".format(prefs['gphoto2_server']),
                                                    local_cover)
        for book_id in ids:
            get_gui().current_db.new_api.set_cover({book_id: open(local_cover)})

        get_gui().library_view.model().books_deleted()
        get_gui().db_images.reset()
        get_gui().tags_view.recount()
        self.qaction.setIcon(get_icon('images/camera.png'))