mirror of
https://github.com/LorenEteval/Furious.git
synced 2026-09-22 23:08:08 +03:00
Update built-in QtWidgets styles
Signed-off-by: Loren Eteval <loren.eteval@proton.me>
This commit is contained in:
@@ -31,6 +31,8 @@ from PySide6.QtWidgets import *
|
||||
|
||||
import functools
|
||||
|
||||
from typing import Union
|
||||
|
||||
__all__ = [
|
||||
'moveToCenter',
|
||||
'AppQCheckBox',
|
||||
@@ -372,7 +374,12 @@ class AppQMenu(QTranslatable, SupportConnectedCallback, QMenu):
|
||||
@staticmethod
|
||||
def getStyleSheet(color):
|
||||
return (
|
||||
f'QMenu {{'
|
||||
f' padding: 6px;'
|
||||
f'}}'
|
||||
f''
|
||||
f'QMenu::item {{'
|
||||
f' padding: 6px 12px;'
|
||||
f' background-color: solid;'
|
||||
f'}}'
|
||||
f''
|
||||
@@ -481,6 +488,7 @@ class AppQTableWidget(SupportConnectedCallback, QTableWidget):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
self.setWordWrap(False)
|
||||
self.setAlternatingRowColors(True)
|
||||
|
||||
@property
|
||||
def selectedIndex(self):
|
||||
@@ -572,6 +580,30 @@ class AppQToolBar(QTranslatable, QToolBar):
|
||||
|
||||
self.setStyleSheet(self.getStyleSheet())
|
||||
|
||||
self.actionTriggered.connect(self.showMenuBelow)
|
||||
|
||||
@QtCore.Slot(AppQAction)
|
||||
def showMenuBelow(self, action: AppQAction):
|
||||
def toolBarWidgetForAction() -> Union[QWidget | None]:
|
||||
# Walk through the toolbar to find the widget for the action
|
||||
for child in self.children():
|
||||
if hasattr(child, 'defaultAction'):
|
||||
# PySide6.QtWidgets.QMenu.defaultAction
|
||||
assert isinstance(child, QWidget)
|
||||
|
||||
if child.defaultAction() == action:
|
||||
return child
|
||||
|
||||
return None
|
||||
|
||||
button = toolBarWidgetForAction()
|
||||
|
||||
if button is not None:
|
||||
menu = action._menu
|
||||
|
||||
if isinstance(menu, AppQMenu):
|
||||
menu.exec(button.mapToGlobal(button.rect().bottomLeft()))
|
||||
|
||||
@staticmethod
|
||||
def getStyleSheet():
|
||||
return f'QToolBar {{ spacing: 5px; }}'
|
||||
|
||||
Reference in New Issue
Block a user