-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3008a90
commit 7255421
Showing
2 changed files
with
17 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,36 @@ | ||
import re | ||
|
||
import qdarkstyle | ||
from PySide2.QtWidgets import QPushButton, QScrollArea, QWidget | ||
import qdarkstyle, re | ||
|
||
|
||
class NoBorderScrollArea(QScrollArea): | ||
"""Note: move this class to eqt.""" | ||
|
||
def __init__(self, widget, parent=None): | ||
"""Creates an instance of a QScrollArea and sets its border to none. | ||
"""Creates an instance of a QScrollArea and sets its border to none. | ||
Sets its widget to resizable.""" | ||
super().__init__(parent) | ||
self.setStyleSheet("QScrollArea { border: none; }") | ||
self.setWidgetResizable(True) | ||
self.setWidget(widget) | ||
self.apply_qdarkstyle_to_buttons(widget) | ||
|
||
def apply_qdarkstyle_to_buttons(self, widget): | ||
"""Applies the qdarkstyle to all the buttons in the widget explicitly. | ||
"""Applies the qdarkstyle to all the buttons in the widget explicitly. | ||
This ensures that the style is consistent with the rest of the app.""" | ||
if isinstance(widget, QPushButton): | ||
|
||
button_style = self._extract_qdarkstyle_button_style() | ||
widget.setStyleSheet(button_style) | ||
for child in widget.findChildren(QWidget): | ||
self.apply_qdarkstyle_to_buttons(child) | ||
|
||
def _extract_qdarkstyle_button_style(self): | ||
"""Returns the QPushButton styles from qdarkstyle, including the different button styles.""" | ||
"""Returns the QPushButton styles from qdarkstyle, including the different | ||
button styles.""" | ||
style = qdarkstyle.load_stylesheet(qt_api='pyside2') | ||
pattern = re.compile(r"(QPushButton\s*{[^}]*}|QPushButton\s*:[^}]*{[^}]*})", re.DOTALL) | ||
matches = pattern.findall(style) | ||
if matches: | ||
return ''.join(matches) | ||
return "" | ||
return "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters