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