diff --git a/mucapy/main.py b/mucapy/main.py index dbb2627..0ffaf03 100644 --- a/mucapy/main.py +++ b/mucapy/main.py @@ -563,14 +563,12 @@ class CameraDisplay(QLabel): super().__init__(parent) self.setAlignment(Qt.AlignCenter) self.setText("No camera feed") - self.setStyleSheet(""" - QLabel { - background-color: #1E1E1E; - color: #DDD; - border: 2px solid #444; - border-radius: 4px; - } - """) + + self.get_camera_display_style = getpath.resource_path("styling/camera_display.qss") + with open(self.get_camera_display_style,"r") as cdst: + 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.fullscreen_window = None self.cam_id = None @@ -817,14 +815,13 @@ class AboutWindow(QDialog): self.toggle_btn.setText("▶") self.toggle_btn.setCheckable(True) self.toggle_btn.setChecked(False) - self.toggle_btn.setStyleSheet(""" - QToolButton { - border: none; - background: transparent; - font-size: 14px; - color: #DDD; - } - """) + toggle_btn_style = getpath.resource_path("styling/togglebtnabout.qss") + with open(toggle_btn_style,"r") as tgbstyle: + self.toggle_btn.setStyleSheet(tgbstyle.read()) + + # Debug shit + #print("i did shit") + self.toggle_btn.toggled.connect(self.toggle_expand) header_layout.addWidget(self.toggle_btn) @@ -923,6 +920,12 @@ class AboutWindow(QDialog): info['NumPy'] = np.__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() info['MemoryGB'] = mem.total // (1024**3) info['Memory'] = f"{info['MemoryGB']} GB RAM" @@ -945,6 +948,7 @@ class AboutWindow(QDialog): class NetworkCameraDialog(QDialog): + def __init__(self, parent=None): super().__init__(parent) self.setWindowTitle("Network Camera Settings") @@ -2035,15 +2039,10 @@ class MainWindow(QMainWindow): # Clear displays for display in self.camera_displays: display.setText("No camera feed") - display.setStyleSheet(""" - QLabel { - background-color: #1E1E1E; - color: #DDD; - border: 2px solid #444; - border-radius: 4px; - } - """) - + cleardisplaypath = getpath.resource_path("styling/cleardisplay.qss") + with open(cleardisplaypath,"r") as cdstyle: + display.setStyleSheet(cdstyle.read()) + def update_feeds(self): """Update the camera feeds in the display""" frames = self.detector.get_frames() @@ -2236,7 +2235,12 @@ class initQT(): # If the OS is Linux get Qts Session Type if platform.system() == "Linux": 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: # If theres no Type then Exit 1 print( @@ -2250,7 +2254,10 @@ class initQT(): # Set the Session Type to the one it got if 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: # If this fails then just exit with 1 print( @@ -2261,14 +2268,21 @@ class initQT(): exit(1) def shutupCV(self): # 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__": - # Initialize Qt - qt = initQT() - qt.getenv() - qt.setenv() - qt.shutupCV() + # Initialize Qt if on Linux + if platform.system() == "Linux": + qt = initQT() + qt.getenv() + qt.setenv() + qt.shutupCV() + else: + # We do nothing, Windows doesnt need this + pass app = QApplication(sys.argv) diff --git a/mucapy/styling/camera_display.qss b/mucapy/styling/camera_display.qss new file mode 100644 index 0000000..63affda --- /dev/null +++ b/mucapy/styling/camera_display.qss @@ -0,0 +1,6 @@ +QLabel { + background-color: #1E1E1E; + color: #DDD; + border: 2px solid #444; + border-radius: 4px; +} \ No newline at end of file diff --git a/mucapy/styling/cleardisplay.qss b/mucapy/styling/cleardisplay.qss new file mode 100644 index 0000000..63affda --- /dev/null +++ b/mucapy/styling/cleardisplay.qss @@ -0,0 +1,6 @@ +QLabel { + background-color: #1E1E1E; + color: #DDD; + border: 2px solid #444; + border-radius: 4px; +} \ No newline at end of file diff --git a/mucapy/styling/togglebtnabout.qss b/mucapy/styling/togglebtnabout.qss new file mode 100644 index 0000000..3c957f3 --- /dev/null +++ b/mucapy/styling/togglebtnabout.qss @@ -0,0 +1,6 @@ +QToolButton { + border: none; + background: transparent; + font-size: 14px; + color: #DDD; +} \ No newline at end of file