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, text, image, authors, translators, parent=None):
        super(AboutDialog, self).__init__(parent)
        self.parent = parent
        self.authors = authors
        self.translators = translators

        imageLabel = QLabel()
        imageLabel.setMaximumSize(QSize(63, 61))
        imageLabel.setPixmap(QPixmap(image))
        imageLabel.setScaledContents(True)
        textLabel = QLabel()
        textLabel.setText(text)
        textLabel.setOpenExternalLinks(True)
        creditsButton = QPushButton('Credits')
        closeButton = QPushButton(self.tr('&Close'))

        vlayout1 = pyqttools.add_to_layout(QVBoxLayout(), imageLabel, None)
        hlayout1 = pyqttools.add_to_layout(QHBoxLayout(), vlayout1, textLabel)
        hlayout2 = pyqttools.add_to_layout(QHBoxLayout(), creditsButton, None,
                                           closeButton)
        fin_layout = pyqttools.add_to_layout(QVBoxLayout(), hlayout1, hlayout2)

        self.setLayout(fin_layout)

        closeButton.clicked.connect(self.close)
        creditsButton.clicked.connect(self.show_credits)

        self.resize(455, 200)
        self.setWindowTitle(self.tr('About FF Multi Converter'))
    def __init__(self, text, image, authors, translators, parent=None):
        super(AboutDialog, self).__init__(parent)
        self.parent = parent
        self.authors = authors
        self.translators = translators

        imageLabel = QLabel()
        imageLabel.setMaximumSize(QSize(63, 61))
        imageLabel.setPixmap(QPixmap(image))
        imageLabel.setScaledContents(True)
        textLabel = QLabel()
        textLabel.setText(text)
        textLabel.setOpenExternalLinks(True)
        creditsButton = QPushButton(self.tr('C&redits'))
        closeButton = QPushButton(self.tr('&Close'))

        vlayout1 = pyqttools.add_to_layout(QVBoxLayout(), imageLabel, None)
        hlayout1 = pyqttools.add_to_layout(QHBoxLayout(), vlayout1, textLabel)
        hlayout2 = pyqttools.add_to_layout(QHBoxLayout(), creditsButton, None,
                                           closeButton)
        fin_layout = pyqttools.add_to_layout(QVBoxLayout(), hlayout1, hlayout2)

        self.setLayout(fin_layout)

        closeButton.clicked.connect(self.close)
        creditsButton.clicked.connect(self.show_credits)

        self.resize(455, 200)
        self.setWindowTitle(self.tr('About FF Multi Converter'))
    def __init__(self, text, parent=None):
        super(Report, self).__init__(parent)
        label = QLabel(text)
        button = QPushButton('OK')

        hlayout = pyqttools.add_to_layout(QHBoxLayout(), None, label, None)
        hlayout2 = pyqttools.add_to_layout(QHBoxLayout(), None, button)
        final_layout = pyqttools.add_to_layout(QVBoxLayout(), hlayout, hlayout2)
        self.setLayout(final_layout)

        button.clicked.connect(self.close)

        self.resize(170, 100)
        self.setWindowTitle('Report')
Exemple #5
0
    def __init__(self, parent):
        self.parent = parent
        super(DocumentTab, self).__init__(parent)
        self.name = 'Documents'
        self.formats = {
            'doc': ['odt', 'pdf'],
            'html': ['odt'],
            'odp': ['pdf', 'ppt'],
            'ods': ['pdf'],
            'odt': ['doc', 'html', 'pdf', 'rtf', 'sxw', 'txt', 'xml'],
            'ppt': ['odp'],
            'rtf': ['odt'],
            'sdw': ['odt'],
            'sxw': ['odt'],
            'txt': ['odt'],
            'xls': ['ods'],
            'xml': ['doc', 'odt', 'pdf']
        }

        flist = []
        for i in self.formats:
            for y in self.formats[i]:
                flist.append(i + ' to ' + y)
        flist.sort()

        convertLabel = QLabel(self.tr('Convert:'))
        self.convertComboBox = QComboBox()
        self.convertComboBox.addItems(flist)
        final_layout = pyqttools.add_to_layout(QHBoxLayout(), convertLabel,
                                               self.convertComboBox, None)
        self.setLayout(final_layout)
    def __init__(self, parent):
        self.parent = parent
        super(DocumentTab, self).__init__(parent)
        self.name = 'Documents'
        self.formats = {
                'doc' : ['odt', 'pdf'],
                'html' : ['odt'],
                'odp' : ['pdf', 'ppt'],
                'ods' : ['pdf'],
                'odt' : ['doc', 'html', 'pdf', 'rtf', 'sxw', 'txt','xml'],
                'ppt' : ['odp'],
                'rtf' : ['odt'],
                'sdw' : ['odt'],
                'sxw' : ['odt'],
                'txt' : ['odt'],
                'xls' : ['ods'],
                'xml' : ['doc', 'odt', 'pdf']
                }

        flist = []
        for i in self.formats:
            for y in self.formats[i]:
                flist.append(i + ' to ' + y)
        flist.sort()

        convertLabel = QLabel(self.tr('Convert:'))
        self.convertComboBox = QComboBox()
        self.convertComboBox.addItems(flist)
        final_layout = pyqttools.add_to_layout(QHBoxLayout(), convertLabel,
                                               self.convertComboBox, None)
        self.setLayout(final_layout)
Exemple #7
0
    def __init__(self, parent):
        super(ImageTab, self).__init__(parent)
        self.parent = parent
        self.name = 'Images'
        self.formats = [
            'bmp', 'cgm', 'dpx', 'emf', 'eps', 'fpx', 'gif', 'jbig', 'jng',
            'jpeg', 'mrsid', 'p7', 'pdf', 'picon', 'png', 'ppm', 'psd', 'rad',
            'tga', 'tif', 'webp', 'xpm'
        ]

        self.extra_img = [
            'bmp2', 'bmp3', 'dib', 'epdf', 'epi', 'eps2', 'eps3', 'epsf',
            'epsi', 'icon', 'jpe', 'jpg', 'pgm', 'png24', 'png32', 'pnm', 'ps',
            'ps2', 'ps3', 'sid', 'tiff'
        ]

        pattern = QRegExp(r'^[1-9]\d*')
        validator = QRegExpValidator(pattern, self)

        converttoLabel = QLabel(self.tr('Convert to:'))
        self.extComboBox = QComboBox()
        self.extComboBox.addItems(self.formats)

        hlayout1 = pyqttools.add_to_layout(QHBoxLayout(), converttoLabel,
                                           self.extComboBox, None)

        sizeLabel = QLabel('<html><p align="center">' +
                           self.tr('Image Size:') + '</p></html>')
        self.widthLineEdit = pyqttools.create_LineEdit((50, 16777215),
                                                       validator, 4)
        self.heightLineEdit = pyqttools.create_LineEdit((50, 16777215),
                                                        validator, 4)
        label = QLabel('x')
        label.setMaximumWidth(25)
        self.aspectCheckBox = QCheckBox(self.tr("Maintain aspect ratio"))
        hlayout2 = pyqttools.add_to_layout(QHBoxLayout(), self.widthLineEdit,
                                           label, self.heightLineEdit)
        vlayout = pyqttools.add_to_layout(QVBoxLayout(), sizeLabel, hlayout2)
        hlayout3 = pyqttools.add_to_layout(QHBoxLayout(), vlayout,
                                           self.aspectCheckBox, None)
        final_layout = pyqttools.add_to_layout(QVBoxLayout(), hlayout1,
                                               hlayout3)
        self.setLayout(final_layout)
    def __init__(self, authors, translators, parent=None):
        super(CreditsDialog, self).__init__(parent)
        self.parent = parent

        authorsLabel = QPlainTextEdit(authors)
        authorsLabel.setReadOnly(True)
        translatorsLabel = QPlainTextEdit(translators)
        translatorsLabel.setReadOnly(True)
        TabWidget = QTabWidget()
        TabWidget.addTab(authorsLabel, self.tr('Written by'))
        TabWidget.addTab(translatorsLabel, self.tr('Translated by'))
        closeButton = QPushButton(self.tr('&Close'))

        hlayout = pyqttools.add_to_layout(QHBoxLayout(), None, closeButton)
        vlayout = pyqttools.add_to_layout(QVBoxLayout(), TabWidget, hlayout)

        self.setLayout(vlayout)
        closeButton.clicked.connect(self.close)

        self.setMinimumSize(QSize(335, 370))
        self.setMaximumSize(QSize(335, 370))
        self.setWindowTitle('Credits')
    def __init__(self, authors, translators, parent=None):
        super(CreditsDialog, self).__init__(parent)
        self.parent = parent

        authorsLabel = QPlainTextEdit(authors)
        authorsLabel.setReadOnly(True)
        translatorsLabel = QPlainTextEdit(translators)
        translatorsLabel.setReadOnly(True)
        TabWidget = QTabWidget()
        TabWidget.addTab(authorsLabel, self.tr('Written by'))
        TabWidget.addTab(translatorsLabel, self.tr('Translated by'))
        closeButton = QPushButton(self.tr('&Close'))

        hlayout = pyqttools.add_to_layout(QHBoxLayout(), None, closeButton)
        vlayout = pyqttools.add_to_layout(QVBoxLayout(), TabWidget, hlayout)

        self.setLayout(vlayout)
        closeButton.clicked.connect(self.close)

        self.setMinimumSize(QSize(335, 370))
        self.setMaximumSize(QSize(335, 370))
        self.setWindowTitle(self.tr('Credits'))
    def __init__(self, parent):
        super(ImageTab, self).__init__(parent)
        self.parent = parent
        self.name = 'Images'
        self.formats = ['bmp', 'cgm', 'dpx', 'emf', 'eps', 'fpx', 'gif',
                        'jbig', 'jng', 'jpeg', 'mrsid', 'p7', 'pdf', 'picon',
                        'png', 'ppm', 'psd', 'rad', 'tga', 'tif','webp', 'xpm']

        self.extra_img = ['bmp2', 'bmp3', 'dib', 'epdf', 'epi', 'eps2', 'eps3',
                          'epsf', 'epsi', 'icon', 'jpe', 'jpg', 'pgm', 'png24',
                          'png32', 'pnm', 'ps', 'ps2', 'ps3', 'sid', 'tiff']

        pattern = QRegExp(r'^[1-9]\d*')
        validator = QRegExpValidator(pattern, self)

        converttoLabel = QLabel(self.tr('Convert to:'))
        self.extComboBox = QComboBox()
        self.extComboBox.addItems(self.formats)

        hlayout1 = pyqttools.add_to_layout(QHBoxLayout(), converttoLabel,
                                           self.extComboBox, None)

        sizeLabel = QLabel('<html><p align="center">' +
                           self.tr('Image Size:') + '</p></html>')
        self.widthLineEdit = pyqttools.create_LineEdit((50, 16777215),
                                                       validator, 4)
        self.heightLineEdit = pyqttools.create_LineEdit((50, 16777215),
                                                        validator,4)
        label = QLabel('x')
        label.setMaximumWidth(25)
        self.aspectCheckBox = QCheckBox(self.tr("Maintain aspect ratio"))
        hlayout2 = pyqttools.add_to_layout(QHBoxLayout(), self.widthLineEdit,
                                           label, self.heightLineEdit)
        vlayout = pyqttools.add_to_layout(QVBoxLayout(), sizeLabel, hlayout2)
        hlayout3 = pyqttools.add_to_layout(QHBoxLayout(), vlayout,
                                           self.aspectCheckBox, None)
        final_layout = pyqttools.add_to_layout(QVBoxLayout(),hlayout1,hlayout3)
        self.setLayout(final_layout)
    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, xml_element, edit=False, parent=None):
        super(AddorEditPreset, self).__init__(parent)

        nameLabel = QLabel(self.tr('Preset name (one word, A-z, 0-9)'))
        self.nameLineEdit = QLineEdit()
        labelLabel = QLabel(self.tr('Preset label'))
        self.labelLineEdit = QLineEdit()
        commandLabel = QLabel(self.tr('Preset command line parameters'))
        self.commandLineEdit = QLineEdit()
        extLabel = QLabel(self.tr('Output file extension'))
        self.extLineEdit = QLineEdit()
        self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok|
                                          QDialogButtonBox.Cancel)

        final_layout = pyqttools.add_to_layout(QVBoxLayout(), nameLabel,
                                               self.nameLineEdit, labelLabel,
                                               self.labelLineEdit, commandLabel,
                                               self.commandLineEdit, extLabel,
                                               self.extLineEdit, self.buttonBox)

        self.setLayout(final_layout)

        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)

        self.resize(410, 280)

        if edit:
            self.nameLineEdit.setText(xml_element.tag)
            self.labelLineEdit.setText(xml_element[0].text)
            self.commandLineEdit.setText(xml_element[1].text)
            self.commandLineEdit.home(False)
            self.extLineEdit.setText(xml_element[2].text)

            title = self.tr('Edit %1').arg(xml_element.tag)
        else:
            title = self.tr('Add preset')

        self.resize(410, 280)
        self.setWindowTitle(title)
    def __init__(self, xml_element, edit=False, parent=None):
        super(AddorEditPreset, self).__init__(parent)

        nameLabel = QLabel(self.tr('Preset name (one word, A-z, 0-9)'))
        self.nameLineEdit = QLineEdit()
        labelLabel = QLabel(self.tr('Preset label'))
        self.labelLineEdit = QLineEdit()
        commandLabel = QLabel(self.tr('Preset command line parameters'))
        self.commandLineEdit = QLineEdit()
        extLabel = QLabel(self.tr('Output file extension'))
        self.extLineEdit = QLineEdit()
        self.buttonBox = QDialogButtonBox(QDialogButtonBox.Ok
                                          | QDialogButtonBox.Cancel)

        final_layout = pyqttools.add_to_layout(
            QVBoxLayout(), nameLabel, self.nameLineEdit, labelLabel,
            self.labelLineEdit, commandLabel, self.commandLineEdit, extLabel,
            self.extLineEdit, self.buttonBox)

        self.setLayout(final_layout)

        self.buttonBox.accepted.connect(self.accept)
        self.buttonBox.rejected.connect(self.reject)

        self.resize(410, 280)

        if edit:
            self.nameLineEdit.setText(xml_element.tag)
            self.labelLineEdit.setText(xml_element[0].text)
            self.commandLineEdit.setText(xml_element[1].text)
            self.commandLineEdit.home(False)
            self.extLineEdit.setText(xml_element[2].text)

            title = self.tr('Edit %1').arg(xml_element.tag)
        else:
            title = self.tr('Add preset')

        self.resize(410, 280)
        self.setWindowTitle(title)
Exemple #14
0
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        self.home = os.getenv('HOME')
        self.fnames = list()  # list of file names to be converted
        self.docconv = False  # True when a documents conversion is running

        # parse command line arguments
        for i in QCoreApplication.argv()[1:]:
            i = codecs.utf_8_decode(os.path.abspath(i))[0]
            if os.path.isfile(i):
                self.fnames.append(i)
            else:
                print("ffmulticonverter: {0}: Not a file".format(i))

        addButton = QPushButton(self.tr('Add'))
        delButton = QPushButton(self.tr('Delete'))
        clearButton = QPushButton(self.tr('Clear'))
        vlayout1 = pyqttools.add_to_layout(QVBoxLayout(), addButton, delButton,
                                           clearButton, None)

        self.filesList = FilesList()
        self.filesList.setSelectionMode(QAbstractItemView.ExtendedSelection)
        hlayout1 = pyqttools.add_to_layout(QHBoxLayout(), self.filesList,
                                           vlayout1)

        output_label = QLabel(self.tr('Output folder:'))
        self.toLineEdit = QLineEdit()
        self.toLineEdit.setReadOnly(True)
        self.toToolButton = QToolButton()
        self.toToolButton.setText('...')
        hlayout2 = pyqttools.add_to_layout(QHBoxLayout(), output_label,
                                           self.toLineEdit, self.toToolButton)

        self.audiovideo_tab = AudioVideoTab(self)
        self.image_tab = ImageTab(self)
        self.document_tab = DocumentTab(self)

        self.tabs = [self.audiovideo_tab, self.image_tab, self.document_tab]
        tab_names = [
            self.tr('Audio/Video'),
            self.tr('Images'),
            self.tr('Documents')
        ]
        self.TabWidget = QTabWidget()
        for num, tab in enumerate(tab_names):
            self.TabWidget.addTab(self.tabs[num], tab)
        self.TabWidget.setCurrentIndex(0)

        self.origCheckBox = QCheckBox(
            self.tr('Save each file in the same\nfolder as input file'))
        self.deleteCheckBox = QCheckBox(self.tr('Delete original'))
        self.convertPushButton = QPushButton(self.tr('&Convert'))

        hlayout3 = pyqttools.add_to_layout(QHBoxLayout(), self.origCheckBox,
                                           self.deleteCheckBox, None)
        hlayout4 = pyqttools.add_to_layout(QHBoxLayout(), None,
                                           self.convertPushButton)
        final_layout = pyqttools.add_to_layout(QVBoxLayout(), hlayout1,
                                               self.TabWidget, hlayout2,
                                               hlayout3, hlayout4)

        self.statusBar = self.statusBar()
        self.dependenciesLabel = QLabel()
        self.statusBar.addPermanentWidget(self.dependenciesLabel, stretch=1)

        Widget = QWidget()
        Widget.setLayout(final_layout)
        self.setCentralWidget(Widget)

        c_act = pyqttools.create_action
        openAction = c_act(self, self.tr('Open'), QKeySequence.Open, None,
                           self.tr('Open a file'), self.add_files)
        convertAction = c_act(self, self.tr('Convert'), 'Ctrl+C', None,
                              self.tr('Convert files'), self.start_conversion)
        quitAction = c_act(self, self.tr('Quit'), 'Ctrl+Q', None,
                           self.tr('Quit'), self.close)
        edit_presetsAction = c_act(self, self.tr('Edit Presets'), 'Ctrl+P',
                                   None, self.tr('Edit Presets'), self.presets)
        importAction = c_act(self, self.tr('Import'), None, None,
                             self.tr('Import presets'), self.import_presets)
        exportAction = c_act(self, self.tr('Export'), None, None,
                             self.tr('Export presets'), self.export_presets)
        resetAction = c_act(self, self.tr('Reset'), None, None,
                            self.tr('Reset presets'), self.reset_presets)
        syncAction = c_act(self, self.tr('Synchronize'), None, None,
                           self.tr('Synchronize presets'), self.sync_presets)
        removeoldAction = c_act(self, self.tr('Remove old'), None, None,
                                self.tr('Remove old presets'),
                                self.removeold_presets)
        clearallAction = c_act(self, self.tr('Clear All'), None, None,
                               self.tr('Clear form'), self.clear_all)
        preferencesAction = c_act(self,
                                  self.tr('Preferences'), 'Alt+Ctrl+P', None,
                                  self.tr('Preferences'), self.preferences)
        aboutAction = c_act(self, self.tr('About'), 'Ctrl+?', None,
                            self.tr('About'), self.about)

        fileMenu = self.menuBar().addMenu(self.tr('File'))
        editMenu = self.menuBar().addMenu(self.tr('Edit'))
        presetsMenu = self.menuBar().addMenu(self.tr('Presets'))
        helpMenu = self.menuBar().addMenu(self.tr('Help'))
        pyqttools.add_actions(fileMenu,
                              [openAction, convertAction, None, quitAction])
        pyqttools.add_actions(presetsMenu, [
            edit_presetsAction, importAction, exportAction, resetAction, None,
            syncAction, removeoldAction
        ])
        pyqttools.add_actions(editMenu,
                              [clearallAction, None, preferencesAction])
        pyqttools.add_actions(helpMenu, [aboutAction])

        self.filesList.dropped.connect(self.url_dropped)
        addButton.clicked.connect(self.add_files)
        delButton.clicked.connect(self.delete_files)
        clearButton.clicked.connect(self.clear_fileslist)
        self.TabWidget.currentChanged.connect(
            lambda: self.tabs[0].moreButton.setChecked(False))
        self.origCheckBox.clicked.connect(lambda: self.toLineEdit.setEnabled(
            not self.origCheckBox.isChecked()))
        self.toToolButton.clicked.connect(self.open_dir)
        self.convertPushButton.clicked.connect(convertAction.triggered)

        del_shortcut = QShortcut(self)
        del_shortcut.setKey(Qt.Key_Delete)
        del_shortcut.activated.connect(self.delete_files)

        self.resize(MAIN_WIDTH, MAIN_HEIGHT)
        self.setWindowTitle('FF Multi Converter')

        QTimer.singleShot(0, self.check_for_dependencies)
        QTimer.singleShot(0, self.load_settings)
        QTimer.singleShot(0, self.audiovideo_tab.set_default_command)
        QTimer.singleShot(0, self.update_filesList)
    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, files, _type, cmd, ffmpeg, size, mntaspect, delete,
                 parent, test=False):
        """
        Keyword arguments:
        files  -- list with dicts containing file names
        _type  -- 'AudioVideo', 'Images' or 'Documents' depending files type
        cmd    -- ffmpeg command, for audio/video conversions
        ffmpeg -- if True ffmpeg will be used, else avconv
                  for audio/video conversions
        size   -- new image size string of type 'widthxheight' eg. '300x300'
                  for image conversions
        mntaspect -- boolean indicating whether aspect ratio must be maintained
                     for image conversions
        delete -- boolean that shows if files must removed after conversion

        files:
        Each dict have only one key and one corresponding value.
        Key is a file to be converted and it's value is the name of the new
        file that will be converted.

        Example list:
        [{"/foo/bar.png" : "/foo/bar.bmp"}, {"/f/bar2.png" : "/f/bar2.bmp"}]
        """
        super(Progress, self).__init__(parent)
        self.parent = parent
        self._type = _type
        self.cmd = cmd
        self.ffmpeg = ffmpeg
        self.size = size
        self.mntaspect = mntaspect

        self.files = files
        self.delete = delete
        if not test:
            self.step = int(100 / len(files))
        self.ok = 0
        self.error = 0
        self.running = True

        self.nowLabel = QLabel(self.tr('In progress: '))
        totalLabel = QLabel(self.tr('Total:'))
        self.nowBar = QProgressBar()
        self.nowBar.setValue(0)
        self.totalBar = QProgressBar()
        self.totalBar.setValue(0)
        self.cancelButton = QPushButton(self.tr('Cancel'))

        detailsButton = QCommandLinkButton(self.tr('Details'))
        detailsButton.setSizePolicy(QSizePolicy(QSizePolicy.Fixed))
        detailsButton.setCheckable(True)
        detailsButton.setMaximumWidth(113)
        line = QFrame()
        line.setFrameShape(QFrame.HLine)
        line.setFrameShadow(QFrame.Sunken)
        self.textEdit = QTextEdit()
        self.textEdit.setReadOnly(True)
        self.frame = QFrame()
        frame_layout = pyqttools.add_to_layout(QHBoxLayout(), self.textEdit)
        self.frame.setLayout(frame_layout)
        self.frame.hide()

        hlayout = pyqttools.add_to_layout(QHBoxLayout(), None, self.nowLabel,
                                          None)
        hlayout2 = pyqttools.add_to_layout(QHBoxLayout(), None, totalLabel,
                                           None)
        hlayout3 = pyqttools.add_to_layout(QHBoxLayout(), detailsButton, line)
        hlayout4 = pyqttools.add_to_layout(QHBoxLayout(), self.frame)
        hlayout5 = pyqttools.add_to_layout(QHBoxLayout(), None,
                                           self.cancelButton)
        vlayout = pyqttools.add_to_layout(QVBoxLayout(), hlayout, self.nowBar,
                                          hlayout2, self.totalBar, None,
                                          hlayout3, hlayout4, hlayout5)
        self.setLayout(vlayout)

        detailsButton.toggled.connect(self.resize_dialog)
        detailsButton.toggled.connect(self.frame.setVisible)
        self.cancelButton.clicked.connect(self.reject)
        self.file_converted_signal.connect(self.file_converted)
        self.refr_bars_signal.connect(self.refresh_progress_bars)
        self.update_text_edit_signal.connect(self.update_text_edit)

        self.resize(484, 200)
        self.setWindowTitle('FF Multi Converter - ' + self.tr('Conversion'))

        if not test:
            QTimer.singleShot(0, self.manage_conversions)
    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):
        super(AudioVideoTab, self).__init__(parent)
        self.parent = parent
        self.name = 'AudioVideo'
        self.formats = ['3gp', 'aac', 'ac3', 'afc', 'aiff', 'amr', 'asf', 'au',
                        'avi', 'dvd', 'flac', 'flv', 'mka', 'mkv', 'mmf',
                        'mov', 'mp3', 'mp4', 'mpg', 'ogg', 'ogv', 'psp', 'rm',
                        'spx', 'vob', 'wav', 'webm', 'wma', 'wmv']
        self.extra_formats = ['aifc', 'm2t', 'm4a', 'm4v', 'mp2', 'mpeg',
                              'ra', 'ts']

        nochange = self.tr('No Change')
        frequency_values = [nochange, '22050', '44100', '48000']
        bitrate_values = [nochange, '32', '96', '112', '128', '160', '192',
                          '256', '320']
        pattern = QRegExp(r'^[1-9]\d*')
        validator = QRegExpValidator(pattern, self)

        converttoLabel = QLabel(self.tr('Convert to:'))
        self.extComboBox = QComboBox()
        self.extComboBox.addItems(self.formats + [self.tr('Other')])
        self.extComboBox.setMinimumWidth(130)
        self.extLineEdit = QLineEdit()
        self.extLineEdit.setMaximumWidth(85)
        self.extLineEdit.setEnabled(False)
        hlayout1 = pyqttools.add_to_layout(QHBoxLayout(), converttoLabel,
                                           None, self.extComboBox,
                                           self.extLineEdit)
        commandLabel = QLabel(self.tr('Command:'))
        self.commandLineEdit = QLineEdit()
        self.presetButton = QPushButton(self.tr('Preset'))
        self.defaultButton = QPushButton(self.tr('Default'))
        hlayout2 = pyqttools.add_to_layout(QHBoxLayout(), commandLabel,
                                       self.commandLineEdit, self.presetButton,
                                       self.defaultButton)

        sizeLabel = QLabel(self.tr('Video Size:'))
        aspectLabel = QLabel(self.tr('Aspect:'))
        frameLabel = QLabel(self.tr('Frame Rate (fps):'))
        bitrateLabel = QLabel(self.tr('Video Bitrate (kbps):'))

        self.widthLineEdit = pyqttools.create_LineEdit((50, 16777215),
                                                       validator, 4)
        self.heightLineEdit = pyqttools.create_LineEdit((50, 16777215),
                                                        validator,4)
        label = QLabel('x')
        layout1 = pyqttools.add_to_layout(QHBoxLayout(), self.widthLineEdit,
                                          label, self.heightLineEdit)
        self.aspect1LineEdit = pyqttools.create_LineEdit((35, 16777215),
                                                         validator,2)
        self.aspect2LineEdit = pyqttools.create_LineEdit((35, 16777215),
                                                         validator,2)
        label = QLabel(':')
        layout2 = pyqttools.add_to_layout(QHBoxLayout(), self.aspect1LineEdit,
                                          label, self.aspect2LineEdit)
        self.frameLineEdit = pyqttools.create_LineEdit(None, validator, 4)
        self.bitrateLineEdit = pyqttools.create_LineEdit(None, validator, 6)

        labels = [sizeLabel, aspectLabel, frameLabel, bitrateLabel]
        widgets = [layout1, layout2, self.frameLineEdit, self.bitrateLineEdit]

        videosettings_layout = QHBoxLayout()
        for a, b in zip(labels, widgets):
            text = a.text()
            a.setText('<html><p align="center">{0}</p></html>'.format(text))
            layout = pyqttools.add_to_layout(QVBoxLayout(), a, b)
            videosettings_layout.addLayout(layout)

        freqLabel = QLabel(self.tr('Frequency (Hz):'))
        chanLabel = QLabel(self.tr('Channels:'))
        bitrateLabel = QLabel(self.tr('Audio Bitrate (kbps):'))

        self.freqComboBox = QComboBox()
        self.freqComboBox.addItems(frequency_values)
        self.chan1RadioButton = QRadioButton('1')
        self.chan1RadioButton.setMaximumSize(QSize(51, 16777215))
        self.chan2RadioButton = QRadioButton('2')
        self.chan2RadioButton.setMaximumSize(QSize(51, 16777215))
        self.group = QButtonGroup()
        self.group.addButton(self.chan1RadioButton)
        self.group.addButton(self.chan2RadioButton)
        spcr1 = QSpacerItem(40, 20, QSizePolicy.Preferred, QSizePolicy.Minimum)
        spcr2 = QSpacerItem(40, 20, QSizePolicy.Preferred, QSizePolicy.Minimum)
        chanlayout = pyqttools.add_to_layout(QHBoxLayout(), spcr1,
                                             self.chan1RadioButton,
                                             self.chan2RadioButton, spcr2)
        self.audio_bitrateComboBox = QComboBox()
        self.audio_bitrateComboBox.addItems(bitrate_values)

        labels = [freqLabel, chanLabel, bitrateLabel]
        widgets = [self.freqComboBox, chanlayout, self.audio_bitrateComboBox]

        audiosettings_layout = QHBoxLayout()
        for a, b in zip(labels, widgets):
            text = a.text()
            a.setText('<html><p align="center">{0}</p></html>'.format(text))
            layout = pyqttools.add_to_layout(QVBoxLayout(), a, b)
            audiosettings_layout.addLayout(layout)

        hidden_layout = pyqttools.add_to_layout(QVBoxLayout(),
                                                videosettings_layout,
                                                audiosettings_layout)

        line = QFrame()
        line.setFrameShape(QFrame.HLine)
        line.setFrameShadow(QFrame.Sunken)
        self.moreButton = QPushButton(QApplication.translate('Tab', 'More'))
        self.moreButton.setSizePolicy(QSizePolicy(QSizePolicy.Fixed))
        self.moreButton.setCheckable(True)
        hlayout3 = pyqttools.add_to_layout(QHBoxLayout(), line, self.moreButton)

        self.frame = QFrame()
        self.frame.setLayout(hidden_layout)
        self.frame.hide()

        final_layout = pyqttools.add_to_layout(QVBoxLayout(), hlayout1,
                                               hlayout2, hlayout3, self.frame)
        self.setLayout(final_layout)


        self.presetButton.clicked.connect(self.choose_preset)
        self.defaultButton.clicked.connect(self.set_default_command)
        self.moreButton.toggled.connect(self.frame.setVisible)
        self.moreButton.toggled.connect(self.resize_parent)
        self.extComboBox.currentIndexChanged.connect(
                lambda: self.extLineEdit.setEnabled(
                self.extComboBox.currentIndex() == len(self.formats)))
        self.widthLineEdit.textChanged.connect(
                lambda: self.command_elements_change('size'))
        self.heightLineEdit.textChanged.connect(
                lambda: self.command_elements_change('size'))
        self.aspect1LineEdit.textChanged.connect(
                lambda: self.command_elements_change('aspect'))
        self.aspect2LineEdit.textChanged.connect(
                lambda: self.command_elements_change('aspect'))
        self.frameLineEdit.textChanged.connect(
                lambda: self.command_elements_change('frames'))
        self.bitrateLineEdit.textChanged.connect(
                lambda: self.command_elements_change('video_bitrate'))
        self.freqComboBox.currentIndexChanged.connect(
                lambda: self.command_elements_change('frequency'))
        self.audio_bitrateComboBox.currentIndexChanged.connect(
                lambda: self.command_elements_change('audio_bitrate'))
        self.chan1RadioButton.clicked.connect(
                lambda: self.command_elements_change('channels1'))
        self.chan2RadioButton.clicked.connect(
                lambda: self.command_elements_change('channels2'))
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)

        self.home = os.getenv('HOME')
        self.fnames = list()  # list of file names to be converted
        self.docconv = False  # True when a documents conversion is running

        # parse command line arguments
        for i in QCoreApplication.argv()[1:]:
            i = codecs.utf_8_decode(os.path.abspath(i))[0]
            if os.path.isfile(i):
                self.fnames.append(i)
            else:
                print("ffmulticonverter: {0}: Not a file".format(i))

        addButton = QPushButton(self.tr('Add'))
        delButton = QPushButton(self.tr('Delete'))
        clearButton = QPushButton(self.tr('Clear'))
        vlayout1 = pyqttools.add_to_layout(QVBoxLayout(), addButton, delButton,
                                           clearButton, None)

        self.filesList = FilesList()
        self.filesList.setSelectionMode(QAbstractItemView.ExtendedSelection)
        hlayout1 = pyqttools.add_to_layout(QHBoxLayout(), self.filesList,
                                           vlayout1)

        output_label = QLabel(self.tr('Output folder:'))
        self.toLineEdit = QLineEdit()
        self.toLineEdit.setReadOnly(True)
        self.toToolButton = QToolButton()
        self.toToolButton.setText('...')
        hlayout2 = pyqttools.add_to_layout(QHBoxLayout(), output_label,
                                           self.toLineEdit, self.toToolButton)

        self.audiovideo_tab = AudioVideoTab(self)
        self.image_tab = ImageTab(self)
        self.document_tab = DocumentTab(self)

        self.tabs = [self.audiovideo_tab, self.image_tab, self.document_tab]
        tab_names = [self.tr('Audio/Video'), self.tr('Images'),
                     self.tr('Documents')]
        self.TabWidget = QTabWidget()
        for num, tab in enumerate(tab_names):
            self.TabWidget.addTab(self.tabs[num], tab)
        self.TabWidget.setCurrentIndex(0)

        self.origCheckBox = QCheckBox(
                   self.tr('Save each file in the same\nfolder as input file'))
        self.deleteCheckBox = QCheckBox(self.tr('Delete original'))
        self.convertPushButton = QPushButton(self.tr('&Convert'))

        hlayout3 = pyqttools.add_to_layout(QHBoxLayout(), self.origCheckBox,
                                           self.deleteCheckBox, None)
        hlayout4 = pyqttools.add_to_layout(QHBoxLayout(), None,
                                          self.convertPushButton)
        final_layout = pyqttools.add_to_layout(QVBoxLayout(), hlayout1,
                                               self.TabWidget, hlayout2,
                                               hlayout3, hlayout4)

        self.statusBar = self.statusBar()
        self.dependenciesLabel = QLabel()
        self.statusBar.addPermanentWidget(self.dependenciesLabel, stretch=1)

        Widget = QWidget()
        Widget.setLayout(final_layout)
        self.setCentralWidget(Widget)

        c_act = pyqttools.create_action
        openAction = c_act(self, self.tr('Open'), QKeySequence.Open, None,
                           self.tr('Open a file'), self.add_files)
        convertAction = c_act(self, self.tr('Convert'), 'Ctrl+C', None,
                              self.tr('Convert files'), self.start_conversion)
        quitAction = c_act(self, self.tr('Quit'), 'Ctrl+Q', None,
                           self.tr('Quit'), self.close)
        edit_presetsAction = c_act(self, self.tr('Edit Presets'), 'Ctrl+P',
                                   None, self.tr('Edit Presets'), self.presets)
        importAction = c_act(self, self.tr('Import'), None, None,
                             self.tr('Import presets'), self.import_presets)
        exportAction = c_act(self, self.tr('Export'), None, None,
                             self.tr('Export presets'), self.export_presets)
        resetAction = c_act(self, self.tr('Reset'), None, None,
                            self.tr('Reset presets'), self.reset_presets)
        syncAction = c_act(self, self.tr('Synchronize'), None, None,
                                  self.tr('Synchronize presets'),
                                  self.sync_presets)
        removeoldAction = c_act(self, self.tr('Remove old'), None, None,
                                self.tr('Remove old presets'),
                                self.removeold_presets)
        clearallAction = c_act(self, self.tr('Clear All'), None, None,
                               self.tr('Clear form'), self.clear_all)
        preferencesAction = c_act(self, self.tr('Preferences'), 'Alt+Ctrl+P',
                                  None, self.tr('Preferences'), self.preferences)
        aboutAction = c_act(self, self.tr('About'), 'Ctrl+?', None,
                            self.tr('About'), self.about)

        fileMenu = self.menuBar().addMenu(self.tr('File'))
        editMenu = self.menuBar().addMenu(self.tr('Edit'))
        presetsMenu = self.menuBar().addMenu(self.tr('Presets'))
        helpMenu = self.menuBar().addMenu(self.tr('Help'))
        pyqttools.add_actions(fileMenu,
                              [openAction, convertAction, None, quitAction])
        pyqttools.add_actions(presetsMenu, [edit_presetsAction, importAction,
                                            exportAction, resetAction, None,
                                            syncAction, removeoldAction])
        pyqttools.add_actions(editMenu,
                              [clearallAction, None, preferencesAction])
        pyqttools.add_actions(helpMenu, [aboutAction])

        self.filesList.dropped.connect(self.url_dropped)
        addButton.clicked.connect(self.add_files)
        delButton.clicked.connect(self.delete_files)
        clearButton.clicked.connect(self.clear_fileslist)
        self.TabWidget.currentChanged.connect(lambda:
                                     self.tabs[0].moreButton.setChecked(False))
        self.origCheckBox.clicked.connect(lambda:
                 self.toLineEdit.setEnabled(not self.origCheckBox.isChecked()))
        self.toToolButton.clicked.connect(self.open_dir)
        self.convertPushButton.clicked.connect(convertAction.triggered)

        del_shortcut = QShortcut(self)
        del_shortcut.setKey(Qt.Key_Delete)
        del_shortcut.activated.connect(self.delete_files)

        self.resize(MAIN_WIDTH, MAIN_HEIGHT)
        self.setWindowTitle('FF Multi Converter')

        QTimer.singleShot(0, self.check_for_dependencies)
        QTimer.singleShot(0, self.load_settings)
        QTimer.singleShot(0, self.audiovideo_tab.set_default_command)
        QTimer.singleShot(0, self.update_filesList)
Exemple #20
0
    def __init__(self, parent):
        super(AudioVideoTab, self).__init__(parent)
        self.parent = parent
        self.name = 'AudioVideo'
        self.formats = [
            '3gp', 'aac', 'ac3', 'afc', 'aiff', 'amr', 'asf', 'au', 'avi',
            'dvd', 'flac', 'flv', 'mka', 'mkv', 'mmf', 'mov', 'mp3', 'mp4',
            'mpg', 'ogg', 'ogv', 'psp', 'rm', 'spx', 'vob', 'wav', 'webm',
            'wma', 'wmv'
        ]
        self.extra_formats = [
            'aifc', 'm2t', 'm4a', 'm4v', 'mp2', 'mpeg', 'ra', 'ts'
        ]

        nochange = self.tr('No Change')
        frequency_values = [nochange, '22050', '44100', '48000']
        bitrate_values = [
            nochange, '32', '96', '112', '128', '160', '192', '256', '320'
        ]
        pattern = QRegExp(r'^[1-9]\d*')
        validator = QRegExpValidator(pattern, self)

        converttoLabel = QLabel(self.tr('Convert to:'))
        self.extComboBox = QComboBox()
        self.extComboBox.addItems(self.formats + [self.tr('Other')])
        self.extComboBox.setMinimumWidth(130)
        self.extLineEdit = QLineEdit()
        self.extLineEdit.setMaximumWidth(85)
        self.extLineEdit.setEnabled(False)
        hlayout1 = pyqttools.add_to_layout(QHBoxLayout(), converttoLabel, None,
                                           self.extComboBox, self.extLineEdit)
        commandLabel = QLabel(self.tr('Command:'))
        self.commandLineEdit = QLineEdit()
        self.presetButton = QPushButton(self.tr('Preset'))
        self.defaultButton = QPushButton(self.tr('Default'))
        hlayout2 = pyqttools.add_to_layout(QHBoxLayout(), commandLabel,
                                           self.commandLineEdit,
                                           self.presetButton,
                                           self.defaultButton)

        sizeLabel = QLabel(self.tr('Video Size:'))
        aspectLabel = QLabel(self.tr('Aspect:'))
        frameLabel = QLabel(self.tr('Frame Rate (fps):'))
        bitrateLabel = QLabel(self.tr('Video Bitrate (kbps):'))

        self.widthLineEdit = pyqttools.create_LineEdit((50, 16777215),
                                                       validator, 4)
        self.heightLineEdit = pyqttools.create_LineEdit((50, 16777215),
                                                        validator, 4)
        label = QLabel('x')
        layout1 = pyqttools.add_to_layout(QHBoxLayout(), self.widthLineEdit,
                                          label, self.heightLineEdit)
        self.aspect1LineEdit = pyqttools.create_LineEdit((35, 16777215),
                                                         validator, 2)
        self.aspect2LineEdit = pyqttools.create_LineEdit((35, 16777215),
                                                         validator, 2)
        label = QLabel(':')
        layout2 = pyqttools.add_to_layout(QHBoxLayout(), self.aspect1LineEdit,
                                          label, self.aspect2LineEdit)
        self.frameLineEdit = pyqttools.create_LineEdit(None, validator, 4)
        self.bitrateLineEdit = pyqttools.create_LineEdit(None, validator, 6)

        labels = [sizeLabel, aspectLabel, frameLabel, bitrateLabel]
        widgets = [layout1, layout2, self.frameLineEdit, self.bitrateLineEdit]

        videosettings_layout = QHBoxLayout()
        for a, b in zip(labels, widgets):
            text = a.text()
            a.setText('<html><p align="center">{0}</p></html>'.format(text))
            layout = pyqttools.add_to_layout(QVBoxLayout(), a, b)
            videosettings_layout.addLayout(layout)

        freqLabel = QLabel(self.tr('Frequency (Hz):'))
        chanLabel = QLabel(self.tr('Channels:'))
        bitrateLabel = QLabel(self.tr('Audio Bitrate (kbps):'))

        self.freqComboBox = QComboBox()
        self.freqComboBox.addItems(frequency_values)
        self.chan1RadioButton = QRadioButton('1')
        self.chan1RadioButton.setMaximumSize(QSize(51, 16777215))
        self.chan2RadioButton = QRadioButton('2')
        self.chan2RadioButton.setMaximumSize(QSize(51, 16777215))
        self.group = QButtonGroup()
        self.group.addButton(self.chan1RadioButton)
        self.group.addButton(self.chan2RadioButton)
        spcr1 = QSpacerItem(40, 20, QSizePolicy.Preferred, QSizePolicy.Minimum)
        spcr2 = QSpacerItem(40, 20, QSizePolicy.Preferred, QSizePolicy.Minimum)
        chanlayout = pyqttools.add_to_layout(QHBoxLayout(), spcr1,
                                             self.chan1RadioButton,
                                             self.chan2RadioButton, spcr2)
        self.audio_bitrateComboBox = QComboBox()
        self.audio_bitrateComboBox.addItems(bitrate_values)

        labels = [freqLabel, chanLabel, bitrateLabel]
        widgets = [self.freqComboBox, chanlayout, self.audio_bitrateComboBox]

        audiosettings_layout = QHBoxLayout()
        for a, b in zip(labels, widgets):
            text = a.text()
            a.setText('<html><p align="center">{0}</p></html>'.format(text))
            layout = pyqttools.add_to_layout(QVBoxLayout(), a, b)
            audiosettings_layout.addLayout(layout)

        hidden_layout = pyqttools.add_to_layout(QVBoxLayout(),
                                                videosettings_layout,
                                                audiosettings_layout)

        line = QFrame()
        line.setFrameShape(QFrame.HLine)
        line.setFrameShadow(QFrame.Sunken)
        self.moreButton = QPushButton(QApplication.translate('Tab', 'More'))
        self.moreButton.setSizePolicy(QSizePolicy(QSizePolicy.Fixed))
        self.moreButton.setCheckable(True)
        hlayout3 = pyqttools.add_to_layout(QHBoxLayout(), line,
                                           self.moreButton)

        self.frame = QFrame()
        self.frame.setLayout(hidden_layout)
        self.frame.hide()

        final_layout = pyqttools.add_to_layout(QVBoxLayout(), hlayout1,
                                               hlayout2, hlayout3, self.frame)
        self.setLayout(final_layout)

        self.presetButton.clicked.connect(self.choose_preset)
        self.defaultButton.clicked.connect(self.set_default_command)
        self.moreButton.toggled.connect(self.frame.setVisible)
        self.moreButton.toggled.connect(self.resize_parent)
        self.extComboBox.currentIndexChanged.connect(
            lambda: self.extLineEdit.setEnabled(self.extComboBox.currentIndex(
            ) == len(self.formats)))
        self.widthLineEdit.textChanged.connect(
            lambda: self.command_elements_change('size'))
        self.heightLineEdit.textChanged.connect(
            lambda: self.command_elements_change('size'))
        self.aspect1LineEdit.textChanged.connect(
            lambda: self.command_elements_change('aspect'))
        self.aspect2LineEdit.textChanged.connect(
            lambda: self.command_elements_change('aspect'))
        self.frameLineEdit.textChanged.connect(
            lambda: self.command_elements_change('frames'))
        self.bitrateLineEdit.textChanged.connect(
            lambda: self.command_elements_change('video_bitrate'))
        self.freqComboBox.currentIndexChanged.connect(
            lambda: self.command_elements_change('frequency'))
        self.audio_bitrateComboBox.currentIndexChanged.connect(
            lambda: self.command_elements_change('audio_bitrate'))
        self.chan1RadioButton.clicked.connect(
            lambda: self.command_elements_change('channels1'))
        self.chan2RadioButton.clicked.connect(
            lambda: self.command_elements_change('channels2'))