From 90085f08aade3a505c6ca91f1692cc4abbee72eb Mon Sep 17 00:00:00 2001 From: Vinicius Moreira Date: Fri, 27 Nov 2020 17:46:29 -0300 Subject: [PATCH] [themes] disabling percentage measures --- bauh/stylesheet.py | 75 +++++++++---------- bauh/view/resources/style/default/default.qss | 22 +++--- 2 files changed, 48 insertions(+), 49 deletions(-) diff --git a/bauh/stylesheet.py b/bauh/stylesheet.py index 681a99d6..708a8535 100644 --- a/bauh/stylesheet.py +++ b/bauh/stylesheet.py @@ -1,17 +1,14 @@ import glob import os import re -import traceback from typing import Optional, Dict, Tuple, Set -from PyQt5.QtWidgets import QApplication - from bauh.api.constants import USER_THEMES_PATH from bauh.view.util import resource from bauh.view.util.translation import I18n -RE_WIDTH_PERCENT = re.compile(r'[\d\\.]+%w') -RE_HEIGHT_PERCENT = re.compile(r'[\d\\.]+%h') +# RE_WIDTH_PERCENT = re.compile(r'[\d\\.]+%w') TODO percentage measures disabled for the moment (requires more testing) +# RE_HEIGHT_PERCENT = re.compile(r'[\d\\.]+%h') TODO percentage measures disabled for the moment (requires more testing) RE_META_I18N_FIELDS = re.compile(r'((name|description)(\[\w+])?)') RE_VAR_PATTERN = re.compile(r'^@[\w.\-_]+') RE_QSS_EXT = re.compile(r'\.qss$') @@ -161,9 +158,10 @@ def process_theme(file_path: str, theme_str: str, metadata: ThemeMetadata, for var in var_list: theme_str = theme_str.replace('@' + var, var_map[var]) - screen_size = QApplication.primaryScreen().size() - theme_str = process_width_percent_measures(theme_str, screen_size.width()) - theme_str = process_height_percent_measures(theme_str, screen_size.height()) + # TODO percentage measures disabled for the moment (requires more testing) + # screen_size = QApplication.primaryScreen().size() + # theme_str = process_width_percent_measures(theme_str, screen_size.width()) + # theme_str = process_height_percent_measures(theme_str, screen_size.height()) return theme_str if not root_theme else '{}\n{}'.format(root_theme[0], theme_str), metadata @@ -172,36 +170,6 @@ def _by_str_len(string: str) -> int: return len(string) -def process_width_percent_measures(theme: str, screen_width: int) -> str: - width_measures = RE_WIDTH_PERCENT.findall(theme) - - final_theme = theme - if width_measures: - for m in width_measures: - try: - percent = float(m.split('%')[0]) - final_theme = final_theme.replace(m, '{}px'.format(round(screen_width * percent))) - except ValueError: - traceback.print_exc() - - return final_theme - - -def process_height_percent_measures(theme: str, screen_height: int) -> str: - width_measures = RE_HEIGHT_PERCENT.findall(theme) - - final_sheet = theme - if width_measures: - for m in width_measures: - try: - percent = float(m.split('%')[0]) - final_sheet = final_sheet.replace(m, '{}px'.format(round(screen_height * percent))) - except ValueError: - traceback.print_exc() - - return final_sheet - - def _read_var_file(theme_file: str) -> dict: vars_file = theme_file.replace('.qss', '.vars') var_map = {} @@ -257,3 +225,34 @@ def process_var_of_vars(var_map: dict): if resolved == len(pending_vars): break + + +# TODO percentage measures disabled for the moment (requires more testing) +# def process_width_percent_measures(theme: str, screen_width: int) -> str: +# width_measures = RE_WIDTH_PERCENT.findall(theme) +# +# final_theme = theme +# if width_measures: +# for m in width_measures: +# try: +# percent = float(m.split('%')[0]) +# final_theme = final_theme.replace(m, '{}px'.format(round(screen_width * percent))) +# except ValueError: +# traceback.print_exc() +# +# return final_theme + + +# def process_height_percent_measures(theme: str, screen_height: int) -> str: +# width_measures = RE_HEIGHT_PERCENT.findall(theme) +# +# final_sheet = theme +# if width_measures: +# for m in width_measures: +# try: +# percent = float(m.split('%')[0]) +# final_sheet = final_sheet.replace(m, '{}px'.format(round(screen_height * percent))) +# except ValueError: +# traceback.print_exc() +# +# return final_sheet diff --git a/bauh/view/resources/style/default/default.qss b/bauh/view/resources/style/default/default.qss index f4bbda03..965f4b0f 100644 --- a/bauh/view/resources/style/default/default.qss +++ b/bauh/view/resources/style/default/default.qss @@ -286,39 +286,39 @@ AboutDialog QLabel { AboutDialog QLabel#logo { qproperty-pixmap: url("@images/logo.svg"); qproperty-scaledContents: true; - min-height: 0.071041667%h; - max-height: 0.071041667%h; - min-width: 0.046852123%w; - max-width: 0.046852123%w; + min-height: 55px; + max-height: 55px; + min-width: 64px; + max-width: 64px; } AboutDialog QLabel#app_name { - font-size: 0.018229167%h; + font-size: 14px; font-weight: bold; } AboutDialog QLabel#app_version { - font-size: 0.014322917%h; + font-size: 11px; font-weight: bold; } AboutDialog QLabel#app_description { - min-width: 0.292397661%w; - font-size: 0.015625%h; + min-width: 400px; + font-size: 12px; font-weight: bold; } AboutDialog QLabel#app_more_information, AboutDialog QLabel#app_license { - font-size: 0.014322917%h; + font-size: 11px; } AboutDialog > QLabel#app_trouble_question, AboutDialog > QLabel#app_rate_question { - font-size: 0.013020833%h; + font-size: 10px; font-weight: bold; } AboutDialog > QLabel#app_trouble_answer, AboutDialog > QLabel#app_rate_answer { - font-size: 0.013020833%h; + font-size: 10px; } RootDialog QLineEdit#password {