def getDial(self, parent): dial = QDial(parent) dial.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) dial.setMinimumSize(50, 50) dial.setMaximumHeight(50) dial.setNotchTarget(25) dial.setNotchesVisible(True) dial.setMinimum(0) dial.setMaximum(99) dial.setPageStep(10) dial.setPageStep(10) return dial
def getDial(self): dial = QDial(self) dial.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) dial.setMinimumSize(50, 50) dial.setMaximumHeight(50) dial.setNotchTarget(25) dial.setNotchesVisible(True) dial.setMinimum(0) dial.setMaximum(99) dial.setPageStep(10) dial.setPageStep(10) return dial
def getDial(self, parent): dial = QDial(parent) dial.setNotchesVisible(True) dial.setNotchTarget(25.0) dial.setMaximumHeight(40) return dial
def getDial(self, parent): dial = QDial(parent) dial.setNotchesVisible(True) dial.setNotchTarget(25.0) dial.setMaximumHeight(40) return dial;
class LayoutWindow(QWidget): SLIDER_RESOLUTION = 1000 DIAL_RESOLUTION = 50 def __init__(self,parent=None): QWidget.__init__(self,parent) self.initWidgets() def initWidgets(self): self.ui_VideoFrame = VideoWidget(self) self.ui_Slider = QtGui.QSlider(QtCore.Qt.Horizontal) #contribution: #self.ui_Slider.setStyleSheet(stylesheet(self)) self.ui_Slider.setMinimum(0) self.ui_Slider.setMaximum(self.SLIDER_RESOLUTION) self.ui_Slider.setToolTip("Video track") #self.ui_Slider.setTickPosition(Qt.TicksAbove) self.ui_Dial = QDial(self) self.ui_Dial.setProperty("value", 0) self.ui_Dial.setNotchesVisible(True) self.ui_Dial.setWrapping(False) self.ui_Dial.setNotchTarget(5.0) self.ui_Dial.setToolTip("Fine tuning") self.setDialResolution(self.DIAL_RESOLUTION) self.ui_GotoField = QSpinBox(self) self.ui_GotoField.setValue(1) self.ui_GotoField.setToolTip("Goto Frame") self.ui_InfoLabel = QLabel(self) changeBackgroundColor(self.ui_InfoLabel , "lightblue") self.ui_InfoLabel.setText("") self.ui_InfoLabel.setToolTip("Infos about the video position") self.ui_CB_Reencode = QCheckBox(self) self.ui_CB_Reencode.setText("Exact cut") self.ui_CB_Reencode.setChecked(False) self.ui_CB_Reencode.setToolTip("Exact cut is slow, but precise") self.ui_List = self.__createListWidget() #self._listSplitter = QSplitter() ->add as widget...+QVBoxLayout #self._listSplitter.addWidget(iconList) #status bar self.statusbar = QStatusBar(self) self.statusbar.setSizeGripEnabled(True) self.statusbar.showMessage("Idle") self.statusbar.addPermanentWidget(self.__createProgressBar()) self.setLayout(self.makeGridLayout()) self.adjustSize() def makeGridLayout(self): gridLayout = QGridLayout() self.ui_List.setSizePolicy(QSizePolicy.Minimum,QSizePolicy.Expanding) gridLayout.addWidget(self.ui_List,0,0,5,1) #row column, rowSpan, columnSpan gridLayout.addWidget(self.ui_VideoFrame,0,2,3,-1); gridLayout.addWidget(self.ui_GotoField,4,1,1,20) gridLayout.addWidget(self.ui_InfoLabel,4,26,1,90) gridLayout.addWidget(self.ui_CB_Reencode,4,121) gridLayout.addWidget(self.ui_Slider,5,0,1,120) gridLayout.addWidget(self.ui_Dial,5,121) gridLayout.addWidget(self.statusbar,6,0,1,122) return gridLayout def makeBoxLayout(self): vbox = QVBoxLayout() vbox.addWidget(self.ui_VideoFrame) vbox.addWidget(self.ui_InfoLabel ); slidehbox = QHBoxLayout() slidehbox.addWidget(self.ui_Slider) slidehbox.addWidget(self.ui_Dial) midHBox = QHBoxLayout() midHBox.addWidget(self.ui_List) self.ui_List.setSizePolicy(QSizePolicy.Minimum,QSizePolicy.Expanding) midHBox.addLayout(vbox) mainVBox = QVBoxLayout() mainVBox.addLayout(midHBox) mainVBox.addStretch(1) mainVBox.addLayout(slidehbox) return mainVBox def showInfo(self,text): self.ui_InfoLabel.setText(text) def showStatusMessage(self,text): self.statusbar.showMessage(text) def setDialResolution(self,resolution): self.ui_Dial.setMinimum(-resolution/2) self.ui_Dial.setMaximum(resolution/2) def syncSliderPos(self,pos): self.ui_Slider.setSliderPosition(pos) def setSliderTicks(self,ticks): self.ui_Slider.setSingleStep(ticks) self.ui_Slider.setPageStep(ticks*2) def setGotoFieldMaximum(self,count): self.ui_GotoField.setMaximum(count) def clearVideoFrame(self): self.ui_VideoFrame.showFrame(None) ### Marks def addCutMark(self,frame,cutEntry,rowIndex): item = QListWidgetItem() img = CVImage(frame).scaled(self.ui_VideoFrame.imageRatio*SIZE_ICON, SIZE_ICON) pix = QtGui.QPixmap.fromImage(img) item.setIcon(QIcon(pix)) if cutEntry.isStartMode(): item.setBackgroundColor(QColor(224,255,224)) else: item.setBackgroundColor(QColor(255,224,224)) self.ui_List.insertItem(rowIndex,item) text = "%s <br> F: %s<br> T: %s" %(cutEntry.modeString,str(cutEntry.frameNumber),str(cutEntry.getTimeString())) marker = QLabel(text) marker.setWordWrap(True) marker.layout() self.ui_List.setItemWidget(item,marker) self.ui_List.setIconSize(QSize(SIZE_ICON,SIZE_ICON)) #Forces an update! self.ui_List.setCurrentItem(item) def hookEvents(self,aVideoController): self.__videoController=aVideoController #for menu callbacks self.ui_Slider.valueChanged.connect(aVideoController.sliderMoved) self.ui_Dial.valueChanged.connect(aVideoController.dialChanged) self.ui_Dial.sliderReleased.connect(self.__resetDial) self.ui_GotoField.editingFinished.connect(self.__gotoFrame) self.ui_CB_Reencode.stateChanged.connect(aVideoController.setExactCut) self.statusMessenger = StatusDispatcher() self.connect(self.statusMessenger,self.statusMessenger.signal,self.showStatusMessage) self._hookListActions() def keyReleaseEvent(self,event): self.__resetDial() def _hookListActions(self): #TOO bad-the list model -should be here... rmAction = QtGui.QAction(QtGui.QIcon('icons/close-x.png'), 'Delete', self) rmAction.triggered.connect(self._removeMarker) rmAllAction = QtGui.QAction(QtGui.QIcon('icons/clear-all.png'), 'Remove all', self) rmAllAction.triggered.connect(self.purgeMarker) self.gotoAction = QtGui.QAction(QtGui.QIcon('icons/go-next.png'), 'Goto', self) self.gotoAction.triggered.connect(self._gotoFromMarker) #menus self.ui_List.customContextMenuRequested.connect(self._openListMenu) self._listMenu = QMenu() self._listMenu.addAction(self.gotoAction) self._listMenu.addSeparator() self._listMenu.addAction(rmAction) self._listMenu.addAction(rmAllAction) def __resetDial(self): self.ui_Dial.setProperty("value", 0) def __gotoFrame(self): self.__videoController._gotoFrame(self.ui_GotoField.value()) def __createProgressBar(self): self.progressBar = QtGui.QProgressBar(self) #self.progressBar.setRange(0,1) #self.progressBar.setValue(-1) #self.progressBar.reset() self.progressBar.setMinimum(0) self.progressBar.setMaximumWidth(150) self.progressBar.setVisible(False) return self.progressBar def showBusy(self): self.progressBar.setRange(0,0) self.progressBar.setVisible(True) def stopProgress(self): self.progressBar.setVisible(False) def __createListWidget(self): iconList=QListWidget() iconList.setAlternatingRowColors(True) iconList.setContextMenuPolicy(Qt.CustomContextMenu) #iconList.setStyleSheet("QListWidget { background: red; } QListWidget::item { background: yellow; } QListWidget::item:selected { background: blue; }") iconList.setStyleSheet("QListWidget::item:selected:active { background: #28D9FF; color:#FFFFFF; } ")#that text color seems not to work! return iconList #---List widget context menu def _removeMarker(self,whatis): selectionList = self.ui_List.selectedIndexes() if len(selectionList)==0: return item = selectionList[0] self.ui_List.takeItem(item.row()) self.__videoController.removeVideoCutIndex(item.row()) def clearMarkerList(self): self.ui_List.clear() #remove contents, remove file def purgeMarker(self): self.ui_List.clear() self.__videoController.purgeVideoCuts() def _gotoFromMarker(self,whatis): selectionList = self.ui_List.selectedIndexes() if len(selectionList)==0: return item = selectionList[0] self.__videoController.gotoCutIndex(item.row()) def _openListMenu(self,position): selectionList = self.ui_List.selectedIndexes() if len(selectionList)==0: return self._listMenu.exec_(self.ui_List.viewport().mapToGlobal(position))