LiquidGUI [1.3.0.0]

- Continued refactoring.
This commit is contained in:
2025-02-10 20:13:22 +00:00
parent c05e8da224
commit 89129fc6e5
7 changed files with 67 additions and 51 deletions
+9 -1
View File
@@ -4,9 +4,17 @@
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: LiquidCTL",
"type": "debugpy",
"request": "launch",
"program": "${workspaceFolder}/main.pyw",
"console": "integratedTerminal",
"justMyCode": true
},
{
"name": "Python: Current File",
"type": "python",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
+8
View File
@@ -0,0 +1,8 @@
from abc import ABC, abstractmethod
class VitalsHelperInterface(ABC):
@abstractmethod
def get_temps(self, HWSensor):
""" Return Temperatures """
pass
+3 -3
View File
@@ -1,13 +1,13 @@
from interfaces.liquidctl_helper_interface import LiquidCTL_Helper_Interface
import subprocess
import re
from liquidctl_helper_interface import LiquidCTL_Helper_Interface
class LiquidCTL_Helper(LiquidCTL_Helper_Interface):
device_name: str = ""
device_name = str()
device_temp = 0
device_fanSpeed = 0
device_pumpSpeed = 0
device_fwVers = None
device_fwVers = str()
devices = None
+3 -3
View File
@@ -1,12 +1,12 @@
from interfaces.liquidctl_helper_interface import LiquidCTL_Helper_Interface
from liquidctl import find_liquidctl_devices, cli # type: ignore
from liquidctl_helper_interface import LiquidCTL_Helper_Interface
class LiquidCTL_Helper(LiquidCTL_Helper_Interface):
device_name = None
device_name = str()
device_temp = 0
device_fanSpeed = 0
device_pumpSpeed = 0
device_fwVers = None
device_fwVers = str()
devices = find_liquidctl_devices()
try:
+26 -21
View File
@@ -16,17 +16,15 @@ import common
from MessageHandler import MessageHandler
## Platform Imports #########################################
import globals
from vitals_helper import Component
from styles import Labels
if globals.os == "Windows":
from liquidctl_helper_windows import LiquidCTL_Helper
from vitals_helper import VitalsHelperWindows as svh
from vitals_helper import VitalsHelperWindows as VitalsHelper
import win32mica # type: ignore
import darkdetect # type: ignore
elif globals.os == "Linux":
from liquidctl_helper_linux import LiquidCTL_Helper
from vitals_helper import VitalsHelperLinux as svh
from vitals_helper import VitalsHelperLinux as VitalsHelper
class MainWindow(QMainWindow):
@@ -37,13 +35,13 @@ class MainWindow(QMainWindow):
self.setWindowTitle("LiquidGUI (v.1.3.0.0) DEV")
self.setFixedSize(450, 700)
self.lctl = lctl
self.svh = svh()
self._lctl = lctl
self.__vitals_helper = VitalsHelper()
# Widgets ##########################################
self.lbl_device_name = Labels.MainLabel()
self.lbl_cpu_temp = Labels.SubLabel(value="🔳 CPU Temp:")
self.lbl_cpu_temp = Labels.SubLabel(value="💻 CPU Temp:")
self.min_max_cur_cpu_temp = common.MinMaxCurrent()
self.prg_cpu_temp = QProgressBar(textVisible=False,
minimum=0,
@@ -101,12 +99,12 @@ class MainWindow(QMainWindow):
self.setCentralWidget(widget)
self.setContentsMargins(20, 20, 20, 20)
# Threading #######################################
# Threading #######################################################################
self.thread_manager = QThreadPool()
self.timer = QTimer()
self.timer.setInterval(1000)
self.timer.timeout.connect(lambda: self.thread_manager.start(self.lctl.Update))
self.timer.timeout.connect(lambda: self.thread_manager.start(self._lctl.Update))
self.timer.timeout.connect(self.update_widgets)
self.timer.start()
@@ -122,39 +120,46 @@ class MainWindow(QMainWindow):
def update_widgets(self):
""" Update widgets using LiquidCTL library."""
# Platform Specific Widgets #######################################################
if globals.platform == "Windows":
self.__vitals_helper()
elif globals.platform == "Linux":
self.lbl_value_prg_cpu_temp.setText(
self.min_max_cur_cpu_temp.builder(
self.svh.get_temps(Component.lin_cpu_amd), "°C"))
self.__vitals_helper.get_temps(
self.__vitals_helper.Component.lin_cpu_amd), "°C"))
self.prg_cpu_temp.setValue(
self.svh.get_temps(Component.lin_cpu_amd))
self.__vitals_helper.get_temps(
self.__vitals_helper.Component.lin_cpu_amd))
# Cross Platform Widgets ##########################################################
self.lbl_device_name.setText(
self.lctl.device_name)
self._lctl.device_name)
self.prg_temp.setValue(
self.lctl.device_temp)
self._lctl.device_temp)
self.lbl_value_prg_temp.setText(
self.min_max_cur_temp.builder(
self.lctl.device_temp, "°C"))
self._lctl.device_temp, "°C"))
self.prg_fanspeed.setValue(
self.lctl.device_fanSpeed)
self._lctl.device_fanSpeed)
self.lbl_value_prg_fanspeed.setText(
self.min_max_cur_fanspeed.builder(
self.lctl.device_fanSpeed, " rpm"))
self._lctl.device_fanSpeed, " rpm"))
self.prg_pumpspeed.setValue(
self.lctl.device_pumpSpeed)
self._lctl.device_pumpSpeed)
self.lbl_value_prg_pumpspeed.setText(
self.min_max_cur_pumpspeed.builder(
self.lctl.device_pumpSpeed, " rpm"))
self._lctl.device_pumpSpeed, " rpm"))
if self.lctl.device_fwVers is not None:
self.lbl_fwvers.setText(f"Firmware: v{self.lctl.device_fwVers}")
if self._lctl.device_fwVers is not None:
self.lbl_fwvers.setText(f"Firmware: v{self._lctl.device_fwVers}")
def main():
@@ -178,7 +183,7 @@ def main():
app.setWindowIcon(icon)
# Show error and quit app if no devices are found
if window.lctl.TestConnectionState():
if window._lctl.TestConnectionState():
MessageHandler().ShowNoDevicesFoundError()
sys.exit(1)
else:
+12 -17
View File
@@ -1,33 +1,28 @@
from interfaces.vitals_helper_interface import VitalsHelperInterface
from enum import Enum
from abc import ABC, abstractmethod
import psutil
import pythonnet
import os
class Component(Enum):
class VitalsHelperLinux(VitalsHelperInterface):
class HWSensor(Enum):
lin_cpu_amd = ("k10temp", "Tctl")
lin_gpu_amd = ("amdgpu", "edge")
lin_mobo_asus = ("asus_wmi_sensors", "Motherboard Temperature")
class VitalsHelperInterface(ABC):
@abstractmethod
def get_temps(self, component: Component):
""" Return Temperatures """
pass
class VitalsHelperLinux(VitalsHelperInterface):
def get_temps(self, component: Component):
def get_temps(self, _hw_sensor: HWSensor):
temps = psutil.sensors_temperatures()
if component.value[0] in temps:
for entry in temps[component.value[0]]:
if entry.label == component.value[1]:
if _hw_sensor.value[0] in temps:
for entry in temps[_hw_sensor.value[0]]:
if entry.label == _hw_sensor.value[1]:
return round(entry.current, 2)
class VitalsHelperWindows(VitalsHelperInterface):
def __init__(self):
print(f"{self.__class__.__name__} is not Implemented")
def get_temps(self, component: Component):
class HWSensor(Enum):
pass
def get_temps(self, _hw_sensor: HWSensor):
return 0