~suutari-olli/openlp/escape-fixes-1294111-1497637

442.1.33 by Tim Bentley
Fix commit due to missing
1
# -*- coding: utf-8 -*-
2134.1.5 by Tim Bentley
More 120 cleanups
2
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
517.2.6 by Raoul Snyman
Changed the license info from docstrings to normal comments.
3
4
###############################################################################
5
# OpenLP - Open Source Lyrics Projection                                      #
6
# --------------------------------------------------------------------------- #
2557.27.1 by Tim Bentley
Year older
7
# Copyright (c) 2008-2016 OpenLP Developers                                   #
517.2.6 by Raoul Snyman
Changed the license info from docstrings to normal comments.
8
# --------------------------------------------------------------------------- #
9
# This program is free software; you can redistribute it and/or modify it     #
10
# under the terms of the GNU General Public License as published by the Free  #
11
# Software Foundation; version 2 of the License.                              #
12
#                                                                             #
13
# This program is distributed in the hope that it will be useful, but WITHOUT #
14
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       #
15
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for    #
16
# more details.                                                               #
17
#                                                                             #
18
# You should have received a copy of the GNU General Public License along     #
19
# with this program; if not, write to the Free Software Foundation, Inc., 59  #
20
# Temple Place, Suite 330, Boston, MA 02111-1307 USA                          #
21
###############################################################################
442.1.33 by Tim Bentley
Fix commit due to missing
22
2557.17.1 by Jonathan Springer
Migrate to PyQt5
23
from PyQt5 import QtGui, QtWidgets
442.1.33 by Tim Bentley
Fix commit due to missing
24
2250.1.55 by Tim Bentley
Move Settings and translate
25
from openlp.core.common import Settings, UiStrings, translate
2275.1.10 by Tomas Groth
Merged with trunk to resolve conflicts.
26
from openlp.core.lib import SettingsTab, build_icon
2275.1.4 by Tomas Groth
Added possible to point to a binary to use for pdf-processing.
27
from openlp.core.lib.ui import critical_error_message_box
2275.1.8 by Tomas Groth
Made branch work with python3.
28
from .pdfcontroller import PdfController
1989.3.220 by Tim Bentley
All Tabs converted
29
2275.1.16 by Tomas Groth
Changed the way a serviceitem from the servicemanager is copied and converted. Also fixed for PEP8.
30
442.1.33 by Tim Bentley
Fix commit due to missing
31
class PresentationTab(SettingsTab):
32
    """
457.1.1 by Raoul Snyman
Fixed displaying of "display" label on the display form.
33
    PresentationsTab is the Presentations settings tab in the settings dialog.
442.1.33 by Tim Bentley
Fix commit due to missing
34
    """
1389.2.53 by Tim Bentley
Fix Tab parentage
35
    def __init__(self, parent, title, visible_title, controllers, icon_path):
734.2.31 by Jonathan Corwin
Presentation thumbnail changes
36
        """
37
        Constructor
38
        """
1989.3.26 by Tim Bentley
fix up settings tab
39
        self.parent = parent
572.2.2 by Jonathan Corwin
Inherit from presentationcontrollers plus powerpoint
40
        self.controllers = controllers
2218.9.1 by Andreas Preikschat
changed constructor
41
        super(PresentationTab, self).__init__(parent, title, visible_title, icon_path)
1866.1.1 by Jonathan Corwin
Setting for X11 bypass flag. Don't open Impress unnecessarily if not enabled
42
        self.activated = False
442.1.33 by Tim Bentley
Fix commit due to missing
43
44
    def setupUi(self):
734.2.31 by Jonathan Corwin
Presentation thumbnail changes
45
        """
46
        Create the controls for the settings tab
47
        """
2218.1.123 by Andreas Preikschat
2to3 and resources.py
48
        self.setObjectName('PresentationTab')
2218.9.1 by Andreas Preikschat
changed constructor
49
        super(PresentationTab, self).setupUi()
2557.17.1 by Jonathan Springer
Migrate to PyQt5
50
        self.controllers_group_box = QtWidgets.QGroupBox(self.left_column)
2218.1.123 by Andreas Preikschat
2to3 and resources.py
51
        self.controllers_group_box.setObjectName('controllers_group_box')
2557.17.1 by Jonathan Springer
Migrate to PyQt5
52
        self.controllers_layout = QtWidgets.QVBoxLayout(self.controllers_group_box)
2218.1.123 by Andreas Preikschat
2to3 and resources.py
53
        self.controllers_layout.setObjectName('ccontrollers_layout')
1989.3.220 by Tim Bentley
All Tabs converted
54
        self.presenter_check_boxes = {}
580.1.1 by Jonathan Corwin
Individual presentation controllers are now completely self-contained.
55
        for key in self.controllers:
56
            controller = self.controllers[key]
2557.17.1 by Jonathan Springer
Migrate to PyQt5
57
            checkbox = QtWidgets.QCheckBox(self.controllers_group_box)
2218.1.123 by Andreas Preikschat
2to3 and resources.py
58
            checkbox.setObjectName(controller.name + 'CheckBox')
1989.3.220 by Tim Bentley
All Tabs converted
59
            self.presenter_check_boxes[controller.name] = checkbox
60
            self.controllers_layout.addWidget(checkbox)
61
        self.left_layout.addWidget(self.controllers_group_box)
2275.1.4 by Tomas Groth
Added possible to point to a binary to use for pdf-processing.
62
        # Advanced
2557.17.1 by Jonathan Springer
Migrate to PyQt5
63
        self.advanced_group_box = QtWidgets.QGroupBox(self.left_column)
2218.1.123 by Andreas Preikschat
2to3 and resources.py
64
        self.advanced_group_box.setObjectName('advanced_group_box')
2557.17.1 by Jonathan Springer
Migrate to PyQt5
65
        self.advanced_layout = QtWidgets.QVBoxLayout(self.advanced_group_box)
2218.1.123 by Andreas Preikschat
2to3 and resources.py
66
        self.advanced_layout.setObjectName('advanced_layout')
2557.17.1 by Jonathan Springer
Migrate to PyQt5
67
        self.override_app_check_box = QtWidgets.QCheckBox(self.advanced_group_box)
2218.1.123 by Andreas Preikschat
2to3 and resources.py
68
        self.override_app_check_box.setObjectName('override_app_check_box')
1989.3.220 by Tim Bentley
All Tabs converted
69
        self.advanced_layout.addWidget(self.override_app_check_box)
2275.1.13 by Tomas Groth
Fixes for the presentation setting tab
70
        self.left_layout.addWidget(self.advanced_group_box)
2524.2.2 by Tomas Groth
Take focus back if Powerpoint steals it - fixes bug 1423913. Optionally advance a Powerpoint slides animation when clicked in the slidecontroller - fixes bug 1194847. Made OpenLP respect hidden slides. Improved logging in case of errors.
71
        # PowerPoint
2557.17.1 by Jonathan Springer
Migrate to PyQt5
72
        self.powerpoint_group_box = QtWidgets.QGroupBox(self.left_column)
2524.2.2 by Tomas Groth
Take focus back if Powerpoint steals it - fixes bug 1423913. Optionally advance a Powerpoint slides animation when clicked in the slidecontroller - fixes bug 1194847. Made OpenLP respect hidden slides. Improved logging in case of errors.
73
        self.powerpoint_group_box.setObjectName('powerpoint_group_box')
2557.17.1 by Jonathan Springer
Migrate to PyQt5
74
        self.powerpoint_layout = QtWidgets.QVBoxLayout(self.powerpoint_group_box)
2524.2.2 by Tomas Groth
Take focus back if Powerpoint steals it - fixes bug 1423913. Optionally advance a Powerpoint slides animation when clicked in the slidecontroller - fixes bug 1194847. Made OpenLP respect hidden slides. Improved logging in case of errors.
75
        self.powerpoint_layout.setObjectName('powerpoint_layout')
2557.17.1 by Jonathan Springer
Migrate to PyQt5
76
        self.ppt_slide_click_check_box = QtWidgets.QCheckBox(self.powerpoint_group_box)
2532.1.16 by Tomas Groth
Added an option for letting powerpoint control the size and position for the presentation window. Workaround for windows 8.1 scaling.
77
        self.ppt_slide_click_check_box.setObjectName('ppt_slide_click_check_box')
2524.2.2 by Tomas Groth
Take focus back if Powerpoint steals it - fixes bug 1423913. Optionally advance a Powerpoint slides animation when clicked in the slidecontroller - fixes bug 1194847. Made OpenLP respect hidden slides. Improved logging in case of errors.
78
        self.powerpoint_layout.addWidget(self.ppt_slide_click_check_box)
2557.17.1 by Jonathan Springer
Migrate to PyQt5
79
        self.ppt_window_check_box = QtWidgets.QCheckBox(self.powerpoint_group_box)
2532.1.16 by Tomas Groth
Added an option for letting powerpoint control the size and position for the presentation window. Workaround for windows 8.1 scaling.
80
        self.ppt_window_check_box.setObjectName('ppt_window_check_box')
81
        self.powerpoint_layout.addWidget(self.ppt_window_check_box)
2524.2.2 by Tomas Groth
Take focus back if Powerpoint steals it - fixes bug 1423913. Optionally advance a Powerpoint slides animation when clicked in the slidecontroller - fixes bug 1194847. Made OpenLP respect hidden slides. Improved logging in case of errors.
82
        self.left_layout.addWidget(self.powerpoint_group_box)
2275.1.4 by Tomas Groth
Added possible to point to a binary to use for pdf-processing.
83
        # Pdf options
2557.17.1 by Jonathan Springer
Migrate to PyQt5
84
        self.pdf_group_box = QtWidgets.QGroupBox(self.left_column)
2275.1.8 by Tomas Groth
Made branch work with python3.
85
        self.pdf_group_box.setObjectName('pdf_group_box')
2557.17.1 by Jonathan Springer
Migrate to PyQt5
86
        self.pdf_layout = QtWidgets.QFormLayout(self.pdf_group_box)
2275.1.8 by Tomas Groth
Made branch work with python3.
87
        self.pdf_layout.setObjectName('pdf_layout')
2557.17.1 by Jonathan Springer
Migrate to PyQt5
88
        self.pdf_program_check_box = QtWidgets.QCheckBox(self.pdf_group_box)
2275.1.8 by Tomas Groth
Made branch work with python3.
89
        self.pdf_program_check_box.setObjectName('pdf_program_check_box')
2275.1.13 by Tomas Groth
Fixes for the presentation setting tab
90
        self.pdf_layout.addRow(self.pdf_program_check_box)
2557.17.1 by Jonathan Springer
Migrate to PyQt5
91
        self.pdf_program_path_layout = QtWidgets.QHBoxLayout()
2275.1.8 by Tomas Groth
Made branch work with python3.
92
        self.pdf_program_path_layout.setObjectName('pdf_program_path_layout')
2557.17.1 by Jonathan Springer
Migrate to PyQt5
93
        self.pdf_program_path = QtWidgets.QLineEdit(self.pdf_group_box)
2275.1.8 by Tomas Groth
Made branch work with python3.
94
        self.pdf_program_path.setObjectName('pdf_program_path')
2275.1.4 by Tomas Groth
Added possible to point to a binary to use for pdf-processing.
95
        self.pdf_program_path.setReadOnly(True)
96
        self.pdf_program_path.setPalette(self.get_grey_text_palette(True))
97
        self.pdf_program_path_layout.addWidget(self.pdf_program_path)
2557.17.1 by Jonathan Springer
Migrate to PyQt5
98
        self.pdf_program_browse_button = QtWidgets.QToolButton(self.pdf_group_box)
2275.1.8 by Tomas Groth
Made branch work with python3.
99
        self.pdf_program_browse_button.setObjectName('pdf_program_browse_button')
100
        self.pdf_program_browse_button.setIcon(build_icon(':/general/general_open.png'))
2275.1.4 by Tomas Groth
Added possible to point to a binary to use for pdf-processing.
101
        self.pdf_program_browse_button.setEnabled(False)
102
        self.pdf_program_path_layout.addWidget(self.pdf_program_browse_button)
103
        self.pdf_layout.addRow(self.pdf_program_path_layout)
2275.1.13 by Tomas Groth
Fixes for the presentation setting tab
104
        self.left_layout.addWidget(self.pdf_group_box)
105
        self.left_layout.addStretch()
2557.17.1 by Jonathan Springer
Migrate to PyQt5
106
        self.right_column.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred)
2275.1.13 by Tomas Groth
Fixes for the presentation setting tab
107
        self.right_layout.addStretch()
108
        # Signals and slots
2275.1.4 by Tomas Groth
Added possible to point to a binary to use for pdf-processing.
109
        self.pdf_program_browse_button.clicked.connect(self.on_pdf_program_browse_button_clicked)
110
        self.pdf_program_check_box.clicked.connect(self.on_pdf_program_check_box_clicked)
442.1.33 by Tim Bentley
Fix commit due to missing
111
112
    def retranslateUi(self):
734.2.31 by Jonathan Corwin
Presentation thumbnail changes
113
        """
114
        Make any translation changes
115
        """
1989.3.220 by Tim Bentley
All Tabs converted
116
        self.controllers_group_box.setTitle(translate('PresentationPlugin.PresentationTab', 'Available Controllers'))
580.1.1 by Jonathan Corwin
Individual presentation controllers are now completely self-contained.
117
        for key in self.controllers:
118
            controller = self.controllers[key]
1989.3.220 by Tim Bentley
All Tabs converted
119
            checkbox = self.presenter_check_boxes[controller.name]
120
            self.set_controller_text(checkbox, controller)
121
        self.advanced_group_box.setTitle(UiStrings().Advanced)
2275.1.4 by Tomas Groth
Added possible to point to a binary to use for pdf-processing.
122
        self.pdf_group_box.setTitle(translate('PresentationPlugin.PresentationTab', 'PDF options'))
2524.2.2 by Tomas Groth
Take focus back if Powerpoint steals it - fixes bug 1423913. Optionally advance a Powerpoint slides animation when clicked in the slidecontroller - fixes bug 1194847. Made OpenLP respect hidden slides. Improved logging in case of errors.
123
        self.powerpoint_group_box.setTitle(translate('PresentationPlugin.PresentationTab', 'PowerPoint options'))
1989.3.220 by Tim Bentley
All Tabs converted
124
        self.override_app_check_box.setText(
2134.1.5 by Tim Bentley
More 120 cleanups
125
            translate('PresentationPlugin.PresentationTab', 'Allow presentation application to be overridden'))
2524.2.2 by Tomas Groth
Take focus back if Powerpoint steals it - fixes bug 1423913. Optionally advance a Powerpoint slides animation when clicked in the slidecontroller - fixes bug 1194847. Made OpenLP respect hidden slides. Improved logging in case of errors.
126
        self.ppt_slide_click_check_box.setText(
127
            translate('PresentationPlugin.PresentationTab',
128
                      'Clicking on a selected slide in the slidecontroller advances to next effect.'))
2532.1.16 by Tomas Groth
Added an option for letting powerpoint control the size and position for the presentation window. Workaround for windows 8.1 scaling.
129
        self.ppt_window_check_box.setText(
130
            translate('PresentationPlugin.PresentationTab',
2543.1.2 by Tomas Groth
Fix traceback when going live with presentation while blanked to desktop
131
                      'Let PowerPoint control the size and position of the presentation window '
132
                      '(workaround for Windows 8 scaling issue).'))
2275.1.4 by Tomas Groth
Added possible to point to a binary to use for pdf-processing.
133
        self.pdf_program_check_box.setText(
134
            translate('PresentationPlugin.PresentationTab', 'Use given full path for mudraw or ghostscript binary:'))
135
1989.3.220 by Tim Bentley
All Tabs converted
136
    def set_controller_text(self, checkbox, controller):
786.2.133 by Jonathan Corwin
Start disabled presentations only when necessary. Try and shutdown Impress at the end correctly
137
        if checkbox.isEnabled():
138
            checkbox.setText(controller.name)
139
        else:
2231.1.1 by Andreas Preikschat
songusage and presentation code standards
140
            checkbox.setText(translate('PresentationPlugin.PresentationTab', '%s (unavailable)') % controller.name)
786.2.133 by Jonathan Corwin
Start disabled presentations only when necessary. Try and shutdown Impress at the end correctly
141
442.1.33 by Tim Bentley
Fix commit due to missing
142
    def load(self):
734.2.31 by Jonathan Corwin
Presentation thumbnail changes
143
        """
144
        Load the settings.
145
        """
2524.2.2 by Tomas Groth
Take focus back if Powerpoint steals it - fixes bug 1423913. Optionally advance a Powerpoint slides animation when clicked in the slidecontroller - fixes bug 1194847. Made OpenLP respect hidden slides. Improved logging in case of errors.
146
        powerpoint_available = False
580.1.1 by Jonathan Corwin
Individual presentation controllers are now completely self-contained.
147
        for key in self.controllers:
148
            controller = self.controllers[key]
1989.3.220 by Tim Bentley
All Tabs converted
149
            checkbox = self.presenter_check_boxes[controller.name]
2218.1.123 by Andreas Preikschat
2to3 and resources.py
150
            checkbox.setChecked(Settings().value(self.settings_section + '/' + controller.name))
2524.2.2 by Tomas Groth
Take focus back if Powerpoint steals it - fixes bug 1423913. Optionally advance a Powerpoint slides animation when clicked in the slidecontroller - fixes bug 1194847. Made OpenLP respect hidden slides. Improved logging in case of errors.
151
            if controller.name == 'Powerpoint' and controller.is_available():
152
                powerpoint_available = True
2218.1.123 by Andreas Preikschat
2to3 and resources.py
153
        self.override_app_check_box.setChecked(Settings().value(self.settings_section + '/override app'))
2524.2.2 by Tomas Groth
Take focus back if Powerpoint steals it - fixes bug 1423913. Optionally advance a Powerpoint slides animation when clicked in the slidecontroller - fixes bug 1194847. Made OpenLP respect hidden slides. Improved logging in case of errors.
154
        # Load Powerpoint settings
2524.2.5 by Tomas Groth
Added test + some cleaning
155
        self.ppt_slide_click_check_box.setChecked(Settings().value(self.settings_section +
156
                                                                   '/powerpoint slide click advance'))
2524.2.2 by Tomas Groth
Take focus back if Powerpoint steals it - fixes bug 1423913. Optionally advance a Powerpoint slides animation when clicked in the slidecontroller - fixes bug 1194847. Made OpenLP respect hidden slides. Improved logging in case of errors.
157
        self.ppt_slide_click_check_box.setEnabled(powerpoint_available)
2532.1.18 by Tomas Groth
pep8 fixes
158
        self.ppt_window_check_box.setChecked(Settings().value(self.settings_section + '/powerpoint control window'))
2532.1.16 by Tomas Groth
Added an option for letting powerpoint control the size and position for the presentation window. Workaround for windows 8.1 scaling.
159
        self.ppt_window_check_box.setEnabled(powerpoint_available)
2275.1.4 by Tomas Groth
Added possible to point to a binary to use for pdf-processing.
160
        # load pdf-program settings
2275.1.9 by Tomas Groth
Mostly code cleanup of PDF support code.
161
        enable_pdf_program = Settings().value(self.settings_section + '/enable_pdf_program')
162
        self.pdf_program_check_box.setChecked(enable_pdf_program)
163
        self.pdf_program_path.setPalette(self.get_grey_text_palette(not enable_pdf_program))
164
        self.pdf_program_browse_button.setEnabled(enable_pdf_program)
165
        pdf_program = Settings().value(self.settings_section + '/pdf_program')
2275.1.4 by Tomas Groth
Added possible to point to a binary to use for pdf-processing.
166
        if pdf_program:
167
            self.pdf_program_path.setText(pdf_program)
442.1.33 by Tim Bentley
Fix commit due to missing
168
169
    def save(self):
734.2.31 by Jonathan Corwin
Presentation thumbnail changes
170
        """
2231.1.1 by Andreas Preikschat
songusage and presentation code standards
171
        Save the settings. If the tab hasn't been made visible to the user then there is nothing to do, so exit. This
172
        removes the need to start presentation applications unnecessarily.
734.2.31 by Jonathan Corwin
Presentation thumbnail changes
173
        """
1866.1.1 by Jonathan Corwin
Setting for X11 bypass flag. Don't open Impress unnecessarily if not enabled
174
        if not self.activated:
175
            return
734.2.40 by Jonathan Corwin
[Bug 608149] [NEW] Presentations are not intuitive
176
        changed = False
580.1.1 by Jonathan Corwin
Individual presentation controllers are now completely self-contained.
177
        for key in self.controllers:
178
            controller = self.controllers[key]
786.2.133 by Jonathan Corwin
Start disabled presentations only when necessary. Try and shutdown Impress at the end correctly
179
            if controller.is_available():
1989.3.220 by Tim Bentley
All Tabs converted
180
                checkbox = self.presenter_check_boxes[controller.name]
2218.1.123 by Andreas Preikschat
2to3 and resources.py
181
                setting_key = self.settings_section + '/' + controller.name
2141.3.8 by Andreas Preikschat
removed value parameter (still needs work)
182
                if Settings().value(setting_key) != checkbox.checkState():
830.1.93 by M2j
Bug #698881 (accessing unavailable presentation controller)
183
                    changed = True
1970.2.24 by Andreas Preikschat
r2074 + conflicts
184
                    Settings().setValue(setting_key, checkbox.checkState())
830.1.93 by M2j
Bug #698881 (accessing unavailable presentation controller)
185
                    if checkbox.isChecked():
186
                        controller.start_process()
187
                    else:
188
                        controller.kill()
2218.1.123 by Andreas Preikschat
2to3 and resources.py
189
        setting_key = self.settings_section + '/override app'
1989.3.220 by Tim Bentley
All Tabs converted
190
        if Settings().value(setting_key) != self.override_app_check_box.checkState():
191
            Settings().setValue(setting_key, self.override_app_check_box.checkState())
734.2.40 by Jonathan Corwin
[Bug 608149] [NEW] Presentations are not intuitive
192
            changed = True
2524.2.2 by Tomas Groth
Take focus back if Powerpoint steals it - fixes bug 1423913. Optionally advance a Powerpoint slides animation when clicked in the slidecontroller - fixes bug 1194847. Made OpenLP respect hidden slides. Improved logging in case of errors.
193
        # Save powerpoint settings
194
        setting_key = self.settings_section + '/powerpoint slide click advance'
195
        if Settings().value(setting_key) != self.ppt_slide_click_check_box.checkState():
196
            Settings().setValue(setting_key, self.ppt_slide_click_check_box.checkState())
197
            changed = True
2532.1.16 by Tomas Groth
Added an option for letting powerpoint control the size and position for the presentation window. Workaround for windows 8.1 scaling.
198
        setting_key = self.settings_section + '/powerpoint control window'
199
        if Settings().value(setting_key) != self.ppt_window_check_box.checkState():
200
            Settings().setValue(setting_key, self.ppt_window_check_box.checkState())
201
            changed = True
2275.1.4 by Tomas Groth
Added possible to point to a binary to use for pdf-processing.
202
        # Save pdf-settings
203
        pdf_program = self.pdf_program_path.text()
2275.1.9 by Tomas Groth
Mostly code cleanup of PDF support code.
204
        enable_pdf_program = self.pdf_program_check_box.checkState()
2275.1.4 by Tomas Groth
Added possible to point to a binary to use for pdf-processing.
205
        # If the given program is blank disable using the program
2275.1.8 by Tomas Groth
Made branch work with python3.
206
        if pdf_program == '':
2275.1.9 by Tomas Groth
Mostly code cleanup of PDF support code.
207
            enable_pdf_program = 0
208
        if pdf_program != Settings().value(self.settings_section + '/pdf_program'):
2345.2.8 by Raoul Snyman
Fix up PEP8 issues.
209
            Settings().setValue(self.settings_section + '/pdf_program', pdf_program)
2275.1.4 by Tomas Groth
Added possible to point to a binary to use for pdf-processing.
210
            changed = True
2275.1.9 by Tomas Groth
Mostly code cleanup of PDF support code.
211
        if enable_pdf_program != Settings().value(self.settings_section + '/enable_pdf_program'):
2345.2.8 by Raoul Snyman
Fix up PEP8 issues.
212
            Settings().setValue(self.settings_section + '/enable_pdf_program', enable_pdf_program)
2275.1.4 by Tomas Groth
Added possible to point to a binary to use for pdf-processing.
213
            changed = True
734.2.40 by Jonathan Corwin
[Bug 608149] [NEW] Presentations are not intuitive
214
        if changed:
2218.1.123 by Andreas Preikschat
2to3 and resources.py
215
            self.settings_form.register_post_process('mediaitem_suffix_reset')
216
            self.settings_form.register_post_process('mediaitem_presentation_rebuild')
217
            self.settings_form.register_post_process('mediaitem_suffixes')
786.2.133 by Jonathan Corwin
Start disabled presentations only when necessary. Try and shutdown Impress at the end correctly
218
1989.3.220 by Tim Bentley
All Tabs converted
219
    def tab_visible(self):
786.2.133 by Jonathan Corwin
Start disabled presentations only when necessary. Try and shutdown Impress at the end correctly
220
        """
221
        Tab has just been made visible to the user
222
        """
1866.1.1 by Jonathan Corwin
Setting for X11 bypass flag. Don't open Impress unnecessarily if not enabled
223
        self.activated = True
786.2.133 by Jonathan Corwin
Start disabled presentations only when necessary. Try and shutdown Impress at the end correctly
224
        for key in self.controllers:
225
            controller = self.controllers[key]
1989.3.220 by Tim Bentley
All Tabs converted
226
            checkbox = self.presenter_check_boxes[controller.name]
786.2.133 by Jonathan Corwin
Start disabled presentations only when necessary. Try and shutdown Impress at the end correctly
227
            checkbox.setEnabled(controller.is_available())
1989.3.222 by Tim Bentley
Fix change typos
228
            self.set_controller_text(checkbox, controller)
2275.1.16 by Tomas Groth
Changed the way a serviceitem from the servicemanager is copied and converted. Also fixed for PEP8.
229
2275.1.21 by Tomas Groth
Only allow pdf-program selection using filedialog.
230
    def on_pdf_program_browse_button_clicked(self):
231
        """
232
        Select the mudraw or ghostscript binary that should be used.
233
        """
2557.17.1 by Jonathan Springer
Migrate to PyQt5
234
        filename, filter_used = QtWidgets.QFileDialog.getOpenFileName(
235
            self, translate('PresentationPlugin.PresentationTab', 'Select mudraw or ghostscript binary.'),
236
            self.pdf_program_path.text())
2275.1.21 by Tomas Groth
Only allow pdf-program selection using filedialog.
237
        if filename:
238
            program_type = PdfController.check_binary(filename)
2275.1.13 by Tomas Groth
Fixes for the presentation setting tab
239
            if not program_type:
2275.1.16 by Tomas Groth
Changed the way a serviceitem from the servicemanager is copied and converted. Also fixed for PEP8.
240
                critical_error_message_box(UiStrings().Error,
241
                                           translate('PresentationPlugin.PresentationTab',
242
                                                     'The program is not ghostscript or mudraw which is required.'))
2275.1.21 by Tomas Groth
Only allow pdf-program selection using filedialog.
243
            else:
244
                self.pdf_program_path.setText(filename)
2275.1.4 by Tomas Groth
Added possible to point to a binary to use for pdf-processing.
245
246
    def on_pdf_program_check_box_clicked(self, checked):
247
        """
248
        When checkbox for manual entering pdf-program is clicked,
249
        enable or disable the textbox for the programpath and the browse-button.
2275.1.18 by Tomas Groth
Added some docstring documentation.
250
251
        :param checked: If the box is checked or not.
2275.1.4 by Tomas Groth
Added possible to point to a binary to use for pdf-processing.
252
        """
253
        self.pdf_program_path.setPalette(self.get_grey_text_palette(not checked))
254
        self.pdf_program_browse_button.setEnabled(checked)
255
256
    def get_grey_text_palette(self, greyed):
257
        """
258
        Returns a QPalette with greyed out text as used for placeholderText.
2275.1.18 by Tomas Groth
Added some docstring documentation.
259
260
        :param greyed: Determines whether the palette should be grayed.
261
        :return: The created palette.
2275.1.4 by Tomas Groth
Added possible to point to a binary to use for pdf-processing.
262
        """
263
        palette = QtGui.QPalette()
264
        color = self.palette().color(QtGui.QPalette.Active, QtGui.QPalette.Text)
265
        if greyed:
266
            color.setAlpha(128)
267
        palette.setColor(QtGui.QPalette.Active, QtGui.QPalette.Text, color)
268
        return palette