5bf353ec37
QToolButton is not really designed to be used in the way we did and since QPushButton supports having a menu attached to, we can replace tool buttons in most cases. * Fix the presentation of the TabButtonWidget by updating RareStyle's css * Reduce the size of the top tab bar to save vertical space. * Remove infoLabel property
30 lines
1 KiB
Python
30 lines
1 KiB
Python
from PyQt5.QtGui import QIcon
|
|
from PyQt5.QtWidgets import QTabBar, QSizePolicy, QPushButton
|
|
|
|
|
|
class MainTabBar(QTabBar):
|
|
def __init__(self, parent=None):
|
|
super(MainTabBar, self).__init__(parent=parent)
|
|
self.setObjectName(type(self).__name__)
|
|
font = self.font()
|
|
font.setPointSize(font.pointSize() + 1)
|
|
font.setBold(True)
|
|
self.setFont(font)
|
|
self.expanded = -1
|
|
|
|
def tabSizeHint(self, index):
|
|
size = super(MainTabBar, self).tabSizeHint(index)
|
|
if index == self.expanded:
|
|
offset = self.width()
|
|
for index in range(self.count()):
|
|
offset -= super(MainTabBar, self).tabSizeHint(index).width()
|
|
size.setWidth(max(size.width(), size.width() + offset))
|
|
return size
|
|
|
|
|
|
class TabButtonWidget(QPushButton):
|
|
def __init__(self, icon: QIcon, tooltip: str = "", parent=None):
|
|
super(TabButtonWidget, self).__init__(parent=parent)
|
|
self.setObjectName(type(self).__name__)
|
|
self.setIcon(icon)
|
|
self.setToolTip(tooltip)
|