2024-02-22 07:25:03 +13:00
|
|
|
from PyQt5.QtGui import QIcon
|
|
|
|
from PyQt5.QtWidgets import QTabBar, QSizePolicy, QPushButton
|
2021-03-25 05:01:12 +13:00
|
|
|
|
|
|
|
|
2021-11-19 09:44:11 +13:00
|
|
|
class MainTabBar(QTabBar):
|
2023-02-06 20:19:31 +13:00
|
|
|
def __init__(self, parent=None):
|
|
|
|
super(MainTabBar, self).__init__(parent=parent)
|
2024-02-22 07:25:03 +13:00
|
|
|
self.setObjectName(type(self).__name__)
|
2021-12-05 04:15:35 +13:00
|
|
|
font = self.font()
|
2024-02-22 07:25:03 +13:00
|
|
|
font.setPointSize(font.pointSize() + 1)
|
2021-12-05 04:15:35 +13:00
|
|
|
font.setBold(True)
|
|
|
|
self.setFont(font)
|
2023-02-06 20:19:31 +13:00
|
|
|
self.expanded = -1
|
2021-03-25 05:01:12 +13:00
|
|
|
|
|
|
|
def tabSizeHint(self, index):
|
2021-11-19 09:44:11 +13:00
|
|
|
size = super(MainTabBar, self).tabSizeHint(index)
|
2023-02-06 20:19:31 +13:00
|
|
|
if index == self.expanded:
|
2021-03-25 05:01:12 +13:00
|
|
|
offset = self.width()
|
|
|
|
for index in range(self.count()):
|
2021-11-19 09:44:11 +13:00
|
|
|
offset -= super(MainTabBar, self).tabSizeHint(index).width()
|
2021-03-25 05:01:12 +13:00
|
|
|
size.setWidth(max(size.width(), size.width() + offset))
|
|
|
|
return size
|
|
|
|
|
|
|
|
|
2024-02-22 07:25:03 +13:00
|
|
|
class TabButtonWidget(QPushButton):
|
|
|
|
def __init__(self, icon: QIcon, tooltip: str = "", parent=None):
|
2023-02-06 20:19:31 +13:00
|
|
|
super(TabButtonWidget, self).__init__(parent=parent)
|
2024-02-22 07:25:03 +13:00
|
|
|
self.setObjectName(type(self).__name__)
|
|
|
|
self.setIcon(icon)
|
|
|
|
self.setToolTip(tooltip)
|