示例#1
0
文件: sendMail.py 项目: zloop1982/USD
def _GenerateButtons(dialog, fields, allowScreenCapSel):
    '''This method generates the buttons used in our sendmail
       dialog. This includes creating signal handlers which batch
       the inputted info for sending across the wire.'''

    # construct buttons
    cancelBt = QtWidgets.QPushButton("Cancel")
    acceptBt = QtWidgets.QPushButton("Send")

    # construct screen cap selector if there are multiple options available
    screenCapSel = None
    if allowScreenCapSel:
        screenCapSel = QtWidgets.QComboBox()
        screenCapSel.setSizeAdjustPolicy(
                QtWidgets.QComboBox.AdjustToContents)
        screenCapSel.addItem("Window")
        screenCapSel.addItem("Viewport")

    buttonLayout = QtWidgets.QHBoxLayout()
    buttonLayout.addStretch(0.5)
    if allowScreenCapSel:
        buttonLayout.addWidget(screenCapSel)
    buttonLayout.addWidget(cancelBt)
    buttonLayout.addWidget(acceptBt)

    # add a signal handler for the accept and close buttons
    # upon cancelling, simply close the dialog
    cancelBt.clicked.connect(lambda : dialog.close())

    # upon accepting, fill the data and close the dialog
    acceptBt.clicked.connect(lambda : _FillDataFromDialog(
         dialog,
         fields,
         screenCapSel.currentText() if allowScreenCapSel else "Window").close())
    return buttonLayout
示例#2
0
def openNodeGraph(usdviewApi):
    from usdNodeGraph.api import GraphState, Node, UsdNodeGraph

    def test_func():
        print('Support Node Types:')
        print(Node.getAllNodeClassNames())

    GraphState.addCallback('stageTimeChanged', whenStateTimeChanged)

    UsdNodeGraph.registerActions([
        ['Test Menu', [['test_action', 'Test Action', None, test_func]]],
    ])

    UsdNodeGraph.registerActionShortCut('open_file', None)
    # UsdNodeGraph.registerActionShortCut('reload_layer', None)

    mainWindow = usdviewApi.qMainWindow

    if not hasattr(mainWindow, 'nodeGraph'):
        nodeGraph = UsdNodeGraph(app='usdview')
        nodeGraph.splitDockWidget(nodeGraph.parameterPanelDock,
                                  nodeGraph.nodeGraphDock, QtCore.Qt.Vertical)
        nodeGraphDock = QtWidgets.QDockWidget()
        nodeGraphDock.setObjectName('usdNodeGraphDock')
        nodeGraphDock.setWindowTitle('Usd Node Graph')
        nodeGraphDock.setWidget(nodeGraph)

        mainWindow.nodeGraph = nodeGraph
        mainWindow.nodeGraphDock = nodeGraphDock
        mainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea,
                                 mainWindow.nodeGraphDock)

    mainWindow.nodeGraph.show()
    mainWindow.nodeGraph.setStage(usdviewApi.stage)
def openNodeGraph(usdviewApi):
    from usdNodeGraph.ui.nodeGraph import UsdNodeGraph

    UsdNodeGraph.registerActionShortCut('open_file', None)
    # UsdNodeGraph.registerActionShortCut('reload_layer', None)

    mainWindow = usdviewApi.qMainWindow

    if not hasattr(mainWindow, 'nodeGraph'):
        nodeGraph = UsdNodeGraph()
        nodeGraph.splitDockWidget(
            nodeGraph.parameterPanelDock, nodeGraph.nodeGraphDock,
            QtCore.Qt.Vertical
        )
        nodeGraphDock = QtWidgets.QDockWidget()
        nodeGraphDock.setObjectName('usdNodeGraphDock')
        nodeGraphDock.setWindowTitle('Usd Node Graph')
        nodeGraphDock.setWidget(nodeGraph)

        mainWindow.nodeGraph = nodeGraph
        mainWindow.nodeGraphDock = nodeGraphDock
        mainWindow.addDockWidget(QtCore.Qt.RightDockWidgetArea, mainWindow.nodeGraphDock)

    mainWindow.nodeGraph.show()
    mainWindow.nodeGraph.setStage(usdviewApi.stage)
示例#4
0
文件: sendMail.py 项目: zloop1982/USD
def _GenerateLayout(dialog, allowScreenCapSel):
    '''This method generates the full dialog, containing the text fields,
       buttons and combobox for choosing the type of screenshot'''
    (fields, textLayout) = _GenerateTextFields(dialog)
    buttonLayout = _GenerateButtons(dialog, fields, allowScreenCapSel)

    # compose layouts
    layout = QtWidgets.QVBoxLayout()
    layout.addLayout(textLayout)
    layout.addLayout(buttonLayout)

    return layout
示例#5
0
文件: sendMail.py 项目: zloop1982/USD
def _GetSendMailInfo(usdviewApi, allowScreenCapSel):
    '''This method takes the generated dialog, runs it and returns the
       inputted information upon the dialogs completion'''
    window = usdviewApi.qMainWindow
    dialog = QtWidgets.QDialog(window)
    dialog.setWindowTitle("Send Screenshot...")

    # set field defaults
    dialog.emailInfo = _GenerateDefaultInfo(usdviewApi, dialog)
    dialog.setMinimumWidth((window.size().width()/2))

    # add layout to dialog and launch
    dialog.setLayout(_GenerateLayout(dialog, allowScreenCapSel))
    dialog.exec_()

    return dialog.emailInfo
示例#6
0
def _testBasic(appController):
    from pxr import Sdf

    #
    # First test that right/left keys sent to a TreeView will navigate the
    # hierarchy, including moving between siblings and cousins.
    #

    # Start out fully collapsed, and make sure PrimView has focus
    _emitCollapseAllAction(appController)
    appController._ui.primView.setFocus()
    QtWidgets.QApplication.processEvents()

    # Send events to the application's QObject to ensure our app filter
    # reroutes it to the focusWidget.
    appObj = QtWidgets.QApplication.instance()

    # Get the stage and selection data model to query selection.
    stage = appController._dataModel.stage
    selectionDataModel = appController._dataModel.selection

    # This test is highly asset-dependent.  Our scene has a single hierarchy
    # chain, so it takes two "move right" actions to select each level of
    # path hierarchy
    path = Sdf.Path("/World/sets/setModel")
    for i in range(2 * path.pathElementCount):
        _postAndProcessKeyEvent(QtCore.Qt.Key_Right, appObj, appController)

    assert len(selectionDataModel.getPrims()) == 1
    assert selectionDataModel.getFocusPrim().GetPrimPath() == path, \
        "Expected <%s>, got <%s>" % (path, selectionDataModel.getFocusPrim().GetPrimPath())

    # Now roll it all back up
    for i in range(1, 2 * path.pathElementCount):
        # Send the event to mainWindow to ensure our app filter reroutes it
        # to the focusWidget.
        _postAndProcessKeyEvent(QtCore.Qt.Key_Left, appObj, appController)

    assert len(selectionDataModel.getPrims()) == 1
    assert selectionDataModel.getFocusPrim().IsPseudoRoot()

    # Then test that right/left keys sent to other widgets (including the
    # MainWindow) will result in transport movement
    startFrame = stage.GetStartTimeCode()
    appController._mainWindow.setFocus()
    assert appController._dataModel.currentFrame == startFrame

    _postAndProcessKeyEvent(QtCore.Qt.Key_Right, appObj, appController)
    assert appController._dataModel.currentFrame == startFrame + 1

    _postAndProcessKeyEvent(QtCore.Qt.Key_Left, appObj, appController)
    assert appController._dataModel.currentFrame == startFrame

    # Regression tests for bugs #154716, 154665: Make sure we don't try
    # to filter events while popups or modal dialogs are active.  The best
    # way to test this is to ensure that ESC operates as a terminator for
    # menus and modals, since our filter changes it to be a focus-changer.
    # If the filter is still active (FAILURE), then the test will not
    # terminate, and eventually be killed.
    escSender = EscapeSender(appController._ui.menuView)
    QtCore.QTimer.singleShot(500, lambda: escSender.doIt(appController))
    _popupViewMenu(appController)

    # Modal dialogs won't receive events sent to the application object,
    # so we must send it to the widget itself. Which means we can't use any
    # of usdview's modals, since we only use static Qt methods that don't
    # return you a widget.
    fileDlg = QtWidgets.QFileDialog(appController._mainWindow)
    escSender = EscapeSender(fileDlg)
    QtCore.QTimer.singleShot(500, lambda: escSender.doIt(appController))
    # Causes a modal dialog to pop up
    fileDlg.exec_()
示例#7
0
文件: sendMail.py 项目: zloop1982/USD
def _GenerateTextFields(dialog):
    '''This method generates the layout containing the text fields to
        be filled by the user, such as sender, sendee and message.
        Note that this takes a reference to the dialog because the buttons
        need to create a signal handler which uses the text field info'''
    # construct text layout
    senderLabel = QtWidgets.QLabel("From: ")
    sendeeLabel = QtWidgets.QLabel("To: ")
    subjectLabel = QtWidgets.QLabel("Subject: ")
    bodyLabel   = QtWidgets.QLabel("Message: ")

    senderFld = QtWidgets.QLineEdit(dialog.emailInfo.sender)
    sendeeFld = QtWidgets.QLineEdit(dialog.emailInfo.sendee)
    subjectFld = QtWidgets.QLineEdit(dialog.emailInfo.subject)
    bodyFld   = QtWidgets.QTextEdit()
    bodyFld.setText(dialog.emailInfo.body)

    senderLayout = QtWidgets.QHBoxLayout()
    senderLayout.addWidget(senderFld)

    sendeeLayout = QtWidgets.QHBoxLayout()
    sendeeLayout.addWidget(sendeeFld)

    subjectLayout = QtWidgets.QHBoxLayout()
    subjectLayout.addWidget(subjectFld)

    bodyLayout = QtWidgets.QHBoxLayout()
    bodyLayout.addWidget(bodyFld)

    fieldsLayout = QtWidgets.QVBoxLayout()
    fieldsLayout.addWidget(senderLabel)
    fieldsLayout.addLayout(senderLayout)
    fieldsLayout.addWidget(sendeeLabel)
    fieldsLayout.addLayout(sendeeLayout)
    fieldsLayout.addWidget(subjectLabel)
    fieldsLayout.addLayout(subjectLayout)
    fieldsLayout.addWidget(bodyLabel)
    fieldsLayout.addLayout(bodyLayout)

    return ({"sender" : senderFld,
            "sendee" : sendeeFld,
            "subject" :subjectFld,
            "body":    bodyFld},
            fieldsLayout)