mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Clean up previous PR
This commit is contained in:
parent
12317215a7
commit
a1a0c57e32
@ -13,7 +13,7 @@ from qt.core import (
|
|||||||
QTableView, Qt, QAbstractItemView, QMenu, pyqtSignal, QFont, QModelIndex,
|
QTableView, Qt, QAbstractItemView, QMenu, pyqtSignal, QFont, QModelIndex,
|
||||||
QIcon, QItemSelection, QMimeData, QDrag, QStyle, QPoint, QUrl, QHeaderView, QEvent,
|
QIcon, QItemSelection, QMimeData, QDrag, QStyle, QPoint, QUrl, QHeaderView, QEvent,
|
||||||
QStyleOptionHeader, QItemSelectionModel, QSize, QFontMetrics, QApplication,
|
QStyleOptionHeader, QItemSelectionModel, QSize, QFontMetrics, QApplication,
|
||||||
QDialog, QGridLayout, QPushButton, QDialogButtonBox, QLabel, QSpinBox)
|
QDialog, QFormLayout, QPushButton, QDialogButtonBox, QLabel, QSpinBox)
|
||||||
|
|
||||||
from calibre.constants import islinux
|
from calibre.constants import islinux
|
||||||
from calibre.gui2.dialogs.enum_values_edit import EnumValuesEdit
|
from calibre.gui2.dialogs.enum_values_edit import EnumValuesEdit
|
||||||
@ -208,51 +208,46 @@ class PreserveViewState: # {{{
|
|||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
|
|
||||||
class AdjustColumnSize(QDialog): # {{{
|
class AdjustColumnSize(QDialog): # {{{
|
||||||
|
|
||||||
def __init__(self, view, column, name):
|
def __init__(self, view, column, name):
|
||||||
QDialog.__init__(self)
|
QDialog.__init__(self)
|
||||||
self.setWindowTitle(_('Adjust column size of {0}').format(name))
|
self.setWindowTitle(_('Adjust width of {0}').format(name))
|
||||||
self.view = view
|
self.view = view
|
||||||
self.column = column
|
self.column = column
|
||||||
l = QGridLayout()
|
l = QFormLayout(self)
|
||||||
self.setLayout(l)
|
|
||||||
|
|
||||||
original_size = self.original_size = view.horizontalHeader().sectionSize(column)
|
original_size = self.original_size = view.horizontalHeader().sectionSize(column)
|
||||||
l.addWidget(QLabel(_('Original size:')), 0, 0)
|
l.addRow(_('Original size:'), QLabel(_('{0} pixels').format(str(original_size))))
|
||||||
l.addWidget(QLabel(_('{0} pixels').format(str(original_size))), 0, 1)
|
|
||||||
|
|
||||||
self.minimum_size = self.view.horizontalHeader().minimumSectionSize()
|
self.minimum_size = self.view.horizontalHeader().minimumSectionSize()
|
||||||
l.addWidget(QLabel(_('Minimum size:')), 1, 0)
|
l.addRow(_('Minimum size:'), QLabel(_('{0} pixels').format(str(self.minimum_size))))
|
||||||
l.addWidget(QLabel(_('{0} pixels').format(str(self.minimum_size))), 1, 1)
|
|
||||||
|
|
||||||
self.maximum_size = max_permitted_column_width(self.view, self.column)
|
self.maximum_size = max_permitted_column_width(self.view, self.column)
|
||||||
l.addWidget(QLabel(_('Maximum size:')), 2, 0)
|
l.addRow(_('Maximum size:'), QLabel(_('{0} pixels').format(str(self.maximum_size))))
|
||||||
l.addWidget(QLabel(_('{0} pixels').format(str(self.maximum_size))), 2, 1)
|
|
||||||
|
|
||||||
b = self.shrink_button = QPushButton('&Shrink 10%')
|
la = QLabel(_('You can also adjust column widths by dragging the divider between column headers'))
|
||||||
l.addWidget(b, 5, 0)
|
la.setWordWrap(True)
|
||||||
b = self.expand_button = QPushButton('&Expand 10%')
|
l.addRow(la)
|
||||||
l.addWidget(b, 5, 1)
|
|
||||||
|
|
||||||
b = self.set_minimum_button = QPushButton('Set to mi&nimum')
|
self.shrink_button = QPushButton(_('&Shrink 10%'))
|
||||||
l.addWidget(b, 6, 0)
|
b = self.expand_button = QPushButton(_('&Expand 10%'))
|
||||||
b = self.set_maximum_button = QPushButton('Set to ma&ximum')
|
l.addRow(self.shrink_button, b)
|
||||||
l.addWidget(b, 6, 1)
|
|
||||||
|
b = self.set_minimum_button = QPushButton(_('Set to mi&nimum'))
|
||||||
|
b = self.set_maximum_button = QPushButton(_('Set to ma&ximum'))
|
||||||
|
l.addRow(self.set_minimum_button, b)
|
||||||
|
|
||||||
sb = self.spin_box = QSpinBox()
|
sb = self.spin_box = QSpinBox()
|
||||||
sb.setMinimum(self.view.horizontalHeader().minimumSectionSize())
|
sb.setMinimum(self.view.horizontalHeader().minimumSectionSize())
|
||||||
sb.setMaximum(self.maximum_size)
|
sb.setMaximum(self.maximum_size)
|
||||||
sb.setValue(original_size)
|
sb.setValue(original_size)
|
||||||
sb.setSuffix(' ' + _('pixels'))
|
sb.setSuffix(' ' + _('pixels'))
|
||||||
l.addWidget(sb, 7, 1)
|
l.addRow(_('Set &to:'), sb)
|
||||||
sb_label = QLabel('Set &to')
|
|
||||||
l.addWidget(sb_label, 7, 0)
|
|
||||||
sb_label.setBuddy(sb)
|
|
||||||
|
|
||||||
bb = self.button_box = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok |
|
bb = self.button_box = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok |
|
||||||
QDialogButtonBox.StandardButton.Cancel)
|
QDialogButtonBox.StandardButton.Cancel)
|
||||||
l.addWidget(bb, 10, 0, 1, 2)
|
l.addRow(bb)
|
||||||
|
|
||||||
self.shrink_button.clicked.connect(self.shrink_button_clicked)
|
self.shrink_button.clicked.connect(self.shrink_button_clicked)
|
||||||
self.expand_button.clicked.connect(self.expand_button_clicked)
|
self.expand_button.clicked.connect(self.expand_button_clicked)
|
||||||
@ -593,7 +588,7 @@ class BooksView(QTableView): # {{{
|
|||||||
partial(self.resize_column_to_fit, view, col))
|
partial(self.resize_column_to_fit, view, col))
|
||||||
ans.addAction(_('Resize column to fit contents'),
|
ans.addAction(_('Resize column to fit contents'),
|
||||||
partial(self.fit_column_to_contents, view, col))
|
partial(self.fit_column_to_contents, view, col))
|
||||||
ans.addAction(_('Manually adjust column size'),
|
ans.addAction(_('Adjust width of column'),
|
||||||
partial(self.manually_adjust_column_size, view, col, name))
|
partial(self.manually_adjust_column_size, view, col, name))
|
||||||
ans.addAction(_('Restore default layout'), partial(handler, action='defaults'))
|
ans.addAction(_('Restore default layout'), partial(handler, action='defaults'))
|
||||||
if self.can_add_columns:
|
if self.can_add_columns:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user