seperate files for the CPU style ; and more error resistant
All checks were successful
Build MuCaPy Executable / build-and-package (push) Successful in 1m42s

This commit is contained in:
rattatwinko
2025-06-08 14:12:42 +02:00
parent 003ea7ddcf
commit dffeb995a0
4 changed files with 146 additions and 14 deletions

View File

@@ -233,6 +233,7 @@ class CameraThread(QThread):
except Exception as e: except Exception as e:
print(f"Connection attempt {attempt + 1} failed: {str(e)}") print(f"Connection attempt {attempt + 1} failed: {str(e)}")
if self.cap: if self.cap:
self.cap.release() self.cap.release()
self.cap = None self.cap = None
@@ -567,7 +568,6 @@ class CameraDisplay(QLabel):
self.get_camera_display_style = getpath.resource_path("styling/camera_display.qss") self.get_camera_display_style = getpath.resource_path("styling/camera_display.qss")
with open(self.get_camera_display_style,"r") as cdst: with open(self.get_camera_display_style,"r") as cdst:
self.setStyleSheet(cdst.read()) self.setStyleSheet(cdst.read())
# I really dont know what the fuck is going on here. The StyleSheet never actually gets called
self.setMinimumSize(320, 240) self.setMinimumSize(320, 240)
self.fullscreen_window = None self.fullscreen_window = None
@@ -1469,7 +1469,10 @@ class MainWindow(QMainWindow):
# Apply saved settings to UI # Apply saved settings to UI
self.apply_saved_settings() self.apply_saved_settings()
# For the CPU Styling we have another one so we set this here!
self.sepstyleing = False
def load_saved_settings(self): def load_saved_settings(self):
"""Load saved settings from configuration""" """Load saved settings from configuration"""
# Load model directory # Load model directory
@@ -2200,20 +2203,62 @@ class MainWindow(QMainWindow):
for bar in [self.cpu_progress] + self.core_bars: for bar in [self.cpu_progress] + self.core_bars:
value = bar.value() value = bar.value()
if value < 60: if value < 60:
u60 = getpath.resource_path("styling/bar/u60.qss") # Here we load the Style File if the CPU Load is under 60%
with open(u60,"r") as u60_style: if self.sepstyleing == False:
bar.setStyleSheet(u60_style.read()) u60 = getpath.resource_path("styling/bar/u60.qss")
try:
with open(u60,"r") as u60_style:
bar.setStyleSheet(u60_style.read())
except FileNotFoundError:
print("Styling for CPU U60 not found!")
exit(1)
else:
u60seperate = getpath.resource_path("styling/bar/seperate/u60.qss")
try:
with open(u60seperate,"r") as u60_seperate_styling:
bar.setStyleSheet(u60_seperate_styling.read())
except FileNotFoundError:
print("No Seperate Styling! Generate one!")
pass
elif value < 85: elif value < 85:
u85 = getpath.resource_path("styling/bar/a85.qss") # Here we load the Style File if the CPU Load is over 85%
with open(u85,"r") as a85_styling: if self.sepstyleing == False:
bar.setStyleSheet(a85_styling.read()) u85 = getpath.resource_path("styling/bar/a85.qss")
try:
with open(u85,"r") as a85_styling:
bar.setStyleSheet(a85_styling.read())
except FileNotFoundError:
print("Styling for CPU u85 not found")
exit(1)
else:
u85sep = getpath.resource_path("styling/bar/seperate/a85.qss")
try:
with open(u85sep,"r") as u85style_sep:
bar.setStyleSheet(u85style_sep.read())
except FileNotFoundError:
print("No Seperate File Found for U85")
pass
else: else:
else_file = getpath.resource_path("styling/bar/else.qss") # Here we load the Style File if the CPU Load is over 85 or 100 or smth idk
with open(else_file, "r") as else_style: if self.sepstyleing == False:
bar.setStyleSheet(else_style.read()) else_file = getpath.resource_path("styling/bar/else.qss")
try:
with open(else_file, "r") as else_style:
bar.setStyleSheet(else_style.read())
except FileNotFoundError:
print("No ElseStyling found!")
exit(1)
else:
else_file_seperate = getpath.resource_path("styling/bar/seperate/else.qss")
try:
with open(else_file_seperate,"r") as efs:
bar.setStyleSheet(efs.read())
except FileNotFoundError:
print("No Sepearte Styling found")
pass
def toggle_detection(self): def toggle_detection(self):
"""Toggle detection enabled/disabled""" """Toggle detection enabled/disabled"""
@@ -2285,7 +2330,13 @@ if __name__ == "__main__":
pass pass
app = QApplication(sys.argv) app = QApplication(sys.argv)
# Here we try to set the AppIcon ; If it isnt find then just pass
try:
app.setWindowIcon(QIcon(getpath.resource_path("styling/icon.png")))
except FileNotFoundError:
pass
# Set application style to Fusion for better dark mode support # Set application style to Fusion for better dark mode support
app.setStyle("Fusion") app.setStyle("Fusion")

View File

@@ -0,0 +1,27 @@
QProgressBar {
border: 2px solid #550000;
border-radius: 50px;
background-color: qradialgradient(
cx:0.5, cy:0.5,
fx:0.5, fy:0.5,
radius:1.0,
stop:0 #0d0d0d,
stop:1 #1a1a1a
);
text-align: center;
color: #cccccc;
font-family: "Fira Code", "OCR A Std", monospace;
font-style: italic;
font-size: 14px;
padding: 5px;
}
QProgressBar::chunk {
background: qlineargradient(
x1:0, y1:0, x2:1, y2:1,
stop:0 #ff0033,
stop:1 #ff6666
);
border-radius: 50px;
margin: 1px;
}

View File

@@ -0,0 +1,27 @@
QProgressBar {
border: 2px solid #550000;
border-radius: 50px;
background-color: qradialgradient(
cx:0.5, cy:0.5,
fx:0.5, fy:0.5,
radius:1.0,
stop:0 #0d0d0d,
stop:1 #1a1a1a
);
text-align: center;
color: #cccccc;
font-family: "Fira Code", "OCR A Std", monospace;
font-style: italic;
font-size: 14px;
padding: 5px;
}
QProgressBar::chunk {
background: qlineargradient(
x1:0, y1:0, x2:1, y2:1,
stop:0 #ff0033,
stop:1 #ff6666
);
border-radius: 50px;
margin: 1px;
}

View File

@@ -0,0 +1,27 @@
QProgressBar {
border: 2px solid #550000;
border-radius: 50px;
background-color: qradialgradient(
cx:0.5, cy:0.5,
fx:0.5, fy:0.5,
radius:1.0,
stop:0 #0d0d0d,
stop:1 #1a1a1a
);
text-align: center;
color: #cccccc;
font-family: "Fira Code", "OCR A Std", monospace;
font-style: italic;
font-size: 14px;
padding: 5px;
}
QProgressBar::chunk {
background: qlineargradient(
x1:0, y1:0, x2:1, y2:1,
stop:0 #ff0033,
stop:1 #ff6666
);
border-radius: 50px;
margin: 1px;
}