mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Book details popup window: Allow dropping of files to add formats/set the cover just as for the book details panel. Fixes #2059162 [Book Details: Unable to drag and drop file onto book details window](https://bugs.launchpad.net/calibre/+bug/2059162)
This commit is contained in:
parent
1fbec2919f
commit
82dcd5d946
@ -1271,34 +1271,14 @@ class DetailsLayout(QSplitter): # {{{
|
||||
cover.do_layout()
|
||||
# }}}
|
||||
|
||||
# Drag 'n drop {{{
|
||||
|
||||
class BookDetails(DetailsLayout): # {{{
|
||||
|
||||
show_book_info = pyqtSignal()
|
||||
open_containing_folder = pyqtSignal(int)
|
||||
open_data_folder = pyqtSignal(int)
|
||||
view_specific_format = pyqtSignal(int, object)
|
||||
search_requested = pyqtSignal(object, object)
|
||||
remove_specific_format = pyqtSignal(int, object)
|
||||
remove_metadata_item = pyqtSignal(int, object, object)
|
||||
save_specific_format = pyqtSignal(int, object)
|
||||
restore_specific_format = pyqtSignal(int, object)
|
||||
set_cover_from_format = pyqtSignal(int, object)
|
||||
compare_specific_format = pyqtSignal(int, object)
|
||||
copy_link = pyqtSignal(object)
|
||||
remote_file_dropped = pyqtSignal(object, object)
|
||||
class DropMixin:
|
||||
files_dropped = pyqtSignal(object, object)
|
||||
cover_changed = pyqtSignal(object, object)
|
||||
open_cover_with = pyqtSignal(object, object)
|
||||
cover_removed = pyqtSignal(object)
|
||||
view_device_book = pyqtSignal(object)
|
||||
manage_category = pyqtSignal(object, object)
|
||||
edit_identifiers = pyqtSignal()
|
||||
open_fmt_with = pyqtSignal(int, object, object)
|
||||
edit_book = pyqtSignal(int, object)
|
||||
find_in_tag_browser = pyqtSignal(object, object)
|
||||
remote_file_dropped = pyqtSignal(object, object)
|
||||
|
||||
# Drag 'n drop {{{
|
||||
def __init__(self):
|
||||
self.setAcceptDrops(True)
|
||||
|
||||
def dragEnterEvent(self, event):
|
||||
md = event.mimeData()
|
||||
@ -1344,10 +1324,35 @@ class BookDetails(DetailsLayout): # {{{
|
||||
|
||||
# }}}
|
||||
|
||||
|
||||
class BookDetails(DetailsLayout, DropMixin): # {{{
|
||||
|
||||
show_book_info = pyqtSignal()
|
||||
open_containing_folder = pyqtSignal(int)
|
||||
open_data_folder = pyqtSignal(int)
|
||||
view_specific_format = pyqtSignal(int, object)
|
||||
search_requested = pyqtSignal(object, object)
|
||||
remove_specific_format = pyqtSignal(int, object)
|
||||
remove_metadata_item = pyqtSignal(int, object, object)
|
||||
save_specific_format = pyqtSignal(int, object)
|
||||
restore_specific_format = pyqtSignal(int, object)
|
||||
set_cover_from_format = pyqtSignal(int, object)
|
||||
compare_specific_format = pyqtSignal(int, object)
|
||||
copy_link = pyqtSignal(object)
|
||||
cover_changed = pyqtSignal(object, object)
|
||||
open_cover_with = pyqtSignal(object, object)
|
||||
cover_removed = pyqtSignal(object)
|
||||
view_device_book = pyqtSignal(object)
|
||||
manage_category = pyqtSignal(object, object)
|
||||
edit_identifiers = pyqtSignal()
|
||||
open_fmt_with = pyqtSignal(int, object, object)
|
||||
edit_book = pyqtSignal(int, object)
|
||||
find_in_tag_browser = pyqtSignal(object, object)
|
||||
|
||||
def __init__(self, vertical, parent=None):
|
||||
super().__init__(vertical, parent)
|
||||
DropMixin.__init__(self)
|
||||
self.last_data = {}
|
||||
self.setAcceptDrops(True)
|
||||
self._layout = self
|
||||
self.current_path = ''
|
||||
|
||||
|
@ -36,7 +36,7 @@ from qt.core import (
|
||||
from calibre import fit_image
|
||||
from calibre.db.constants import RESOURCE_URL_SCHEME
|
||||
from calibre.gui2 import BOOK_DETAILS_DISPLAY_DEBOUNCE_DELAY, NO_URL_FORMATTING, gprefs
|
||||
from calibre.gui2.book_details import create_open_cover_with_menu, details_context_menu_event, render_html, resolved_css, set_html
|
||||
from calibre.gui2.book_details import DropMixin, create_open_cover_with_menu, details_context_menu_event, render_html, resolved_css, set_html
|
||||
from calibre.gui2.ui import get_gui
|
||||
from calibre.gui2.widgets import CoverView
|
||||
from calibre.gui2.widgets2 import Dialog, HTMLDisplay
|
||||
@ -169,7 +169,7 @@ class DialogNumbers(IntEnum):
|
||||
DetailsLink = 2
|
||||
|
||||
|
||||
class BookInfo(QDialog):
|
||||
class BookInfo(QDialog, DropMixin):
|
||||
|
||||
closed = pyqtSignal(object)
|
||||
open_cover_with = pyqtSignal(object, object)
|
||||
@ -177,6 +177,9 @@ class BookInfo(QDialog):
|
||||
def __init__(self, parent, view, row, link_delegate, dialog_number=None,
|
||||
library_id=None, library_path=None, book_id=None):
|
||||
QDialog.__init__(self, parent)
|
||||
DropMixin.__init__(self)
|
||||
self.files_dropped.connect(self.on_files_dropped)
|
||||
self.remote_file_dropped.connect(self.on_remote_file_dropped)
|
||||
self.dialog_number = dialog_number
|
||||
self.library_id = library_id
|
||||
self.marked = None
|
||||
@ -185,6 +188,7 @@ class BookInfo(QDialog):
|
||||
self._l = l = QVBoxLayout(self)
|
||||
self.setLayout(l)
|
||||
l.addWidget(self.splitter)
|
||||
self.setAcceptDrops(True)
|
||||
|
||||
self.cover = Cover(self, show_size=gprefs['bd_overlay_cover_size'])
|
||||
self.cover.copy_to_clipboard_requested.connect(self.copy_cover_to_clipboard)
|
||||
@ -297,6 +301,14 @@ class BookInfo(QDialog):
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
def on_files_dropped(self, event, paths):
|
||||
gui = get_gui()
|
||||
gui.iactions['Add Books'].files_dropped_on_book(event, paths)
|
||||
|
||||
def on_remote_file_dropped(self, event, url):
|
||||
gui = get_gui()
|
||||
gui.iactions['Add Books'].remote_file_dropped_on_book(event, url)
|
||||
|
||||
def geometry_string(self, txt):
|
||||
if self.dialog_number is None or self.dialog_number == DialogNumbers.Slaved:
|
||||
return txt
|
||||
|
Loading…
x
Reference in New Issue
Block a user