示例#1
0
    def savePreferences(self):
        """ Map all widget values back to App Preferences """
        num_versions = self.numberOfVisibleVersionsSB.value()
        num_snapshot = self.numSnapshotTB.value()
        snap_enabled = 1
        if self.snapShotCB.checkState() == QtCore.Qt.Unchecked:
            snap_enabled = 0
        file_store = 1
        if self.fileStoreCB.checkState() == QtCore.Qt.Unchecked:
            file_store = 0
        autosave_enabled = 1
        if self.autosaveCB.checkState() == QtCore.Qt.Unchecked:
            autosave_enabled = 0
        autosave_delay = self.autosaveDelayTB.value()

        if self.alwaysOnTopCB.checkState() == QtCore.Qt.Unchecked:
            getBuilderWindow().setWindowFlags(getBuilderWindow().windowFlags() & ~QtCore.Qt.WindowStaysOnTopHint)
            getBuilderWindow().show()
            always_on_top = 0
        else:
            getBuilderWindow().setWindowFlags(getBuilderWindow().windowFlags() | QtCore.Qt.WindowStaysOnTopHint)
            getBuilderWindow().show()
            always_on_top = 1

        controller = getBuilderWindow().viewManager.currentWidget().controller
        controller.set_num_versions_always_shown(num_versions)

        reset_autosave = autosave_enabled != int(
            CaptureAPI.getPreference("VisTrailsAutosaveEnabled")
        ) or autosave_delay != int(CaptureAPI.getPreference("VisTrailsAutosaveDelay"))

        if CaptureAPI.getPreference("VisTrailsNumberOfVisibleVersions") is not None:
            CaptureAPI.setPreference("VisTrailsNumberOfVisibleVersions", str(num_versions))
        if CaptureAPI.getPreference("VisTrailsSnapshotCount") is not None:
            CaptureAPI.setPreference("VisTrailsSnapshotCount", str(num_snapshot))
        if CaptureAPI.getPreference("VisTrailsSnapshotEnabled") is not None:
            CaptureAPI.setPreference("VisTrailsSnapshotEnabled", str(snap_enabled))
        if CaptureAPI.getPreference("VisTrailsAutosaveEnabled") is not None:
            CaptureAPI.setPreference("VisTrailsAutosaveEnabled", str(autosave_enabled))
        if CaptureAPI.getPreference("VisTrailsAutosaveDelay") is not None:
            CaptureAPI.setPreference("VisTrailsAutosaveDelay", str(autosave_delay))
        if CaptureAPI.getPreference("VisTrailsStoreFiles") is not None:
            CaptureAPI.setPreference("VisTrailsStoreFiles", str(file_store))
        if CaptureAPI.getPreference("VisTrailsAlwaysOnTop") is not None:
            CaptureAPI.setPreference("VisTrailsAlwaysOnTop", str(always_on_top))

        if reset_autosave:
            controller.reset_autosave_timer()
        try:
            CaptureAPI.savePreferences()
        except:
            print "Warning: could not save preferences"
    def __init__(self, parent=None):
        """ QPlaybackToolBar(parent: QWidget) -> QPlaybackToolBar
        
        """
        QAddonToolBar.__init__(self, parent)

        self.setWindowTitle('Playback')
        self.setIconSize(QtCore.QSize(16, 16))

        # Play/Pause/Stop Buttons
        self.playPauseAction = QtGui.QAction(CurrentTheme.PLAY_ICON, 'Play', self)
        self.playPauseAction.setStatusTip('Play/Pause the animation')
        self.addAction(self.playPauseAction)
        self.connect(self.playPauseAction, QtCore.SIGNAL('triggered(bool)'),
                     self.playPauseTriggered)
        
        self.stopAction = QtGui.QAction(CurrentTheme.STOP_ICON, 'Stop', self)
        self.stopAction.setStatusTip('Stop the animation')
        self.addAction(self.stopAction)
        self.connect(self.stopAction, QtCore.SIGNAL('triggered(bool)'),
                     self.stop)
        
        self.playerTimer = QtCore.QTimer()
        self.playerTimer.setSingleShot(True)
        self.connect(self.playerTimer, QtCore.SIGNAL('timeout()'),
                     self.playNextVersion)

        self.speedGroup = QtGui.QActionGroup(self)
        self.slowAction = QtGui.QAction('Slow', self)
        self.slowAction.setCheckable(True)
        self.speedGroup.addAction(self.slowAction)
        self.mediumAction = QtGui.QAction('Medium', self)
        self.mediumAction.setCheckable(True)
        self.speedGroup.addAction(self.mediumAction)
        self.fastAction = QtGui.QAction('Fast', self)
        self.fastAction.setCheckable(True)
        self.speedGroup.addAction(self.fastAction)
        self.speedGroup.setExclusive(True)
        speed = int(CaptureAPI.getPreference('VisTrailsPlaybackSpeed'))
        if speed == 0:
            self.slowAction.setChecked(True)
        elif speed == 1:
            self.mediumAction.setChecked(True)
        else:
            self.fastAction.setChecked(True)

        self.speedMenu = QtGui.QMenu()
        self.speedMenu.addAction(self.slowAction)
        self.speedMenu.addAction(self.mediumAction)
        self.speedMenu.addAction(self.fastAction)
        self.speedAction = QtGui.QToolButton(self)
        self.speedAction.setIcon(CurrentTheme.SPEED_ICON)
        self.speedAction.setToolTip('Speed')
        self.speedAction.setStatusTip('Change the playback speed')
        self.speedAction.setPopupMode(QtGui.QToolButton.InstantPopup)
        self.speedAction.setMenu(self.speedMenu)
        self.addWidget(self.speedAction)
        
        self.connect(self.slowAction, QtCore.SIGNAL('triggered(bool)'),
                     self.setSpeed)
        self.connect(self.mediumAction, QtCore.SIGNAL('triggered(bool)'),
                     self.setSpeed)
        self.connect(self.fastAction, QtCore.SIGNAL('triggered(bool)'),
                     self.setSpeed)

        self.addSeparator()

        # Pick Start/Stop Buttons
        
        self.pickAction = QtGui.QAction(CurrentTheme.PICK_VERSIONS_ICON,
                                        'Select versions', self)
        self.pickAction.setStatusTip('Select start and end versions')
        self.pickAction.setCheckable(False)
        self.addAction(self.pickAction)        
        self.connect(self.pickAction, QtCore.SIGNAL('triggered(bool)'),
                     self.pickingTriggered)

        self.addSeparator()
        
        # Frame Slider
        self.frameSlider = QtGui.QSlider(self)
        self.frameSlider.setOrientation(QtCore.Qt.Horizontal)
        self.frameSlider.setMinimum(0)
        self.frameSlider.setMaximum(0)
        self.frameSlider.setSingleStep(1)
        self.addWidget(self.frameSlider)
        self.addSeparator()
        self.frameLabel = QtGui.QLabel(self)
        self.frameLabel.setMinimumWidth(30)
        self.addWidget(self.frameLabel)
        self.connect(self.frameSlider, QtCore.SIGNAL('valueChanged(int)'),
                     self.sliderChanged)
        self.connect(self.frameSlider, QtCore.SIGNAL('sliderMoved(int)'),
                     self.updateFrameSlider)
        self.connect(self.frameSlider, QtCore.SIGNAL('sliderReleased()'),
                     self.updateFrameContent)

        # Set the view toggle icon
        tva = self.toggleViewAction()
        tva.setIcon(CurrentTheme.PLAY_ICON)
        tva.setToolTip('Playback')
        tva.setStatusTip('Playback the changes from one version to another')
        tva.setShortcut('Ctrl+P')

        # Default version
        self.frames = []
        self.currentFrame = 0
        self.opsMap = {}
        self.lastVersion = -1

        self.setCurrentFrame(0)

        self.previousVersions = (-1, -1)
    def __init__(self, parent=None):
        QBuilderWindow.__init__(self, parent)
        self.descriptionWidget = QtGui.QLabel()
        self.progressLabel = QtGui.QLabel()
        self.progressLabel.setMaximumWidth(80)
        self.progressLabel.setMinimumWidth(80)
        self.progressWidget = QtGui.QProgressBar()
        self.progressWidget.setRange(0,100)
        self.statusBar().addWidget(self.descriptionWidget,1)
        self.statusBar().addWidget(self.progressLabel,1)
        self.statusBar().addWidget(self.progressWidget,1)
        self.statusWarning = None
        self.descriptionWidget.hide()
        self.progressLabel.hide()
        self.progressWidget.hide()

        self.title = CaptureAPI.getPluginTitle()
        self.setWindowTitle(self.title)
        self.setWindowIcon(CurrentTheme.APPLICATION_ICON)
        #self.modulePalette.toolWindow().destroy()
        self.updateApp = False
        self.timeStatsWindow = None

        if core.system.systemType in ['Darwin']:
            self.menuBar().setAttribute(QtCore.Qt.WA_MacSmallSize)
            self.menuBar().setAttribute(QtCore.Qt.WA_MacMetalStyle)

        self.searchToolBar = QSearchToolBar(self)
        self.addToolBar(QtCore.Qt.BottomToolBarArea, self.searchToolBar)

        self.addToolBarBreak(QtCore.Qt.BottomToolBarArea)

        self.playbackToolBar = QPlaybackToolBar(self)
        self.addToolBar(QtCore.Qt.BottomToolBarArea, self.playbackToolBar)

        self.addonToolBar.addAction(self.keepViewAction)
        self.addonToolBar.addAction(self.searchToolBar.toggleViewAction())
        self.addonToolBar.addAction(self.playbackToolBar.toggleViewAction())

        self.toolsMenu.addSeparator()
        self.toolsMenu.addAction(self.searchToolBar.toggleViewAction())
        self.toolsMenu.addAction(self.playbackToolBar.toggleViewAction())

        self.interactionToolBar._selectCursorAction.setToolTip('Select')
        self.interactionToolBar._selectCursorAction.setStatusTip('Select versions and edit the tree view')
        self.interactionToolBar._panCursorAction.setToolTip('Pan')
        self.interactionToolBar._panCursorAction.setStatusTip('Pan the tree view (Shift + Click)')
        self.interactionToolBar._zoomCursorAction.setToolTip('Zoom')
        self.interactionToolBar._zoomCursorAction.setStatusTip('Zoom the tree view (Ctrl + Click)')

        self.connect(self.viewManager,
                     QtCore.SIGNAL('currentVistrailChanged'),
                     self.updateAddonToolBar)

        geometry = CaptureAPI.getPreference('VisTrailsBuilderWindowGeometry')
        if geometry!='':
            self.restoreGeometry(QtCore.QByteArray.fromBase64(QtCore.QByteArray(geometry)))
            desktop = QtGui.QDesktopWidget()
            if desktop.screenNumber(self)==-1:
                self.move(desktop.screenGeometry().topLeft())

        alwaysOnTop = int(CaptureAPI.getPreference('VisTrailsAlwaysOnTop'))
        if alwaysOnTop:
            self.setWindowFlags(self.windowFlags() | QtCore.Qt.WindowStaysOnTopHint)
    def createActions(self):
        """ createActions() -> None
        Construct Plug-in specific actions

        """
        QBuilderWindow.createActions(self)

        # Modify Core Actions
        self.redoAction.setShortcuts(['Shift+Z','Ctrl+Y'])
        self.quitVistrailsAction = QtGui.QAction('Quit Plug-In', self)
        self.quitVistrailsAction.setShortcut('Ctrl+Q')
        self.quitVistrailsAction.setStatusTip('Exit Plug-In')
        self.editPreferencesAction.setStatusTip('Edit plug-in preferences')
        self.helpAction = QtGui.QAction(self.tr('About Provenance Explorer...'), self)

        # Create plugin specific actions
        self.keepViewAction = QtGui.QAction(CurrentTheme.VIEW_ON_ICON, 'Lock View', self)
        self.keepViewAction.setEnabled(True)
        self.keepViewAction.setCheckable(True)
        if int(CaptureAPI.getPreference('VisTrailsUseRecordedViews')):
            self.keepViewAction.setChecked(0)
            self.keepViewAction.setIcon(CurrentTheme.VIEW_OFF_ICON)
        else:
            self.keepViewAction.setChecked(1)
        self.keepViewAction.setStatusTip('Lock the current view settings while navigating versions')

        self.expandBranchAction = QtGui.QAction('Expand Branch', self)
        self.expandBranchAction.setEnabled(True)
        self.expandBranchAction.setStatusTip('Expand all versions in the tree below the current version')

        self.collapseBranchAction = QtGui.QAction('Collapse Branch', self)
        self.collapseBranchAction.setEnabled(True)
        self.collapseBranchAction.setStatusTip('Collapse all expanded versions in the tree below the current version')

        self.collapseAllAction = QtGui.QAction('Collapse All', self)
        self.collapseAllAction.setEnabled(True)
        self.collapseAllAction.setStatusTip('Collapse all expanded branches of the tree')

        self.hideBranchAction = QtGui.QAction('Hide Branch', self)
        if core.system.systemType in ['Darwin']:
            self.hideBranchAction.setShortcut('Meta+H')
        else:
            self.hideBranchAction.setShortcut('Ctrl+H')
        self.hideBranchAction.setEnabled(True)
        self.hideBranchAction.setStatusTip('Hide all versions in the tree including and below the current version')

        self.showAllAction = QtGui.QAction('Show All', self)
        self.showAllAction.setEnabled(True)
        self.showAllAction.setStatusTip('Show all hidden versions')

        self.resetViewAction = QtGui.QAction('Frame All', self)
        if core.system.systemType in ['Darwin']:
            self.resetViewAction.setShortcut('Meta+A')
        else:
            self.resetViewAction.setShortcut('A')
        self.resetViewAction.setShortcutContext(QtCore.Qt.WidgetShortcut)
        self.resetViewAction.setStatusTip('Reset tree view to show all versions')

        self.focusViewAction = QtGui.QAction('Frame Selection', self)
        if core.system.systemType in ['Darwin']:
            self.focusViewAction.setShortcut('Meta+F')
        else:
            self.focusViewAction.setShortcut('F')
        self.focusViewAction.setShortcutContext(QtCore.Qt.WidgetShortcut)
        self.focusViewAction.setStatusTip('Reset tree view to show selected version')

        self.timeStatsAllAction = QtGui.QAction('Compute Statistics', self)
        self.timeStatsAllAction.setEnabled(True)
        self.timeStatsAllAction.setStatusTip('Show time statistics for entire version tree')
        
        self.timeStatsAction = QtGui.QAction('Compute Sequence Statistics...', self)
        self.timeStatsAction.setEnabled(True)
        self.timeStatsAction.setStatusTip('Show time statistics between two versions')

        self.snapshotAction = QtGui.QAction('Create Snapshot', self)
        self.snapshotAction.setEnabled(False)
        self.snapshotAction.setStatusTip('Create a new version with the contents of the current scene')

        self.visDiffAction = QtGui.QAction('Compute Visual Difference...', self)
        self.visDiffAction.setEnabled(True)
        self.visDiffAction.setStatusTip('Visually display differences between two versions')

        self.copyOperationAction = QtGui.QAction('Copy', self)
        self.copyOperationAction.setShortcut('Ctrl+C')
        self.copyOperationAction.setEnabled(True)
        self.copyOperationAction.setStatusTip('Copy the selected operation to the clipboard')

        self.copySequenceAction = QtGui.QAction('Copy Sequence...', self)
        self.copySequenceAction.setEnabled(True)
        self.copySequenceAction.setStatusTip('Copy a sequence of operations to the clipboard')

        self.pasteOperationAction = QtGui.QAction('Paste', self)
        self.pasteOperationAction.setShortcut('Ctrl+V')
        self.pasteOperationAction.setEnabled(False)
        self.pasteOperationAction.setStatusTip('Paste operations from the clipboard to selected version')

        # Reader
        if CaptureAPI.isReadOnly():
            self.newVistrailAction.setText('&New (Pro)')
            self.newVistrailAction.setEnabled(False)
            self.saveFileAction.setText('&Save (Pro)')
            self.saveFileAction.setEnabled(False)
            self.saveFileAsAction.setText('Save as... (Pro)')
            self.saveFileAsAction.setEnabled(False)
            self.timeStatsAllAction.setText('Compute Statistics... (Pro)')
            self.timeStatsAllAction.setEnabled(False)
            self.timeStatsAction.setText('Compute Sequence Statistics... (Pro)')
            self.timeStatsAction.setEnabled(False)
            self.snapshotAction.setText('Take Snapshot (Pro)')
            self.snapshotAction.setEnabled(False)
            self.copyOperationAction.setText('Copy (Pro)')
            self.copyOperationAction.setEnabled(False)
            self.copySequenceAction.setText('Copy Sequence... (Pro)')
            self.copySequenceAction.setEnabled(False)
            self.pasteOperationAction.setText('Paste (Pro)')
            self.pasteOperationAction.setEnabled(False)
            self.hideBranchAction.setText('Hide Branch (Pro)')
            self.hideBranchAction.setEnabled(False)
            self.showAllAction.setText('Show All (Pro)')
            self.showAllAction.setEnabled(False)
示例#5
0
    def __init__(self, parent=None):
        """ Construct a simple dialog layout """
        QtGui.QDialog.__init__(self, parent)
        self.setWindowTitle("Provenance Explorer Preferences")
        layout = QtGui.QVBoxLayout(self)
        self.setLayout(layout)

        # vistrails window always on top
        self.alwaysOnTopCB = QtGui.QCheckBox("Plug-in window always on top")
        state = CaptureAPI.getPreference("VisTrailsAlwaysOnTop")
        if state is not None:
            state = int(CaptureAPI.getPreference("VisTrailsAlwaysOnTop"))
            if state:
                self.alwaysOnTopCB.setCheckState(QtCore.Qt.Checked)
            else:
                self.alwaysOnTopCB.setCheckState(QtCore.Qt.Unchecked)
            layout.addWidget(self.alwaysOnTopCB)

        # The number of visible versions edit box
        self.numberOfVisibleVersionsSB = QtGui.QSpinBox()
        if CaptureAPI.getPreference("VisTrailsNumberOfVisibleVersions") is not None:
            novLayout = QtGui.QHBoxLayout()
            layout.addLayout(novLayout)
            novLayout.setMargin(0)

            novLabel = QtGui.QLabel("Number of recent versions visible")
            novLayout.addWidget(novLabel)

            novLayout.addWidget(self.numberOfVisibleVersionsSB)
            self.numberOfVisibleVersionsSB.setRange(0, 1000)
            self.numberOfVisibleVersionsSB.setValue(int(CaptureAPI.getPreference("VisTrailsNumberOfVisibleVersions")))
            novLayout.addStretch()

        # Enabling snapshots
        self.snapShotCB = QtGui.QCheckBox("Take state snapshots")
        self.numSnapshotTB = QtGui.QSpinBox()
        state = CaptureAPI.getPreference("VisTrailsSnapshotEnabled")
        if state is not None:
            layout.addSpacing(10)
            state = int(CaptureAPI.getPreference("VisTrailsSnapshotEnabled"))
            if state:
                self.snapShotCB.setCheckState(QtCore.Qt.Checked)
            else:
                self.snapShotCB.setCheckState(QtCore.Qt.Unchecked)
            layout.addWidget(self.snapShotCB)
            self.connect(self.snapShotCB, QtCore.SIGNAL("clicked()"), self.updateState)

            # The number of actions before a snapshot
            if CaptureAPI.getPreference("VisTrailsSnapshotCount") is not None:
                nosLayout = QtGui.QHBoxLayout()
                layout.addLayout(nosLayout)
                nosLayout.setMargin(0)

                nosLabel = QtGui.QLabel("Number of actions between snapshots")
                nosLayout.addWidget(nosLabel)

                nosLayout.addWidget(self.numSnapshotTB)
                self.numSnapshotTB.setRange(0, 1000)
                self.numSnapshotTB.setValue(int(CaptureAPI.getPreference("VisTrailsSnapshotCount")))
                self.numSnapshotTB.setEnabled(state)
                nosLayout.addStretch()

        # Enabling Autosave
        self.autosaveCB = QtGui.QCheckBox("Autosave")
        self.autosaveDelayTB = QtGui.QSpinBox()
        state = CaptureAPI.getPreference("VisTrailsAutosaveEnabled")
        if state is not None:
            layout.addSpacing(10)
            state = int(CaptureAPI.getPreference("VisTrailsAutosaveEnabled"))
            if state:
                self.autosaveCB.setCheckState(QtCore.Qt.Checked)
            else:
                self.autosaveCB.setCheckState(QtCore.Qt.Unchecked)
            layout.addWidget(self.autosaveCB)
            self.connect(self.autosaveCB, QtCore.SIGNAL("clicked()"), self.updateState)

            # The delay in minutes between autosaves
            if CaptureAPI.getPreference("VisTrailsAutosaveDelay") is not None:
                adLayout = QtGui.QHBoxLayout()
                layout.addLayout(adLayout)
                adLayout.setMargin(0)

                adLabel = QtGui.QLabel("Minutes between autosave")
                adLayout.addWidget(adLabel)

                adLayout.addWidget(self.autosaveDelayTB)
                self.autosaveDelayTB.setRange(1, 100)
                self.autosaveDelayTB.setValue(int(CaptureAPI.getPreference("VisTrailsAutosaveDelay")))
                self.autosaveDelayTB.setEnabled(state)
                adLayout.addStretch()

        # Store files in vt
        self.fileStoreCB = QtGui.QCheckBox("Store opened and imported files in vistrail")
        if CaptureAPI.getPreference("VisTrailsStoreFiles") is not None:
            layout.addSpacing(10)
            state = int(CaptureAPI.getPreference("VisTrailsStoreFiles"))
            if state:
                self.fileStoreCB.setCheckState(QtCore.Qt.Checked)
            else:
                self.fileStoreCB.setCheckState(QtCore.Qt.Unchecked)
            layout.addWidget(self.fileStoreCB)

        # A space
        layout.addSpacing(10)
        layout.addStretch()

        # Then the buttons
        bLayout = QtGui.QHBoxLayout()
        layout.addLayout(bLayout)
        bLayout.addStretch()

        self.saveButton = QtGui.QPushButton("Save")
        bLayout.addWidget(self.saveButton)

        self.cancelButton = QtGui.QPushButton("Cancel")
        bLayout.addWidget(self.cancelButton)
        bLayout.addStretch()

        # Connect buttons to dialog handlers
        self.connect(self.saveButton, QtCore.SIGNAL("clicked()"), self.accept)
        self.connect(self.cancelButton, QtCore.SIGNAL("clicked()"), self.reject)

        controller = getBuilderWindow().viewManager.currentWidget().controller
        controller.set_num_versions_always_shown(self.numberOfVisibleVersionsSB.value())

        # Reader specific GUI
        if CaptureAPI.isReadOnly():
            self.autosaveCB.setText("Autosave (Pro)")
            self.autosaveCB.setEnabled(False)
            adLabel.setText("Minutes between autosave (Pro)")
            adLabel.setEnabled(False)
            self.autosaveDelayTB.setEnabled(False)
            self.fileStoreCB.setText("Store opened and imported files in vistrail (Pro)")
            self.fileStoreCB.setEnabled(False)
            self.snapShotCB.setText("Take state snapshots (Pro)")
            self.snapShotCB.setEnabled(False)
            nosLabel.setText("Number of actions between snapshots (Pro)")
            nosLabel.setEnabled(False)
            self.numSnapshotTB.setEnabled(False)