示例#1
0
    def __init__(self, parent=None):
        Qt.QListView.__init__(self, parent)

        self.setSelectionMode(Qt.QListView.ExtendedSelection)

        self.removeAction = Qt.QAction(getIcon(":/actions/list-remove.svg"),
                                       "Remove from favourites", self)
        self.removeAction.triggered.connect(self.removeMacros)
        self.removeAction.setToolTip(
            "Clicking this button will remove selected macros "
            "from favourites.")

        self.removeAllAction = Qt.QAction(getIcon(":/places/user-trash.svg"),
                                          "Remove all from favourites", self)
        self.removeAllAction.triggered.connect(self.removeAllMacros)
        self.removeAllAction.setToolTip(
            "Clicking this button will remove all macros from favourites.")

        self.moveUpAction = Qt.QAction(getIcon(":/actions/go-up.svg"),
                                       "Move up", self)
        self.moveUpAction.triggered.connect(self.upMacro)
        self.moveUpAction.setToolTip(
            "Clicking this button will move the macro up "
            "in the favourites hierarchy.")

        self.moveDownAction = Qt.QAction(getIcon(":/actions/go-down.svg"),
                                         "Move down", self)
        self.moveDownAction.triggered.connect(self.downMacro)
        self.moveDownAction.setToolTip(
            "Clicking this button will move the macro down "
            "in the favourites hierarchy.")

        self.disableActions()
示例#2
0
文件: cmdline.py 项目: cmft/sardana
    def __init__(self, qt_parent=None, designMode=False):
        Qt.QWidget.__init__(self, qt_parent)

        self._history = CommandLineHistory()

        l = Qt.QHBoxLayout()
        self.setLayout(l)
        l.setContentsMargins(0, 0, 0, 0)
        l.setSpacing(0)

        self._detailsButton = Qt.QToolButton()
        self._detailsButton.setText("...")

        self._cmdLine = Qt.QComboBox()
        self._cmdLine.setEditable(True)

        self._applyButton = Qt.QToolButton()
        self._applyButton.setIcon(getIcon(":/actions/media_playback_start.svg"))

        self._stopButton = Qt.QToolButton()
        self._stopButton.setIcon(getIcon(":/actions/media_playback_stop.svg"))

        self._clearButton = Qt.QToolButton()
        self._clearButton.setIcon(getThemeIcon("edit-clear"))

        l.addWidget(self._detailsButton, 0)
        l.addWidget(self._cmdLine, 1)
        l.addWidget(self._applyButton, 0)
        l.addWidget(self._stopButton, 0)
        l.addWidget(self._clearButton, 0)
示例#3
0
文件: common.py 项目: cmft/sardana
 def __retriveMacroServersFromDB(self):
     ms_stateIcons = []
     db = taurus.Database()
     macroServerList = db.getValueObj().get_device_name('*', 'MacroServer')
     for macroServer in macroServerList:
         #state = Device(macroServer).getState()
         state = None
         try:
             state = PyTango.DeviceProxy(macroServer).state()
         except:
             pass
         icon = None
         if state == PyTango.DevState.ON:
             icon = getIcon(":/leds/images24/ledgreen.png")
         elif state == PyTango.DevState.FAULT:
             icon = getIcon(":/leds/images24/ledred.png")
         elif state == None:
             icon = getIcon(":/leds/images24/ledredoff.png")
         ms_stateIcons.append((macroServer, icon))
     return ms_stateIcons
示例#4
0
    def __init__(self, parent=None, door=None, plotsButton=True):
        Qt.QWidget.__init__(self, parent)
        TaurusBaseWidget.__init__(self, 'ExpDescriptionEditor')
        self.loadUi()
        self.ui.buttonBox.setStandardButtons(Qt.QDialogButtonBox.Reset | Qt.QDialogButtonBox.Apply)
        newperspectivesDict = copy.deepcopy(self.ui.sardanaElementTree.KnownPerspectives)
        #newperspectivesDict[self.ui.sardanaElementTree.DftPerspective]['model'] = [SardanaAcquirableProxyModel, SardanaElementPlainModel]
        newperspectivesDict[self.ui.sardanaElementTree.DftPerspective]['model'][0] = SardanaAcquirableProxyModel
        self.ui.sardanaElementTree.KnownPerspectives = newperspectivesDict  #assign a copy because if just a key of this class memberwas modified, all instances of this class would be affected
        self.ui.sardanaElementTree._setPerspective(self.ui.sardanaElementTree.DftPerspective)

        self._localConfig = None
        self._originalConfiguration = None
        self._dirty = False
        self._dirtyMntGrps = set()

        self.connect(self.ui.activeMntGrpCB, Qt.SIGNAL('activated (QString)'), self.changeActiveMntGrp)
        self.connect(self.ui.createMntGrpBT, Qt.SIGNAL('clicked ()'), self.createMntGrp)
        self.connect(self.ui.deleteMntGrpBT, Qt.SIGNAL('clicked ()'), self.deleteMntGrp)
        self.connect(self.ui.compressionCB, Qt.SIGNAL('currentIndexChanged (int)'), self.onCompressionCBChanged)
        self.connect(self.ui.pathLE, Qt.SIGNAL('textEdited (QString)'), self.onPathLEEdited)
        self.connect(self.ui.filenameLE, Qt.SIGNAL('textEdited (QString)'), self.onFilenameLEEdited)
        self.connect(self.ui.channelEditor.getQModel(), Qt.SIGNAL('dataChanged (QModelIndex, QModelIndex)'), self._updateButtonBox)
        self.connect(self.ui.channelEditor.getQModel(), Qt.SIGNAL('modelReset ()'), self._updateButtonBox)
        preScanList = self.ui.preScanList
        self.connect(preScanList, Qt.SIGNAL('dataChanged'),
                     self.onPreScanSnapshotChanged)
        #TODO: For Taurus 4 compatibility
        if hasattr(preScanList, "dataChangedSignal"):
            preScanList.dataChangedSignal.connect(self.onPreScanSnapshotChanged)
        self.connect(self.ui.choosePathBT, Qt.SIGNAL('clicked ()'), self.onChooseScanDirButtonClicked)
        
        self.__plotManager = None
        icon = resource.getIcon(":/actions/view.svg")
        self.togglePlotsAction = Qt.QAction(icon, "Show/Hide plots", self)
        self.togglePlotsAction.setCheckable(True)
        self.togglePlotsAction.setChecked(False)
        self.togglePlotsAction.setEnabled(plotsButton)
        self.addAction(self.togglePlotsAction)
        self.connect(self.togglePlotsAction, Qt.SIGNAL("toggled(bool)"), 
                     self.onPlotsButtonToggled)
        self.ui.plotsButton.setDefaultAction(self.togglePlotsAction)
        
        if door is not None:
            self.setModel(door)
        self.connect(self.ui.buttonBox, Qt.SIGNAL("clicked(QAbstractButton *)"), self.onDialogButtonClicked)

        #Taurus Configuration properties and delegates
        self.registerConfigDelegate(self.ui.channelEditor)
示例#5
0
def getElementTypeIcon(t):
    if t == ChannelView.Channel:
        return getIcon(":/actions/system-shutdown.svg")
    elif t == ChannelView.Enabled:
        return getIcon(":/status/true.svg")
    elif t == ChannelView.Output:
        return getThemeIcon("utilities-terminal")
    elif t == ChannelView.PlotType:
        return getIcon(":/apps/utilities-system-monitor.svg")
    elif t == ChannelView.PlotAxes:
        return getIcon(":/apps/utilities-system-monitor.svg")
    elif t == ChannelView.Timer:
        return getIcon(":/status/flag-green-clock.svg")
    elif t == ChannelView.Monitor:
        return getIcon(":/status/flag-green.svg")
    elif t == ChannelView.Synchronization:
        return getIcon(":/actions/system-shutdown.svg")
    elif t == ChannelView.NXPath:
        return getThemeIcon("document-save-as")
    elif t == ChannelView.Synchronizer:
        return getIcon(":/actions/system-shutdown.svg")

    return getIcon(":/tango.png")
示例#6
0
文件: common.py 项目: cmft/sardana
 def __init__(self, parent=None, designMode=False):
     TaurusMainWindow.__init__(self, parent, designMode)
     self.statusBar().showMessage("")
     self.setModelInConfig(True)
     self._doorName = ""
     self.registerConfigProperty("doorName", "setDoorName", "doorName")
     self._customMacroEditorPaths = ""
     self.registerConfigProperty("customMacroEditorPaths", "setCustomMacroEditorPaths", "customMacroEditorPaths")
     self._qDoor = None
     self.setWindowIcon(getIcon(":/apps/preferences-system-session.svg"))
     toolBar = self.basicTaurusToolbar()
     toolBar.setIconSize(Qt.QSize(24, 24))
     self.configureAction = self.createConfigureAction()
     toolBar.addAction(self.configureAction)
     self.taurusMenu.addAction(self.configureAction)
     self.customMacroEditorsPathsAction = self.createCustomMacroEditorPathsAction()
     self.taurusMenu.addAction(self.customMacroEditorsPathsAction)
     self.addToolBar(toolBar)
     self.initComponents()
     self.splashScreen().finish(self)
     self.connect(self, Qt.SIGNAL("doorChanged"), self.onDoorChanged)
示例#7
0
 def icon(self, index):
     return getIcon(":/python-file.png")
示例#8
0
def getElementTypeIcon(t):
    if t == MacroView.MacroModule:
        return getIcon(":/python-file.png")
    elif t == MacroView.Macro:
        return getIcon(":/python.png")
    return getIcon(":/tango.png")
示例#9
0
    def __init__(self, parent=None, designMode=False):
        TaurusWidget.__init__(self, parent, designMode)
        # list representing all macros ids (all from sequence) currently
        # executed
        self._macroIds = []
        self._sequencesPath = str(Qt.QDir.homePath())
        self._sequenceModel = MacroSequenceTreeModel()

        self.registerConfigProperty(
            "sequencesPath", "setSequencesPath", "sequencesPath")

        self.setLayout(Qt.QVBoxLayout())
        self.layout().setContentsMargins(0, 0, 0, 0)
        splitter = Qt.QSplitter()
        self.layout().addWidget(splitter)
        splitter.setOrientation(Qt.Qt.Vertical)

        sequenceEditor = TaurusWidget()
        splitter.addWidget(sequenceEditor)
        sequenceEditor.setUseParentModel(True)
        sequenceEditor.setLayout(Qt.QVBoxLayout())
        sequenceEditor.layout().setContentsMargins(0, 0, 0, 0)

        self.tree = MacroSequenceTree(sequenceEditor)
        self.sequenceProxyModel = MacroSequenceProxyModel()
        self.sequenceProxyModel.setSourceModel(self._sequenceModel)
        self.tree.setModel(self.sequenceProxyModel)
        self.tree.setItemDelegate(SequenceEditorDelegate(self.tree))

        actionsLayout = Qt.QHBoxLayout()
        actionsLayout.setContentsMargins(0, 0, 0, 0)
        self.newSequenceAction = Qt.QAction(
            getThemeIcon("document-new"), "New", self)
        self.newSequenceAction.triggered.connect(self.onNewSequence)
        self.newSequenceAction.setToolTip("New sequence")
        self.newSequenceAction.setEnabled(False)
        newSequenceButton = Qt.QToolButton()
        newSequenceButton.setDefaultAction(self.newSequenceAction)
        actionsLayout.addWidget(newSequenceButton)

        self.openSequenceAction = Qt.QAction(
            getThemeIcon("document-open"), "Open...", self)
        self.openSequenceAction.triggered.connect(self.onOpenSequence)
        self.openSequenceAction.setToolTip("Open sequence...")
        openSequenceButton = Qt.QToolButton()
        openSequenceButton.setDefaultAction(self.openSequenceAction)
        actionsLayout.addWidget(openSequenceButton)

        self.saveSequenceAction = Qt.QAction(
            getThemeIcon("document-save"), "Save...", self)
        self.saveSequenceAction.triggered.connect(self.onSaveSequence)
        self.saveSequenceAction.setToolTip("Save sequence...")
        self.saveSequenceAction.setEnabled(False)
        saveSequenceButton = Qt.QToolButton()
        saveSequenceButton.setDefaultAction(self.saveSequenceAction)
        actionsLayout.addWidget(saveSequenceButton)

        self.stopSequenceAction = Qt.QAction(
            getIcon(":/actions/media_playback_stop.svg"), "Stop", self)
        self.stopSequenceAction.triggered.connect(self.onStopSequence)
        self.stopSequenceAction.setToolTip("Stop sequence")
        stopSequenceButton = Qt.QToolButton()
        stopSequenceButton.setDefaultAction(self.stopSequenceAction)
        actionsLayout.addWidget(stopSequenceButton)

        self.pauseSequenceAction = Qt.QAction(
            getIcon(":/actions/media_playback_pause.svg"), "Pause", self)
        self.pauseSequenceAction.triggered.connect(self.onPauseSequence)
        self.pauseSequenceAction.setToolTip("Pause sequence")
        pauseSequenceButton = Qt.QToolButton()
        pauseSequenceButton.setDefaultAction(self.pauseSequenceAction)
        actionsLayout.addWidget(pauseSequenceButton)

        self.playSequenceAction = Qt.QAction(
            getIcon(":/actions/media_playback_start.svg"), "Play", self)
        self.playSequenceAction.triggered.connect(self.onPlaySequence)
        self.playSequenceAction.setToolTip("Play sequence")
        playSequenceButton = Qt.QToolButton()
        playSequenceButton.setDefaultAction(self.playSequenceAction)
        actionsLayout.addWidget(playSequenceButton)

        self.doorStateLed = TaurusLed(self)
        actionsLayout.addWidget(self.doorStateLed)

        #@todo this feature will be replaced by checkboxes in the
        # sequence tree view indicating clearing of the plot after execution
        self.fullSequencePlotCheckBox = Qt.QCheckBox(
            "Full sequence plot", self)
        self.fullSequencePlotCheckBox.toggled.connect(self.setFullSequencePlot)
        self.fullSequencePlotCheckBox.setChecked(True)
        actionsLayout.addWidget(self.fullSequencePlotCheckBox)

        spacerItem = Qt.QSpacerItem(
            0, 0, Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Fixed)
        actionsLayout.addItem(spacerItem)

        sequenceEditor.layout().addLayout(actionsLayout)

        macroLayout = Qt.QHBoxLayout()
        macroLayout.setContentsMargins(0, 0, 0, 0)
        macroLabel = Qt.QLabel("Macro:")
        macroLayout.addWidget(macroLabel)
        self.macroComboBox = MacroComboBox(self)
        self.macroComboBox.setUseParentModel(True)
        self.macroComboBox.setModelColumn(0)
        self.macroComboBox.setSizePolicy(
            Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Minimum)
        macroLayout.addWidget(self.macroComboBox)

        self.addMacroAction = Qt.QAction(
            getThemeIcon("list-add"), "Add macro...", self)
        self.addMacroAction.triggered.connect(self.onAdd)
        self.addMacroAction.setToolTip(
            "Clicking this button will add selected macro")
        self.addMacroAction.setEnabled(False)
        addButton = Qt.QToolButton()
        addButton.setDefaultAction(self.addMacroAction)
        macroLayout.addWidget(addButton)

        sequenceEditor.layout().addLayout(macroLayout)

        sequenceLayout = Qt.QHBoxLayout()
        sequenceLayout.addWidget(self.tree)

        layout = Qt.QVBoxLayout()
        delButton = Qt.QToolButton()
        delButton.setDefaultAction(self.tree.deleteAction)
        delButton.setEnabled(False)
        layout.addWidget(delButton)
        upButton = Qt.QToolButton()
        upButton.setDefaultAction(self.tree.moveUpAction)
        upButton.setEnabled(False)
        layout.addWidget(upButton)
        downButton = Qt.QToolButton()
        downButton.setDefaultAction(self.tree.moveDownAction)
        downButton.setEnabled(False)
        layout.addWidget(downButton)
        leftButton = Qt.QToolButton()
        leftButton.setDefaultAction(self.tree.moveLeftAction)
        leftButton.setEnabled(False)
        layout.addWidget(leftButton)
        rightButton = Qt.QToolButton()
        rightButton.setDefaultAction(self.tree.moveRightAction)
        rightButton.setEnabled(False)
        layout.addWidget(rightButton)
        spacerItem = Qt.QSpacerItem(
            0, 40, Qt.QSizePolicy.Fixed, Qt.QSizePolicy.Expanding)
        layout.addItem(spacerItem)
        sequenceLayout.addLayout(layout)
        sequenceEditor.layout().addLayout(sequenceLayout)

        self.parametersProxyModel = MacroParametersProxyModel()
        self.parametersProxyModel.setSourceModel(self._sequenceModel)

        self.stackedWidget = Qt.QStackedWidget()
        splitter.addWidget(self.stackedWidget)
        self.standardMacroParametersEditor = StandardMacroParametersEditor(
            self.stackedWidget)
        self.standardMacroParametersEditor.setModel(self.parametersProxyModel)
        self.standardMacroParametersEditor.tree.setItemDelegate(
            ParamEditorDelegate(self.standardMacroParametersEditor.tree))
        self.stackedWidget.addWidget(self.standardMacroParametersEditor)
        self.customMacroParametersEditor = None

        self.macroComboBox.currentIndexChanged.connect(
            self.onMacroComboBoxChanged)
        self.tree.macroChanged.connect(self.setMacroParametersRootIndex)
示例#10
0
def getElementTypeIcon(t):
    if t == PoolControllerView.ControllerModule:
        return getIcon(":/python-file.png")
    elif t == PoolControllerView.ControllerClass:
        return getIcon(":/python.png")
    return getIcon(":/tango.png")
示例#11
0
 def icon(self):
     return getIcon(":/python.png")
示例#12
0
文件: gui.py 项目: sergirubio/panic
def main(args=[]):
    import widgets
    from taurus.qt.qtgui import resource
#    print os.getenv('TANGO_HOST')
    print '='*80
    trace(' Launching Panic ...')
    print '='*80
    opts = [a for a in args if a.startswith('--')]
    args = [a for a in args if not a.startswith('--')]
    URL = 'http://www.cells.es/Intranet/Divisions/Computing/Controls/Help/Alarms/panic'
    
    uniqueapp = Qt.QApplication([])
    if '--calc' in opts:
        args = args or ['']
        form = AlarmPreview(*args)
        form.show()
        uniqueapp.exec_()
        return
    
    tmw = CleanMainWindow()
    tmw.setWindowTitle('PANIC') #str(os.getenv('TANGO_HOST')).split(':',1)[0]+' )
    tmw.menuBar = Qt.QMenuBar(tmw)
    tmw.toolsMenu = Qt.QMenu('Tools',tmw.menuBar)
    tmw.fileMenu = Qt.QMenu('File',tmw.menuBar)
    tmw.viewMenu = Qt.QMenu('View',tmw.menuBar)
    tmw.helpMenu = Qt.QMenu('Help',tmw.menuBar)
    
    trace('\tlaunching AlarmGUI ... %s'%sys.argv)
    alarmApp = AlarmGUI(filters='|'.join(a for a in sys.argv[1:] if not a.startswith('--')),options=opts,mainwindow=tmw)
    tmw.setCentralWidget(alarmApp)

    tmw.setMenuBar(tmw.menuBar)
    [tmw.menuBar.addAction(a.menuAction()) for a in (tmw.fileMenu,tmw.toolsMenu,tmw.helpMenu,tmw.viewMenu)]
    toolbar = Qt.QToolBar(tmw)
    toolbar.setIconSize(Qt.QSize(20,20))
    
    tmw.helpMenu.addAction(getThemeIcon("applications-system"),"Webpage",lambda : os.system('konqueror %s &'%URL))
    tmw.toolsMenu.addAction(getThemeIcon("applications-system"),"Jive",lambda : os.system('jive &'))
    tmw.toolsMenu.addAction(getThemeIcon("applications-system"),"Astor",lambda : os.system('astor &'))
    tmw.fileMenu.addAction(resource.getIcon(":/designer/back.png"),"Export to CSV file",alarmApp.saveToFile)
    tmw.fileMenu.addAction(resource.getIcon(":/designer/forward.png"),"Import from CSV file",alarmApp.loadFromFile)
    tmw.fileMenu.addAction(resource.getIcon(":/designer/filereader.png"),"Use external editor",alarmApp.editFile)
    tmw.fileMenu.addAction(getThemeIcon("applications-system"),"Exit",tmw.close)
    tmw.viewMenu.connect(tmw.viewMenu,Qt.SIGNAL('aboutToShow()'),alarmApp.setViewMenu)
    
    from phonebook import PhoneBook
    alarmApp.tools['bookApp'] = WindowManager.addWindow(PhoneBook(container=tmw))
    tmw.toolsMenu.addAction(getThemeIcon("x-office-address-book"), "PhoneBook", alarmApp.tools['bookApp'].show)
    toolbar.addAction(getThemeIcon("x-office-address-book") ,"PhoneBook",alarmApp.tools['bookApp'].show)
    
    trend_action = (resource.getIcon(":/designer/qwtplot.png"),
        'Trend',
        lambda:WindowManager.addWindow(widgets.get_archive_trend(show=True))
        )
    tmw.toolsMenu.addAction(*trend_action)
    toolbar.addAction(*trend_action)
    
    alarmApp.tools['config'] = WindowManager.addWindow(widgets.dacWidget(container=tmw))
    tmw.toolsMenu.addAction(getThemeIcon("applications-system"),"Advanced Configuration", alarmApp.tools['config'].show)
    toolbar.addAction(getThemeIcon("applications-system") ,"Advanced Configuration",alarmApp.tools['config'].show)
    
    toolbar.setMovable(False)
    toolbar.setFloatable(False)
    tmw.addToolBar(toolbar)
    
    if SNAP_ALLOWED:
        alarmApp.tools['history'] = WindowManager.addWindow(widgets.ahWidget(container=tmw))
        tmw.toolsMenu.addAction(getThemeIcon("office-calendar"),"Alarm History Viewer",alarmApp.tools['history'].show)
        toolbar.addAction(getThemeIcon("office-calendar") ,"Alarm History Viewer",alarmApp.tools['history'].show)
    else:
        trace("Unable to load SNAP",'History Viewer Disabled!')
        
    alarm_preview_action = (getThemeIcon("accessories-calculator"),"Alarm Calculator",
        lambda g=alarmApp:WindowManager.addWindow(AlarmPreview.showEmptyAlarmPreview(g)))
    [o.addAction(*alarm_preview_action) for o in (tmw.toolsMenu,toolbar)]
        
    tmw.show()
    return uniqueapp #.exec_()
示例#13
0
 def icon(self, index):
     taurus_role = index.model().role(index.column())
     if taurus_role == ChannelView.Channel:
         return getIcon(":/actions/system-shutdown.svg")
示例#14
0
    def __init__(self, parent=None, designMode=False):
        TaurusWidget.__init__(self, parent, designMode)
        self.setObjectName(self.__class__.__name__)

        self._doorName = ""
        self._macroId = None
        self.setLayout(Qt.QVBoxLayout())
        self.layout().setContentsMargins(0, 0, 0, 0)

        self.addToFavouritesAction = Qt.QAction(getThemeIcon(
            "software-update-available"), "Add to favourites", self)
        self.addToFavouritesAction.triggered.connect(self.onAddToFavourites)
        self.addToFavouritesAction.setToolTip("Add to favourites")
        self.stopMacroAction = Qt.QAction(
            getIcon(":/actions/media_playback_stop.svg"), "Stop macro", self)
        self.stopMacroAction.triggered.connect(self.onStopMacro)
        self.stopMacroAction.setToolTip("Stop macro")
        self.pauseMacroAction = Qt.QAction(
            getIcon(":/actions/media_playback_pause.svg"), "Pause macro", self)
        self.pauseMacroAction.triggered.connect(self.onPauseMacro)
        self.pauseMacroAction.setToolTip("Pause macro")
        self.playMacroAction = Qt.QAction(
            getIcon(":/actions/media_playback_start.svg"), "Start macro", self)
        self.playMacroAction.triggered.connect(self.onPlayMacro)
        self.playMacroAction.setToolTip("Start macro")
        actionsLayout = Qt.QHBoxLayout()
        actionsLayout.setContentsMargins(0, 0, 0, 0)
        addToFavouritsButton = Qt.QToolButton()
        addToFavouritsButton.setDefaultAction(self.addToFavouritesAction)
        self.addToFavouritesAction.setEnabled(False)
        actionsLayout.addWidget(addToFavouritsButton)

        self.macroComboBox = MacroComboBox(self)
        self.macroComboBox.setUseParentModel(True)
        self.macroComboBox.setModelColumn(0)
        actionsLayout.addWidget(self.macroComboBox)
        stopMacroButton = Qt.QToolButton()
        stopMacroButton.setDefaultAction(self.stopMacroAction)
        actionsLayout.addWidget(stopMacroButton)
        pauseMacroButton = Qt.QToolButton()
        pauseMacroButton.setDefaultAction(self.pauseMacroAction)
        actionsLayout.addWidget(pauseMacroButton)
        self.playMacroButton = Qt.QToolButton()
        self.playMacroButton.setDefaultAction(self.playMacroAction)
        actionsLayout.addWidget(self.playMacroButton)
        self.disableControlActions()
        self.doorStateLed = TaurusLed(self)
        actionsLayout.addWidget(self.doorStateLed)
        self.layout().addLayout(actionsLayout)

        splitter = Qt.QSplitter(self)
        self.layout().addWidget(splitter)
        splitter.setOrientation(Qt.Qt.Vertical)

        self._paramEditorModel = ParamEditorModel()
        self.stackedWidget = Qt.QStackedWidget()
        self.standardMacroParametersEditor = StandardMacroParametersEditor(
            self.stackedWidget)
        self.stackedWidget.addWidget(self.standardMacroParametersEditor)
        self.customMacroParametersEditor = None
        splitter.addWidget(self.stackedWidget)

        self._favouritesBuffer = None
        self.favouritesMacrosEditor = FavouritesMacrosEditor(self)
        self.registerConfigDelegate(self.favouritesMacrosEditor)
        self.favouritesMacrosEditor.setUseParentModel(True)
        self.favouritesMacrosEditor.setFocusPolicy(Qt.Qt.NoFocus)

        self._historyBuffer = None
        self.historyMacrosViewer = HistoryMacrosViewer(self)
        self.registerConfigDelegate(self.historyMacrosViewer)
        self.historyMacrosViewer.setUseParentModel(True)
        self.historyMacrosViewer.setFocusPolicy(Qt.Qt.NoFocus)

        self.tabMacroListsWidget = Qt.QTabWidget(self)
        self.tabMacroListsWidget.addTab(
            self.favouritesMacrosEditor, "Favourite list")
        self.tabMacroListsWidget.addTab(
            self.historyMacrosViewer, "History Viewer")
        splitter.addWidget(self.tabMacroListsWidget)
        # Due to a limitation in the useParentModel architecture of Taurus,
        # the parent of historyMacrosViewer and favouritesMacrosEditor
        # must be recalculated. See more details in the taurus snippet code [1]
        # [1] https://raw.githubusercontent.com/taurus-org/taurus/develop/doc/source/devel/examples/parentmodel_issue_demo.py
        self.historyMacrosViewer.recheckTaurusParent()
        self.favouritesMacrosEditor.recheckTaurusParent()

        self._isHistoryMacro = False
        self.macroProgressBar = MacroProgressBar(self)
        self.layout().addWidget(self.macroProgressBar)

        #spockCommandLabel = Qt.QLabel("Spock command:", self)
        # spockCommandLabel.setFont(Qt.QFont("Courier",9))
        self.spockCommand = SpockCommandWidget("Spock", self)
        self.spockCommand.setSizePolicy(
            Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Minimum)
        self.spockCommand.setUseParentModel(True)
        spockCommandLayout = Qt.QHBoxLayout()
        spockCommandLayout.setContentsMargins(0, 0, 0, 0)
        # spockCommandLayout.addWidget(spockCommandLabel)
        spockCommandLayout.addWidget(self.spockCommand)
        self.layout().addLayout(spockCommandLayout)

        self.macroComboBox.currentIndexChanged['QString'].connect(
            self.onMacroComboBoxChanged)
        self.favouritesMacrosEditor.list.favouriteSelected.connect(
            self.onFavouriteSelected)
        self.historyMacrosViewer.list.historySelected.connect(
            self.onHistorySelected)

        self.spockCommand.pressedReturn.connect(self.onPlayMacro)
        self.spockCommand.spockComboBox.connect(self.setComboBoxItem)
        self.spockCommand.elementUp.connect(self.setHistoryUp)
        self.spockCommand.elementDown.connect(self.setHistoryDown)
        self.spockCommand.expandTree.connect(
            self.standardMacroParametersEditor.tree.expandAll)
示例#15
0
    def __init__(self, parent=None, designMode=False):
        TaurusWidget.__init__(self, parent, designMode)
        self.setObjectName(self.__class__.__name__)

        self._doorName = ""
        self._macroId = None
        self.setLayout(Qt.QVBoxLayout())
        self.layout().setContentsMargins(0, 0, 0, 0)

        self.addToFavouritesAction = Qt.QAction(getThemeIcon("software-update-available"), "Add to favourites", self)
        self.connect(self.addToFavouritesAction, Qt.SIGNAL("triggered()"), self.onAddToFavourites)
        self.addToFavouritesAction.setToolTip("Add to favourites")
        self.stopMacroAction = Qt.QAction(getIcon(":/actions/media_playback_stop.svg"), "Stop macro", self)
        self.connect(self.stopMacroAction, Qt.SIGNAL("triggered()"), self.onStopMacro)
        self.stopMacroAction.setToolTip("Stop macro")
        self.pauseMacroAction = Qt.QAction(getIcon(":/actions/media_playback_pause.svg"), "Pause macro", self)
        self.connect(self.pauseMacroAction, Qt.SIGNAL("triggered()"), self.onPauseMacro)
        self.pauseMacroAction.setToolTip("Pause macro")
        self.playMacroAction = Qt.QAction(getIcon(":/actions/media_playback_start.svg"), "Start macro", self)
        self.connect(self.playMacroAction, Qt.SIGNAL("triggered()"), self.onPlayMacro)
        self.playMacroAction.setToolTip("Start macro")
        actionsLayout = Qt.QHBoxLayout()
        actionsLayout.setContentsMargins(0, 0, 0, 0)
        addToFavouritsButton = Qt.QToolButton()
        addToFavouritsButton.setDefaultAction(self.addToFavouritesAction)
        self.addToFavouritesAction.setEnabled(False)
        actionsLayout.addWidget(addToFavouritsButton)

        self.macroComboBox = MacroComboBox(self)
        self.macroComboBox.setUseParentModel(True)
        self.macroComboBox.setModelColumn(0)
        actionsLayout.addWidget(self.macroComboBox)
        stopMacroButton = Qt.QToolButton()
        stopMacroButton.setDefaultAction(self.stopMacroAction)
        actionsLayout.addWidget(stopMacroButton)
        pauseMacroButton = Qt.QToolButton()
        pauseMacroButton.setDefaultAction(self.pauseMacroAction)
        actionsLayout.addWidget(pauseMacroButton)
        self.playMacroButton = Qt.QToolButton()
        self.playMacroButton.setDefaultAction(self.playMacroAction)
        actionsLayout.addWidget(self.playMacroButton)
        self.disableControlActions()
        self.doorStateLed = TaurusLed(self)
        actionsLayout.addWidget(self.doorStateLed)
        self.layout().addLayout(actionsLayout)

        splitter = Qt.QSplitter(self)
        self.layout().addWidget(splitter)
        splitter.setOrientation(Qt.Qt.Vertical)

        self._paramEditorModel = ParamEditorModel()
        self.stackedWidget = Qt.QStackedWidget()
        self.standardMacroParametersEditor = StandardMacroParametersEditor(self.stackedWidget)
        self.stackedWidget.addWidget(self.standardMacroParametersEditor)
        self.customMacroParametersEditor = None
        splitter.addWidget(self.stackedWidget)

        self._favouritesBuffer = None
        self.favouritesMacrosEditor = FavouritesMacrosEditor(self)
        self.registerConfigDelegate(self.favouritesMacrosEditor)
        self.favouritesMacrosEditor.setUseParentModel(True)
        self.favouritesMacrosEditor.setFocusPolicy(Qt.Qt.NoFocus)

        self._historyBuffer = None
        self.historyMacrosViewer = HistoryMacrosViewer(self)
        self.registerConfigDelegate(self.historyMacrosViewer)
        self.historyMacrosViewer.setUseParentModel(True)
        self.historyMacrosViewer.setFocusPolicy(Qt.Qt.NoFocus)

        self.tabMacroListsWidget = Qt.QTabWidget(self)
        self.tabMacroListsWidget.addTab(self.favouritesMacrosEditor, "Favourite list")
        self.tabMacroListsWidget.addTab(self.historyMacrosViewer, "History Viewer")
        splitter.addWidget(self.tabMacroListsWidget)

        self._isHistoryMacro = False
        self.macroProgressBar = MacroProgressBar(self)
        self.layout().addWidget(self.macroProgressBar)

        #spockCommandLabel = Qt.QLabel("Spock command:", self)
        #spockCommandLabel.setFont(Qt.QFont("Courier",9))
        self.spockCommand = SpockCommandWidget("Spock", self)
        self.spockCommand.setSizePolicy(Qt.QSizePolicy.Expanding, Qt.QSizePolicy.Minimum)
        self.spockCommand.setUseParentModel(True)
        spockCommandLayout = Qt.QHBoxLayout()
        spockCommandLayout.setContentsMargins(0, 0, 0, 0)
        #spockCommandLayout.addWidget(spockCommandLabel)
        spockCommandLayout.addWidget(self.spockCommand)
        self.layout().addLayout(spockCommandLayout)
        self.connect(self.macroComboBox, Qt.SIGNAL("currentIndexChanged(QString)"), self.onMacroComboBoxChanged)
        self.connect(self.favouritesMacrosEditor.list, Qt.SIGNAL("favouriteSelected"), self.onFavouriteSelected)
        self.connect(self.historyMacrosViewer.list, Qt.SIGNAL("historySelected"), self.onHistorySelected)

        self.connect(self.spockCommand, Qt.SIGNAL("pressedReturn"), self.onPlayMacro)
        self.connect(self.spockCommand, Qt.SIGNAL("spockComboBox"), self.setComboBoxItem)
        self.connect(self.spockCommand, Qt.SIGNAL("elementUp"), self.setHistoryUp)
        self.connect(self.spockCommand, Qt.SIGNAL("elementDown"), self.setHistoryDown)
        self.connect(self.spockCommand, Qt.SIGNAL("setHistoryFocus"), self.setHistoryFocus)
        self.connect(self.spockCommand, Qt.SIGNAL("expandTree"), self.standardMacroParametersEditor.tree.expandAll)