forked from openlp/openlp
Fixes for the presentation setting tab
This commit is contained in:
parent
47ea300786
commit
82aaf11860
@ -41,7 +41,6 @@ from .presentationcontroller import PresentationController, PresentationDocument
|
|||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class PdfController(PresentationController):
|
class PdfController(PresentationController):
|
||||||
"""
|
"""
|
||||||
Class to control PDF presentations
|
Class to control PDF presentations
|
||||||
@ -61,12 +60,15 @@ class PdfController(PresentationController):
|
|||||||
if self.check_installed() and self.mudrawbin:
|
if self.check_installed() and self.mudrawbin:
|
||||||
self.also_supports = ['xps']
|
self.also_supports = ['xps']
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
def check_binary(program_path):
|
def check_binary(program_path):
|
||||||
"""
|
"""
|
||||||
Function that checks whether a binary is either ghostscript or mudraw or neither.
|
Function that checks whether a binary is either ghostscript or mudraw or neither.
|
||||||
|
Is also used from presentationtab.py
|
||||||
"""
|
"""
|
||||||
program_type = None
|
program_type = None
|
||||||
runlog = ''
|
runlog = ''
|
||||||
|
log.debug('testing program_path: %s', program_path)
|
||||||
try:
|
try:
|
||||||
runlog = check_output([program_path, '--help'], stderr=STDOUT)
|
runlog = check_output([program_path, '--help'], stderr=STDOUT)
|
||||||
except CalledProcessError as e:
|
except CalledProcessError as e:
|
||||||
@ -75,15 +77,16 @@ class PdfController(PresentationController):
|
|||||||
runlog = ''
|
runlog = ''
|
||||||
# Analyse the output to see it the program is mudraw, ghostscript or neither
|
# Analyse the output to see it the program is mudraw, ghostscript or neither
|
||||||
for line in runlog.splitlines():
|
for line in runlog.splitlines():
|
||||||
found_mudraw = re.search('usage: mudraw.*', line)
|
decoded_line = line.decode()
|
||||||
|
found_mudraw = re.search('usage: mudraw.*', decoded_line)
|
||||||
if found_mudraw:
|
if found_mudraw:
|
||||||
program_type = 'mudraw'
|
program_type = 'mudraw'
|
||||||
break
|
break
|
||||||
found_gs = re.search('GPL Ghostscript.*', line)
|
found_gs = re.search('GPL Ghostscript.*', decoded_line)
|
||||||
if found_gs:
|
if found_gs:
|
||||||
program_type = 'gs'
|
program_type = 'gs'
|
||||||
break
|
break
|
||||||
log.info('in check_binary, found: ' + program_type)
|
log.debug('in check_binary, found: %s', program_type)
|
||||||
return program_type
|
return program_type
|
||||||
|
|
||||||
def check_available(self):
|
def check_available(self):
|
||||||
@ -101,11 +104,11 @@ class PdfController(PresentationController):
|
|||||||
# Use the user defined program if given
|
# Use the user defined program if given
|
||||||
if (Settings().value('presentations/enable_pdf_program')):
|
if (Settings().value('presentations/enable_pdf_program')):
|
||||||
pdf_program = Settings().value('presentations/pdf_program')
|
pdf_program = Settings().value('presentations/pdf_program')
|
||||||
type = self.check_binary(pdf_program)
|
program_type = check_binary(pdf_program)
|
||||||
if type == 'gs':
|
if program_type == 'gs':
|
||||||
self.gsbin = pdf_program
|
self.gsbin = pdf_program
|
||||||
return True
|
return True
|
||||||
elif type == 'mudraw':
|
elif program_type == 'mudraw':
|
||||||
self.mudrawbin = pdf_program
|
self.mudrawbin = pdf_program
|
||||||
return True
|
return True
|
||||||
# Fallback to autodetection
|
# Fallback to autodetection
|
||||||
|
@ -73,7 +73,7 @@ class PresentationTab(SettingsTab):
|
|||||||
self.override_app_check_box = QtGui.QCheckBox(self.advanced_group_box)
|
self.override_app_check_box = QtGui.QCheckBox(self.advanced_group_box)
|
||||||
self.override_app_check_box.setObjectName('override_app_check_box')
|
self.override_app_check_box.setObjectName('override_app_check_box')
|
||||||
self.advanced_layout.addWidget(self.override_app_check_box)
|
self.advanced_layout.addWidget(self.override_app_check_box)
|
||||||
|
self.left_layout.addWidget(self.advanced_group_box)
|
||||||
# Pdf options
|
# Pdf options
|
||||||
self.pdf_group_box = QtGui.QGroupBox(self.left_column)
|
self.pdf_group_box = QtGui.QGroupBox(self.left_column)
|
||||||
self.pdf_group_box.setObjectName('pdf_group_box')
|
self.pdf_group_box.setObjectName('pdf_group_box')
|
||||||
@ -81,7 +81,7 @@ class PresentationTab(SettingsTab):
|
|||||||
self.pdf_layout.setObjectName('pdf_layout')
|
self.pdf_layout.setObjectName('pdf_layout')
|
||||||
self.pdf_program_check_box = QtGui.QCheckBox(self.pdf_group_box)
|
self.pdf_program_check_box = QtGui.QCheckBox(self.pdf_group_box)
|
||||||
self.pdf_program_check_box.setObjectName('pdf_program_check_box')
|
self.pdf_program_check_box.setObjectName('pdf_program_check_box')
|
||||||
self.pdf_layout.addWidget(self.pdf_program_check_box)
|
self.pdf_layout.addRow(self.pdf_program_check_box)
|
||||||
self.pdf_program_path_layout = QtGui.QHBoxLayout()
|
self.pdf_program_path_layout = QtGui.QHBoxLayout()
|
||||||
self.pdf_program_path_layout.setObjectName('pdf_program_path_layout')
|
self.pdf_program_path_layout.setObjectName('pdf_program_path_layout')
|
||||||
self.pdf_program_path = QtGui.QLineEdit(self.pdf_group_box)
|
self.pdf_program_path = QtGui.QLineEdit(self.pdf_group_box)
|
||||||
@ -95,13 +95,14 @@ class PresentationTab(SettingsTab):
|
|||||||
self.pdf_program_browse_button.setEnabled(False)
|
self.pdf_program_browse_button.setEnabled(False)
|
||||||
self.pdf_program_path_layout.addWidget(self.pdf_program_browse_button)
|
self.pdf_program_path_layout.addWidget(self.pdf_program_browse_button)
|
||||||
self.pdf_layout.addRow(self.pdf_program_path_layout)
|
self.pdf_layout.addRow(self.pdf_program_path_layout)
|
||||||
|
self.left_layout.addWidget(self.pdf_group_box)
|
||||||
|
self.left_layout.addStretch()
|
||||||
|
self.right_column.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Preferred)
|
||||||
|
self.right_layout.addStretch()
|
||||||
|
# Signals and slots
|
||||||
self.pdf_program_path.editingFinished.connect(self.on_pdf_program_path_edit_finished)
|
self.pdf_program_path.editingFinished.connect(self.on_pdf_program_path_edit_finished)
|
||||||
self.pdf_program_browse_button.clicked.connect(self.on_pdf_program_browse_button_clicked)
|
self.pdf_program_browse_button.clicked.connect(self.on_pdf_program_browse_button_clicked)
|
||||||
self.pdf_program_check_box.clicked.connect(self.on_pdf_program_check_box_clicked)
|
self.pdf_program_check_box.clicked.connect(self.on_pdf_program_check_box_clicked)
|
||||||
self.left_layout.addWidget(self.advanced_group_box)
|
|
||||||
self.left_layout.addWidget(self.pdf_group_box)
|
|
||||||
self.left_layout.addStretch()
|
|
||||||
self.right_layout.addStretch()
|
|
||||||
|
|
||||||
def retranslateUi(self):
|
def retranslateUi(self):
|
||||||
"""
|
"""
|
||||||
@ -203,10 +204,10 @@ class PresentationTab(SettingsTab):
|
|||||||
"""
|
"""
|
||||||
After selecting/typing in a program it is validated that it is a actually ghostscript or mudraw
|
After selecting/typing in a program it is validated that it is a actually ghostscript or mudraw
|
||||||
"""
|
"""
|
||||||
type = None
|
program_type = None
|
||||||
if self.pdf_program_path.text() != '':
|
if self.pdf_program_path.text() != '':
|
||||||
type = PdfController.check_binary(self.pdf_program_path.text())
|
program_type = PdfController.check_binary(self.pdf_program_path.text())
|
||||||
if not type:
|
if not program_type:
|
||||||
critical_error_message_box(UiStrings().Error,
|
critical_error_message_box(UiStrings().Error,
|
||||||
translate('PresentationPlugin.PresentationTab', 'The program is not ghostscript or mudraw which is required.'))
|
translate('PresentationPlugin.PresentationTab', 'The program is not ghostscript or mudraw which is required.'))
|
||||||
self.pdf_program_path.setFocus()
|
self.pdf_program_path.setFocus()
|
||||||
|
Loading…
Reference in New Issue
Block a user