Esempio n. 1
0
    def init_qt_app(self):
        self.logger.debug("%s: Initializing QtApp for Unreal", self)

        from sgtk.platform.qt5 import QtWidgets

        if not QtWidgets.QApplication.instance():
            self._qt_app = QtWidgets.QApplication(sys.argv)
            self._qt_app.setQuitOnLastWindowClosed(False)
            unreal.log("Created QApplication instance: {0}".format(
                self._qt_app))

            def _app_tick(dt):
                QtWidgets.QApplication.processEvents()

            tick_handle = unreal.register_slate_post_tick_callback(_app_tick)

            def _app_quit():
                unreal.unregister_slate_post_tick_callback(tick_handle)

            QtWidgets.QApplication.instance().aboutToQuit.connect(_app_quit)
        else:
            self._qt_app = QtWidgets.QApplication.instance()

        # Make the QApplication use the dark theme. Must be called after the QApplication is instantiated
        self._initialize_dark_look_and_feel()
Esempio n. 2
0
    def init_qt_app(self):
        """
        Initializes if not done already the QT Application for the engine.
        """
        from sgtk.platform.qt5 import QtWidgets, QtGui

        if not QtWidgets.QApplication.instance():
            self._qt_app = QtWidgets.QApplication(sys.argv)
            self._qt_app.setWindowIcon(QtGui.QIcon(self.icon_256))

            self._qt_app_main_window = QtWidgets.QMainWindow()
            self._qt_app_central_widget = QtWidgets.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()

        else:
            self._qt_app = QtWidgets.QApplication.instance()
Esempio n. 3
0
    def init_qt_app(self):
        self.logger.debug("%s: Initializing QtApp for Unreal", self)

        from sgtk.platform.qt5 import QtWidgets

        if not QtWidgets.QApplication.instance():
            self._qt_app = QtWidgets.QApplication(sys.argv)
            self._qt_app.setQuitOnLastWindowClosed(False)
            unreal.log("Created QApplication instance: {0}".format(
                self._qt_app))
        else:
            self._qt_app = QtWidgets.QApplication.instance()

        # Make the QApplication use the dark theme. Must be called after the QApplication is instantiated
        self._initialize_dark_look_and_feel()
Esempio n. 4
0
    def init_qt_app(self):
        self.logger.debug("%s: Initializing QtApp for Unreal", self)
        from sgtk.platform.qt5 import QtWidgets

        if not QtWidgets.QApplication.instance():
            self._qt_app = QtWidgets.QApplication(sys.argv)
            self._qt_app.setQuitOnLastWindowClosed(False)
        else:
            self._qt_app = QtWidgets.QApplication.instance()

        # On other platforms than Windows, we need to process the Qt events otherwise
        # UIs are "frozen". We use a slate tick callback to do that on a regular basis.
        # It is not clear why this is not needed on Windows, possibly because a
        # dedicated Windows event dispatcher is used instead of a regular
        # QAbstractEventDispatcher
        if sys.platform != "win32":
            unreal.register_slate_post_tick_callback(
                self._process_qt_events_cb)
        # Make the QApplication use the dark theme. Must be called after the QApplication is instantiated
        self._initialize_dark_look_and_feel()
Esempio n. 5
0
    def show_message(self, msg, level="info"):
        """
        Displays a dialog with the message according to  the severity level
        specified.
        """
        if self._qt_app_central_widget:
            from sgtk.platform.qt5 import QtWidgets, QtGui, QtCore
            level_icon = {
                "info": QtWidgets.QMessageBox.Information,
                "error": QtWidgets.QMessageBox.Critical,
                "warning": QtWidgets.QMessageBox.Warning
            }

            dlg = QtWidgets.QMessageBox(self._qt_app_central_widget)
            dlg.setIcon(level_icon[level])
            dlg.setText(msg)
            dlg.setWindowTitle("Shotgun Substance Painter Engine")
            dlg.setWindowFlags(dlg.windowFlags()
                               | QtCore.Qt.WindowStaysOnTopHint)
            dlg.show()
            dlg.exec_()