diff --git a/liquidctl_worker.py b/liquidctl_worker.py index 5646883..05df6a2 100644 --- a/liquidctl_worker.py +++ b/liquidctl_worker.py @@ -13,20 +13,25 @@ class LiquidCTL_Init(): #print(f'{dev.description}') device_name = dev.description init_status = dev.initialize() - if init_status: for key, value, unit in init_status: #print(f'- {key}: {value} {unit}') device_fwVers = value + def TestConnectionState(self): + if self.device_name != None: + return False + else: + return True + def Update(self): with self.dev.connect(): - status = self.dev.get_status() - for key, value, unit in status: - #print(f'- {key}: {value} {unit}') - if key == "Liquid temperature": - self.device_temp = value - elif key == "Fan speed": - self.device_fanSpeed = value - elif key == "Pump speed": - self.device_pumpSpeed = value \ No newline at end of file + status = self.dev.get_status() + for key, value, unit in status: + #print(f'- {key}: {value} {unit}') + if key == "Liquid temperature": + self.device_temp = value + elif key == "Fan speed": + self.device_fanSpeed = value + elif key == "Pump speed": + self.device_pumpSpeed = value \ No newline at end of file diff --git a/main.pyw b/main.pyw index b25c80b..99dd6a3 100644 --- a/main.pyw +++ b/main.pyw @@ -1,16 +1,17 @@ import sys import qdarktheme import win32mica -import liquidctl_worker import resources from PySide6.QtWidgets import QApplication, QMainWindow, QWidget, QVBoxLayout, QLabel, QProgressBar, QGroupBox from PySide6.QtCore import Qt, QTimer, QThreadPool from PySide6.QtGui import QFont, QIcon +from liquidctl_worker import LiquidCTL_Init +from messagehandler import MessageHandler class MainWindow(QMainWindow): def __init__(self): 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.setWindowFlags(Qt.WindowType.Dialog) widget = QWidget(self) @@ -56,7 +57,6 @@ class MainWindow(QMainWindow): self.timer.timeout.connect(self.update_widgets) self.timer.start() - def update_widgets(self): self.lbl_device_name.setText(lctl_worker.device_name) 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}") app = QApplication(sys.argv) - icon = QIcon(":/icons/LiquidGUI.ico") 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.setWindowIcon(icon) diff --git a/messagehandler.py b/messagehandler.py new file mode 100644 index 0000000..d5f1fc1 --- /dev/null +++ b/messagehandler.py @@ -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() \ No newline at end of file