From 110935e5e4bf29d622360d1dbf1aa01687380a82 Mon Sep 17 00:00:00 2001 From: Et0h Date: Sat, 25 Oct 2014 09:45:27 +0100 Subject: [PATCH] Less hacky fix to give usernames enough room --- syncplay/constants.py | 2 ++ syncplay/ui/gui.py | 13 +++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/syncplay/constants.py b/syncplay/constants.py index c300163..501a2ba 100644 --- a/syncplay/constants.py +++ b/syncplay/constants.py @@ -108,6 +108,8 @@ STYLE_DIFFERENTITEM_COLOR = 'red' STYLE_NOFILEITEM_COLOR = 'blue' STYLE_NOTCONTROLLER_COLOR = 'grey' +USERLIST_GUI_USERNAME_OFFSET = 21 # Pixels + MPLAYER_SLAVE_ARGS = ['-slave', '--hr-seek=always', '-nomsgcolor', '-msglevel', 'all=1:global=4:cplayer=4'] # --quiet works with both mpv 0.2 and 0.3 MPV_SLAVE_ARGS = ['--hr-seek=always', '--quiet', '--keep-open'] diff --git a/syncplay/ui/gui.py b/syncplay/ui/gui.py index 1902e90..53f1d0d 100644 --- a/syncplay/ui/gui.py +++ b/syncplay/ui/gui.py @@ -12,6 +12,12 @@ class UserlistItemDelegate(QtGui.QStyledItemDelegate): def __init__(self): QtGui.QStyledItemDelegate.__init__(self) + def sizeHint(self, option, index): + size = QtGui.QStyledItemDelegate.sizeHint(self, option, index) + if (index.column() == 0): + size.setWidth(size.width() + constants.USERLIST_GUI_USERNAME_OFFSET) + return size + def paint(self, itemQPainter, optionQStyleOptionViewItem, indexQModelIndex): column = indexQModelIndex.column() if column == 0: @@ -46,7 +52,7 @@ class UserlistItemDelegate(QtGui.QStyledItemDelegate): crossIconQPixmap.scaled(16, 16, Qt.KeepAspectRatio)) isUserRow = indexQModelIndex.parent() != indexQModelIndex.parent().parent() if isUserRow: - optionQStyleOptionViewItem.rect.setX(optionQStyleOptionViewItem.rect.x()+21) + optionQStyleOptionViewItem.rect.setX(optionQStyleOptionViewItem.rect.x()+constants.USERLIST_GUI_USERNAME_OFFSET) QtGui.QStyledItemDelegate.paint(self, itemQPainter, optionQStyleOptionViewItem, indexQModelIndex) class MainWindow(QtGui.QMainWindow): @@ -171,14 +177,9 @@ class MainWindow(QtGui.QMainWindow): roomtocheck += 1 self.listTreeView.header().setStretchLastSection(False) self.listTreeView.header().setResizeMode(0, QtGui.QHeaderView.ResizeToContents) - namecolumnwidth = self.listTreeView.header().sectionSize(0) + 40 - if self.listTreeView.header().sectionSize(0) == self.listTreeView.header().sectionSizeHint(0): - namecolumnwidth = namecolumnwidth - 20 self.listTreeView.header().setResizeMode(1, QtGui.QHeaderView.ResizeToContents) self.listTreeView.header().setResizeMode(2, QtGui.QHeaderView.ResizeToContents) self.listTreeView.header().setResizeMode(3, QtGui.QHeaderView.ResizeToContents) - self.listTreeView.header().setResizeMode(0, QtGui.QHeaderView.Fixed) - self.listTreeView.header().resizeSection(0,namecolumnwidth) NarrowTabsWidth = self.listTreeView.header().sectionSize(0)+self.listTreeView.header().sectionSize(1)+self.listTreeView.header().sectionSize(2) if self.listTreeView.header().width() < (NarrowTabsWidth+self.listTreeView.header().sectionSize(3)): self.listTreeView.header().resizeSection(3,self.listTreeView.header().width()-NarrowTabsWidth)