def __init__(self, parent=None): super(ShowPresets, self).__init__(parent) self.original_presets_file = '/usr/share/ffmulticonverter/presets.xml' self.config_folder = os.getenv('HOME') + '/.config/ffmulticonverter/' self.current_presets_file = self.config_folder + 'presets.xml' self.presListWidget = QListWidget() labelLabel = QLabel(self.tr('Preset label')) self.labelLineEdit = QLineEdit() self.labelLineEdit.setReadOnly(True) commandLabel = QLabel(self.tr('Preset command line parameters')) self.commandLineEdit = QLineEdit() self.commandLineEdit.setReadOnly(True) extLabel = QLabel(self.tr('Output file extension')) self.extLineEdit = QLineEdit() self.extLineEdit.setReadOnly(True) addButton = QPushButton(self.tr('Add')) self.deleteButton = QPushButton(self.tr('Delete')) self.delete_allButton = QPushButton(self.tr('Delete all')) self.editButton = QPushButton(self.tr('Edit')) searchLabel = QLabel(self.tr('Search')) self.searchLineEdit = QLineEdit() okButton = QPushButton(self.tr('OK')) okButton.setDefault(True) spc1 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) spc2 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) spc3 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) grid = pyqttools.add_to_grid( QGridLayout(), [self.delete_allButton, addButton, spc1], [self.deleteButton, self.editButton, spc2]) hlayout = pyqttools.add_to_layout(QHBoxLayout(), searchLabel, self.searchLineEdit, None, okButton) final_layout = pyqttools.add_to_layout( QVBoxLayout(), self.presListWidget, labelLabel, self.labelLineEdit, commandLabel, self.commandLineEdit, extLabel, self.extLineEdit, grid, spc3, hlayout) self.setLayout(final_layout) okButton.clicked.connect(self.accept) self.presListWidget.currentRowChanged.connect(self.show_preset) addButton.clicked.connect(self.add_preset) self.deleteButton.clicked.connect(self.delete_preset) self.delete_allButton.clicked.connect(self.delete_all_presets) self.editButton.clicked.connect(self.edit_preset) self.searchLineEdit.textEdited.connect(self.search) del_shortcut = QShortcut(self) del_shortcut.setKey(Qt.Key_Delete) del_shortcut.activated.connect(self.delete_preset) self.resize(430, 480) self.setWindowTitle(self.tr('Edit Presets')) QTimer.singleShot(0, self.load_xml) QTimer.singleShot(0, self.fill_presListWidget)
def __init__(self, parent=None): super(ShowPresets, self).__init__(parent) self.original_presets_file = '/usr/share/ffmulticonverter/presets.xml' self.config_folder = os.getenv('HOME') + '/.config/ffmulticonverter/' self.current_presets_file = self.config_folder + 'presets.xml' self.presListWidget = QListWidget() labelLabel = QLabel(self.tr('Preset label')) self.labelLineEdit = QLineEdit() self.labelLineEdit.setReadOnly(True) commandLabel = QLabel(self.tr('Preset command line parameters')) self.commandLineEdit = QLineEdit() self.commandLineEdit.setReadOnly(True) extLabel = QLabel(self.tr('Output file extension')) self.extLineEdit = QLineEdit() self.extLineEdit.setReadOnly(True) addButton = QPushButton(self.tr('Add')) self.deleteButton = QPushButton(self.tr('Delete')) self.delete_allButton = QPushButton(self.tr('Delete all')) self.editButton = QPushButton(self.tr('Edit')) okButton = QPushButton(self.tr('OK')) okButton.setDefault(True) spc1 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) spc2 = QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum) grid = pyqttools.add_to_grid(QGridLayout(), [self.delete_allButton, addButton, spc1, None], [self.deleteButton, self.editButton, spc2, okButton]) final_layout = pyqttools.add_to_layout(QVBoxLayout(), self.presListWidget, labelLabel, self.labelLineEdit, commandLabel, self.commandLineEdit, extLabel, self.extLineEdit, grid) self.setLayout(final_layout) okButton.clicked.connect(self.accept) self.presListWidget.currentRowChanged.connect(self.show_preset) addButton.clicked.connect(self.add_preset) self.deleteButton.clicked.connect(self.delete_preset) self.delete_allButton.clicked.connect(self.delete_all_presets) self.editButton.clicked.connect(self.edit_preset) self.resize(410, 410) self.setWindowTitle(self.tr('Edit Presets')) QTimer.singleShot(0, self.load_xml) QTimer.singleShot(0, self.fill_presListWidget)
def __init__(self, parent=None, test = False): super(Preferences, self).__init__(parent) self.parent = parent self.home = os.getenv('HOME') saveLabel = QLabel('<html><b>' + self.tr('Save files') + '</b></html>') exist_Label = QLabel(self.tr('Existing files:')) self.exst_add_prefixRadioButton = QRadioButton( self.tr("Add '~' prefix")) self.exst_overwriteRadioButton = QRadioButton(self.tr('Overwrite')) exist_layout = pyqttools.add_to_layout(QHBoxLayout(), self.exst_add_prefixRadioButton, self.exst_overwriteRadioButton) defaultLabel = QLabel(self.tr('Default output destination:')) self.defaultLineEdit = QLineEdit() self.defaultToolButton = QToolButton() self.defaultToolButton.setText('...') deafult_fol_layout = pyqttools.add_to_layout(QHBoxLayout(), self.defaultLineEdit, self.defaultToolButton) name_Label = QLabel('<html><b>' + self.tr('Name files') +'</b></html>') prefixLabel = QLabel(self.tr('Prefix:')) suffixLabel = QLabel(self.tr('Suffix:')) self.prefixLineEdit = QLineEdit() self.suffixLineEdit = QLineEdit() grid = pyqttools.add_to_grid(QGridLayout(), [prefixLabel, self.prefixLineEdit], [suffixLabel, self.suffixLineEdit]) prefix_layout = pyqttools.add_to_layout(QHBoxLayout(), grid, None) tabwidget1_layout = pyqttools.add_to_layout(QVBoxLayout(), saveLabel, QSpacerItem(14, 13), exist_Label, exist_layout, QSpacerItem(14, 13), defaultLabel, deafult_fol_layout, QSpacerItem(13, 13), name_Label, QSpacerItem(14, 13), prefix_layout) ffmpegLabel = QLabel('<html><b>' + self.tr('FFmpeg') +'</b></html>') default_commandLabel = QLabel(self.tr('Default command:')) self.commandLineEdit = QLineEdit() useLabel = QLabel(self.tr('Use:')) self.ffmpegRadioButton = QRadioButton(self.tr('FFmpeg')) self.avconvRadioButton = QRadioButton(self.tr('avconv')) hlayout = pyqttools.add_to_layout(QHBoxLayout(), self.ffmpegRadioButton, self.avconvRadioButton) tabwidget2_layout = pyqttools.add_to_layout(QVBoxLayout(), ffmpegLabel, QSpacerItem(14, 13), useLabel, hlayout, QSpacerItem(14, 13), default_commandLabel, self.commandLineEdit, None) widget1 = QWidget() widget1.setLayout(tabwidget1_layout) widget2 = QWidget() widget2.setLayout(tabwidget2_layout) self.TabWidget = QTabWidget() self.TabWidget.addTab(widget1, self.tr('General')) self.TabWidget.addTab(widget2, self.tr('Audio/Video')) self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok| QDialogButtonBox.Cancel) final_layout = pyqttools.add_to_layout(QVBoxLayout(), self.TabWidget, None, self.buttonBox) self.setLayout(final_layout) self.defaultToolButton.clicked.connect(self.open_dir) self.buttonBox.accepted.connect(self.save_settings) self.buttonBox.rejected.connect(self.reject) settings = QSettings() overwrite_existing = settings.value('overwrite_existing').toBool() default_output = settings.value('default_output').toString() prefix = settings.value('prefix').toString() suffix = settings.value('suffix').toString() avconv_prefered = settings.value('avconv_prefered').toBool() default_command = settings.value('default_command').toString() if overwrite_existing: self.exst_overwriteRadioButton.setChecked(True) else: self.exst_add_prefixRadioButton.setChecked(True) if default_output: self.defaultLineEdit.setText(default_output) if prefix: self.prefixLineEdit.setText(prefix) if suffix: self.suffixLineEdit.setText(suffix) if avconv_prefered: self.avconvRadioButton.setChecked(True) else: self.ffmpegRadioButton.setChecked(True) if default_command: self.commandLineEdit.setText(default_command) else: self.commandLineEdit.setText('-ab 320k -ar 48000 -ac 2') if not test and not self.parent.ffmpeg: self.avconvRadioButton.setChecked(True) self.ffmpegRadioButton.setEnabled(False) if not test and not self.parent.avconv: self.ffmpegRadioButton.setChecked(True) self.avconvRadioButton.setEnabled(False) self.resize(400, 390) self.setWindowTitle(self.tr('Preferences'))
def __init__(self, parent=None, test=False): super(Preferences, self).__init__(parent) self.parent = parent self.home = os.getenv("HOME") saveLabel = QLabel("<html><b>" + self.tr("Save files") + "</b></html>") exist_Label = QLabel(self.tr("Existing files:")) self.exst_add_prefixRadioButton = QRadioButton(self.tr("Add '~' prefix")) self.exst_overwriteRadioButton = QRadioButton(self.tr("Overwrite")) exist_layout = pyqttools.add_to_layout( QHBoxLayout(), self.exst_add_prefixRadioButton, self.exst_overwriteRadioButton ) defaultLabel = QLabel(self.tr("Default output destination:")) self.defaultLineEdit = QLineEdit() self.defaultToolButton = QToolButton() self.defaultToolButton.setText("...") deafult_fol_layout = pyqttools.add_to_layout(QHBoxLayout(), self.defaultLineEdit, self.defaultToolButton) name_Label = QLabel("<html><b>" + self.tr("Name files") + "</b></html>") prefixLabel = QLabel(self.tr("Prefix:")) suffixLabel = QLabel(self.tr("Suffix:")) self.prefixLineEdit = QLineEdit() self.suffixLineEdit = QLineEdit() grid = pyqttools.add_to_grid( QGridLayout(), [prefixLabel, self.prefixLineEdit], [suffixLabel, self.suffixLineEdit] ) prefix_layout = pyqttools.add_to_layout(QHBoxLayout(), grid, None) tabwidget1_layout = pyqttools.add_to_layout( QVBoxLayout(), saveLabel, QSpacerItem(14, 13), exist_Label, exist_layout, QSpacerItem(14, 13), defaultLabel, deafult_fol_layout, QSpacerItem(13, 13), name_Label, QSpacerItem(14, 13), prefix_layout, ) ffmpegLabel = QLabel("<html><b>" + self.tr("FFmpeg") + "</b></html>") default_commandLabel = QLabel(self.tr("Default command:")) self.commandLineEdit = QLineEdit() useLabel = QLabel(self.tr("Use:")) self.ffmpegRadioButton = QRadioButton(self.tr("FFmpeg")) self.avconvRadioButton = QRadioButton(self.tr("avconv")) hlayout = pyqttools.add_to_layout(QHBoxLayout(), self.ffmpegRadioButton, self.avconvRadioButton) tabwidget2_layout = pyqttools.add_to_layout( QVBoxLayout(), ffmpegLabel, QSpacerItem(14, 13), useLabel, hlayout, QSpacerItem(14, 13), default_commandLabel, self.commandLineEdit, None, ) widget1 = QWidget() widget1.setLayout(tabwidget1_layout) widget2 = QWidget() widget2.setLayout(tabwidget2_layout) self.TabWidget = QTabWidget() self.TabWidget.addTab(widget1, self.tr("General")) self.TabWidget.addTab(widget2, self.tr("Audio/Video")) self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) final_layout = pyqttools.add_to_layout(QVBoxLayout(), self.TabWidget, None, self.buttonBox) self.setLayout(final_layout) self.defaultToolButton.clicked.connect(self.open_dir) self.buttonBox.accepted.connect(self.save_settings) self.buttonBox.rejected.connect(self.reject) settings = QSettings() overwrite_existing = settings.value("overwrite_existing").toBool() default_output = settings.value("default_output").toString() prefix = settings.value("prefix").toString() suffix = settings.value("suffix").toString() avconv_prefered = settings.value("avconv_prefered").toBool() default_command = settings.value("default_command").toString() if overwrite_existing: self.exst_overwriteRadioButton.setChecked(True) else: self.exst_add_prefixRadioButton.setChecked(True) if default_output: self.defaultLineEdit.setText(default_output) if prefix: self.prefixLineEdit.setText(prefix) if suffix: self.suffixLineEdit.setText(suffix) if avconv_prefered: self.avconvRadioButton.setChecked(True) else: self.ffmpegRadioButton.setChecked(True) if default_command: self.commandLineEdit.setText(default_command) else: self.commandLineEdit.setText("-ab 320k -ar 48000 -ac 2") if not test and not self.parent.ffmpeg: self.avconvRadioButton.setChecked(True) self.ffmpegRadioButton.setEnabled(False) if not test and not self.parent.avconv: self.ffmpegRadioButton.setChecked(True) self.avconvRadioButton.setEnabled(False) self.resize(400, 390) self.setWindowTitle(self.tr("Preferences"))