mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Implement Drag&Drop support for dragging files from the operating system to the library
This commit is contained in:
parent
086d4c6d44
commit
1c24785e68
@ -440,9 +440,11 @@ class BooksView(TableView):
|
|||||||
|
|
||||||
|
|
||||||
def dragEnterEvent(self, event):
|
def dragEnterEvent(self, event):
|
||||||
if int(event.possibleActions() & Qt.CopyAction) != 1:
|
if int(event.possibleActions() & Qt.CopyAction) + \
|
||||||
|
int(event.possibleActions() & Qt.MoveAction) == 0:
|
||||||
return
|
return
|
||||||
paths = self.paths_from_event(event)
|
paths = self.paths_from_event(event)
|
||||||
|
|
||||||
if paths:
|
if paths:
|
||||||
event.acceptProposedAction()
|
event.acceptProposedAction()
|
||||||
|
|
||||||
|
@ -179,6 +179,8 @@ class Main(MainWindow, Ui_MainWindow):
|
|||||||
|
|
||||||
####################### Library view ########################
|
####################### Library view ########################
|
||||||
self.library_view.set_database(self.database_path)
|
self.library_view.set_database(self.database_path)
|
||||||
|
QObject.connect(self.library_view, SIGNAL('files_dropped(PyQt_PyObject)'),
|
||||||
|
self.files_dropped)
|
||||||
for func, target in [
|
for func, target in [
|
||||||
('connect_to_search_box', self.search),
|
('connect_to_search_box', self.search),
|
||||||
('connect_to_book_display', self.status_bar.book_info.show_data),
|
('connect_to_book_display', self.status_bar.book_info.show_data),
|
||||||
@ -335,7 +337,9 @@ class Main(MainWindow, Ui_MainWindow):
|
|||||||
'''
|
'''
|
||||||
self.add_recursive(False)
|
self.add_recursive(False)
|
||||||
|
|
||||||
|
def files_dropped(self, paths):
|
||||||
|
to_device = self.stack.currentIndex() != 0
|
||||||
|
self._add_books(paths, to_device)
|
||||||
|
|
||||||
|
|
||||||
def add_books(self, checked):
|
def add_books(self, checked):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user