mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-08 15:34:15 +02:00
style combo
This commit is contained in:
28
bauh/view/qt/styles.py
Normal file
28
bauh/view/qt/styles.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from PyQt5.QtWidgets import QComboBox, QApplication, QStyleFactory, QWidget
|
||||
|
||||
from bauh.core import config
|
||||
|
||||
|
||||
class StylesComboBox(QComboBox):
|
||||
|
||||
def __init__(self, parent: QWidget, i18n: dict):
|
||||
super(StylesComboBox, self).__init__(parent=parent)
|
||||
self.app = QApplication.instance()
|
||||
self.styles = []
|
||||
|
||||
for idx, style in enumerate(QStyleFactory.keys()):
|
||||
self.styles.append(style)
|
||||
self.addItem('{}: {}'.format(i18n['style'].capitalize(), style), style)
|
||||
|
||||
if style.lower() == self.app.style().objectName():
|
||||
self.setCurrentIndex(idx)
|
||||
|
||||
self.currentIndexChanged.connect(self.change_style)
|
||||
|
||||
def change_style(self, idx: int):
|
||||
style = self.styles[idx]
|
||||
self.app.setStyle(style)
|
||||
|
||||
user_config = config.read()
|
||||
user_config.style = style
|
||||
config.save(user_config)
|
||||
Reference in New Issue
Block a user