Free Motion Capture for Everyone πβ¨
TypeScript
Philip + Trent: window sizing (#489)
philipqueen904059125c47
diff --git a/freemocap/gui/qt/main_window/freemocap_main_window.py b/freemocap/gui/qt/main_window/freemocap_main_window.pyindex a8af9714..4e3bed0e 100644--- a/freemocap/gui/qt/main_window/freemocap_main_window.py+++ b/freemocap/gui/qt/main_window/freemocap_main_window.py@@ -97,7 +97,7 @@ class MainWindow(QMainWindow):self._log_view_widget = LogViewWidget(parent=self) # start this first so it will grab the setup logslogger.info("Initializing FreeMoCap MainWindow")- self.setGeometry(100, 100, 1280, 720)+ self._size_main_window(width_fraction=1, height_fraction=0.95)self.setWindowIcon(QIcon(PATH_TO_FREEMOCAP_LOGO_SVG))self.setWindowTitle("freemocap \U0001F480 \U00002728")@@ -179,10 +179,9 @@ class MainWindow(QMainWindow):width = screen.width() * width_fractionheight = screen.height() * height_fraction- # Position the window in the center of the screen- left = (screen.width() - width) / 2- top = (screen.height() - height) / 2- self.setGeometry(int(left), int(top), int(width), int(height))+ self.setFixedSize(int(width), int(height))+ self.setMinimumSize(1280, 720)+ self.setMaximumSize(int(width * 2), int(height * 2))def _create_tools_dock_widget(self):tools_dock_widget = QDockWidget("Control Panel", self)diff --git a/freemocap/gui/qt/widgets/control_panel/control_panel_dock_widget.py b/freemocap/gui/qt/widgets/control_panel/control_panel_dock_widget.pyindex 81ddecae..2f51280c 100644--- a/freemocap/gui/qt/widgets/control_panel/control_panel_dock_widget.py+++ b/freemocap/gui/qt/widgets/control_panel/control_panel_dock_widget.py@@ -33,7 +33,6 @@ class ControlPanelWidget(QWidget):def __init__(self,camera_configuration_parameter_tree_widget: SkellyCamParameterTreeWidget,- # calibration_control_panel: CalibrationControlPanel,process_motion_capture_data_panel: ProcessMotionCaptureDataPanel,visualize_data_widget: QWidget,parent=None,@@ -50,7 +49,6 @@ class ControlPanelWidget(QWidget):camera_configuration_parameter_tree_widget,"Camera Configuration",)- # self._tool_box.addTab(calibration_control_panel, "Capture Volume Calibration")self._tab_widget.addTab(process_motion_capture_data_panel, "Process Data")self._tab_widget.addTab(visualize_data_widget, "Export Data")diff --git a/freemocap/gui/qt/widgets/home_widget.py b/freemocap/gui/qt/widgets/home_widget.pyindex 6dc2699a..c23f79fe 100644--- a/freemocap/gui/qt/widgets/home_widget.py+++ b/freemocap/gui/qt/widgets/home_widget.py@@ -3,7 +3,6 @@ from typing import Unionimport requestsfrom PyQt6.QtCore import Qt-from PyQt6.QtGui import QPixmapfrom PyQt6.QtWidgets import (QCheckBox,QLabel,@@ -17,12 +16,12 @@ from packaging import versionimport freemocapfrom freemocap.gui.qt.actions_and_menus.actions import (CREATE_NEW_RECORDING_ACTION_NAME,- LOAD_MOST_RECENT_RECORDING_ACTION_NAME,LOAD_RECORDING_ACTION_NAME,IMPORT_VIDEOS_ACTION_NAME,Actions,)from freemocap.gui.qt.utilities.save_and_load_gui_state import GuiState, save_gui_state+from freemocap.gui.qt.widgets.image_widget import ImageWidgetfrom freemocap.system.paths_and_filenames.file_and_folder_names import PATH_TO_FREEMOCAP_LOGO_SVGfrom freemocap.system.paths_and_filenames.path_getters import get_gui_state_json_path@@ -46,11 +45,11 @@ class HomeWidget(QWidget):self._layout = QVBoxLayout()self.setLayout(self._layout)+ self._layout.setContentsMargins(0, 0, 0, 0)+self.sizePolicy().setHorizontalStretch(1)self.sizePolicy().setVerticalStretch(1)- self._layout.addStretch(1)-self._add_freemocap_logo()self._welcome_to_freemocap_title_widget = self._welcome_to_freemocap_title()@@ -61,10 +60,6 @@ class HomeWidget(QWidget):self._layout.addWidget(self._create_new_session_button, alignment=Qt.AlignmentFlag.AlignCenter)self._create_new_session_button.setProperty("recommended_next", True)- self._load_most_recent_session_button = WelcomeScreenButton(f"{LOAD_MOST_RECENT_RECORDING_ACTION_NAME}")- # self._load_most_recent_session_button.clicked.connect(actions.load_most_recent_recording_action.trigger)- # self._layout.addWidget(self._load_most_recent_session_button, alignment=Qt.AlignmentFlag.AlignCenter)- #self._load_existing_session_button = WelcomeScreenButton(f"{LOAD_RECORDING_ACTION_NAME}")self._load_existing_session_button.clicked.connect(actions.load_existing_recording_action.trigger)self._layout.addWidget(self._load_existing_session_button, alignment=Qt.AlignmentFlag.AlignCenter)@@ -73,8 +68,6 @@ class HomeWidget(QWidget):self._import_videos_button.clicked.connect(actions.import_videos_action.trigger)self._layout.addWidget(self._import_videos_button, alignment=Qt.AlignmentFlag.AlignCenter)- # self._layout.addStretch(1)-self._create_user_info_consent_checkbox()self._add_text_links()@@ -184,12 +177,5 @@ class HomeWidget(QWidget):return session_title_labeldef _add_freemocap_logo(self):- freemocap_logo_label = QLabel(self)- freemocap_logo_label.sizePolicy().setHorizontalStretch(1)- freemocap_logo_label.sizePolicy().setVerticalStretch(1)+ freemocap_logo_label = ImageWidget(image_path=PATH_TO_FREEMOCAP_LOGO_SVG, scaling_factor=0.88)self._layout.addWidget(freemocap_logo_label)-- freemocap_logo_pixmap = QPixmap(PATH_TO_FREEMOCAP_LOGO_SVG)- freemocap_logo_pixmap = freemocap_logo_pixmap.scaledToWidth(200)- freemocap_logo_label.setPixmap(freemocap_logo_pixmap)- freemocap_logo_label.setAlignment(Qt.AlignmentFlag.AlignCenter)diff --git a/freemocap/gui/qt/widgets/image_widget.py b/freemocap/gui/qt/widgets/image_widget.pynew file mode 100644index 00000000..074f9e90--- /dev/null+++ b/freemocap/gui/qt/widgets/image_widget.py@@ -0,0 +1,21 @@+from PyQt6.QtCore import Qt+from PyQt6.QtGui import QPixmap, QImage+from PyQt6.QtWidgets import QWidget, QLabel, QVBoxLayout+++class ImageWidget(QWidget):+ def __init__(self, image_path: str, scaling_factor: float = 0.85):+ super().__init__()+ self.image = QImage(image_path)+ self.label = QLabel()+ self.label.setPixmap(QPixmap.fromImage(self.image))+ self.label.setAlignment(Qt.AlignmentFlag.AlignCenter)+ self.layout = QVBoxLayout()+ self.layout.addWidget(self.label)+ self.setLayout(self.layout)+ self.scaling_factor = scaling_factor++ def resizeEvent(self, event):+ self.label.setPixmap(+ QPixmap.fromImage(self.image).scaled(self.size() * self.scaling_factor, Qt.AspectRatioMode.KeepAspectRatio)+ )