refactored , now doesnt load qt shit on windows. check blame for more info
All checks were successful
Build MuCaPy Executable / build-and-package (push) Successful in 1m42s

This commit is contained in:
rattatwinko
2025-06-07 23:13:05 +02:00
parent 9f5c3f014c
commit 003ea7ddcf
4 changed files with 65 additions and 33 deletions

View File

@@ -563,14 +563,12 @@ class CameraDisplay(QLabel):
super().__init__(parent) super().__init__(parent)
self.setAlignment(Qt.AlignCenter) self.setAlignment(Qt.AlignCenter)
self.setText("No camera feed") self.setText("No camera feed")
self.setStyleSheet("""
QLabel { self.get_camera_display_style = getpath.resource_path("styling/camera_display.qss")
background-color: #1E1E1E; with open(self.get_camera_display_style,"r") as cdst:
color: #DDD; self.setStyleSheet(cdst.read())
border: 2px solid #444; # I really dont know what the fuck is going on here. The StyleSheet never actually gets called
border-radius: 4px;
}
""")
self.setMinimumSize(320, 240) self.setMinimumSize(320, 240)
self.fullscreen_window = None self.fullscreen_window = None
self.cam_id = None self.cam_id = None
@@ -817,14 +815,13 @@ class AboutWindow(QDialog):
self.toggle_btn.setText("") self.toggle_btn.setText("")
self.toggle_btn.setCheckable(True) self.toggle_btn.setCheckable(True)
self.toggle_btn.setChecked(False) self.toggle_btn.setChecked(False)
self.toggle_btn.setStyleSheet(""" toggle_btn_style = getpath.resource_path("styling/togglebtnabout.qss")
QToolButton { with open(toggle_btn_style,"r") as tgbstyle:
border: none; self.toggle_btn.setStyleSheet(tgbstyle.read())
background: transparent;
font-size: 14px; # Debug shit
color: #DDD; #print("i did shit")
}
""")
self.toggle_btn.toggled.connect(self.toggle_expand) self.toggle_btn.toggled.connect(self.toggle_expand)
header_layout.addWidget(self.toggle_btn) header_layout.addWidget(self.toggle_btn)
@@ -923,6 +920,12 @@ class AboutWindow(QDialog):
info['NumPy'] = np.__version__ info['NumPy'] = np.__version__
info['Requests'] = requests.__version__ info['Requests'] = requests.__version__
# If we are on Linux we display the QTVAR
if platform.system() == "Linux":
info["XDG_ENVIROMENT_TYPE "] = initQT.getenv(self) # get the stupid env var of qt
else:
pass
mem = psutil.virtual_memory() mem = psutil.virtual_memory()
info['MemoryGB'] = mem.total // (1024**3) info['MemoryGB'] = mem.total // (1024**3)
info['Memory'] = f"{info['MemoryGB']} GB RAM" info['Memory'] = f"{info['MemoryGB']} GB RAM"
@@ -945,6 +948,7 @@ class AboutWindow(QDialog):
class NetworkCameraDialog(QDialog): class NetworkCameraDialog(QDialog):
def __init__(self, parent=None): def __init__(self, parent=None):
super().__init__(parent) super().__init__(parent)
self.setWindowTitle("Network Camera Settings") self.setWindowTitle("Network Camera Settings")
@@ -2035,14 +2039,9 @@ class MainWindow(QMainWindow):
# Clear displays # Clear displays
for display in self.camera_displays: for display in self.camera_displays:
display.setText("No camera feed") display.setText("No camera feed")
display.setStyleSheet(""" cleardisplaypath = getpath.resource_path("styling/cleardisplay.qss")
QLabel { with open(cleardisplaypath,"r") as cdstyle:
background-color: #1E1E1E; display.setStyleSheet(cdstyle.read())
color: #DDD;
border: 2px solid #444;
border-radius: 4px;
}
""")
def update_feeds(self): def update_feeds(self):
"""Update the camera feeds in the display""" """Update the camera feeds in the display"""
@@ -2236,7 +2235,12 @@ class initQT():
# If the OS is Linux get Qts Session Type # If the OS is Linux get Qts Session Type
if platform.system() == "Linux": if platform.system() == "Linux":
self.session_type = os.getenv("XDG_SESSION_TYPE") self.session_type = os.getenv("XDG_SESSION_TYPE")
print(f"got {self.session_type} ")
# Enable this is stuff is exiting!
# print(f"got {self.session_type} ")
return self.session_type
else: else:
# If theres no Type then Exit 1 # If theres no Type then Exit 1
print( print(
@@ -2250,7 +2254,10 @@ class initQT():
# Set the Session Type to the one it got # Set the Session Type to the one it got
if self.session_type: if self.session_type:
os.environ["XDG_SESSION_TYPE"] = self.session_type os.environ["XDG_SESSION_TYPE"] = self.session_type
print(f"set the ENVVAR to {self.session_type}")
# Enable if stuff is exiting!
# print(f"set the ENVVAR to {self.session_type}")
else: else:
# If this fails then just exit with 1 # If this fails then just exit with 1
print( print(
@@ -2261,14 +2268,21 @@ class initQT():
exit(1) exit(1)
def shutupCV(self): def shutupCV(self):
# This needs some fixing as this only works before importing CV2 ; too much refactoring work tho! # This needs some fixing as this only works before importing CV2 ; too much refactoring work tho!
os.environ["OPENCV_LOG_LEVEL"] = "ERROR" if platform.system() == "Linux":
os.environ["OPENCV_LOG_LEVEL"] = "ERROR"
else:
pass
if __name__ == "__main__": if __name__ == "__main__":
# Initialize Qt # Initialize Qt if on Linux
qt = initQT() if platform.system() == "Linux":
qt.getenv() qt = initQT()
qt.setenv() qt.getenv()
qt.shutupCV() qt.setenv()
qt.shutupCV()
else:
# We do nothing, Windows doesnt need this
pass
app = QApplication(sys.argv) app = QApplication(sys.argv)

View File

@@ -0,0 +1,6 @@
QLabel {
background-color: #1E1E1E;
color: #DDD;
border: 2px solid #444;
border-radius: 4px;
}

View File

@@ -0,0 +1,6 @@
QLabel {
background-color: #1E1E1E;
color: #DDD;
border: 2px solid #444;
border-radius: 4px;
}

View File

@@ -0,0 +1,6 @@
QToolButton {
border: none;
background: transparent;
font-size: 14px;
color: #DDD;
}