From aedd54b6a971eb0cfad2149d482b4fb3de44875f Mon Sep 17 00:00:00 2001 From: Dunestorm Date: Wed, 29 Jan 2025 21:13:16 +0000 Subject: [PATCH] LiquidGUI [1.3.0.0] - Unified Labels class to handle Linux and Windows. --- main.pyw | 8 +++---- styles/Labels.py | 46 ++++++++++++++++++++++++++++++++++++++++ styles/Labels_Linux.py | 27 ----------------------- styles/Labels_Windows.py | 27 ----------------------- 4 files changed, 49 insertions(+), 59 deletions(-) create mode 100644 styles/Labels.py delete mode 100644 styles/Labels_Linux.py delete mode 100644 styles/Labels_Windows.py diff --git a/main.pyw b/main.pyw index 2e5aa7e..0363c54 100644 --- a/main.pyw +++ b/main.pyw @@ -16,17 +16,15 @@ import common from MessageHandler import MessageHandler ## Platform Imports ######################################### import globals -from sys_vitals_helper import SysVitals_Helper +from sys_vitals_helper import SysVitals_Helper, Component +from styles import Labels if globals.os == "Windows": from LiquidCTL_Helper_Windows import LiquidCTL_Helper - from styles import Labels_Windows as Labels import win32mica # type: ignore import darkdetect # type: ignore elif globals.os == "Linux": from LiquidCTL_Helper_Linux import LiquidCTL_Helper - from styles import Labels_Linux as Labels - from pathlib import Path - from sys_vitals_helper import SysVitals_Helper, Component + class MainWindow(QMainWindow): diff --git a/styles/Labels.py b/styles/Labels.py new file mode 100644 index 0000000..b99c6a5 --- /dev/null +++ b/styles/Labels.py @@ -0,0 +1,46 @@ +from PySide6.QtWidgets import QLabel +from PySide6.QtGui import QFont +from PySide6.QtCore import Qt +import globals + +def _set_os_family_font(ClassName: str): + _font = None + + if globals.os == "Linux": + if ClassName == MainLabel.__name__ or SubLabel.__name__: + _font = "Noto Sans" + elif ClassName == SubLabelValue.__name__: + _font = "Noto Sans Mono" + elif globals.os == "Windows": + if ClassName == MainLabel.__name__ or SubLabel.__name__: + _font = "Calibri" + elif ClassName == SubLabelValue.__name__: + _font = "Cascadia Code" + + return _font + + +class MainLabel(QLabel): + def __init__(self): + super().__init__() + self.setAlignment(Qt.AlignmentFlag.AlignCenter) + self.setFont(QFont(_set_os_family_font(__class__.__name__), + 16, + weight=QFont.Weight.ExtraBold)) + +class SubLabel(QLabel): + """ Formatting for sub-labels. """ + + def __init__(self, value): + super().__init__() + self.setFont(QFont(_set_os_family_font(__class__.__name__), + 12, + weight=QFont.Weight.Thin)) + self.setText(value) + +class SubLabelValue(QLabel): + """ Formatting for values. """ + def __init__(self): + super().__init__() + self.setAlignment(Qt.AlignmentFlag.AlignRight) + self.setFont(QFont(_set_os_family_font(__class__.__name__), 8)) \ No newline at end of file diff --git a/styles/Labels_Linux.py b/styles/Labels_Linux.py deleted file mode 100644 index 84aecc5..0000000 --- a/styles/Labels_Linux.py +++ /dev/null @@ -1,27 +0,0 @@ -from PySide6.QtWidgets import QLabel -from PySide6.QtGui import QFont -from PySide6.QtCore import Qt - -class MainLabel(QLabel): - def __init__(self): - super().__init__() - self.setAlignment(Qt.AlignmentFlag.AlignCenter) - self.setFont(QFont("Noto Sans", - 16, - weight=QFont.Weight.ExtraBold)) -class SubLabel(QLabel): - """ Formatting for sub-labels. """ - - def __init__(self, value): - super().__init__() - self.setFont(QFont("Noto Sans", 12, weight=QFont.Weight.Thin)) - self.setText(value) -class SubLabelValue(QLabel): - """ Formatting for values. """ - def __init__(self): - super().__init__() - self.setAlignment(Qt.AlignmentFlag.AlignRight) - self.setFont(QFont("Noto Sans Mono", 8)) - - - diff --git a/styles/Labels_Windows.py b/styles/Labels_Windows.py deleted file mode 100644 index 3c548c1..0000000 --- a/styles/Labels_Windows.py +++ /dev/null @@ -1,27 +0,0 @@ -from PySide6.QtWidgets import QLabel -from PySide6.QtGui import QFont -from PySide6.QtCore import Qt - -class MainLabel(QLabel): - def __init__(self): - super().__init__() - self.setAlignment(Qt.AlignmentFlag.AlignCenter) - self.setFont(QFont("Calibri", - 14.5, - weight=QFont.Weight.ExtraBold)) -class SubLabel(QLabel): - """ Formatting for sub-labels. """ - - def __init__(self, value): - super().__init__() - self.setFont(QFont("Calibri", 12, weight=QFont.Weight.Thin)) - self.setText(value) -class SubLabelValue(QLabel): - """ Formatting for values. """ - def __init__(self): - super().__init__() - self.setAlignment(Qt.AlignmentFlag.AlignRight) - self.setFont(QFont("Cascadia Code", 8)) - - -