mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge branch 'master' of https://github.com/cbhaley/calibre
This commit is contained in:
commit
7204a1a038
1
imgsrc/width.svg
Normal file
1
imgsrc/width.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg width="300" height="300" enable-background="new 0 0 97.8 97.8" version="1.1" viewBox="0 0 97.8 97.8" xml:space="preserve" xmlns="http://www.w3.org/2000/svg"><path d="m32.38 34.13c-0.1625-4.4e-4 -0.3151 0.04564-0.4489 0.1484l-18.37 14.03c-0.1386 0.1055-0.2601 0.2585-0.2993 0.4241-0.01305 0.05519 0 0.1121 0 0.17 0 0.2314 0.1144 0.4534 0.2993 0.5941l18.39 14.05c0.1345 0.1027 0.2658 0.1484 0.4272 0.1484 0.1593 0 0.3361-0.04777 0.4699-0.1484 0.2691-0.2012 0.3792-0.5798 0.256-0.8914l-3.695-9.273h38.98l-3.695 9.273c-0.1232 0.3116-0.01311 0.6902 0.256 0.8914 0.1338 0.1006 0.3106 0.1484 0.4699 0.1484 0.1614 0 0.2927-0.04568 0.4272-0.1484l18.39-14.05c0.1848-0.1407 0.2993-0.3626 0.2993-0.5941 0-0.05786 0.01305-0.1148 0-0.17-0.03916-0.1656-0.1607-0.3185-0.2993-0.4241l-18.37-14.03c-0.1338-0.1027-0.2864-0.1488-0.4489-0.1484-0.1625 4.41e-4 -0.3354 0.04739-0.4699 0.1484-0.2691 0.2012-0.3799 0.5384-0.256 0.8494l3.695 9.294s-38.84 0.1753-38.98 0l3.695-9.294c0.1239-0.3109 0.0131-0.6482-0.256-0.8494-0.1345-0.101-0.3074-0.1479-0.4699-0.1484z" fill="#2caf45" stroke-width="1.221"/><path d="m86.71 11.75c-0.7817 0-1.41 1.118-1.41 2.51v69.28c0 1.392 0.6272 2.511 1.41 2.51h9.547c0.7817 0 1.431-1.118 1.431-2.51v-69.28c0-1.392-0.6493-2.51-1.431-2.51z" fill="#2271d5" stroke-width="1.635"/><path d="m1.522 11.75c-0.7817 0-1.41 1.118-1.41 2.51v69.28c0 1.392 0.6272 2.511 1.41 2.51h9.547c0.7817 0 1.431-1.118 1.431-2.51v-69.28c0-1.392-0.6493-2.51-1.431-2.51z" fill="#2271d5" stroke-width="1.635"/></svg>
|
After Width: | Height: | Size: 1.5 KiB |
BIN
resources/images/width.png
Normal file
BIN
resources/images/width.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
@ -231,7 +231,9 @@ class AdjustColumnSize(QDialog): # {{{
|
||||
l.addRow = add_row
|
||||
|
||||
original_size = self.original_size = view.horizontalHeader().sectionSize(column)
|
||||
l.addRow(_('Original size:'), QLabel(_('{0} pixels').format(str(original_size))))
|
||||
label = QLabel(_('{0} pixels').format(str(original_size)))
|
||||
label.setToolTip('<p>' + _('The original size can be larger than the maximum if the window has been resized') + '</p>')
|
||||
l.addRow(_('Original size:'), label)
|
||||
|
||||
self.minimum_size = self.view.horizontalHeader().minimumSectionSize()
|
||||
l.addRow(_('Minimum size:'), QLabel(_('{0} pixels').format(str(self.minimum_size))))
|
||||
@ -251,12 +253,17 @@ class AdjustColumnSize(QDialog): # {{{
|
||||
b = self.set_maximum_button = QPushButton(_('Set to ma&ximum'))
|
||||
l.addRow(self.set_minimum_button, b)
|
||||
|
||||
b = self.resize_to_fit_button = QPushButton(_('&Resize column to fit contents'))
|
||||
b.setToolTip('<p>' + _('The width will be set to the size of the widest entry or the maximum size, whichever is smaller') + '</p>')
|
||||
l.addRow(b)
|
||||
|
||||
sb = self.spin_box = QSpinBox()
|
||||
sb.setMinimum(self.view.horizontalHeader().minimumSectionSize())
|
||||
sb.setMaximum(self.maximum_size)
|
||||
sb.setValue(original_size)
|
||||
sb.setSuffix(' ' + _('pixels'))
|
||||
l.addRow(_('Set &to:'), sb)
|
||||
sb.setToolTip(_('This box shows the current width after using the above buttons'))
|
||||
l.addRow(_('Set width &to:'), sb)
|
||||
|
||||
bb = self.button_box = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok |
|
||||
QDialogButtonBox.StandardButton.Cancel)
|
||||
@ -267,6 +274,7 @@ class AdjustColumnSize(QDialog): # {{{
|
||||
self.spin_box.valueChanged.connect(self.spin_box_changed)
|
||||
self.set_minimum_button.clicked.connect(self.set_minimum_button_clicked)
|
||||
self.set_maximum_button.clicked.connect(self.set_maximum_button_clicked)
|
||||
self.resize_to_fit_button.clicked.connect(self.resize_to_fit_button_clicked)
|
||||
bb.accepted.connect(self.accept)
|
||||
bb.rejected.connect(self.reject)
|
||||
|
||||
@ -274,6 +282,12 @@ class AdjustColumnSize(QDialog): # {{{
|
||||
self.view.setColumnWidth(self.column, self.original_size)
|
||||
QDialog.reject(self)
|
||||
|
||||
def resize_to_fit_button_clicked(self):
|
||||
self.view.resizeColumnToContents(self.column)
|
||||
w = self.view.horizontalHeader().sectionSize(self.column)
|
||||
w = w if w <= self.maximum_size else self.maximum_size
|
||||
self.spin_box.setValue(w)
|
||||
|
||||
def set_maximum_button_clicked(self):
|
||||
# Do this dance in case the current width exceeds the maximum, which can
|
||||
# happen if the user is playing across multiple monitors
|
||||
@ -531,8 +545,6 @@ class BooksView(QTableView): # {{{
|
||||
def create_context_menu(self, col, name, view):
|
||||
ans = QMenu(view)
|
||||
handler = partial(self.column_header_context_handler, view=view, column=col)
|
||||
if col not in ('ondevice', 'inlibrary'):
|
||||
ans.addAction(QIcon.ic('minus.png'), _('Hide column %s') % name, partial(handler, action='hide'))
|
||||
m = ans.addMenu(_('Sort on %s') % name)
|
||||
m.setIcon(QIcon.ic('sort.png'))
|
||||
a = m.addAction(_('Ascending'), partial(handler, action='ascending'))
|
||||
@ -567,6 +579,8 @@ class BooksView(QTableView): # {{{
|
||||
if f is col_font:
|
||||
a.setCheckable(True)
|
||||
a.setChecked(True)
|
||||
ans.addAction(QIcon.ic('width.png'), _('Adjust width of column {0}').format(name),
|
||||
partial(self.manually_adjust_column_size, view, col, name))
|
||||
|
||||
if self.is_library_view:
|
||||
if self._model.db.field_metadata[col]['is_category']:
|
||||
@ -583,6 +597,8 @@ class BooksView(QTableView): # {{{
|
||||
if view.column_header.isSectionHidden(i) and self.column_map[i] not in ('ondevice', 'inlibrary')}
|
||||
|
||||
ans.addSeparator()
|
||||
if col not in ('ondevice', 'inlibrary'):
|
||||
ans.addAction(QIcon.ic('minus.png'), _('Hide column %s') % name, partial(handler, action='hide'))
|
||||
if hidden_cols:
|
||||
m = ans.addMenu(_('Show column'))
|
||||
m.setIcon(QIcon.ic('plus.png'))
|
||||
@ -597,12 +613,6 @@ class BooksView(QTableView): # {{{
|
||||
partial(handler, action='remember_ondevice_width'))
|
||||
ans.addAction(_('Reset On Device column width to default'),
|
||||
partial(handler, action='reset_ondevice_width'))
|
||||
ans.addAction(_('Shrink column if it is too wide to fit'),
|
||||
partial(self.resize_column_to_fit, view, col))
|
||||
ans.addAction(_('Resize column to fit contents'),
|
||||
partial(self.fit_column_to_contents, view, col))
|
||||
ans.addAction(_('Adjust width of column'),
|
||||
partial(self.manually_adjust_column_size, view, col, name))
|
||||
ans.addAction(_('Restore default layout'), partial(handler, action='defaults'))
|
||||
if self.can_add_columns:
|
||||
ans.addAction(
|
||||
@ -1026,15 +1036,6 @@ class BooksView(QTableView): # {{{
|
||||
self._model.set_row_height(self.rowHeight(0))
|
||||
self.row_sizing_done = True
|
||||
|
||||
def resize_column_to_fit(self, view, column):
|
||||
col = self.column_map.index(column)
|
||||
w = view.columnWidth(col)
|
||||
restrict_column_width(view, col, w, w)
|
||||
|
||||
def fit_column_to_contents(self, view, column):
|
||||
col = self.column_map.index(column)
|
||||
view.resizeColumnToContents(col)
|
||||
|
||||
def manually_adjust_column_size(self, view, column, name):
|
||||
col = self.column_map.index(column)
|
||||
AdjustColumnSize(view, col, name).exec_()
|
||||
|
Loading…
x
Reference in New Issue
Block a user