mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Add context menu item to resize a column to the viewport size if it is bigger.
This commit is contained in:
parent
0ee4cbe48d
commit
99be7da6c8
@ -215,6 +215,9 @@ class BooksView(QTableView): # {{{
|
||||
|
||||
|
||||
self.column_header_context_menu.addSeparator()
|
||||
self.column_header_context_menu.addAction(
|
||||
_('Resize column to fit'),
|
||||
partial(self.resize_column_to_fit, column=self.column_map[idx]))
|
||||
self.column_header_context_menu.addAction(
|
||||
_('Restore default layout'),
|
||||
partial(self.column_header_context_handler,
|
||||
@ -463,6 +466,10 @@ class BooksView(QTableView): # {{{
|
||||
|
||||
self.was_restored = True
|
||||
|
||||
def resize_column_to_fit(self, column):
|
||||
col = self.column_map.index(column)
|
||||
self.column_resized(col, self.columnWidth(col), self.columnWidth(col))
|
||||
|
||||
def column_resized(self, col, old_size, new_size):
|
||||
# arbitrary: scroll bar + header + some
|
||||
max_width = self.width() - (self.verticalScrollBar().width() +
|
||||
|
Loading…
x
Reference in New Issue
Block a user