mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Book list column header context menu: Add an entry to resize the column to fit its current contents. Fixes #1878450 [[Enhancement] Maximize a column width to fit all text](https://bugs.launchpad.net/calibre/+bug/1878450)
This commit is contained in:
parent
e0dbdf3c9c
commit
4ecfc43d3d
@ -471,6 +471,8 @@ class BooksView(QTableView): # {{{
|
||||
ans.addSeparator()
|
||||
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(_('Restore default layout'), partial(handler, action='defaults'))
|
||||
if self.can_add_columns:
|
||||
ans.addAction(
|
||||
@ -829,6 +831,10 @@ class BooksView(QTableView): # {{{
|
||||
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 column_resized(self, col, old_size, new_size):
|
||||
restrict_column_width(self, col, old_size, new_size)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user