mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 01:14:15 +02:00
[themes] refactoring: renameing the attribute 'root_sheet' to 'root_theme'
This commit is contained in:
@@ -276,7 +276,7 @@ environment:
|
|||||||
- name: name that will be displayed on the interface. It supports translations by adding additional `name` keys with brackets and the language code (e.g: `name[es]=Mi tema`)
|
- name: name that will be displayed on the interface. It supports translations by adding additional `name` keys with brackets and the language code (e.g: `name[es]=Mi tema`)
|
||||||
- description: theme's description that will be displayed on the interface. It supports translations like `name` (e.g: description[es] = Mi tema).
|
- description: theme's description that will be displayed on the interface. It supports translations like `name` (e.g: description[es] = Mi tema).
|
||||||
- version: theme's version. It just works as information at the moment. (e.g: 1.0)
|
- version: theme's version. It just works as information at the moment. (e.g: 1.0)
|
||||||
- root_sheet: optional attribute that points to a theme that must be preloaded before the theme. It supports the default theme keys (e.g: default, light, ...) or a file path (e.g: `/path/to/root/file.qss`).
|
- root_theme: optional attribute that points to a theme that must be loaded before the theme. It supports the bauh's default theme keys (e.g: default, light, ...) or a file path (e.g: `/path/to/root/file.qss`).
|
||||||
- **my_theme.vars**: optional file defining `key=value` pairs of variables that will be available for the .qss file (can be referenced through the symbol **@**. e.g `@my_var`). Full example: [light.vars](https://raw.githubusercontent.com/vinifmor/bauh/qss/bauh/view/resources/style/light/light.vars)
|
- **my_theme.vars**: optional file defining `key=value` pairs of variables that will be available for the .qss file (can be referenced through the symbol **@**. e.g `@my_var`). Full example: [light.vars](https://raw.githubusercontent.com/vinifmor/bauh/qss/bauh/view/resources/style/light/light.vars)
|
||||||
- common theme variables available:
|
- common theme variables available:
|
||||||
- **style_dir**: path to the .qss file directory. Example: @style_dir/my_icon.svg
|
- **style_dir**: path to the .qss file directory. Example: @style_dir/my_icon.svg
|
||||||
|
|||||||
@@ -18,12 +18,12 @@ class ThemeMetadata:
|
|||||||
|
|
||||||
def __init__(self, file_path: str, default: bool, default_name: Optional[str] = None,
|
def __init__(self, file_path: str, default: bool, default_name: Optional[str] = None,
|
||||||
default_description: Optional[str] = None, version: Optional[str] = None,
|
default_description: Optional[str] = None, version: Optional[str] = None,
|
||||||
root_sheet: Optional[str] = None, abstract: bool = False):
|
root_theme: Optional[str] = None, abstract: bool = False):
|
||||||
self.names = {}
|
self.names = {}
|
||||||
self.default_name = default_name
|
self.default_name = default_name
|
||||||
self.descriptions = {}
|
self.descriptions = {}
|
||||||
self.default_description = default_description
|
self.default_description = default_description
|
||||||
self.root_sheet = root_sheet
|
self.root_theme = root_theme
|
||||||
self.version = version
|
self.version = version
|
||||||
self.file_path = file_path
|
self.file_path = file_path
|
||||||
self.file_dir = '/'.join(file_path.split('/')[0:-1])
|
self.file_dir = '/'.join(file_path.split('/')[0:-1])
|
||||||
@@ -83,8 +83,8 @@ def read_theme_metada(key: str, file_path: str) -> ThemeMetadata:
|
|||||||
for field, val in meta_dict.items():
|
for field, val in meta_dict.items():
|
||||||
if field == 'version':
|
if field == 'version':
|
||||||
meta_obj.version = val
|
meta_obj.version = val
|
||||||
elif field == 'root_sheet':
|
elif field == 'root_theme':
|
||||||
meta_obj.root_sheet = val
|
meta_obj.root_theme = val
|
||||||
elif field == 'name':
|
elif field == 'name':
|
||||||
meta_obj.default_name = val
|
meta_obj.default_name = val
|
||||||
elif field == 'description':
|
elif field == 'description':
|
||||||
@@ -133,15 +133,15 @@ def process_theme(file_path: str, theme_str: str, metadata: ThemeMetadata,
|
|||||||
available_themes: Optional[Dict[str, str]]) -> Optional[Tuple[str, ThemeMetadata]]:
|
available_themes: Optional[Dict[str, str]]) -> Optional[Tuple[str, ThemeMetadata]]:
|
||||||
if theme_str and metadata:
|
if theme_str and metadata:
|
||||||
root_theme = None
|
root_theme = None
|
||||||
if metadata.root_sheet and metadata.root_sheet in available_themes:
|
if metadata.root_theme and metadata.root_theme in available_themes:
|
||||||
root_file = available_themes[metadata.root_sheet]
|
root_file = available_themes[metadata.root_theme]
|
||||||
|
|
||||||
if os.path.isfile(root_file):
|
if os.path.isfile(root_file):
|
||||||
with open(root_file) as f:
|
with open(root_file) as f:
|
||||||
root_theme_str = f.read()
|
root_theme_str = f.read()
|
||||||
|
|
||||||
if root_theme_str:
|
if root_theme_str:
|
||||||
root_metadata = read_theme_metada(key=metadata.root_sheet, file_path=root_file)
|
root_metadata = read_theme_metada(key=metadata.root_theme, file_path=root_file)
|
||||||
root_theme = process_theme(file_path=root_file,
|
root_theme = process_theme(file_path=root_file,
|
||||||
theme_str=root_theme_str,
|
theme_str=root_theme_str,
|
||||||
metadata=root_metadata,
|
metadata=root_metadata,
|
||||||
|
|||||||
@@ -3,4 +3,4 @@ description=Dark based on Darcula theme (JetBrains)
|
|||||||
description[pt]=Escuro baseada no tema Darcula (JetBrains)
|
description[pt]=Escuro baseada no tema Darcula (JetBrains)
|
||||||
description[es]=Oscuro basado en el tema Darcula (JetBrains)
|
description[es]=Oscuro basado en el tema Darcula (JetBrains)
|
||||||
version=1.0
|
version=1.0
|
||||||
root_sheet=default
|
root_theme=default
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ description=Default light theme
|
|||||||
description[pt]=Tema padrão claro
|
description[pt]=Tema padrão claro
|
||||||
description[es]=Tema predeterminado claro
|
description[es]=Tema predeterminado claro
|
||||||
version=1.0
|
version=1.0
|
||||||
root_sheet=default
|
root_theme=default
|
||||||
@@ -3,4 +3,4 @@ description=Dark based on Sublime Text's editor theme
|
|||||||
description[pt]=Escuro baseado no tema do editor Sublime Text
|
description[pt]=Escuro baseado no tema do editor Sublime Text
|
||||||
description[es]=Oscuro basado en el tema del editor Sublime Text
|
description[es]=Oscuro basado en el tema del editor Sublime Text
|
||||||
version=1.0
|
version=1.0
|
||||||
root_sheet=default
|
root_theme=default
|
||||||
Reference in New Issue
Block a user