Ejemplo n.º 1
0
	def setModal( self, modal, parentWindow=None ) :
	
		assert( modal != self.getModal() )
	
		if modal :
		
			if parentWindow is not None :
				focusWidget = self._qtWidget().focusWidget()
				parentWindow.addChildWindow( self )
				if focusWidget is not None :
					# the reparenting above removes the focus, so we reclaim it.
					# this is important for PathChooserWidget, which puts the focus
					# in the right place in waitForPath(), then calls waitForButton().
					focusWidget.setFocus( QtCore.Qt.ActiveWindowFocusReason )
			
			self.setVisible( False )
			self._qtWidget().setWindowModality( QtCore.Qt.ApplicationModal )
			self.setVisible( True )

			self.__closeConnection = self.closedSignal().connect( Gaffer.WeakMethod( self.__close ) )
		
			self.__modalEventLoop = GafferUI.EventLoop()		
			self.__modalEventLoop.start()

			self.__closeConnection = None
			self.__modalEventLoop = None
			
			self._qtWidget().setWindowModality( QtCore.Qt.NonModal )

			if parentWindow is not None :
				parentWindow.removeChild( self )
			
		else :
		
			self.__modalEventLoop.stop()
Ejemplo n.º 2
0
    def setModal(self, modal, parentWindow=None):

        assert (modal != self.getModal())

        if modal:

            if parentWindow is not None:
                focusWidget = self._qtWidget().focusWidget()
                parentWindow.addChildWindow(self)
                if focusWidget is not None:
                    # the reparenting above removes the focus, so we reclaim it.
                    # this is important for PathChooserWidget, which puts the focus
                    # in the right place in waitForPath(), then calls waitForButton().
                    focusWidget.setFocus(QtCore.Qt.ActiveWindowFocusReason)

            self.setVisible(False)
            self._qtWidget().setWindowModality(QtCore.Qt.ApplicationModal)
            self.setVisible(True)

            self.__closeConnection = self.closedSignal().connect(
                Gaffer.WeakMethod(self.__close))

            self.__modalEventLoop = GafferUI.EventLoop()
            self.__modalEventLoop.start()

            self.__closeConnection = None
            self.__modalEventLoop = None

            # Here we want to call `self._qtWidget().setWindowModality( QtCore.Qt.NonModal )`,
            # but that causes crashes in Qt 5, because it doesn't support changing modality on
            # the fly. See https://bugreports.qt.io/browse/QTBUG-47599. In practice, everywhere
            # we use modal dialogues in Gaffer, we close the dialogue immediately after exiting
            # the modal loop anyway, so at least for now we can get away with not switching the
            # modality back.

            if parentWindow is not None:
                parentWindow.removeChild(self)

        else:

            self.__modalEventLoop.stop()
Ejemplo n.º 3
0
    def waitForButton(self, parentWindow=None):

        assert (len(self.__buttonRow))

        if parentWindow is not None:
            focusWidget = self._qtWidget().focusWidget()
            parentWindow.addChildWindow(self)
            if focusWidget is not None:
                # the reparenting above removes the focus, so we reclaim it.
                # this is important for PathChooserWidget, which puts the focus
                # in the right place in waitForPath(), then calls waitForButton().
                focusWidget.setFocus(QtCore.Qt.ActiveWindowFocusReason)

        self.setVisible(False)
        self._qtWidget().setWindowModality(QtCore.Qt.ApplicationModal)
        self.setVisible(True)

        self.__eventLoop = GafferUI.EventLoop()
        self.__buttonConnections = []
        self.__closeConnection = self.closedSignal().connect(
            Gaffer.WeakMethod(self.__close))
        for button in self.__buttonRow:
            self.__buttonConnections.append(button.clickedSignal().connect(
                Gaffer.WeakMethod(self.__buttonClicked)))

        self.__resultOfWait = None
        self.__eventLoop.start()  # returns when a button has been pressed
        self.__buttonConnections = []
        self.__closeConnection = None
        self.__eventLoop = None

        self._qtWidget().setWindowModality(QtCore.Qt.NonModal)

        if parentWindow is not None:
            parentWindow.removeChild(self)

        return self.__resultOfWait