mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Allow d'nd to the convert books action
This commit is contained in:
parent
e43616c654
commit
ab44bb5064
@ -8,7 +8,7 @@ __docformat__ = 'restructuredtext en'
|
|||||||
import os
|
import os
|
||||||
from functools import partial
|
from functools import partial
|
||||||
|
|
||||||
from PyQt4.Qt import QModelIndex
|
from PyQt4.Qt import QModelIndex, QTimer
|
||||||
|
|
||||||
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
|
||||||
@ -24,6 +24,31 @@ class ConvertAction(InterfaceAction):
|
|||||||
action_type = 'current'
|
action_type = 'current'
|
||||||
action_add_menu = True
|
action_add_menu = True
|
||||||
|
|
||||||
|
accepts_drops = True
|
||||||
|
|
||||||
|
def accept_enter_event(self, event, mime_data):
|
||||||
|
if mime_data.hasFormat("application/calibre+from_library"):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def accept_drag_move_event(self, event, mime_data):
|
||||||
|
if mime_data.hasFormat("application/calibre+from_library"):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def drop_event(self, event, mime_data):
|
||||||
|
mime = 'application/calibre+from_library'
|
||||||
|
if mime_data.hasFormat(mime):
|
||||||
|
self.dropped_ids = tuple(map(int, str(mime_data.data(mime)).split()))
|
||||||
|
QTimer.singleShot(1, self.do_drop)
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
def do_drop(self):
|
||||||
|
book_ids = self.dropped_ids
|
||||||
|
del self.dropped_ids
|
||||||
|
self.do_convert(book_ids)
|
||||||
|
|
||||||
def genesis(self):
|
def genesis(self):
|
||||||
m = self.convert_menu = self.qaction.menu()
|
m = self.convert_menu = self.qaction.menu()
|
||||||
cm = partial(self.create_menu_action, self.convert_menu)
|
cm = partial(self.create_menu_action, self.convert_menu)
|
||||||
@ -112,6 +137,9 @@ class ConvertAction(InterfaceAction):
|
|||||||
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
|
||||||
|
self.do_convert(book_ids, bulk=bulk)
|
||||||
|
|
||||||
|
def do_convert(self, book_ids, bulk=None):
|
||||||
previous = self.gui.library_view.currentIndex()
|
previous = self.gui.library_view.currentIndex()
|
||||||
rows = [x.row() for x in \
|
rows = [x.row() for x in \
|
||||||
self.gui.library_view.selectionModel().selectedRows()]
|
self.gui.library_view.selectionModel().selectedRows()]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user