|
1 | 1 | #!/usr/bin/python |
2 | 2 | from Qt import QtCore, QtWidgets |
3 | 3 |
|
4 | | -from NodeGraphQt.widgets.stylesheet import STYLE_QMENU |
| 4 | +from NodeGraphQt.constants import VIEWER_BG_COLOR |
5 | 5 |
|
6 | 6 |
|
7 | 7 | class BaseMenu(QtWidgets.QMenu): |
8 | 8 |
|
9 | 9 | def __init__(self, *args, **kwargs): |
10 | 10 | super(BaseMenu, self).__init__(*args, **kwargs) |
11 | | - self.setStyleSheet(STYLE_QMENU) |
| 11 | + text_color = self.palette().text().color().toTuple() |
| 12 | + selected_color = self.palette().highlight().color().toTuple() |
| 13 | + style_dict = { |
| 14 | + 'QMenu': { |
| 15 | + 'color': 'rgb({0},{1},{2})'.format(*text_color), |
| 16 | + 'background-color': 'rgb({0},{1},{2})'.format(*VIEWER_BG_COLOR), |
| 17 | + 'border': '1px solid rgba({0},{1},{2},30)'.format(*text_color), |
| 18 | + 'border-radius': '3px', |
| 19 | + }, |
| 20 | + 'QMenu::item': { |
| 21 | + 'padding': '5px 18px 2px', |
| 22 | + 'background-color': 'transparent', |
| 23 | + }, |
| 24 | + 'QMenu::item:selected': { |
| 25 | + 'color': 'rgb({0},{1},{2})'.format(*text_color), |
| 26 | + 'background-color': 'rgba({0},{1},{2},200)' |
| 27 | + .format(*selected_color), |
| 28 | + }, |
| 29 | + 'QMenu::separator': { |
| 30 | + 'height': '1px', |
| 31 | + 'background': 'rgba({0},{1},{2}, 50)'.format(*text_color), |
| 32 | + 'margin': '4px 8px', |
| 33 | + } |
| 34 | + } |
| 35 | + stylesheet = '' |
| 36 | + for css_class, css in style_dict.items(): |
| 37 | + style = '{} {{\n'.format(css_class) |
| 38 | + for elm_name, elm_val in css.items(): |
| 39 | + style += ' {}:{};\n'.format(elm_name, elm_val) |
| 40 | + style += '}\n' |
| 41 | + stylesheet += style |
| 42 | + self.setStyleSheet(stylesheet) |
12 | 43 | self.node_class = None |
13 | 44 | self.graph = None |
14 | 45 |
|
|
0 commit comments