"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "ffmulticonverter/documenttab.py" between
ffmulticonverter-1.7.2.tar.gz and ffmulticonverter-1.8.0.tar.gz

About: FF Multi Converter is a graphical application which enables you to convert audio, video, image and document files between all popular formats, using and combining other programs.

documenttab.py  (ffmulticonverter-1.7.2):documenttab.py  (ffmulticonverter-1.8.0)
# Copyright (C) 2011-2015 Ilias Stamatis <stamatis.iliass@gmail.com> # Copyright (C) 2011-2016 Ilias Stamatis <stamatis.iliass@gmail.com>
# #
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or # the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version. # (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import os from PyQt5.QtWidgets import QWidget, QLabel, QComboBox, QMessageBox
from PyQt4.QtGui import QWidget, QLabel, QComboBox, QMessageBox
from ffmulticonverter import utils from ffmulticonverter import utils
from ffmulticonverter import config from ffmulticonverter import config
class ValidationError(Exception): class ValidationError(Exception):
pass pass
class DocumentTab(QWidget): class DocumentTab(QWidget):
def __init__(self, parent): def __init__(self, parent):
self.parent = parent self.parent = parent
super(DocumentTab, self).__init__(parent) super(DocumentTab, self).__init__(parent)
self.name = 'Documents' self.name = 'Documents'
self.formats = config.document_formats self.formats = config.document_formats
flist = [] convertQL = QLabel(self.tr('Convert to:'))
for i in self.formats: self.extQCB = QComboBox()
for y in self.formats[i]: final_layout = utils.add_to_layout('h', convertQL, self.extQCB, None)
flist.append(i + ' to ' + y)
flist.sort()
convertQL = QLabel(self.tr('Convert:'))
self.convertQCB = QComboBox()
self.convertQCB.addItems(flist)
final_layout = utils.add_to_layout(
'h', convertQL, self.convertQCB, None)
self.setLayout(final_layout) self.setLayout(final_layout)
def fill_extension_combobox(self, extraformats):
self.extQCB.clear()
self.extQCB.addItems(sorted(self.formats + extraformats))
def ok_to_continue(self): def ok_to_continue(self):
""" """
Check if everything is ok with documenttab to continue conversion. Check if everything is ok with documenttab to continue conversion.
Checks if: Checks if:
- unoconv is missing. - unoconv is missing.
- Given file extension is same with the declared extension.
Return True if all tests pass, else False. Return True if all tests pass, else False.
""" """
decl_ext = self.convertQCB.currentText().split(' ')[0] if not self.parent.unoconv:
QMessageBox.warning(self, 'FF Multi Converter - ' + self.tr('Error!'
try: ),
if not self.parent.unoconv: self.tr('Unocov is not installed!'))
raise ValidationError(
self.tr(
'Unocov is not installed.\nYou will not be able '
'to convert document files until you install it.')
)
for i in self.parent.fnames:
file_ext = os.path.splitext(i)[-1][1:]
if file_ext != decl_ext:
raise ValidationError(
self.trUtf8('{0} is not {1}!'.format(i, decl_ext)))
return True
except ValidationError as e:
QMessageBox.warning(self, 'FF Multi Converter - ' + \
self.tr('Error!'), str(e))
return False return False
return True
 End of changes. 7 change blocks. 
35 lines changed or deleted 13 lines changed or added

Home  |  About  |  All  |  Newest  |  Fossies Dox  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTPS