def __init__(self, parent=None): QMainWindow.__init__(self, parent) self.resize(640,480) self.task = None self.settingDialog = None # create actions newAction = QAction(self) newAction.setText("添加文件") newAction.setIcon(QIcon('./images/new.png')) newAction.triggered.connect(self.addMediaFile) # removeAction = QAction(self) # removeAction.setText("删除文件") # removeAction.setIcon(QIcon('./images/remove.png')) convertAction = QAction(self) convertAction.setText("开始转码") convertAction.setIcon(QIcon('./images/convert.png')) settingAction = QAction(self) settingAction.setText("设置") aboutAction = QAction(self) aboutAction.setText("关于") # Begin MenuBar self.menuBar = QMenuBar(self) self.menuBar.setObjectName("menuBar") # self.menuBar.setGeometry(QtCore.QRect(0, 0, 400, 20)) self.menuFile = QMenu(self.menuBar) self.menuFile.setTitle("文件") self.setMenuBar(self.menuBar) # self.actionAdd_Media = QAction(self) # self.actionAdd_Media.setText("Add Media") self.menuFile.addAction(newAction) # self.menuFile.addAction(removeAction) self.menuFile.addAction(convertAction) self.menuBar.addAction(self.menuFile.menuAction()) menuEdit = QMenu(self.menuBar) menuEdit.setTitle("编辑") menuEdit.addAction(settingAction) self.menuBar.addAction(menuEdit.menuAction()) # menuOption = QMenu(self.menuBar) # menuOption.setTitle("选项") # self.menuBar.addAction(menuOption.menuAction()) menuHelp = QMenu(self.menuBar) menuHelp.setTitle("帮助") menuHelp.addAction(aboutAction) self.menuBar.addAction(menuHelp.menuAction()) # End MenuBar # Start toolbar mainToolBar = QToolBar(self) mainToolBar.setObjectName("mainToolBar") self.addToolBar(mainToolBar) mainToolBar.addAction(newAction) # mainToolBar.addAction(removeAction) mainToolBar.addAction(convertAction) # End toolbar # splitter self.mainSplitter = QSplitter(Qt.Vertical) self.setCentralWidget(self.mainSplitter) self.mainSplitter.setStretchFactor(0, 3) self.mainSplitter.setStretchFactor(1, 1) # timely update progress rate # use add file to add task self.convTaskModel = ConvTaskModel() # for test use # convTask = ConvTask("/home/ss/Test1.mp4") # self.convTaskModel.addTask(convTask) self.taskTableView = ConvTaskTableView() self.taskTableView.setModel(self.convTaskModel) self.taskTableView.setItemDelegate(ConvTaskDelegate(self)) self.taskTableView.setColumnWidth(0, 400) # self.taskListWidget = QWidget() # self.mainSplitter.addWidget(self.taskListWidget) self.mainSplitter.addWidget(self.taskTableView) self.mainTabWidget = QTabWidget() self.mainSplitter.addWidget(self.mainTabWidget) # Begin info tabWidget self.generalSettingWidget = GeneralSettingWidget(self) self.mainTabWidget.addTab(self.generalSettingWidget, "通用设置") # End info tabWidget # Begin tab2Widget self.vSettingWidget = VideoSettingWidget() self.mainTabWidget.addTab(self.vSettingWidget, "视频参数设置") # End tab2Widget # self.aSettingWidget = AudioSettingWidget() # self.mainTabWidget.addTab(self.aSettingWidget, "音频参数设置") # # self.tab_4 = QWidget() # self.mainTabWidget.addTab(self.tab_4, "转码命令行") self.statusBar = QStatusBar(self) self.statusBar.setObjectName("statusBar") self.setStatusBar(self.statusBar) self.timer = QTimer() self.timer.timeout.connect(self.refreshProgress) self.timer.start(1500) self.taskTableView.clickOnRow.connect(self.clickOnRow) self.taskTableView.deleteTaskSig.connect(self.deleteTask) convertAction.triggered.connect(self.startConvert) aboutAction.triggered.connect(self.about) #self.convTaskModel.tasks[0].startTask() settingAction.triggered.connect(self.setting)
def __init__(self, parent=None): QMainWindow.__init__(self, parent) self.resize(640, 480) self.task = None self.settingDialog = None # create actions newAction = QAction(self) newAction.setText("添加文件") newAction.setIcon(QIcon('./images/new.png')) newAction.triggered.connect(self.addMediaFile) # removeAction = QAction(self) # removeAction.setText("删除文件") # removeAction.setIcon(QIcon('./images/remove.png')) convertAction = QAction(self) convertAction.setText("开始转码") convertAction.setIcon(QIcon('./images/convert.png')) settingAction = QAction(self) settingAction.setText("设置") aboutAction = QAction(self) aboutAction.setText("关于") # Begin MenuBar self.menuBar = QMenuBar(self) self.menuBar.setObjectName("menuBar") # self.menuBar.setGeometry(QtCore.QRect(0, 0, 400, 20)) self.menuFile = QMenu(self.menuBar) self.menuFile.setTitle("文件") self.setMenuBar(self.menuBar) # self.actionAdd_Media = QAction(self) # self.actionAdd_Media.setText("Add Media") self.menuFile.addAction(newAction) # self.menuFile.addAction(removeAction) self.menuFile.addAction(convertAction) self.menuBar.addAction(self.menuFile.menuAction()) menuEdit = QMenu(self.menuBar) menuEdit.setTitle("编辑") menuEdit.addAction(settingAction) self.menuBar.addAction(menuEdit.menuAction()) # menuOption = QMenu(self.menuBar) # menuOption.setTitle("选项") # self.menuBar.addAction(menuOption.menuAction()) menuHelp = QMenu(self.menuBar) menuHelp.setTitle("帮助") menuHelp.addAction(aboutAction) self.menuBar.addAction(menuHelp.menuAction()) # End MenuBar # Start toolbar mainToolBar = QToolBar(self) mainToolBar.setObjectName("mainToolBar") self.addToolBar(mainToolBar) mainToolBar.addAction(newAction) # mainToolBar.addAction(removeAction) mainToolBar.addAction(convertAction) # End toolbar # splitter self.mainSplitter = QSplitter(Qt.Vertical) self.setCentralWidget(self.mainSplitter) self.mainSplitter.setStretchFactor(0, 3) self.mainSplitter.setStretchFactor(1, 1) # timely update progress rate # use add file to add task self.convTaskModel = ConvTaskModel() # for test use # convTask = ConvTask("/home/ss/Test1.mp4") # self.convTaskModel.addTask(convTask) self.taskTableView = ConvTaskTableView() self.taskTableView.setModel(self.convTaskModel) self.taskTableView.setItemDelegate(ConvTaskDelegate(self)) self.taskTableView.setColumnWidth(0, 400) # self.taskListWidget = QWidget() # self.mainSplitter.addWidget(self.taskListWidget) self.mainSplitter.addWidget(self.taskTableView) self.mainTabWidget = QTabWidget() self.mainSplitter.addWidget(self.mainTabWidget) # Begin info tabWidget self.generalSettingWidget = GeneralSettingWidget(self) self.mainTabWidget.addTab(self.generalSettingWidget, "通用设置") # End info tabWidget # Begin tab2Widget self.vSettingWidget = VideoSettingWidget() self.mainTabWidget.addTab(self.vSettingWidget, "视频参数设置") # End tab2Widget # self.aSettingWidget = AudioSettingWidget() # self.mainTabWidget.addTab(self.aSettingWidget, "音频参数设置") # # self.tab_4 = QWidget() # self.mainTabWidget.addTab(self.tab_4, "转码命令行") self.statusBar = QStatusBar(self) self.statusBar.setObjectName("statusBar") self.setStatusBar(self.statusBar) self.timer = QTimer() self.timer.timeout.connect(self.refreshProgress) self.timer.start(1500) self.taskTableView.clickOnRow.connect(self.clickOnRow) self.taskTableView.deleteTaskSig.connect(self.deleteTask) convertAction.triggered.connect(self.startConvert) aboutAction.triggered.connect(self.about) #self.convTaskModel.tasks[0].startTask() settingAction.triggered.connect(self.setting)
class Window(QMainWindow): addNewTask = Signal() def __init__(self, parent=None): QMainWindow.__init__(self, parent) self.resize(640,480) self.task = None self.settingDialog = None # create actions newAction = QAction(self) newAction.setText("添加文件") newAction.setIcon(QIcon('./images/new.png')) newAction.triggered.connect(self.addMediaFile) # removeAction = QAction(self) # removeAction.setText("删除文件") # removeAction.setIcon(QIcon('./images/remove.png')) convertAction = QAction(self) convertAction.setText("开始转码") convertAction.setIcon(QIcon('./images/convert.png')) settingAction = QAction(self) settingAction.setText("设置") aboutAction = QAction(self) aboutAction.setText("关于") # Begin MenuBar self.menuBar = QMenuBar(self) self.menuBar.setObjectName("menuBar") # self.menuBar.setGeometry(QtCore.QRect(0, 0, 400, 20)) self.menuFile = QMenu(self.menuBar) self.menuFile.setTitle("文件") self.setMenuBar(self.menuBar) # self.actionAdd_Media = QAction(self) # self.actionAdd_Media.setText("Add Media") self.menuFile.addAction(newAction) # self.menuFile.addAction(removeAction) self.menuFile.addAction(convertAction) self.menuBar.addAction(self.menuFile.menuAction()) menuEdit = QMenu(self.menuBar) menuEdit.setTitle("编辑") menuEdit.addAction(settingAction) self.menuBar.addAction(menuEdit.menuAction()) # menuOption = QMenu(self.menuBar) # menuOption.setTitle("选项") # self.menuBar.addAction(menuOption.menuAction()) menuHelp = QMenu(self.menuBar) menuHelp.setTitle("帮助") menuHelp.addAction(aboutAction) self.menuBar.addAction(menuHelp.menuAction()) # End MenuBar # Start toolbar mainToolBar = QToolBar(self) mainToolBar.setObjectName("mainToolBar") self.addToolBar(mainToolBar) mainToolBar.addAction(newAction) # mainToolBar.addAction(removeAction) mainToolBar.addAction(convertAction) # End toolbar # splitter self.mainSplitter = QSplitter(Qt.Vertical) self.setCentralWidget(self.mainSplitter) self.mainSplitter.setStretchFactor(0, 3) self.mainSplitter.setStretchFactor(1, 1) # timely update progress rate # use add file to add task self.convTaskModel = ConvTaskModel() # for test use # convTask = ConvTask("/home/ss/Test1.mp4") # self.convTaskModel.addTask(convTask) self.taskTableView = ConvTaskTableView() self.taskTableView.setModel(self.convTaskModel) self.taskTableView.setItemDelegate(ConvTaskDelegate(self)) self.taskTableView.setColumnWidth(0, 400) # self.taskListWidget = QWidget() # self.mainSplitter.addWidget(self.taskListWidget) self.mainSplitter.addWidget(self.taskTableView) self.mainTabWidget = QTabWidget() self.mainSplitter.addWidget(self.mainTabWidget) # Begin info tabWidget self.generalSettingWidget = GeneralSettingWidget(self) self.mainTabWidget.addTab(self.generalSettingWidget, "通用设置") # End info tabWidget # Begin tab2Widget self.vSettingWidget = VideoSettingWidget() self.mainTabWidget.addTab(self.vSettingWidget, "视频参数设置") # End tab2Widget # self.aSettingWidget = AudioSettingWidget() # self.mainTabWidget.addTab(self.aSettingWidget, "音频参数设置") # # self.tab_4 = QWidget() # self.mainTabWidget.addTab(self.tab_4, "转码命令行") self.statusBar = QStatusBar(self) self.statusBar.setObjectName("statusBar") self.setStatusBar(self.statusBar) self.timer = QTimer() self.timer.timeout.connect(self.refreshProgress) self.timer.start(1500) self.taskTableView.clickOnRow.connect(self.clickOnRow) self.taskTableView.deleteTaskSig.connect(self.deleteTask) convertAction.triggered.connect(self.startConvert) aboutAction.triggered.connect(self.about) #self.convTaskModel.tasks[0].startTask() settingAction.triggered.connect(self.setting) @Slot() def setting(self): if not self.settingDialog: self.settingDialog = SettingDialog() self.settingDialog.show() self.settingDialog.raise_() self.settingDialog.activateWindow() @Slot() def about(self): QMessageBox.about(self, self.tr("About"), "本软件基于ffmpeg或libav, 目标是提供一个简易的图形界面视频转码器\n 作者:疏爽") @Slot() def deleteTask(self): self.generalSettingWidget.setDisabled(True) @Slot() def clickOnRow(self, row): task = self.convTaskModel.tasks[row] self.task = task self.generalSettingWidget.setTask(self.convTaskModel.tasks[row]) self.vSettingWidget.setTask(task) @Slot() def startConvert(self): if self.generalSettingWidget.saveParameters(): if self.vSettingWidget.saveParameters(): self.task.startTask() @Slot() def addMediaFile(self): filename = QFileDialog.getOpenFileName(self, "Find File", QDir.currentPath()) print(filename[0]) if filename[0]: convTask = ConvTask(filename[0]) self.convTaskModel.addTask(convTask) self.convTaskModel.layoutChanged.emit() @Slot() def refreshProgress(self): for task in self.convTaskModel.tasks: if(task.status == ConvTask.RUN): task.updateProgress() self.taskTableView.reset()
class Window(QMainWindow): addNewTask = Signal() def __init__(self, parent=None): QMainWindow.__init__(self, parent) self.resize(640, 480) self.task = None self.settingDialog = None # create actions newAction = QAction(self) newAction.setText("添加文件") newAction.setIcon(QIcon('./images/new.png')) newAction.triggered.connect(self.addMediaFile) # removeAction = QAction(self) # removeAction.setText("删除文件") # removeAction.setIcon(QIcon('./images/remove.png')) convertAction = QAction(self) convertAction.setText("开始转码") convertAction.setIcon(QIcon('./images/convert.png')) settingAction = QAction(self) settingAction.setText("设置") aboutAction = QAction(self) aboutAction.setText("关于") # Begin MenuBar self.menuBar = QMenuBar(self) self.menuBar.setObjectName("menuBar") # self.menuBar.setGeometry(QtCore.QRect(0, 0, 400, 20)) self.menuFile = QMenu(self.menuBar) self.menuFile.setTitle("文件") self.setMenuBar(self.menuBar) # self.actionAdd_Media = QAction(self) # self.actionAdd_Media.setText("Add Media") self.menuFile.addAction(newAction) # self.menuFile.addAction(removeAction) self.menuFile.addAction(convertAction) self.menuBar.addAction(self.menuFile.menuAction()) menuEdit = QMenu(self.menuBar) menuEdit.setTitle("编辑") menuEdit.addAction(settingAction) self.menuBar.addAction(menuEdit.menuAction()) # menuOption = QMenu(self.menuBar) # menuOption.setTitle("选项") # self.menuBar.addAction(menuOption.menuAction()) menuHelp = QMenu(self.menuBar) menuHelp.setTitle("帮助") menuHelp.addAction(aboutAction) self.menuBar.addAction(menuHelp.menuAction()) # End MenuBar # Start toolbar mainToolBar = QToolBar(self) mainToolBar.setObjectName("mainToolBar") self.addToolBar(mainToolBar) mainToolBar.addAction(newAction) # mainToolBar.addAction(removeAction) mainToolBar.addAction(convertAction) # End toolbar # splitter self.mainSplitter = QSplitter(Qt.Vertical) self.setCentralWidget(self.mainSplitter) self.mainSplitter.setStretchFactor(0, 3) self.mainSplitter.setStretchFactor(1, 1) # timely update progress rate # use add file to add task self.convTaskModel = ConvTaskModel() # for test use # convTask = ConvTask("/home/ss/Test1.mp4") # self.convTaskModel.addTask(convTask) self.taskTableView = ConvTaskTableView() self.taskTableView.setModel(self.convTaskModel) self.taskTableView.setItemDelegate(ConvTaskDelegate(self)) self.taskTableView.setColumnWidth(0, 400) # self.taskListWidget = QWidget() # self.mainSplitter.addWidget(self.taskListWidget) self.mainSplitter.addWidget(self.taskTableView) self.mainTabWidget = QTabWidget() self.mainSplitter.addWidget(self.mainTabWidget) # Begin info tabWidget self.generalSettingWidget = GeneralSettingWidget(self) self.mainTabWidget.addTab(self.generalSettingWidget, "通用设置") # End info tabWidget # Begin tab2Widget self.vSettingWidget = VideoSettingWidget() self.mainTabWidget.addTab(self.vSettingWidget, "视频参数设置") # End tab2Widget # self.aSettingWidget = AudioSettingWidget() # self.mainTabWidget.addTab(self.aSettingWidget, "音频参数设置") # # self.tab_4 = QWidget() # self.mainTabWidget.addTab(self.tab_4, "转码命令行") self.statusBar = QStatusBar(self) self.statusBar.setObjectName("statusBar") self.setStatusBar(self.statusBar) self.timer = QTimer() self.timer.timeout.connect(self.refreshProgress) self.timer.start(1500) self.taskTableView.clickOnRow.connect(self.clickOnRow) self.taskTableView.deleteTaskSig.connect(self.deleteTask) convertAction.triggered.connect(self.startConvert) aboutAction.triggered.connect(self.about) #self.convTaskModel.tasks[0].startTask() settingAction.triggered.connect(self.setting) @Slot() def setting(self): if not self.settingDialog: self.settingDialog = SettingDialog() self.settingDialog.show() self.settingDialog.raise_() self.settingDialog.activateWindow() @Slot() def about(self): QMessageBox.about(self, self.tr("About"), "本软件基于ffmpeg或libav, 目标是提供一个简易的图形界面视频转码器\n 作者:疏爽") @Slot() def deleteTask(self): self.generalSettingWidget.setDisabled(True) @Slot() def clickOnRow(self, row): task = self.convTaskModel.tasks[row] self.task = task self.generalSettingWidget.setTask(self.convTaskModel.tasks[row]) self.vSettingWidget.setTask(task) @Slot() def startConvert(self): if self.generalSettingWidget.saveParameters(): if self.vSettingWidget.saveParameters(): self.task.startTask() @Slot() def addMediaFile(self): filename = QFileDialog.getOpenFileName(self, "Find File", QDir.currentPath()) print(filename[0]) if filename[0]: convTask = ConvTask(filename[0]) self.convTaskModel.addTask(convTask) self.convTaskModel.layoutChanged.emit() @Slot() def refreshProgress(self): for task in self.convTaskModel.tasks: if (task.status == ConvTask.RUN): task.updateProgress() self.taskTableView.reset()