mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Windows: Fix drag and drop of long paths onto book list and book details panels
This commit is contained in:
parent
758f3e1452
commit
687f9f056e
@ -6,20 +6,24 @@ __license__ = 'GPL v3'
|
||||
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import posixpath, os, re
|
||||
import os
|
||||
import posixpath
|
||||
import re
|
||||
from PyQt5.Qt import (
|
||||
QDialog, QDialogButtonBox, QImageReader, QLabel, QPixmap, QProgressBar, Qt,
|
||||
QTimer, QUrl, QVBoxLayout
|
||||
)
|
||||
from threading import Thread
|
||||
|
||||
from PyQt5.Qt import QPixmap, Qt, QDialog, QLabel, QVBoxLayout, \
|
||||
QDialogButtonBox, QProgressBar, QTimer, QUrl, QImageReader
|
||||
|
||||
from calibre.constants import DEBUG
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
from calibre import browser, as_unicode, prints
|
||||
from calibre import as_unicode, browser, prints
|
||||
from calibre.constants import DEBUG, iswindows
|
||||
from calibre.gui2 import error_dialog
|
||||
from calibre.ptempfile import PersistentTemporaryFile
|
||||
from calibre.utils.filenames import make_long_path_useable
|
||||
from calibre.utils.imghdr import what
|
||||
from polyglot.builtins import unicode_type
|
||||
from polyglot.queue import Empty, Queue
|
||||
from polyglot.urllib import unquote, urlparse
|
||||
from polyglot.queue import Queue, Empty
|
||||
|
||||
|
||||
def image_extensions():
|
||||
@ -163,6 +167,10 @@ def urls_from_md(md):
|
||||
def path_from_qurl(qurl, allow_remote=False):
|
||||
lf = qurl.toLocalFile()
|
||||
if lf:
|
||||
if iswindows:
|
||||
from calibre_extensions.winutil import get_long_path_name
|
||||
lf = get_long_path_name(lf)
|
||||
lf = make_long_path_useable(lf)
|
||||
return lf
|
||||
if not allow_remote:
|
||||
return ''
|
||||
|
@ -5,29 +5,33 @@
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
import itertools, operator, os, math
|
||||
from threading import Event, Thread
|
||||
import itertools
|
||||
import math
|
||||
import operator
|
||||
import os
|
||||
from functools import wraps
|
||||
from textwrap import wrap
|
||||
|
||||
from PyQt5.Qt import (
|
||||
QListView, QSize, QStyledItemDelegate, QModelIndex, Qt, QImage, pyqtSignal,
|
||||
QTimer, QColor, QItemSelection, QPixmap, QApplication,
|
||||
QMimeData, QUrl, QDrag, QPoint, QPainter, QRect, pyqtProperty, QEvent,
|
||||
QPropertyAnimation, QEasingCurve, pyqtSlot, QHelpEvent, QAbstractItemView,
|
||||
QStyleOptionViewItem, QToolTip, QByteArray, QBuffer, qRed, qGreen,
|
||||
qBlue, QItemSelectionModel, QIcon, QFont, QTableView, QTreeView)
|
||||
QAbstractItemView, QApplication, QBuffer, QByteArray, QColor, QDrag,
|
||||
QEasingCurve, QEvent, QFont, QHelpEvent, QIcon, QImage, QItemSelection,
|
||||
QItemSelectionModel, QListView, QMimeData, QModelIndex, QPainter, QPixmap,
|
||||
QPoint, QPropertyAnimation, QRect, QSize, QStyledItemDelegate,
|
||||
QStyleOptionViewItem, Qt, QTableView, QTimer, QToolTip, QTreeView, QUrl,
|
||||
pyqtProperty, pyqtSignal, pyqtSlot, qBlue, qGreen, qRed
|
||||
)
|
||||
from textwrap import wrap
|
||||
from threading import Event, Thread
|
||||
|
||||
from calibre import fit_image, prints, prepare_string_for_xml, human_readable
|
||||
from calibre import fit_image, human_readable, prepare_string_for_xml, prints
|
||||
from calibre.constants import DEBUG, config_dir, islinux
|
||||
from calibre.gui2.pin_columns import PinContainer
|
||||
from calibre.ebooks.metadata import fmt_sidx, rating_to_stars
|
||||
from calibre.utils import join_with_timeout
|
||||
from calibre.gui2 import gprefs, config, rating_font, empty_index
|
||||
from calibre.gui2 import config, empty_index, gprefs, rating_font
|
||||
from calibre.gui2.dnd import path_from_qurl
|
||||
from calibre.gui2.gestures import GestureManager
|
||||
from calibre.gui2.library.caches import CoverCache, ThumbnailCache
|
||||
from calibre.gui2.pin_columns import PinContainer
|
||||
from calibre.utils import join_with_timeout
|
||||
from calibre.utils.config import prefs, tweaks
|
||||
from polyglot.builtins import itervalues, unicode_type, range
|
||||
from polyglot.builtins import itervalues, range, unicode_type
|
||||
from polyglot.queue import LifoQueue
|
||||
|
||||
CM_TO_INCH = 0.393701
|
||||
@ -246,10 +250,9 @@ def paths_from_event(self, event):
|
||||
and represent files with extensions.
|
||||
'''
|
||||
md = event.mimeData()
|
||||
if md.hasFormat('text/uri-list') and not \
|
||||
md.hasFormat('application/calibre+from_library'):
|
||||
urls = [unicode_type(u.toLocalFile()) for u in md.urls()]
|
||||
return [u for u in urls if os.path.splitext(u)[1] and os.path.exists(u)]
|
||||
if md.hasFormat('text/uri-list') and not md.hasFormat('application/calibre+from_library'):
|
||||
urls = map(path_from_qurl, md.urls())
|
||||
return [u for u in urls if u and os.path.splitext(u)[1] and os.path.exists(u)]
|
||||
|
||||
|
||||
def setup_dnd_interface(cls_or_self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user