Merge lp:~trb143/openlp/background_videos into lp:openlp
- background_videos
- Merge into trunk
Status: | Superseded |
---|---|
Proposed branch: | lp:~trb143/openlp/background_videos |
Merge into: | lp:openlp |
Diff against target: |
469 lines (+183/-32) 9 files modified
openlp/core/common/uistrings.py (+1/-0) openlp/core/lib/theme.py (+24/-1) openlp/core/ui/maindisplay.py (+22/-9) openlp/core/ui/media/webkitplayer.py (+2/-9) openlp/core/ui/themeform.py (+40/-3) openlp/core/ui/thememanager.py (+2/-2) openlp/core/ui/themewizard.py (+30/-5) scripts/translation_utils.py (+2/-2) tests/functional/openlp_core_ui/test_maindisplay.py (+60/-1) |
To merge this branch: | bzr merge lp:~trb143/openlp/background_videos |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
OpenLP Core | Pending | ||
Review via email: mp+293468@code.launchpad.net |
This proposal has been superseded by a proposal from 2016-04-30.
Commit message
Description of the change
Allow themes to have video files so allow for background videos behind text.
lp:~trb143/openlp/background_videos (revision 2689)
[SUCCESS] https:/
[SUCCESS] https:/
[SUCCESS] https:/
[SUCCESS] https:/
[SUCCESS] https:/
[SUCCESS] https:/
[SUCCESS] https:/
- 2690. By Tim Bentley
-
minor fixes
- 2691. By Tim Bentley
-
head
- 2692. By Tim Bentley
-
fix strings
- 2693. By Tim Bentley
-
change net to com
- 2694. By Tim Bentley
-
remove rogue print
Unmerged revisions
Preview Diff
1 | === modified file 'openlp/core/common/uistrings.py' | |||
2 | --- openlp/core/common/uistrings.py 2016-04-16 19:51:35 +0000 | |||
3 | +++ openlp/core/common/uistrings.py 2016-04-30 17:20:12 +0000 | |||
4 | @@ -152,3 +152,4 @@ | |||
5 | 152 | self.Version = translate('OpenLP.Ui', 'Version') | 152 | self.Version = translate('OpenLP.Ui', 'Version') |
6 | 153 | self.View = translate('OpenLP.Ui', 'View') | 153 | self.View = translate('OpenLP.Ui', 'View') |
7 | 154 | self.ViewMode = translate('OpenLP.Ui', 'View Mode') | 154 | self.ViewMode = translate('OpenLP.Ui', 'View Mode') |
8 | 155 | self.Video = translate('OpenLP.Ui', 'Video') | ||
9 | 155 | 156 | ||
10 | === modified file 'openlp/core/lib/theme.py' | |||
11 | --- openlp/core/lib/theme.py 2015-12-31 22:46:06 +0000 | |||
12 | +++ openlp/core/lib/theme.py 2016-04-30 17:20:12 +0000 | |||
13 | @@ -44,6 +44,7 @@ | |||
14 | 44 | Gradient = 1 | 44 | Gradient = 1 |
15 | 45 | Image = 2 | 45 | Image = 2 |
16 | 46 | Transparent = 3 | 46 | Transparent = 3 |
17 | 47 | Video = 4 | ||
18 | 47 | 48 | ||
19 | 48 | @staticmethod | 49 | @staticmethod |
20 | 49 | def to_string(background_type): | 50 | def to_string(background_type): |
21 | @@ -58,6 +59,8 @@ | |||
22 | 58 | return 'image' | 59 | return 'image' |
23 | 59 | elif background_type == BackgroundType.Transparent: | 60 | elif background_type == BackgroundType.Transparent: |
24 | 60 | return 'transparent' | 61 | return 'transparent' |
25 | 62 | elif background_type == BackgroundType.Video: | ||
26 | 63 | return 'video' | ||
27 | 61 | 64 | ||
28 | 62 | @staticmethod | 65 | @staticmethod |
29 | 63 | def from_string(type_string): | 66 | def from_string(type_string): |
30 | @@ -72,6 +75,8 @@ | |||
31 | 72 | return BackgroundType.Image | 75 | return BackgroundType.Image |
32 | 73 | elif type_string == 'transparent': | 76 | elif type_string == 'transparent': |
33 | 74 | return BackgroundType.Transparent | 77 | return BackgroundType.Transparent |
34 | 78 | elif type_string == 'video': | ||
35 | 79 | return BackgroundType.Video | ||
36 | 75 | 80 | ||
37 | 76 | 81 | ||
38 | 77 | class BackgroundGradientType(object): | 82 | class BackgroundGradientType(object): |
39 | @@ -184,7 +189,7 @@ | |||
40 | 184 | 189 | ||
41 | 185 | :param path: The path name to be added. | 190 | :param path: The path name to be added. |
42 | 186 | """ | 191 | """ |
44 | 187 | if self.background_type == 'image': | 192 | if self.background_type == 'image' or self.background_type == 'video': |
45 | 188 | if self.background_filename and path: | 193 | if self.background_filename and path: |
46 | 189 | self.theme_name = self.theme_name.strip() | 194 | self.theme_name = self.theme_name.strip() |
47 | 190 | self.background_filename = self.background_filename.strip() | 195 | self.background_filename = self.background_filename.strip() |
48 | @@ -255,6 +260,21 @@ | |||
49 | 255 | # Create endColor element | 260 | # Create endColor element |
50 | 256 | self.child_element(background, 'borderColor', str(border_color)) | 261 | self.child_element(background, 'borderColor', str(border_color)) |
51 | 257 | 262 | ||
52 | 263 | def add_background_video(self, filename, border_color): | ||
53 | 264 | """ | ||
54 | 265 | Add a video background. | ||
55 | 266 | |||
56 | 267 | :param filename: The file name of the video. | ||
57 | 268 | :param border_color: | ||
58 | 269 | """ | ||
59 | 270 | background = self.theme_xml.createElement('background') | ||
60 | 271 | background.setAttribute('type', 'video') | ||
61 | 272 | self.theme.appendChild(background) | ||
62 | 273 | # Create Filename element | ||
63 | 274 | self.child_element(background, 'filename', filename) | ||
64 | 275 | # Create endColor element | ||
65 | 276 | self.child_element(background, 'borderColor', str(border_color)) | ||
66 | 277 | |||
67 | 258 | def add_font(self, name, color, size, override, fonttype='main', bold='False', italics='False', | 278 | def add_font(self, name, color, size, override, fonttype='main', bold='False', italics='False', |
68 | 259 | line_adjustment=0, xpos=0, ypos=0, width=0, height=0, outline='False', outline_color='#ffffff', | 279 | line_adjustment=0, xpos=0, ypos=0, width=0, height=0, outline='False', outline_color='#ffffff', |
69 | 260 | outline_pixel=2, shadow='False', shadow_color='#ffffff', shadow_pixel=5): | 280 | outline_pixel=2, shadow='False', shadow_color='#ffffff', shadow_pixel=5): |
70 | @@ -512,6 +532,9 @@ | |||
71 | 512 | elif self.background_type == BackgroundType.to_string(BackgroundType.Image): | 532 | elif self.background_type == BackgroundType.to_string(BackgroundType.Image): |
72 | 513 | filename = os.path.split(self.background_filename)[1] | 533 | filename = os.path.split(self.background_filename)[1] |
73 | 514 | self.add_background_image(filename, self.background_border_color) | 534 | self.add_background_image(filename, self.background_border_color) |
74 | 535 | elif self.background_type == BackgroundType.to_string(BackgroundType.Video): | ||
75 | 536 | filename = os.path.split(self.background_filename)[1] | ||
76 | 537 | self.add_background_video(filename, self.background_border_color) | ||
77 | 515 | elif self.background_type == BackgroundType.to_string(BackgroundType.Transparent): | 538 | elif self.background_type == BackgroundType.to_string(BackgroundType.Transparent): |
78 | 516 | self.add_background_transparent() | 539 | self.add_background_transparent() |
79 | 517 | self.add_font( | 540 | self.add_font( |
80 | 518 | 541 | ||
81 | === modified file 'openlp/core/ui/maindisplay.py' | |||
82 | --- openlp/core/ui/maindisplay.py 2016-04-01 02:32:36 +0000 | |||
83 | +++ openlp/core/ui/maindisplay.py 2016-04-30 17:20:12 +0000 | |||
84 | @@ -31,13 +31,15 @@ | |||
85 | 31 | 31 | ||
86 | 32 | import html | 32 | import html |
87 | 33 | import logging | 33 | import logging |
88 | 34 | import os | ||
89 | 34 | 35 | ||
90 | 35 | from PyQt5 import QtCore, QtWidgets, QtWebKit, QtWebKitWidgets, QtOpenGL, QtGui, QtMultimedia | 36 | from PyQt5 import QtCore, QtWidgets, QtWebKit, QtWebKitWidgets, QtOpenGL, QtGui, QtMultimedia |
91 | 36 | 37 | ||
93 | 37 | from openlp.core.common import Registry, RegistryProperties, OpenLPMixin, Settings, translate, is_macosx, is_win | 38 | from openlp.core.common import AppLocation, Registry, RegistryProperties, OpenLPMixin, Settings, translate,\ |
94 | 39 | is_macosx, is_win | ||
95 | 38 | from openlp.core.lib import ServiceItem, ImageSource, ScreenList, build_html, expand_tags, image_to_byte | 40 | from openlp.core.lib import ServiceItem, ImageSource, ScreenList, build_html, expand_tags, image_to_byte |
96 | 39 | from openlp.core.lib.theme import BackgroundType | 41 | from openlp.core.lib.theme import BackgroundType |
98 | 40 | from openlp.core.ui import HideMode, AlertLocation | 42 | from openlp.core.ui import HideMode, AlertLocation, DisplayControllerType |
99 | 41 | 43 | ||
100 | 42 | if is_macosx(): | 44 | if is_macosx(): |
101 | 43 | from ctypes import pythonapi, c_void_p, c_char_p, py_object | 45 | from ctypes import pythonapi, c_void_p, c_char_p, py_object |
102 | @@ -457,13 +459,13 @@ | |||
103 | 457 | background = self.image_manager.get_image_bytes(self.override['image'], ImageSource.ImagePlugin) | 459 | background = self.image_manager.get_image_bytes(self.override['image'], ImageSource.ImagePlugin) |
104 | 458 | self.set_transparency(self.service_item.theme_data.background_type == | 460 | self.set_transparency(self.service_item.theme_data.background_type == |
105 | 459 | BackgroundType.to_string(BackgroundType.Transparent)) | 461 | BackgroundType.to_string(BackgroundType.Transparent)) |
113 | 460 | if self.service_item.theme_data.background_filename: | 462 | image_bytes = None |
114 | 461 | self.service_item.bg_image_bytes = self.image_manager.get_image_bytes( | 463 | if self.service_item.theme_data.background_type == 'image': |
115 | 462 | self.service_item.theme_data.background_filename, ImageSource.Theme) | 464 | if self.service_item.theme_data.background_filename: |
116 | 463 | if image_path: | 465 | self.service_item.bg_image_bytes = self.image_manager.get_image_bytes( |
117 | 464 | image_bytes = self.image_manager.get_image_bytes(image_path, ImageSource.ImagePlugin) | 466 | self.service_item.theme_data.background_filename, ImageSource.Theme) |
118 | 465 | else: | 467 | if image_path: |
119 | 466 | image_bytes = None | 468 | image_bytes = self.image_manager.get_image_bytes(image_path, ImageSource.ImagePlugin) |
120 | 467 | html = build_html(self.service_item, self.screen, self.is_live, background, image_bytes, | 469 | html = build_html(self.service_item, self.screen, self.is_live, background, image_bytes, |
121 | 468 | plugins=self.plugin_manager.plugins) | 470 | plugins=self.plugin_manager.plugins) |
122 | 469 | self.web_view.setHtml(html) | 471 | self.web_view.setHtml(html) |
123 | @@ -475,6 +477,17 @@ | |||
124 | 475 | Registry().execute('slidecontroller_live_unblank') | 477 | Registry().execute('slidecontroller_live_unblank') |
125 | 476 | else: | 478 | else: |
126 | 477 | self.hide_display(self.hide_mode) | 479 | self.hide_display(self.hide_mode) |
127 | 480 | if self.service_item.theme_data.background_type == 'video' and self.is_live: | ||
128 | 481 | if self.service_item.theme_data.background_filename: | ||
129 | 482 | service_item = ServiceItem() | ||
130 | 483 | service_item.title = 'webkit' | ||
131 | 484 | service_item.processor = 'webkit' | ||
132 | 485 | path = os.path.join(AppLocation.get_section_data_path('themes'), | ||
133 | 486 | self.service_item.theme_data.theme_name) | ||
134 | 487 | service_item.add_from_command(path, | ||
135 | 488 | self.service_item.theme_data.background_filename, | ||
136 | 489 | ':/media/slidecontroller_multimedia.png') | ||
137 | 490 | self.media_controller.video(DisplayControllerType.Live, service_item, video_behind_text=True) | ||
138 | 478 | self._hide_mouse() | 491 | self._hide_mouse() |
139 | 479 | 492 | ||
140 | 480 | def footer(self, text): | 493 | def footer(self, text): |
141 | 481 | 494 | ||
142 | === modified file 'openlp/core/ui/media/webkitplayer.py' | |||
143 | --- openlp/core/ui/media/webkitplayer.py 2016-02-26 16:00:04 +0000 | |||
144 | +++ openlp/core/ui/media/webkitplayer.py 2016-04-30 17:20:12 +0000 | |||
145 | @@ -45,7 +45,7 @@ | |||
146 | 45 | """ | 45 | """ |
147 | 46 | 46 | ||
148 | 47 | VIDEO_JS = """ | 47 | VIDEO_JS = """ |
150 | 48 | function show_video(state, path, volume, loop, variable_value){ | 48 | function show_video(state, path, volume, variable_value){ |
151 | 49 | // Sometimes video.currentTime stops slightly short of video.duration and video.ended is intermittent! | 49 | // Sometimes video.currentTime stops slightly short of video.duration and video.ended is intermittent! |
152 | 50 | 50 | ||
153 | 51 | var video = document.getElementById('video'); | 51 | var video = document.getElementById('video'); |
154 | @@ -55,9 +55,6 @@ | |||
155 | 55 | switch(state){ | 55 | switch(state){ |
156 | 56 | case 'load': | 56 | case 'load': |
157 | 57 | video.src = 'file:///' + path; | 57 | video.src = 'file:///' + path; |
158 | 58 | if(loop == true) { | ||
159 | 59 | video.loop = true; | ||
160 | 60 | } | ||
161 | 61 | video.load(); | 58 | video.load(); |
162 | 62 | break; | 59 | break; |
163 | 63 | case 'play': | 60 | case 'play': |
164 | @@ -180,12 +177,8 @@ | |||
165 | 180 | else: | 177 | else: |
166 | 181 | vol = 0 | 178 | vol = 0 |
167 | 182 | path = controller.media_info.file_info.absoluteFilePath() | 179 | path = controller.media_info.file_info.absoluteFilePath() |
168 | 183 | if controller.media_info.is_background: | ||
169 | 184 | loop = 'true' | ||
170 | 185 | else: | ||
171 | 186 | loop = 'false' | ||
172 | 187 | display.web_view.setVisible(True) | 180 | display.web_view.setVisible(True) |
174 | 188 | js = 'show_video("load", "%s", %s, %s);' % (path.replace('\\', '\\\\'), str(vol), loop) | 181 | js = 'show_video("load", "%s", %s, %s);' % (path.replace('\\', '\\\\'), str(vol)) |
175 | 189 | display.frame.evaluateJavaScript(js) | 182 | display.frame.evaluateJavaScript(js) |
176 | 190 | return True | 183 | return True |
177 | 191 | 184 | ||
178 | 192 | 185 | ||
179 | === modified file 'openlp/core/ui/themeform.py' | |||
180 | --- openlp/core/ui/themeform.py 2016-04-17 18:57:03 +0000 | |||
181 | +++ openlp/core/ui/themeform.py 2016-04-30 17:20:12 +0000 | |||
182 | @@ -31,7 +31,7 @@ | |||
183 | 31 | from openlp.core.lib.theme import BackgroundType, BackgroundGradientType | 31 | from openlp.core.lib.theme import BackgroundType, BackgroundGradientType |
184 | 32 | from openlp.core.lib.ui import critical_error_message_box | 32 | from openlp.core.lib.ui import critical_error_message_box |
185 | 33 | from openlp.core.ui import ThemeLayoutForm | 33 | from openlp.core.ui import ThemeLayoutForm |
187 | 34 | from openlp.core.ui.lib.colorbutton import ColorButton | 34 | from openlp.core.ui.media.webkitplayer import VIDEO_EXT |
188 | 35 | from .themewizard import Ui_ThemeWizard | 35 | from .themewizard import Ui_ThemeWizard |
189 | 36 | 36 | ||
190 | 37 | log = logging.getLogger(__name__) | 37 | log = logging.getLogger(__name__) |
191 | @@ -66,10 +66,13 @@ | |||
192 | 66 | self.gradient_combo_box.currentIndexChanged.connect(self.on_gradient_combo_box_current_index_changed) | 66 | self.gradient_combo_box.currentIndexChanged.connect(self.on_gradient_combo_box_current_index_changed) |
193 | 67 | self.color_button.colorChanged.connect(self.on_color_changed) | 67 | self.color_button.colorChanged.connect(self.on_color_changed) |
194 | 68 | self.image_color_button.colorChanged.connect(self.on_image_color_changed) | 68 | self.image_color_button.colorChanged.connect(self.on_image_color_changed) |
195 | 69 | self.video_color_button.colorChanged.connect(self.on_video_color_changed) | ||
196 | 69 | self.gradient_start_button.colorChanged.connect(self.on_gradient_start_color_changed) | 70 | self.gradient_start_button.colorChanged.connect(self.on_gradient_start_color_changed) |
197 | 70 | self.gradient_end_button.colorChanged.connect(self.on_gradient_end_color_changed) | 71 | self.gradient_end_button.colorChanged.connect(self.on_gradient_end_color_changed) |
198 | 71 | self.image_browse_button.clicked.connect(self.on_image_browse_button_clicked) | 72 | self.image_browse_button.clicked.connect(self.on_image_browse_button_clicked) |
199 | 72 | self.image_file_edit.editingFinished.connect(self.on_image_file_edit_editing_finished) | 73 | self.image_file_edit.editingFinished.connect(self.on_image_file_edit_editing_finished) |
200 | 74 | self.video_browse_button.clicked.connect(self.on_video_browse_button_clicked) | ||
201 | 75 | self.video_file_edit.editingFinished.connect(self.on_video_file_edit_editing_finished) | ||
202 | 73 | self.main_color_button.colorChanged.connect(self.on_main_color_changed) | 76 | self.main_color_button.colorChanged.connect(self.on_main_color_changed) |
203 | 74 | self.outline_color_button.colorChanged.connect(self.on_outline_color_changed) | 77 | self.outline_color_button.colorChanged.connect(self.on_outline_color_changed) |
204 | 75 | self.shadow_color_button.colorChanged.connect(self.on_shadow_color_changed) | 78 | self.shadow_color_button.colorChanged.connect(self.on_shadow_color_changed) |
205 | @@ -307,6 +310,10 @@ | |||
206 | 307 | self.image_color_button.color = self.theme.background_border_color | 310 | self.image_color_button.color = self.theme.background_border_color |
207 | 308 | self.image_file_edit.setText(self.theme.background_filename) | 311 | self.image_file_edit.setText(self.theme.background_filename) |
208 | 309 | self.setField('background_type', 2) | 312 | self.setField('background_type', 2) |
209 | 313 | elif self.theme.background_type == BackgroundType.to_string(BackgroundType.Video): | ||
210 | 314 | self.video_color_button.color = self.theme.background_border_color | ||
211 | 315 | self.video_file_edit.setText(self.theme.background_filename) | ||
212 | 316 | self.setField('background_type', 4) | ||
213 | 310 | elif self.theme.background_type == BackgroundType.to_string(BackgroundType.Transparent): | 317 | elif self.theme.background_type == BackgroundType.to_string(BackgroundType.Transparent): |
214 | 311 | self.setField('background_type', 3) | 318 | self.setField('background_type', 3) |
215 | 312 | if self.theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.Horizontal): | 319 | if self.theme.background_direction == BackgroundGradientType.to_string(BackgroundGradientType.Horizontal): |
216 | @@ -384,10 +391,12 @@ | |||
217 | 384 | if self.update_theme_allowed: | 391 | if self.update_theme_allowed: |
218 | 385 | self.theme.background_type = BackgroundType.to_string(index) | 392 | self.theme.background_type = BackgroundType.to_string(index) |
219 | 386 | if self.theme.background_type != BackgroundType.to_string(BackgroundType.Image) and \ | 393 | if self.theme.background_type != BackgroundType.to_string(BackgroundType.Image) and \ |
220 | 394 | self.theme.background_type != BackgroundType.to_string(BackgroundType.Video) and \ | ||
221 | 387 | self.temp_background_filename == '': | 395 | self.temp_background_filename == '': |
222 | 388 | self.temp_background_filename = self.theme.background_filename | 396 | self.temp_background_filename = self.theme.background_filename |
223 | 389 | self.theme.background_filename = '' | 397 | self.theme.background_filename = '' |
225 | 390 | if self.theme.background_type == BackgroundType.to_string(BackgroundType.Image) and \ | 398 | if (self.theme.background_type == BackgroundType.to_string(BackgroundType.Image) or |
226 | 399 | self.theme.background_type != BackgroundType.to_string(BackgroundType.Video)) and \ | ||
227 | 391 | self.temp_background_filename != '': | 400 | self.temp_background_filename != '': |
228 | 392 | self.theme.background_filename = self.temp_background_filename | 401 | self.theme.background_filename = self.temp_background_filename |
229 | 393 | self.temp_background_filename = '' | 402 | self.temp_background_filename = '' |
230 | @@ -413,6 +422,12 @@ | |||
231 | 413 | """ | 422 | """ |
232 | 414 | self.theme.background_border_color = color | 423 | self.theme.background_border_color = color |
233 | 415 | 424 | ||
234 | 425 | def on_video_color_changed(self, color): | ||
235 | 426 | """ | ||
236 | 427 | Background / Gradient 1 _color button pushed. | ||
237 | 428 | """ | ||
238 | 429 | self.theme.background_border_color = color | ||
239 | 430 | |||
240 | 416 | def on_gradient_start_color_changed(self, color): | 431 | def on_gradient_start_color_changed(self, color): |
241 | 417 | """ | 432 | """ |
242 | 418 | Gradient 2 _color button pushed. | 433 | Gradient 2 _color button pushed. |
243 | @@ -444,6 +459,27 @@ | |||
244 | 444 | """ | 459 | """ |
245 | 445 | self.theme.background_filename = str(self.image_file_edit.text()) | 460 | self.theme.background_filename = str(self.image_file_edit.text()) |
246 | 446 | 461 | ||
247 | 462 | def on_video_browse_button_clicked(self): | ||
248 | 463 | """ | ||
249 | 464 | Background video button pushed. | ||
250 | 465 | """ | ||
251 | 466 | visible_formats = '(%s)' % '; '.join(VIDEO_EXT) | ||
252 | 467 | actual_formats = '(%s)' % ' '.join(VIDEO_EXT) | ||
253 | 468 | video_filter = '%s %s %s' % (translate('OpenLP', 'Video Files'), visible_formats, actual_formats) | ||
254 | 469 | video_filter = '%s;;%s (*.*)' % (video_filter, UiStrings().AllFiles) | ||
255 | 470 | filename, filter_used = QtWidgets.QFileDialog.getOpenFileName( | ||
256 | 471 | self, translate('OpenLP.ThemeWizard', 'Select Video'), | ||
257 | 472 | self.video_file_edit.text(), video_filter) | ||
258 | 473 | if filename: | ||
259 | 474 | self.theme.background_filename = filename | ||
260 | 475 | self.set_background_page_values() | ||
261 | 476 | |||
262 | 477 | def on_video_file_edit_editing_finished(self): | ||
263 | 478 | """ | ||
264 | 479 | Background video path edited | ||
265 | 480 | """ | ||
266 | 481 | self.theme.background_filename = str(self.image_file_edit.text()) | ||
267 | 482 | |||
268 | 447 | def on_main_color_changed(self, color): | 483 | def on_main_color_changed(self, color): |
269 | 448 | """ | 484 | """ |
270 | 449 | Set the main colour value | 485 | Set the main colour value |
271 | @@ -519,7 +555,8 @@ | |||
272 | 519 | return | 555 | return |
273 | 520 | save_from = None | 556 | save_from = None |
274 | 521 | save_to = None | 557 | save_to = None |
276 | 522 | if self.theme.background_type == BackgroundType.to_string(BackgroundType.Image): | 558 | if self.theme.background_type == BackgroundType.to_string(BackgroundType.Image) or \ |
277 | 559 | self.theme.background_type == BackgroundType.to_string(BackgroundType.Video): | ||
278 | 523 | filename = os.path.split(str(self.theme.background_filename))[1] | 560 | filename = os.path.split(str(self.theme.background_filename))[1] |
279 | 524 | save_to = os.path.join(self.path, self.theme.theme_name, filename) | 561 | save_to = os.path.join(self.path, self.theme.theme_name, filename) |
280 | 525 | save_from = self.theme.background_filename | 562 | save_from = self.theme.background_filename |
281 | 526 | 563 | ||
282 | === modified file 'openlp/core/ui/thememanager.py' | |||
283 | --- openlp/core/ui/thememanager.py 2016-04-17 19:32:15 +0000 | |||
284 | +++ openlp/core/ui/thememanager.py 2016-04-30 17:20:12 +0000 | |||
285 | @@ -300,7 +300,7 @@ | |||
286 | 300 | """ | 300 | """ |
287 | 301 | save_to = None | 301 | save_to = None |
288 | 302 | save_from = None | 302 | save_from = None |
290 | 303 | if theme_data.background_type == 'image': | 303 | if theme_data.background_type == 'image' or theme_data.background_type == 'video': |
291 | 304 | save_to = os.path.join(self.path, new_theme_name, os.path.split(str(theme_data.background_filename))[1]) | 304 | save_to = os.path.join(self.path, new_theme_name, os.path.split(str(theme_data.background_filename))[1]) |
292 | 305 | save_from = theme_data.background_filename | 305 | save_from = theme_data.background_filename |
293 | 306 | theme_data.theme_name = new_theme_name | 306 | theme_data.theme_name = new_theme_name |
294 | @@ -318,7 +318,7 @@ | |||
295 | 318 | translate('OpenLP.ThemeManager', 'You must select a theme to edit.')): | 318 | translate('OpenLP.ThemeManager', 'You must select a theme to edit.')): |
296 | 319 | item = self.theme_list_widget.currentItem() | 319 | item = self.theme_list_widget.currentItem() |
297 | 320 | theme = self.get_theme_data(item.data(QtCore.Qt.UserRole)) | 320 | theme = self.get_theme_data(item.data(QtCore.Qt.UserRole)) |
299 | 321 | if theme.background_type == 'image': | 321 | if theme.background_type == 'image' or theme.background_type == 'video': |
300 | 322 | self.old_background_image = theme.background_filename | 322 | self.old_background_image = theme.background_filename |
301 | 323 | self.theme_form.theme = theme | 323 | self.theme_form.theme = theme |
302 | 324 | self.theme_form.exec(True) | 324 | self.theme_form.exec(True) |
303 | 325 | 325 | ||
304 | === modified file 'openlp/core/ui/themewizard.py' | |||
305 | --- openlp/core/ui/themewizard.py 2016-04-17 18:57:03 +0000 | |||
306 | +++ openlp/core/ui/themewizard.py 2016-04-30 17:20:12 +0000 | |||
307 | @@ -62,7 +62,7 @@ | |||
308 | 62 | self.background_label = QtWidgets.QLabel(self.background_page) | 62 | self.background_label = QtWidgets.QLabel(self.background_page) |
309 | 63 | self.background_label.setObjectName('background_label') | 63 | self.background_label.setObjectName('background_label') |
310 | 64 | self.background_combo_box = QtWidgets.QComboBox(self.background_page) | 64 | self.background_combo_box = QtWidgets.QComboBox(self.background_page) |
312 | 65 | self.background_combo_box.addItems(['', '', '', '']) | 65 | self.background_combo_box.addItems(['', '', '', '', '']) |
313 | 66 | self.background_combo_box.setObjectName('background_combo_box') | 66 | self.background_combo_box.setObjectName('background_combo_box') |
314 | 67 | self.background_type_layout.addRow(self.background_label, self.background_combo_box) | 67 | self.background_type_layout.addRow(self.background_label, self.background_combo_box) |
315 | 68 | self.background_type_layout.setItem(1, QtWidgets.QFormLayout.LabelRole, self.spacer) | 68 | self.background_type_layout.setItem(1, QtWidgets.QFormLayout.LabelRole, self.spacer) |
316 | @@ -135,6 +135,30 @@ | |||
317 | 135 | self.transparent_layout.setObjectName('Transparent_layout') | 135 | self.transparent_layout.setObjectName('Transparent_layout') |
318 | 136 | self.background_stack.addWidget(self.transparent_widget) | 136 | self.background_stack.addWidget(self.transparent_widget) |
319 | 137 | self.background_layout.addLayout(self.background_stack) | 137 | self.background_layout.addLayout(self.background_stack) |
320 | 138 | self.video_widget = QtWidgets.QWidget(self.background_page) | ||
321 | 139 | self.video_widget.setObjectName('video_widget') | ||
322 | 140 | self.video_layout = QtWidgets.QFormLayout(self.video_widget) | ||
323 | 141 | self.video_layout.setContentsMargins(0, 0, 0, 0) | ||
324 | 142 | self.video_layout.setObjectName('video_layout') | ||
325 | 143 | self.video_color_label = QtWidgets.QLabel(self.color_widget) | ||
326 | 144 | self.video_color_label.setObjectName('video_color_label') | ||
327 | 145 | self.video_color_button = ColorButton(self.color_widget) | ||
328 | 146 | self.video_color_button.setObjectName('video_color_button') | ||
329 | 147 | self.video_layout.addRow(self.video_color_label, self.video_color_button) | ||
330 | 148 | self.video_label = QtWidgets.QLabel(self.video_widget) | ||
331 | 149 | self.video_label.setObjectName('video_label') | ||
332 | 150 | self.video_file_layout = QtWidgets.QHBoxLayout() | ||
333 | 151 | self.video_file_layout.setObjectName('video_file_layout') | ||
334 | 152 | self.video_file_edit = QtWidgets.QLineEdit(self.video_widget) | ||
335 | 153 | self.video_file_edit.setObjectName('video_file_edit') | ||
336 | 154 | self.video_file_layout.addWidget(self.video_file_edit) | ||
337 | 155 | self.video_browse_button = QtWidgets.QToolButton(self.video_widget) | ||
338 | 156 | self.video_browse_button.setObjectName('video_browse_button') | ||
339 | 157 | self.video_browse_button.setIcon(build_icon(':/general/general_open.png')) | ||
340 | 158 | self.video_file_layout.addWidget(self.video_browse_button) | ||
341 | 159 | self.video_layout.addRow(self.video_label, self.video_file_layout) | ||
342 | 160 | self.video_layout.setItem(2, QtWidgets.QFormLayout.LabelRole, self.spacer) | ||
343 | 161 | self.background_stack.addWidget(self.video_widget) | ||
344 | 138 | theme_wizard.addPage(self.background_page) | 162 | theme_wizard.addPage(self.background_page) |
345 | 139 | # Main Area Page | 163 | # Main Area Page |
346 | 140 | self.main_area_page = QtWidgets.QWizardPage() | 164 | self.main_area_page = QtWidgets.QWizardPage() |
347 | @@ -390,11 +414,10 @@ | |||
348 | 390 | self.background_page.setSubTitle(translate('OpenLP.ThemeWizard', 'Set up your theme\'s background ' | 414 | self.background_page.setSubTitle(translate('OpenLP.ThemeWizard', 'Set up your theme\'s background ' |
349 | 391 | 'according to the parameters below.')) | 415 | 'according to the parameters below.')) |
350 | 392 | self.background_label.setText(translate('OpenLP.ThemeWizard', 'Background type:')) | 416 | self.background_label.setText(translate('OpenLP.ThemeWizard', 'Background type:')) |
355 | 393 | self.background_combo_box.setItemText(BackgroundType.Solid, | 417 | self.background_combo_box.setItemText(BackgroundType.Solid, translate('OpenLP.ThemeWizard', 'Solid color')) |
356 | 394 | translate('OpenLP.ThemeWizard', 'Solid color')) | 418 | self.background_combo_box.setItemText(BackgroundType.Gradient, translate('OpenLP.ThemeWizard', 'Gradient')) |
353 | 395 | self.background_combo_box.setItemText(BackgroundType.Gradient, | ||
354 | 396 | translate('OpenLP.ThemeWizard', 'Gradient')) | ||
357 | 397 | self.background_combo_box.setItemText(BackgroundType.Image, UiStrings().Image) | 419 | self.background_combo_box.setItemText(BackgroundType.Image, UiStrings().Image) |
358 | 420 | self.background_combo_box.setItemText(BackgroundType.Video, UiStrings().Video) | ||
359 | 398 | self.background_combo_box.setItemText(BackgroundType.Transparent, | 421 | self.background_combo_box.setItemText(BackgroundType.Transparent, |
360 | 399 | translate('OpenLP.ThemeWizard', 'Transparent')) | 422 | translate('OpenLP.ThemeWizard', 'Transparent')) |
361 | 400 | self.color_label.setText(translate('OpenLP.ThemeWizard', 'color:')) | 423 | self.color_label.setText(translate('OpenLP.ThemeWizard', 'color:')) |
362 | @@ -413,6 +436,8 @@ | |||
363 | 413 | translate('OpenLP.ThemeWizard', 'Bottom Left - Top Right')) | 436 | translate('OpenLP.ThemeWizard', 'Bottom Left - Top Right')) |
364 | 414 | self.image_color_label.setText(translate('OpenLP.ThemeWizard', 'Background color:')) | 437 | self.image_color_label.setText(translate('OpenLP.ThemeWizard', 'Background color:')) |
365 | 415 | self.image_label.setText('%s:' % UiStrings().Image) | 438 | self.image_label.setText('%s:' % UiStrings().Image) |
366 | 439 | self.video_color_label.setText(translate('OpenLP.ThemeWizard', 'Background color:')) | ||
367 | 440 | self.video_label.setText('%s:' % UiStrings().Video) | ||
368 | 416 | self.main_area_page.setTitle(translate('OpenLP.ThemeWizard', 'Main Area Font Details')) | 441 | self.main_area_page.setTitle(translate('OpenLP.ThemeWizard', 'Main Area Font Details')) |
369 | 417 | self.main_area_page.setSubTitle(translate('OpenLP.ThemeWizard', 'Define the font and display ' | 442 | self.main_area_page.setSubTitle(translate('OpenLP.ThemeWizard', 'Define the font and display ' |
370 | 418 | 'characteristics for the Display text')) | 443 | 'characteristics for the Display text')) |
371 | 419 | 444 | ||
372 | === modified file 'scripts/translation_utils.py' | |||
373 | --- scripts/translation_utils.py 2015-12-31 22:46:06 +0000 | |||
374 | +++ scripts/translation_utils.py 2016-04-30 17:20:12 +0000 | |||
375 | @@ -60,7 +60,7 @@ | |||
376 | 60 | from PyQt5 import QtCore | 60 | from PyQt5 import QtCore |
377 | 61 | from lxml import etree, objectify | 61 | from lxml import etree, objectify |
378 | 62 | 62 | ||
380 | 63 | SERVER_URL = 'http://www.transifex.net/api/2/project/openlp/resource/openlp-24x/' | 63 | SERVER_URL = 'http://www.transifex.net/api/2/project/openlp/resource/openlp-26x/' |
381 | 64 | IGNORED_PATHS = ['scripts'] | 64 | IGNORED_PATHS = ['scripts'] |
382 | 65 | IGNORED_FILES = ['setup.py'] | 65 | IGNORED_FILES = ['setup.py'] |
383 | 66 | 66 | ||
384 | @@ -270,7 +270,7 @@ | |||
385 | 270 | return | 270 | return |
386 | 271 | else: | 271 | else: |
387 | 272 | os.chdir(os.path.abspath('..')) | 272 | os.chdir(os.path.abspath('..')) |
389 | 273 | run('pylupdate4 -verbose -noobsolete openlp.pro') | 273 | run('pylupdate5 -verbose -noobsolete openlp.pro') |
390 | 274 | os.chdir(os.path.abspath('scripts')) | 274 | os.chdir(os.path.abspath('scripts')) |
391 | 275 | 275 | ||
392 | 276 | 276 | ||
393 | 277 | 277 | ||
394 | === modified file 'tests/functional/openlp_core_ui/test_maindisplay.py' | |||
395 | --- tests/functional/openlp_core_ui/test_maindisplay.py 2016-03-31 20:35:04 +0000 | |||
396 | +++ tests/functional/openlp_core_ui/test_maindisplay.py 2016-04-30 17:20:12 +0000 | |||
397 | @@ -27,8 +27,9 @@ | |||
398 | 27 | from PyQt5 import QtCore | 27 | from PyQt5 import QtCore |
399 | 28 | 28 | ||
400 | 29 | from openlp.core.common import Registry, is_macosx, Settings | 29 | from openlp.core.common import Registry, is_macosx, Settings |
402 | 30 | from openlp.core.lib import ScreenList | 30 | from openlp.core.lib import ScreenList, PluginManager |
403 | 31 | from openlp.core.ui import MainDisplay | 31 | from openlp.core.ui import MainDisplay |
404 | 32 | from openlp.core.ui.media import MediaController | ||
405 | 32 | from openlp.core.ui.maindisplay import TRANSPARENT_STYLESHEET, OPAQUE_STYLESHEET | 33 | from openlp.core.ui.maindisplay import TRANSPARENT_STYLESHEET, OPAQUE_STYLESHEET |
406 | 33 | 34 | ||
407 | 34 | from tests.helpers.testmixin import TestMixin | 35 | from tests.helpers.testmixin import TestMixin |
408 | @@ -223,3 +224,61 @@ | |||
409 | 223 | 224 | ||
410 | 224 | # THEN: setVisible should had not been called | 225 | # THEN: setVisible should had not been called |
411 | 225 | main_display.setVisible.assert_not_called() | 226 | main_display.setVisible.assert_not_called() |
412 | 227 | |||
413 | 228 | @patch(u'openlp.core.ui.maindisplay.Settings') | ||
414 | 229 | @patch(u'openlp.core.ui.maindisplay.build_html') | ||
415 | 230 | def build_html_no_video_test(self, MockedSettings, Mocked_build_html): | ||
416 | 231 | # GIVEN: Mocked display | ||
417 | 232 | display = MagicMock() | ||
418 | 233 | mocked_media_controller = MagicMock() | ||
419 | 234 | Registry.create() | ||
420 | 235 | Registry().register('media_controller', mocked_media_controller) | ||
421 | 236 | main_display = MainDisplay(display) | ||
422 | 237 | main_display.frame = MagicMock() | ||
423 | 238 | mocked_settings = MagicMock() | ||
424 | 239 | mocked_settings.value.return_value = False | ||
425 | 240 | MockedSettings.return_value = mocked_settings | ||
426 | 241 | main_display.shake_web_view = MagicMock() | ||
427 | 242 | service_item = MagicMock() | ||
428 | 243 | mocked_plugin = MagicMock() | ||
429 | 244 | display.plugin_manager = PluginManager() | ||
430 | 245 | display.plugin_manager.plugins = [mocked_plugin] | ||
431 | 246 | main_display.web_view = MagicMock() | ||
432 | 247 | |||
433 | 248 | # WHEN: build_html is called with a normal service item and a non video theme. | ||
434 | 249 | main_display.build_html(service_item) | ||
435 | 250 | |||
436 | 251 | # THEN: the following should had not been called | ||
437 | 252 | self.assertEquals(main_display.web_view.setHtml.call_count, 1, 'setHTML should be called once') | ||
438 | 253 | self.assertEquals(main_display.media_controller.video.call_count, 0, | ||
439 | 254 | 'Media Controller video should not have been called') | ||
440 | 255 | |||
441 | 256 | @patch(u'openlp.core.ui.maindisplay.Settings') | ||
442 | 257 | @patch(u'openlp.core.ui.maindisplay.build_html') | ||
443 | 258 | def build_html_video_test(self, MockedSettings, Mocked_build_html): | ||
444 | 259 | # GIVEN: Mocked display | ||
445 | 260 | display = MagicMock() | ||
446 | 261 | mocked_media_controller = MagicMock() | ||
447 | 262 | Registry.create() | ||
448 | 263 | Registry().register('media_controller', mocked_media_controller) | ||
449 | 264 | main_display = MainDisplay(display) | ||
450 | 265 | main_display.frame = MagicMock() | ||
451 | 266 | mocked_settings = MagicMock() | ||
452 | 267 | mocked_settings.value.return_value = False | ||
453 | 268 | MockedSettings.return_value = mocked_settings | ||
454 | 269 | main_display.shake_web_view = MagicMock() | ||
455 | 270 | service_item = MagicMock() | ||
456 | 271 | service_item.theme_data = MagicMock() | ||
457 | 272 | service_item.theme_data.background_type = 'video' | ||
458 | 273 | mocked_plugin = MagicMock() | ||
459 | 274 | display.plugin_manager = PluginManager() | ||
460 | 275 | display.plugin_manager.plugins = [mocked_plugin] | ||
461 | 276 | main_display.web_view = MagicMock() | ||
462 | 277 | |||
463 | 278 | # WHEN: build_html is called with a normal service item and a video theme. | ||
464 | 279 | main_display.build_html(service_item) | ||
465 | 280 | |||
466 | 281 | # THEN: the following should had not been called | ||
467 | 282 | self.assertEquals(main_display.web_view.setHtml.call_count, 1, 'setHTML should be called once') | ||
468 | 283 | self.assertEquals(main_display.media_controller.video.call_count, 1, | ||
469 | 284 | 'Media Controller video should have been called once') |