mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-01-06 04:05:07 +01: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
1 changed files with 6 additions and 0 deletions
|
|
@ -471,6 +471,8 @@ def create_context_menu(self, col, name, view):
|
|||
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 @@ def resize_column_to_fit(self, view, 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 column_resized(self, col, old_size, new_size):
|
||||
restrict_column_width(self, col, old_size, new_size)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue