1
0
Fork 0
mirror of synced 2024-05-18 11:32:50 +12:00
Rare/rare/components/tabs/tab_widgets.py
loathingKernel 5bf353ec37
Rare: Replace QToolButton with QPushButton
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
2024-02-21 20:25:03 +02:00

31 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)