mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
minor bug fixes.
This commit is contained in:
parent
1495b8c843
commit
361a841062
@ -13,7 +13,7 @@
|
|||||||
## with this program; if not, write to the Free Software Foundation, Inc.,
|
## with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
''' E-book management software'''
|
''' E-book management software'''
|
||||||
__version__ = "0.3.89"
|
__version__ = "0.3.90"
|
||||||
__docformat__ = "epytext"
|
__docformat__ = "epytext"
|
||||||
__author__ = "Kovid Goyal <kovid@kovidgoyal.net>"
|
__author__ = "Kovid Goyal <kovid@kovidgoyal.net>"
|
||||||
__appname__ = 'libprs500'
|
__appname__ = 'libprs500'
|
||||||
|
@ -22,7 +22,7 @@ from libprs500 import __author__
|
|||||||
NONE = QVariant() #: Null value to return from the data function of item models
|
NONE = QVariant() #: Null value to return from the data function of item models
|
||||||
|
|
||||||
BOOK_EXTENSIONS = ['lrf', 'lrx', 'rar', 'zip', 'rtf', 'lit', 'txt', 'htm',
|
BOOK_EXTENSIONS = ['lrf', 'lrx', 'rar', 'zip', 'rtf', 'lit', 'txt', 'htm',
|
||||||
'html', 'xhtml', 'epub',]
|
'html', 'xhtml', 'epub', 'pdf']
|
||||||
|
|
||||||
def extension(path):
|
def extension(path):
|
||||||
return os.path.splitext(path)[1][1:].lower()
|
return os.path.splitext(path)[1][1:].lower()
|
||||||
@ -89,7 +89,7 @@ class FileIconProvider(QFileIconProvider):
|
|||||||
self.icons = {}
|
self.icons = {}
|
||||||
for key in self.__class__.ICONS.keys():
|
for key in self.__class__.ICONS.keys():
|
||||||
self.icons[key] = ':/images/mimetypes/'+self.__class__.ICONS[key]+'.svg'
|
self.icons[key] = ':/images/mimetypes/'+self.__class__.ICONS[key]+'.svg'
|
||||||
for i in ('dir', 'default'):
|
for i in ('dir', 'default', 'zero'):
|
||||||
self.icons[i] = QIcon(self.icons[i])
|
self.icons[i] = QIcon(self.icons[i])
|
||||||
|
|
||||||
def key_from_ext(self, ext):
|
def key_from_ext(self, ext):
|
||||||
@ -144,7 +144,7 @@ def file_icon_provider():
|
|||||||
global _file_icon_provider
|
global _file_icon_provider
|
||||||
return _file_icon_provider
|
return _file_icon_provider
|
||||||
|
|
||||||
class FileDialog(QFileDialog):
|
class FileDialog(QObject):
|
||||||
def __init__(self, title='Choose Files',
|
def __init__(self, title='Choose Files',
|
||||||
filters=[],
|
filters=[],
|
||||||
add_all_files_filter=True,
|
add_all_files_filter=True,
|
||||||
@ -153,14 +153,15 @@ class FileDialog(QFileDialog):
|
|||||||
name = '',
|
name = '',
|
||||||
mode = QFileDialog.ExistingFiles,
|
mode = QFileDialog.ExistingFiles,
|
||||||
):
|
):
|
||||||
|
QObject.__init__(self)
|
||||||
initialize_file_icon_provider()
|
initialize_file_icon_provider()
|
||||||
QFileDialog.__init__(self, parent)
|
self.fd = QFileDialog(parent)
|
||||||
self.setIconProvider(_file_icon_provider)
|
self.fd.setIconProvider(_file_icon_provider)
|
||||||
self.setModal(modal)
|
self.fd.setModal(modal)
|
||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
state = settings.value(name, QVariant()).toByteArray()
|
state = settings.value(name, QVariant()).toByteArray()
|
||||||
if not self.restoreState(state):
|
if not self.fd.restoreState(state):
|
||||||
self.setDirectory(os.path.expanduser('~'))
|
self.fd.setDirectory(os.path.expanduser('~'))
|
||||||
self.dialog_name = name
|
self.dialog_name = name
|
||||||
ftext = ''
|
ftext = ''
|
||||||
if filters:
|
if filters:
|
||||||
@ -170,16 +171,18 @@ class FileDialog(QFileDialog):
|
|||||||
ftext += '%s (%s);;'%(text, ' '.join(extensions))
|
ftext += '%s (%s);;'%(text, ' '.join(extensions))
|
||||||
if add_all_files_filter or not ftext:
|
if add_all_files_filter or not ftext:
|
||||||
ftext += 'All files (*)'
|
ftext += 'All files (*)'
|
||||||
self.setFilter(ftext)
|
self.fd.setFilter(ftext)
|
||||||
self.setWindowTitle(title)
|
self.fd.setWindowTitle(title)
|
||||||
QObject.connect(self, SIGNAL('accepted()'), self.save_dir)
|
QObject.connect(self.fd, SIGNAL('accepted()'), self.save_dir)
|
||||||
|
self.exec_ = self.fd.exec_
|
||||||
|
self.show = self.fd.show
|
||||||
|
|
||||||
def get_files(self):
|
def get_files(self):
|
||||||
return tuple(os.path.abspath(qstring_to_unicode(i)) for i in self.selectedFiles())
|
return tuple(os.path.abspath(qstring_to_unicode(i)) for i in self.fd.selectedFiles())
|
||||||
|
|
||||||
def save_dir(self):
|
def save_dir(self):
|
||||||
settings = QSettings()
|
settings = QSettings()
|
||||||
settings.setValue(self.dialog_name, QVariant(self.saveState()))
|
settings.setValue(self.dialog_name, QVariant(self.fd.saveState()))
|
||||||
|
|
||||||
|
|
||||||
def choose_files(window, name, title,
|
def choose_files(window, name, title,
|
||||||
|
@ -438,8 +438,7 @@ class Main(QObject, Ui_MainWindow):
|
|||||||
|
|
||||||
def wrap_traceback(self, tb):
|
def wrap_traceback(self, tb):
|
||||||
tb = unicode(tb, 'utf8', 'replace')
|
tb = unicode(tb, 'utf8', 'replace')
|
||||||
if iswindows or isosx:
|
tb = '\n'.join(self.tb_wrapper.wrap(tb))
|
||||||
tb = '\n'.join(self.tb_wrapper.wrap(tb))
|
|
||||||
return tb
|
return tb
|
||||||
|
|
||||||
def device_job_exception(self, id, description, exception, formatted_traceback):
|
def device_job_exception(self, id, description, exception, formatted_traceback):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user