Exemplo n.º 1
0
    def __init__(self, parent=None):
        super(GeneralSettingWidget, self).__init__(parent)
        self.presetLibrary = PresetLibrary()
        mainLayout = QGridLayout()

        presetLabel = QLabel()
        presetLabel.setText("Preset:")
        self.presetComboBox = QComboBox()
        self.presetComboBox.addItems(self.presetLibrary.getPresets())
        self.presetComboBox.currentIndexChanged.connect(self.changePreset)

        fNameLabel = QLabel(self)
        fNameLabel.setText("输出文件名:")

        fnameEditComboWidget = QWidget(self)
        fnameEditlayout = QVBoxLayout()
        fnameEditComboWidget.setLayout(fnameEditlayout)
        self.fnameEdit = QLineEdit(self)
        # self.startConvertBtn = QToolButton(self)
        # self.startConvertBtn.setText("开始转码")
        fnameEditlayout.addWidget(fNameLabel)
        fnameEditlayout.addWidget(self.fnameEdit)
        # fnameEditlayout.addWidget(self.startConvertBtn)

        dirLabel = QLabel(self)
        dirLabel.setText("输出文件夹:")
        dirEditComboWidget = QWidget(self)
        dirEditLayout = QHBoxLayout()
        dirEditComboWidget.setLayout(dirEditLayout)
        self.dirEdit = QLineEdit(self)
        dirEditBtn = QToolButton(self)
        dirEditBtn.setText("...")
        dirEditBtn.clicked.connect(self.openDir)
        dirEditLayout.addWidget(self.dirEdit)
        dirEditLayout.addWidget(dirEditBtn)

        mainLayout.addWidget(presetLabel, 0, 0)
        mainLayout.addWidget(self.presetComboBox, 1, 0)
        mainLayout.addWidget(fNameLabel, 2, 0)
        mainLayout.addWidget(fnameEditComboWidget, 3, 0)
        mainLayout.addWidget(dirLabel, 4, 0)
        mainLayout.addWidget(dirEditComboWidget, 5, 0)
        self.setLayout(mainLayout)
        self.setDisabled(True)
Exemplo n.º 2
0
    def __init__(self, parent=None):
        super(GeneralSettingWidget, self).__init__(parent)
        self.presetLibrary = PresetLibrary()
        mainLayout = QGridLayout()

        presetLabel = QLabel()
        presetLabel.setText("Preset:")
        self.presetComboBox = QComboBox()
        self.presetComboBox.addItems(self.presetLibrary.getPresets())
        self.presetComboBox.currentIndexChanged.connect(self.changePreset)

        fNameLabel = QLabel(self)
        fNameLabel.setText("输出文件名:")

        fnameEditComboWidget = QWidget(self)
        fnameEditlayout = QVBoxLayout()
        fnameEditComboWidget.setLayout(fnameEditlayout)
        self.fnameEdit = QLineEdit(self)
        # self.startConvertBtn = QToolButton(self)
        # self.startConvertBtn.setText("开始转码")
        fnameEditlayout.addWidget(fNameLabel)
        fnameEditlayout.addWidget(self.fnameEdit)
        # fnameEditlayout.addWidget(self.startConvertBtn)

        dirLabel = QLabel(self)
        dirLabel.setText("输出文件夹:")
        dirEditComboWidget = QWidget(self)
        dirEditLayout = QHBoxLayout()
        dirEditComboWidget.setLayout(dirEditLayout)
        self.dirEdit = QLineEdit(self)
        dirEditBtn = QToolButton(self)
        dirEditBtn.setText("...")
        dirEditBtn.clicked.connect(self.openDir)
        dirEditLayout.addWidget(self.dirEdit)
        dirEditLayout.addWidget(dirEditBtn)

        mainLayout.addWidget(presetLabel, 0, 0)
        mainLayout.addWidget(self.presetComboBox, 1, 0)
        mainLayout.addWidget(fNameLabel, 2, 0)
        mainLayout.addWidget(fnameEditComboWidget, 3, 0)
        mainLayout.addWidget(dirLabel, 4, 0)
        mainLayout.addWidget(dirEditComboWidget, 5, 0)
        self.setLayout(mainLayout)
        self.setDisabled(True)
Exemplo n.º 3
0
class GeneralSettingWidget(QWidget):
    def __init__(self, parent=None):
        super(GeneralSettingWidget, self).__init__(parent)
        self.presetLibrary = PresetLibrary()
        mainLayout = QGridLayout()

        presetLabel = QLabel()
        presetLabel.setText("Preset:")
        self.presetComboBox = QComboBox()
        self.presetComboBox.addItems(self.presetLibrary.getPresets())
        self.presetComboBox.currentIndexChanged.connect(self.changePreset)

        fNameLabel = QLabel(self)
        fNameLabel.setText("输出文件名:")

        fnameEditComboWidget = QWidget(self)
        fnameEditlayout = QVBoxLayout()
        fnameEditComboWidget.setLayout(fnameEditlayout)
        self.fnameEdit = QLineEdit(self)
        # self.startConvertBtn = QToolButton(self)
        # self.startConvertBtn.setText("开始转码")
        fnameEditlayout.addWidget(fNameLabel)
        fnameEditlayout.addWidget(self.fnameEdit)
        # fnameEditlayout.addWidget(self.startConvertBtn)

        dirLabel = QLabel(self)
        dirLabel.setText("输出文件夹:")
        dirEditComboWidget = QWidget(self)
        dirEditLayout = QHBoxLayout()
        dirEditComboWidget.setLayout(dirEditLayout)
        self.dirEdit = QLineEdit(self)
        dirEditBtn = QToolButton(self)
        dirEditBtn.setText("...")
        dirEditBtn.clicked.connect(self.openDir)
        dirEditLayout.addWidget(self.dirEdit)
        dirEditLayout.addWidget(dirEditBtn)

        mainLayout.addWidget(presetLabel, 0, 0)
        mainLayout.addWidget(self.presetComboBox, 1, 0)
        mainLayout.addWidget(fNameLabel, 2, 0)
        mainLayout.addWidget(fnameEditComboWidget, 3, 0)
        mainLayout.addWidget(dirLabel, 4, 0)
        mainLayout.addWidget(dirEditComboWidget, 5, 0)
        self.setLayout(mainLayout)
        self.setDisabled(True)
        # self.startConvertBtn.clicked.connect(self.startConvert)


    def changePreset(self, index):
        if not self.task:
            print("task not intialized")
        else:
            preset_name = self.presetComboBox.itemText(index)
            self.task.setPreset(self.presetLibrary.loadPreset(preset_name))

    def setTask(self, task):
        self.setDisabled(False)
        self.task = task
        self.changePreset(self.presetComboBox.currentIndex())
        self.fnameEdit.setText(task.outputFile)
        self.dirEdit.setText(task.outputDir)

    def saveParameters(self):
        oFileFullName = self.fnameEdit.text() + "." + self.task.preset.ext
        # check file if exists
        outputDir = self.dirEdit.text()
        outputPath = os.path.join(outputDir, oFileFullName)
        if os.path.exists(outputPath):
            QMessageBox.critical(self, "Error",
                                    "通用设置:存在同名文件,请重命名")
            return False
        self.task.outputFile = self.fnameEdit.text()
        self.task.outputDir = outputDir
        return True

    def openDir(self):
        directory = QFileDialog.getExistingDirectory(self, "选择目录",
                                                     QDir.currentPath())
        if directory:
            self.dirEdit.setText(directory)
Exemplo n.º 4
0
class GeneralSettingWidget(QWidget):
    def __init__(self, parent=None):
        super(GeneralSettingWidget, self).__init__(parent)
        self.presetLibrary = PresetLibrary()
        mainLayout = QGridLayout()

        presetLabel = QLabel()
        presetLabel.setText("Preset:")
        self.presetComboBox = QComboBox()
        self.presetComboBox.addItems(self.presetLibrary.getPresets())
        self.presetComboBox.currentIndexChanged.connect(self.changePreset)

        fNameLabel = QLabel(self)
        fNameLabel.setText("输出文件名:")

        fnameEditComboWidget = QWidget(self)
        fnameEditlayout = QVBoxLayout()
        fnameEditComboWidget.setLayout(fnameEditlayout)
        self.fnameEdit = QLineEdit(self)
        # self.startConvertBtn = QToolButton(self)
        # self.startConvertBtn.setText("开始转码")
        fnameEditlayout.addWidget(fNameLabel)
        fnameEditlayout.addWidget(self.fnameEdit)
        # fnameEditlayout.addWidget(self.startConvertBtn)

        dirLabel = QLabel(self)
        dirLabel.setText("输出文件夹:")
        dirEditComboWidget = QWidget(self)
        dirEditLayout = QHBoxLayout()
        dirEditComboWidget.setLayout(dirEditLayout)
        self.dirEdit = QLineEdit(self)
        dirEditBtn = QToolButton(self)
        dirEditBtn.setText("...")
        dirEditBtn.clicked.connect(self.openDir)
        dirEditLayout.addWidget(self.dirEdit)
        dirEditLayout.addWidget(dirEditBtn)

        mainLayout.addWidget(presetLabel, 0, 0)
        mainLayout.addWidget(self.presetComboBox, 1, 0)
        mainLayout.addWidget(fNameLabel, 2, 0)
        mainLayout.addWidget(fnameEditComboWidget, 3, 0)
        mainLayout.addWidget(dirLabel, 4, 0)
        mainLayout.addWidget(dirEditComboWidget, 5, 0)
        self.setLayout(mainLayout)
        self.setDisabled(True)
        # self.startConvertBtn.clicked.connect(self.startConvert)

    def changePreset(self, index):
        if not self.task:
            print("task not intialized")
        else:
            preset_name = self.presetComboBox.itemText(index)
            self.task.setPreset(self.presetLibrary.loadPreset(preset_name))

    def setTask(self, task):
        self.setDisabled(False)
        self.task = task
        self.changePreset(self.presetComboBox.currentIndex())
        self.fnameEdit.setText(task.outputFile)
        self.dirEdit.setText(task.outputDir)

    def saveParameters(self):
        oFileFullName = self.fnameEdit.text() + "." + self.task.preset.ext
        # check file if exists
        outputDir = self.dirEdit.text()
        outputPath = os.path.join(outputDir, oFileFullName)
        if os.path.exists(outputPath):
            QMessageBox.critical(self, "Error", "通用设置:存在同名文件,请重命名")
            return False
        self.task.outputFile = self.fnameEdit.text()
        self.task.outputDir = outputDir
        return True

    def openDir(self):
        directory = QFileDialog.getExistingDirectory(self, "选择目录",
                                                     QDir.currentPath())
        if directory:
            self.dirEdit.setText(directory)