LiquidGUI [1.0.1.2]

- Error handling and app termination for no compatible coolers.
- Minor code refactoring.
This commit is contained in:
2023-08-18 21:37:59 +01:00
parent 9e38120cfb
commit 7b32a214df
3 changed files with 35 additions and 15 deletions
+6 -1
View File
@@ -13,12 +13,17 @@ class LiquidCTL_Init():
#print(f'{dev.description}') #print(f'{dev.description}')
device_name = dev.description device_name = dev.description
init_status = dev.initialize() init_status = dev.initialize()
if init_status: if init_status:
for key, value, unit in init_status: for key, value, unit in init_status:
#print(f'- {key}: {value} {unit}') #print(f'- {key}: {value} {unit}')
device_fwVers = value device_fwVers = value
def TestConnectionState(self):
if self.device_name != None:
return False
else:
return True
def Update(self): def Update(self):
with self.dev.connect(): with self.dev.connect():
status = self.dev.get_status() status = self.dev.get_status()
+10 -5
View File
@@ -1,16 +1,17 @@
import sys import sys
import qdarktheme import qdarktheme
import win32mica import win32mica
import liquidctl_worker
import resources import resources
from PySide6.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayout, QLabel, QProgressBar, QGroupBox from PySide6.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayout, QLabel, QProgressBar, QGroupBox
from PySide6.QtCore import Qt, QTimer, QThreadPool from PySide6.QtCore import Qt, QTimer, QThreadPool
from PySide6.QtGui import QFont, QIcon from PySide6.QtGui import QFont, QIcon
from liquidctl_worker import LiquidCTL_Init
from messagehandler import MessageHandler
class MainWindow(QMainWindow): class MainWindow(QMainWindow):
def __init__(self): def __init__(self):
super(MainWindow, self).__init__() super(MainWindow, self).__init__()
self.setWindowTitle("LiquidGUI (v.1.0.0.1)") self.setWindowTitle("LiquidGUI (v.1.0.1.2)")
self.setFixedSize(450, 300) self.setFixedSize(450, 300)
self.setWindowFlags(Qt.WindowType.Dialog) self.setWindowFlags(Qt.WindowType.Dialog)
widget = QWidget(self) widget = QWidget(self)
@@ -56,7 +57,6 @@ class MainWindow(QMainWindow):
self.timer.timeout.connect(self.update_widgets) self.timer.timeout.connect(self.update_widgets)
self.timer.start() self.timer.start()
def update_widgets(self): def update_widgets(self):
self.lbl_device_name.setText(lctl_worker.device_name) self.lbl_device_name.setText(lctl_worker.device_name)
self.prg_temp.setValue(lctl_worker.device_temp) self.prg_temp.setValue(lctl_worker.device_temp)
@@ -66,11 +66,16 @@ class MainWindow(QMainWindow):
self.lbl_fwVers.setText(f"Firmware: v{lctl_worker.device_fwVers}") self.lbl_fwVers.setText(f"Firmware: v{lctl_worker.device_fwVers}")
app = QApplication(sys.argv) app = QApplication(sys.argv)
icon = QIcon(":/icons/LiquidGUI.ico") icon = QIcon(":/icons/LiquidGUI.ico")
app.setWindowIcon(icon) app.setWindowIcon(icon)
lctl_worker = liquidctl_worker.LiquidCTL_Init() messagehandler = MessageHandler()
lctl_worker = LiquidCTL_Init()
# Show error and quit app if no devices are found
if lctl_worker.TestConnectionState() == True:
messagehandler.ShowNoDevicesFoundError()
sys.exit(1)
window = MainWindow() window = MainWindow()
window.setWindowIcon(icon) window.setWindowIcon(icon)
+10
View File
@@ -0,0 +1,10 @@
from PySide6.QtWidgets import QMessageBox
class MessageHandler():
def ShowNoDevicesFoundError(self):
msg = QMessageBox()
msg.setWindowTitle("LiquidGUI Error")
msg.setText("No suitable devices could be detected. Please ensure you have a cooler \
both compatible with LiquidCTL, and connected to the system.")
msg.setIcon(QMessageBox.Icon.Warning)
msg.exec()