mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fixes to the new metadata dialog
This commit is contained in:
parent
75f61b44a5
commit
23251c969d
@ -1,5 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||
from __future__ import (unicode_literals, division, absolute_import,
|
||||
print_function)
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
@ -7,10 +9,10 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
import textwrap, re, os
|
||||
|
||||
from PyQt4.Qt import Qt, QDateEdit, QDate, \
|
||||
QIcon, QToolButton, QWidget, QLabel, QGridLayout, \
|
||||
QDoubleSpinBox, QListWidgetItem, QSize, QPixmap, \
|
||||
QPushButton, QSpinBox, QLineEdit
|
||||
from PyQt4.Qt import (Qt, QDateEdit, QDate,
|
||||
QIcon, QToolButton, QWidget, QLabel, QGridLayout,
|
||||
QDoubleSpinBox, QListWidgetItem, QSize, QPixmap,
|
||||
QPushButton, QSpinBox, QLineEdit, QSizePolicy)
|
||||
|
||||
from calibre.gui2.widgets import EnLineEdit, FormatList, ImageView
|
||||
from calibre.gui2.complete import MultiCompleteLineEdit, MultiCompleteComboBox
|
||||
@ -22,7 +24,7 @@ from calibre.ebooks.metadata.meta import get_metadata
|
||||
from calibre.gui2 import file_icon_provider, UNDEFINED_QDATE, UNDEFINED_DATE, \
|
||||
choose_files, error_dialog, choose_images, question_dialog
|
||||
from calibre.utils.date import local_tz, qt_to_dt
|
||||
from calibre import strftime
|
||||
from calibre import strftime, fit_image
|
||||
from calibre.ebooks import BOOK_EXTENSIONS
|
||||
from calibre.customize.ui import run_plugins_on_import
|
||||
from calibre.utils.date import utcfromtimestamp
|
||||
@ -480,6 +482,7 @@ class FormatsManager(QWidget): # {{{
|
||||
|
||||
def initialize(self, db, id_):
|
||||
self.changed = False
|
||||
self.formats.clear()
|
||||
exts = db.formats(id_, index_is_id=True)
|
||||
self.original_val = set([])
|
||||
if exts:
|
||||
@ -638,6 +641,23 @@ class Cover(ImageView): # {{{
|
||||
self.trim_cover_button, self.download_cover_button,
|
||||
self.generate_cover_button]
|
||||
|
||||
self.frame_size = (300, 400)
|
||||
self.setSizePolicy(QSizePolicy(QSizePolicy.Preferred,
|
||||
QSizePolicy.Preferred))
|
||||
|
||||
def frame_resized(self, ev):
|
||||
sz = ev.size()
|
||||
self.frame_size = (sz.width()//3, sz.height())
|
||||
|
||||
def sizeHint(self):
|
||||
sz = ImageView.sizeHint(self)
|
||||
w, h = sz.width(), sz.height()
|
||||
resized, nw, nh = fit_image(w, h, self.frame_size[0],
|
||||
self.frame_size[1])
|
||||
if resized:
|
||||
sz = QSize(nw, nh)
|
||||
return sz
|
||||
|
||||
def select_cover(self, *args):
|
||||
files = choose_images(self, 'change cover dialog',
|
||||
_('Choose cover for ') +
|
||||
|
@ -1,5 +1,7 @@
|
||||
#!/usr/bin/env python
|
||||
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
|
||||
from __future__ import (unicode_literals, division, absolute_import,
|
||||
print_function)
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2011, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
@ -8,10 +10,10 @@ __docformat__ = 'restructuredtext en'
|
||||
import os
|
||||
from functools import partial
|
||||
|
||||
from PyQt4.Qt import Qt, QVBoxLayout, QHBoxLayout, QWidget, QPushButton, \
|
||||
QGridLayout, pyqtSignal, QDialogButtonBox, QScrollArea, QFont, \
|
||||
QTabWidget, QIcon, QToolButton, QSplitter, QGroupBox, QSpacerItem, \
|
||||
QSizePolicy, QPalette, QFrame, QSize, QKeySequence
|
||||
from PyQt4.Qt import (Qt, QVBoxLayout, QHBoxLayout, QWidget, QPushButton,
|
||||
QGridLayout, pyqtSignal, QDialogButtonBox, QScrollArea, QFont,
|
||||
QTabWidget, QIcon, QToolButton, QSplitter, QGroupBox, QSpacerItem,
|
||||
QSizePolicy, QPalette, QFrame, QSize, QKeySequence)
|
||||
|
||||
from calibre.ebooks.metadata import authors_to_string, string_to_authors
|
||||
from calibre.gui2 import ResizableDialog, error_dialog, gprefs
|
||||
@ -385,6 +387,14 @@ class MetadataSingleDialogBase(ResizableDialog):
|
||||
disconnect(x.clicked)
|
||||
# }}}
|
||||
|
||||
class Splitter(QSplitter):
|
||||
|
||||
frame_resized = pyqtSignal(object)
|
||||
|
||||
def resizeEvent(self, ev):
|
||||
self.frame_resized.emit(ev)
|
||||
return QSplitter.resizeEvent(self, ev)
|
||||
|
||||
class MetadataSingleDialog(MetadataSingleDialogBase): # {{{
|
||||
|
||||
def do_layout(self):
|
||||
@ -437,8 +447,9 @@ class MetadataSingleDialog(MetadataSingleDialogBase): # {{{
|
||||
|
||||
tl.addWidget(self.formats_manager, 0, 6, 3, 1)
|
||||
|
||||
self.splitter = QSplitter(Qt.Horizontal, self)
|
||||
self.splitter = Splitter(Qt.Horizontal, self)
|
||||
self.splitter.addWidget(self.cover)
|
||||
self.splitter.frame_resized.connect(self.cover.frame_resized)
|
||||
l.addWidget(self.splitter)
|
||||
self.tabs[0].gb = gb = QGroupBox(_('Change cover'), self)
|
||||
gb.l = l = QGridLayout()
|
||||
|
@ -312,6 +312,7 @@ class ImageView(QWidget, ImageDropMixin):
|
||||
p.setPen(pen)
|
||||
if self.draw_border:
|
||||
p.drawRect(target)
|
||||
#p.drawRect(self.rect())
|
||||
p.end()
|
||||
|
||||
class CoverView(QGraphicsView, ImageDropMixin):
|
||||
|
Loading…
x
Reference in New Issue
Block a user