chore(themes): reorgonize it to submodules
All checks were successful
Code check / Check code (push) Successful in 1m8s
All checks were successful
Code check / Check code (push) Successful in 1m8s
Signed-off-by: Boris Yumankulov <boria138@altlinux.org>
This commit is contained in:
@@ -31,17 +31,49 @@ mkdir -p ~/.local/share/PortProtonQT/themes/my_custom_theme
|
||||
|
||||
## 🎨 Style File (`styles.py`)
|
||||
|
||||
Create a `styles.py` in the theme root. It should define variables or functions that return CSS.
|
||||
Create a `styles.py` in the theme root. It should define variables or functions that return QSS (Qt Style Sheets). For better organization, you can split your theme into multiple submodules by creating a `styles` subdirectory with separate Python files for different components, and import them in `styles.py`.
|
||||
|
||||
**Example:**
|
||||
**Example of modular structure:**
|
||||
```
|
||||
my_custom_theme/
|
||||
├── styles.py
|
||||
├── metainfo.ini
|
||||
├── fonts/
|
||||
├── images/
|
||||
└── styles/
|
||||
├── __init__.py # This empty file makes the directory a Python package
|
||||
├── constants.py
|
||||
├── base.py
|
||||
├── game_card.py
|
||||
├── detail_page.py
|
||||
├── settings.py
|
||||
├── winetricks.py
|
||||
└── theme_utils.py
|
||||
```
|
||||
|
||||
**Main styles.py file:**
|
||||
```python
|
||||
def custom_button_style(color1, color2):
|
||||
return f"""
|
||||
QPushButton {{
|
||||
background: qlineargradient(x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 {color1}, stop:1 {color2});
|
||||
}}
|
||||
"""
|
||||
# Import from the theme's submodules using absolute paths relative to the package
|
||||
# Replace 'my_custom_theme' with your actual theme folder name
|
||||
from portprotonqt.themes.my_custom_theme.styles.constants import *
|
||||
from portprotonqt.themes.my_custom_theme.styles.base import *
|
||||
from portprotonqt.themes.my_custom_theme.styles.game_card import *
|
||||
from portprotonqt.themes.my_custom_theme.styles.detail_page import *
|
||||
from portprotonqt.themes.my_custom_theme.styles.settings import *
|
||||
from portprotonqt.themes.my_custom_theme.styles.winetricks import *
|
||||
from portprotonqt.themes.my_custom_theme.styles.theme_utils import *
|
||||
```
|
||||
|
||||
**Example submodule (styles/constants.py):**
|
||||
```python
|
||||
# Theme constants
|
||||
font_family = "Play"
|
||||
font_size_a = "16px"
|
||||
font_size_b = "24px"
|
||||
border_radius_a = "10px"
|
||||
color_a = "#409EFF"
|
||||
color_b = "#282a33"
|
||||
# ... other constants
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
@@ -31,17 +31,49 @@ mkdir -p ~/.local/share/PortProtonQT/themes/my_custom_theme
|
||||
|
||||
## 🎨 Файл стилей (`styles.py`)
|
||||
|
||||
Создайте `styles.py` в корне темы. В нём определите переменные и/или функции, возвращающие CSS-оформление.
|
||||
Создайте `styles.py` в корне темы. В нём определите переменные и/или функции, возвращающие QSS-оформление (Qt Style Sheets). Для лучшей организации кода, вы можете разделить тему на несколько подмодулей, создав поддиректорию `styles` с отдельными Python-файлами для разных компонентов, и импортировать их в `styles.py`.
|
||||
|
||||
**Пример функции:**
|
||||
**Пример модульной структуры:**
|
||||
```
|
||||
my_custom_theme/
|
||||
├── styles.py
|
||||
├── metainfo.ini
|
||||
├── fonts/
|
||||
├── images/
|
||||
└── styles/
|
||||
├── __init__.py # Этот пустой файл делает директорию Python-пакетом
|
||||
├── constants.py
|
||||
├── base.py
|
||||
├── game_card.py
|
||||
├── detail_page.py
|
||||
├── settings.py
|
||||
├── winetricks.py
|
||||
└── theme_utils.py
|
||||
```
|
||||
|
||||
**Основной файл styles.py:**
|
||||
```python
|
||||
def custom_button_style(color1, color2):
|
||||
return f"""
|
||||
QPushButton {{
|
||||
background: qlineargradient(x1:0, y1:0, x2:1, y2:0,
|
||||
stop:0 {color1}, stop:1 {color2});
|
||||
}}
|
||||
"""
|
||||
# Импорт из подмодулей темы с использованием абсолютных путей относительно пакета
|
||||
# Замените 'my_custom_theme' на фактическое имя папки вашей темы
|
||||
from portprotonqt.themes.my_custom_theme.styles.constants import *
|
||||
from portprotonqt.themes.my_custom_theme.styles.base import *
|
||||
from portprotonqt.themes.my_custom_theme.styles.game_card import *
|
||||
from portprotonqt.themes.my_custom_theme.styles.detail_page import *
|
||||
from portprotonqt.themes.my_custom_theme.styles.settings import *
|
||||
from portprotonqt.themes.my_custom_theme.styles.winetricks import *
|
||||
from portprotonqt.themes.my_custom_theme.styles.theme_utils import *
|
||||
```
|
||||
|
||||
**Пример подмодуля (styles/constants.py):**
|
||||
```python
|
||||
# Константы темы
|
||||
font_family = "Play"
|
||||
font_size_a = "16px"
|
||||
font_size_b = "24px"
|
||||
border_radius_a = "10px"
|
||||
color_a = "#409EFF"
|
||||
color_b = "#282a33"
|
||||
# ... другие константы
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Reference in New Issue
Block a user