def createPlaylistDock(self): # from playlist import PlayList self.next_id = 0 # self.playlist = PlayList(self, None) self.propertydock = Q.QDockWidget() self.propertydock.setWindowTitle("Playlist") self.propertydock.setFeatures(Q.QDockWidget.DockWidgetFloatable | Q.QDockWidget.DockWidgetMovable) tw = Q.QTabWidget(parent=self.propertydock) player = self.playerwidget player._property_model = AVTreePropertyModel(player=player, parent=player) if self._use_tree: tv = Q.QTreeView() tv.setModel(player._property_model) tw.addTab(tv, 'tree') tv.header().setSectionResizeMode(Q.QHeaderView.Stretch) # player._flat_model = AVFlatPropertyModel(player=player, parent=player) # if self._use_table: # self.propertymodel= AVFlatPropertyModel(player=self.playerwidget,parent=self) # self.propertyview = Q.QTableView(self.propertydock) # self.propertyview.setModel(player._flat_model) # tw.addTab(self.propertyview, 'table') # self.propertyview.horizontalHeader().setSectionResizeMode(Q.QHeaderView.Stretch) self.propertydock.setWidget(tw) tw.show() tw.parent().adjustSize() tw.parent().update() self.propertydock.show()
def __init__(self, *args, **kwargs): fp = kwargs.pop('fp', None) use_tabs = kwargs.pop('tabs', True) super().__init__(*args, **kwargs) self.setSizePolicy( Q.QSizePolicy(Q.QSizePolicy.MinimumExpanding, Q.QSizePolicy.MinimumExpanding, Q.QSizePolicy.Frame)) childwidget = self.childwidget = AVPlayer(fp=fp, parent=self) childwidget.setSizePolicy( Q.QSizePolicy(Q.QSizePolicy.MinimumExpanding, Q.QSizePolicy.MinimumExpanding, Q.QSizePolicy.Label)) self.splitter = Q.QSplitter() self.splitter.setOrientation(Q.Qt.Vertical) self.layout = Q.QVBoxLayout() self.splitter.addWidget(self.childwidget) self.layout.addWidget(self.splitter) self.setLayout(self.layout) controls_widget = Q.QWidget() controls_layout = Q.QVBoxLayout() controls_widget.setLayout(controls_layout) self.splitter.addWidget(controls_widget) time_layout = Q.QVBoxLayout() timespin_layout = Q.QHBoxLayout() self.timespin = Q.QDoubleSpinBox() self.timespin.setFixedWidth(120) self.timespin.setDecimals(5) self.timespin.setSingleStep(1e-2) timespin_layout.addWidget(self.timespin) step_back = Q.QPushButton("step -") step_back.clicked.connect( lambda: self.childwidget.try_command('frame-back-step')) timespin_layout.addWidget(step_back) step_forward = Q.QPushButton("step +") step_forward.clicked.connect( lambda: self.childwidget.try_command('frame-step')) timespin_layout.addWidget(step_forward) timespin_layout.addStretch(-1) time_layout.addLayout(timespin_layout) self.timeline = Q.QSlider(Q.Qt.Horizontal) self.timeline.setSizePolicy(Q.QSizePolicy.Expanding, Q.QSizePolicy.Preferred) self.timeline.setEnabled(True) self.timeline.sliderReleased.connect( lambda: self.onTimelineChanged(self.timeline.value())) time_layout.addWidget(self.timeline) controls_layout.addLayout(time_layout) childwidget.time_pos.valueChanged.connect(self.onTime_posChanged) self.timeline.valueChanged.connect(self.onTimelineChanged) self.timespin.valueChanged.connect(self.onTimespinChanged) childwidget.duration.valueChanged.connect(self.onDurationChanged) self.speed = Q.QSlider(Q.Qt.Horizontal) self.speed.setSizePolicy(Q.QSizePolicy.Expanding, Q.QSizePolicy.Preferred) self.speed_base = 1e8 self.speed_max = 5.0 self.speed_pow = 5.0**(self.speed_base**-1) self.speed.setValue(self.speed_base) self.speed.setRange(16, 2 * self.speed_base) self.speed.setEnabled(True) self.speed.valueChanged.connect(self.speedChanged) childwidget.speed.valueChanged.connect(self.onSpeedChanged) play_button = Q.QPushButton("play/pause") play_button.clicked.connect(self.pause) self.play_button = play_button rate_down_button = Q.QPushButton("rate -") rate_down_button.clicked.connect(lambda: self.rate_adj(1. / 1.1)) rate_down_tmp_button = Q.QPushButton(" tmp -") rate_down_tmp_button.pressed.connect(lambda: self.temp_rate(1. / 1.1)) rate_down_tmp_button.released.connect(self.temp_rate_release) rate_up_button = Q.QPushButton("rate +") rate_up_button.clicked.connect(lambda: self.rate_adj(1.1)) rate_up_tmp_button = Q.QPushButton(" tmp +") rate_up_tmp_button.pressed.connect(lambda: self.temp_rate(1.1)) rate_up_tmp_button.released.connect(self.temp_rate_release) rate_down_layout = Q.QVBoxLayout() rate_down_layout.addWidget(rate_down_button) rate_down_layout.addWidget(rate_down_tmp_button) play_speed_layout = Q.QVBoxLayout() play_speed_layout.addWidget(play_button) play_speed_layout.addWidget(self.speed) rate_up_layout = Q.QVBoxLayout() rate_up_layout.addWidget(rate_up_button) rate_up_layout.addWidget(rate_up_tmp_button) control_layout = Q.QHBoxLayout() control_layout.addLayout(rate_down_layout) control_layout.addLayout(play_speed_layout) control_layout.addLayout(rate_up_layout) childwidget.video_params.valueChanged.connect( self.onVideo_paramsChanged) childwidget.reconfig.connect(self.reconfig) childwidget.novid.connect(self.novid) childwidget.hasvid.connect(self.hasvid) self.sized_once = False self.reconfig(640, 480) self.sized_once = False controls_layout.addLayout(control_layout) toolbarlayout = Q.QVBoxLayout() cmdlinelayout = Q.QHBoxLayout() histloglayout = Q.QHBoxLayout() self.histline = Q.QPlainTextEdit() self.histline.setReadOnly(True) self.histline.setCenterOnScroll(False) self.histline.setSizePolicy(Q.QSizePolicy.Expanding, Q.QSizePolicy.Preferred) self.logline = Q.QPlainTextEdit() self.logline.setReadOnly(True) self.logline.setSizePolicy(Q.QSizePolicy.Expanding, Q.QSizePolicy.Preferred) self.cmdline = cmdline = CmdLine() er_label = self.er_label = Q.QLabel() pr_label = self.pr_label = Q.QLabel() fr_label = self.fr_label = Q.QLabel() sr_label = self.sr_label = Q.QLabel() self._timer = Q.QTimer(self) self._timer.setInterval(int(1000 / 5)) self._timer.setTimerType(Q.Qt.CoarseTimer) def updateLabels(): self.pr_label.setText('paint rate: {:.6f}'.format( self.childwidget.paintRate)) self.er_label.setText('event rate: {:.6f}'.format( self.childwidget.eventRate)) self.fr_label.setText('frame rate: {:.6f}'.format( self.childwidget.frameRate)) self.sr_label.setText('swap rate: {:.6f}'.format( self.childwidget.swapRate)) self._timer.timeout.connect(updateLabels, Q.Qt.QueuedConnection) self._timer.start() # self.cmdline = cmdline = CmdLine(self.toolbargroup) self.cmdline.setSizePolicy(Q.QSizePolicy.Expanding, Q.QSizePolicy.Preferred) cmdlinelayout.addWidget(self.cmdline) cmdlinelayout.addWidget(er_label) cmdlinelayout.addWidget(pr_label) cmdlinelayout.addWidget(fr_label) cmdlinelayout.addWidget(sr_label) toolbarlayout.addLayout(cmdlinelayout) histloglayout.addWidget(self.histline) histloglayout.addWidget(self.logline) if use_tabs: tw = Q.QTabWidget(parent=self) tg = Q.QWidget() tg.setLayout(histloglayout) tw.addTab(tg, "history/log") childwidget._property_model = AVTreePropertyModel( player=childwidget, parent=childwidget) tv = Q.QTreeView() tv.setModel(childwidget._property_model) tw.addTab(tv, "properties") tw.setVisible(True) toolbarlayout.addWidget(tw) else: toolbarlayout.addLayout(histloglayout) controls_layout.addLayout(toolbarlayout) cmdline.submitted.connect(self.onCmdlineAccept, Q.Qt.UniqueConnection | Q.Qt.AutoConnection) cmdline.historyChanged.connect(self.redoHistory) self.childwidget.logMessage.connect(self.onLogMessage)