Fix table maximum size being off by a few pixels

* Sometimes, the splitter doesn't fully reach the table maximum height, and the scrollbar is still displayed on the right because a few pixels are still hidden.
* It seems the splitter handle counts towards the total height of the widget (the table), so we add it to the maximum height of the table
* The scrollbar disappears when we reach just above the actual table's height
This commit is contained in:
glubsy 2020-09-02 23:45:31 +02:00
parent 18c933b4bf
commit a55e02b36d
1 changed files with 4 additions and 5 deletions

View File

@ -9,7 +9,6 @@ from PyQt5.QtWidgets import (
QAbstractItemView, QSizePolicy, QGridLayout, QSplitter, QFrame) QAbstractItemView, QSizePolicy, QGridLayout, QSplitter, QFrame)
from PyQt5.QtGui import QResizeEvent from PyQt5.QtGui import QResizeEvent
from hscommon.trans import trget from hscommon.trans import trget
from hscommon.plat import ISWINDOWS
from ..details_dialog import DetailsDialog as DetailsDialogBase from ..details_dialog import DetailsDialog as DetailsDialogBase
from ..details_table import DetailsTable from ..details_table import DetailsTable
from .image_viewer import ( from .image_viewer import (
@ -102,14 +101,14 @@ class DetailsDialog(DetailsDialogBase):
self.vController.updateBothImages() self.vController.updateBothImages()
def show(self): def show(self):
# Compute the maximum size the table view can reach # Give the splitter a maximum height to reach. This is assuming that
# Assuming all rows below headers have the same height # all rows below their headers have the same height
self.tableView.setMaximumHeight( self.tableView.setMaximumHeight(
self.tableView.rowHeight(1) self.tableView.rowHeight(1)
* self.tableModel.model.row_count() * self.tableModel.model.row_count()
+ self.tableView.verticalHeader().sectionSize(0) + self.tableView.verticalHeader().sectionSize(0)
# Windows seems to add a few pixels more to the table somehow # looks like the handle is taken into account by the splitter
+ (5 if ISWINDOWS else 0)) + self.splitter.handle(1).size().height())
DetailsDialogBase.show(self) DetailsDialogBase.show(self)
self.ensure_same_sizes() self.ensure_same_sizes()
self._update() self._update()