示例#1
0
    def init_qt_app(self):
        """
        Initializes if not done already the QT Application for the engine.
        """
        from sgtk.platform.qt import QtGui

        self.logger.debug("Initializing QT Application for the engine")

        if not QtGui.QApplication.instance():
            self._qt_app = QtGui.QApplication(sys.argv)
        else:
            self._qt_app = QtGui.QApplication.instance()

        # set icon for the engine windows
        self._qt_app.setWindowIcon(QtGui.QIcon(self.icon_256))

        self._qt_app_main_window = QtGui.QMainWindow()
        self._qt_app_central_widget = QtGui.QWidget()
        self._qt_app_main_window.setCentralWidget(self._qt_app_central_widget)
        self._qt_app.setQuitOnLastWindowClosed(False)

        # Make the QApplication use the dark theme. Must be called after the
        # QApplication is instantiated
        self._initialize_dark_look_and_feel()

        self.logger.debug("QT Application: %s" % self._qt_app)
示例#2
0
    def init_qt_app(self):
        """
        Initializes if not done already the QT Application for the engine.
        """
        """
        Ensure the QApplication is initialized
        """
        from sgtk.platform.qt import QtGui

        self._qt_app = QtGui.QApplication.instance()
        self._qt_app.setWindowIcon(QtGui.QIcon(self.icon_256))
        self._qt_app.setQuitOnLastWindowClosed(False)
        self._qt_app.setQuitOnLastWindowClosed(False)

        if self._qt_app_main_window is None:
            self.log_debug("Initializing main QApplication...")

            self._qt_app_main_window = QtGui.QMainWindow()

            # parent the main window under the Blender main window
            if is_windows():
                import ctypes

                hwnd = ctypes.windll.user32.GetActiveWindow()
                if hwnd:
                    self._qt_app_main_window.create(hwnd)

            self._qt_app_central_widget = QtGui.QWidget()
            self._qt_app_main_window.setCentralWidget(
                self._qt_app_central_widget)

        # set up the dark style
        self._initialize_dark_look_and_feel()

        # try to set the font size the same as Blender
        text_size = 9
        if len(bpy.context.preferences.ui_styles) > 0:
            self.log_debug(
                "Applying Blender settings to QApplication style...")
            text_size = (bpy.context.preferences.ui_styles[0].widget.points - 2
                         )  # MAGIC NUMBER TOTALLY CHOSEN BY EYE

        ui_scale = bpy.context.preferences.system.ui_scale
        text_size *= ui_scale
        self._qt_app.setStyleSheet(f""".QMenu {{ font-size: {text_size}pt; }}
                .QWidget {{ font-size: {text_size}pt; }}""")

        self.logger.debug("QT Application: %s" % self._qt_app_main_window)