mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Allow the formats list to use less height
Also remove some wasted margins in various sub layouts
This commit is contained in:
parent
70a88ca40f
commit
0c77d88404
@ -811,6 +811,10 @@ class FormatList(_FormatList):
|
|||||||
_FormatList.__init__(self, parent)
|
_FormatList.__init__(self, parent)
|
||||||
self.setContextMenuPolicy(Qt.ContextMenuPolicy.DefaultContextMenu)
|
self.setContextMenuPolicy(Qt.ContextMenuPolicy.DefaultContextMenu)
|
||||||
|
|
||||||
|
def sizeHint(self):
|
||||||
|
sz = self.iconSize()
|
||||||
|
return QSize(sz.width() * 7, sz.height() * 3)
|
||||||
|
|
||||||
def contextMenuEvent(self, event):
|
def contextMenuEvent(self, event):
|
||||||
item = self.itemFromIndex(self.currentIndex())
|
item = self.itemFromIndex(self.currentIndex())
|
||||||
originals = [self.item(x).ext.upper() for x in range(self.count())]
|
originals = [self.item(x).ext.upper() for x in range(self.count())]
|
||||||
@ -850,6 +854,7 @@ class FormatList(_FormatList):
|
|||||||
class FormatsManager(QWidget):
|
class FormatsManager(QWidget):
|
||||||
|
|
||||||
data_changed = pyqtSignal()
|
data_changed = pyqtSignal()
|
||||||
|
ICON_SIZE = 32
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def changed(self):
|
def changed(self):
|
||||||
@ -868,29 +873,30 @@ class FormatsManager(QWidget):
|
|||||||
self._changed = False
|
self._changed = False
|
||||||
|
|
||||||
self.l = l = QGridLayout()
|
self.l = l = QGridLayout()
|
||||||
|
l.setContentsMargins(0, 0, 0, 0)
|
||||||
self.setLayout(l)
|
self.setLayout(l)
|
||||||
self.cover_from_format_button = QToolButton(self)
|
self.cover_from_format_button = QToolButton(self)
|
||||||
self.cover_from_format_button.setToolTip(
|
self.cover_from_format_button.setToolTip(
|
||||||
_('Set the cover for the book from the selected format'))
|
_('Set the cover for the book from the selected format'))
|
||||||
self.cover_from_format_button.setIcon(QIcon(I('default_cover.png')))
|
self.cover_from_format_button.setIcon(QIcon(I('default_cover.png')))
|
||||||
self.cover_from_format_button.setIconSize(QSize(32, 32))
|
self.cover_from_format_button.setIconSize(QSize(self.ICON_SIZE, self.ICON_SIZE))
|
||||||
|
|
||||||
self.metadata_from_format_button = QToolButton(self)
|
self.metadata_from_format_button = QToolButton(self)
|
||||||
self.metadata_from_format_button.setIcon(QIcon(I('edit_input.png')))
|
self.metadata_from_format_button.setIcon(QIcon(I('edit_input.png')))
|
||||||
self.metadata_from_format_button.setIconSize(QSize(32, 32))
|
self.metadata_from_format_button.setIconSize(QSize(self.ICON_SIZE, self.ICON_SIZE))
|
||||||
self.metadata_from_format_button.setToolTip(
|
self.metadata_from_format_button.setToolTip(
|
||||||
_('Set metadata for the book from the selected format'))
|
_('Set metadata for the book from the selected format'))
|
||||||
|
|
||||||
self.add_format_button = QToolButton(self)
|
self.add_format_button = QToolButton(self)
|
||||||
self.add_format_button.setIcon(QIcon(I('add_book.png')))
|
self.add_format_button.setIcon(QIcon(I('add_book.png')))
|
||||||
self.add_format_button.setIconSize(QSize(32, 32))
|
self.add_format_button.setIconSize(QSize(self.ICON_SIZE, self.ICON_SIZE))
|
||||||
self.add_format_button.clicked.connect(self.add_format)
|
self.add_format_button.clicked.connect(self.add_format)
|
||||||
self.add_format_button.setToolTip(
|
self.add_format_button.setToolTip(
|
||||||
_('Add a format to this book'))
|
_('Add a format to this book'))
|
||||||
|
|
||||||
self.remove_format_button = QToolButton(self)
|
self.remove_format_button = QToolButton(self)
|
||||||
self.remove_format_button.setIcon(QIcon(I('trash.png')))
|
self.remove_format_button.setIcon(QIcon(I('trash.png')))
|
||||||
self.remove_format_button.setIconSize(QSize(32, 32))
|
self.remove_format_button.setIconSize(QSize(self.ICON_SIZE, self.ICON_SIZE))
|
||||||
self.remove_format_button.clicked.connect(self.remove_format)
|
self.remove_format_button.clicked.connect(self.remove_format)
|
||||||
self.remove_format_button.setToolTip(
|
self.remove_format_button.setToolTip(
|
||||||
_('Remove the selected format from this book'))
|
_('Remove the selected format from this book'))
|
||||||
@ -904,8 +910,7 @@ class FormatsManager(QWidget):
|
|||||||
self.formats.delete_format.connect(self.remove_format)
|
self.formats.delete_format.connect(self.remove_format)
|
||||||
self.formats.itemDoubleClicked.connect(self.show_format)
|
self.formats.itemDoubleClicked.connect(self.show_format)
|
||||||
self.formats.setDragDropMode(QAbstractItemView.DragDropMode.DropOnly)
|
self.formats.setDragDropMode(QAbstractItemView.DragDropMode.DropOnly)
|
||||||
self.formats.setIconSize(QSize(32, 32))
|
self.formats.setIconSize(QSize(self.ICON_SIZE, self.ICON_SIZE))
|
||||||
self.formats.setMaximumWidth(200)
|
|
||||||
|
|
||||||
l.addWidget(self.cover_from_format_button, 0, 0, 1, 1)
|
l.addWidget(self.cover_from_format_button, 0, 0, 1, 1)
|
||||||
l.addWidget(self.metadata_from_format_button, 2, 0, 1, 1)
|
l.addWidget(self.metadata_from_format_button, 2, 0, 1, 1)
|
||||||
|
@ -1176,24 +1176,28 @@ class MetadataSingleDialogAlt2(MetadataSingleDialogBase): # {{{
|
|||||||
# First the cover & buttons
|
# First the cover & buttons
|
||||||
cover_group_box = QGroupBox(_('Cover'), tab0)
|
cover_group_box = QGroupBox(_('Cover'), tab0)
|
||||||
cover_layout = QVBoxLayout()
|
cover_layout = QVBoxLayout()
|
||||||
|
cover_layout.setContentsMargins(0, 0, 0, 0)
|
||||||
cover_group_box.setLayout(cover_layout)
|
cover_group_box.setLayout(cover_layout)
|
||||||
cover_layout.addWidget(self.cover)
|
cover_layout.addWidget(self.cover)
|
||||||
sto(self.manage_authors_button, self.cover.buttons[0])
|
sto(self.manage_authors_button, self.cover.buttons[0])
|
||||||
# First row of cover buttons
|
# First row of cover buttons
|
||||||
hl = QHBoxLayout()
|
hl = QHBoxLayout()
|
||||||
|
hl.setContentsMargins(0, 0, 0, 0)
|
||||||
for i, b in enumerate(self.cover.buttons[:3]):
|
for i, b in enumerate(self.cover.buttons[:3]):
|
||||||
hl.addWidget(b)
|
hl.addWidget(b)
|
||||||
sto(b, self.cover.buttons[i+1])
|
sto(b, self.cover.buttons[i+1])
|
||||||
cover_layout.addLayout(hl)
|
cover_layout.addLayout(hl)
|
||||||
# Second row of cover buttons
|
# Second row of cover buttons
|
||||||
hl = QHBoxLayout()
|
hl = QHBoxLayout()
|
||||||
|
hl.setContentsMargins(0, 0, 0, 0)
|
||||||
for b in self.cover.buttons[3:]:
|
for b in self.cover.buttons[3:]:
|
||||||
hl.addWidget(b)
|
hl.addWidget(b)
|
||||||
cover_layout.addLayout(hl)
|
cover_layout.addLayout(hl)
|
||||||
sto(self.cover.buttons[-2], self.cover.buttons[-1])
|
sto(self.cover.buttons[-2], self.cover.buttons[-1])
|
||||||
# Layout for both cover & formats boxes
|
# Layout for both cover & formats boxes
|
||||||
cover_and_formats = QVBoxLayout()
|
cover_and_formats = QVBoxLayout()
|
||||||
cover_and_formats.addWidget(cover_group_box, stretch = 10)
|
cover_and_formats.setContentsMargins(0, 0, 0, 0)
|
||||||
|
cover_and_formats.addWidget(cover_group_box, stretch=100)
|
||||||
cover_and_formats.addWidget(self.formats_manager)
|
cover_and_formats.addWidget(self.formats_manager)
|
||||||
l.addLayout(cover_and_formats, 0, 2, 2, 1)
|
l.addLayout(cover_and_formats, 0, 2, 2, 1)
|
||||||
sto(self.cover.buttons[-1], self.formats_manager)
|
sto(self.cover.buttons[-1], self.formats_manager)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user