Merge lp:~meths/openlp/trivialfixes into lp:openlp
- trivialfixes
- Merge into trunk
Proposed by
Jon Tibble
Status: | Merged |
---|---|
Merged at revision: | not available |
Proposed branch: | lp:~meths/openlp/trivialfixes |
Merge into: | lp:openlp |
Diff against target: | None lines |
To merge this branch: | bzr merge lp:~meths/openlp/trivialfixes |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Raoul Snyman | Approve | ||
Review via email:
|
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Jon Tibble (meths) wrote : | # |
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Raoul Snyman (raoul-snyman) : | # |
review:
Approve
lp:~meths/openlp/trivialfixes
updated
- 557. By Jon Tibble
-
Refactor services
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'openlp/core/lib/serviceitem.py' | |||
2 | --- openlp/core/lib/serviceitem.py 2009-09-16 04:59:38 +0000 | |||
3 | +++ openlp/core/lib/serviceitem.py 2009-09-19 21:45:50 +0000 | |||
4 | @@ -174,12 +174,12 @@ | |||
5 | 174 | self.service_item_path = path | 174 | self.service_item_path = path |
6 | 175 | self.service_frames.append({u'title': frame_title, u'command': None}) | 175 | self.service_frames.append({u'title': frame_title, u'command': None}) |
7 | 176 | 176 | ||
9 | 177 | def get_oos_repr(self): | 177 | def get_service_repr(self): |
10 | 178 | """ | 178 | """ |
12 | 179 | This method returns some text which can be saved into the OOS | 179 | This method returns some text which can be saved into the service |
13 | 180 | file to represent this item. | 180 | file to represent this item. |
14 | 181 | """ | 181 | """ |
16 | 182 | oos_header = { | 182 | service_header = { |
17 | 183 | u'name': self.name.lower(), | 183 | u'name': self.name.lower(), |
18 | 184 | u'plugin': self.shortname, | 184 | u'plugin': self.shortname, |
19 | 185 | u'theme':self.theme, | 185 | u'theme':self.theme, |
20 | @@ -189,19 +189,19 @@ | |||
21 | 189 | u'type':self.service_item_type, | 189 | u'type':self.service_item_type, |
22 | 190 | u'audit':self.audit | 190 | u'audit':self.audit |
23 | 191 | } | 191 | } |
25 | 192 | oos_data = [] | 192 | service_data = [] |
26 | 193 | if self.service_item_type == ServiceType.Text: | 193 | if self.service_item_type == ServiceType.Text: |
27 | 194 | for slide in self.service_frames: | 194 | for slide in self.service_frames: |
29 | 195 | oos_data.append(slide) | 195 | service_data.append(slide) |
30 | 196 | elif self.service_item_type == ServiceType.Image: | 196 | elif self.service_item_type == ServiceType.Image: |
31 | 197 | for slide in self.service_frames: | 197 | for slide in self.service_frames: |
33 | 198 | oos_data.append(slide[u'title']) | 198 | service_data.append(slide[u'title']) |
34 | 199 | elif self.service_item_type == ServiceType.Command: | 199 | elif self.service_item_type == ServiceType.Command: |
35 | 200 | for slide in self.service_frames: | 200 | for slide in self.service_frames: |
38 | 201 | oos_data.append(slide[u'title']) | 201 | service_data.append(slide[u'title']) |
39 | 202 | return {u'header': oos_header, u'data': oos_data} | 202 | return {u'header': service_header, u'data': service_data} |
40 | 203 | 203 | ||
42 | 204 | def set_from_oos(self, serviceitem, path=None): | 204 | def set_from_service(self, serviceitem, path=None): |
43 | 205 | """ | 205 | """ |
44 | 206 | This method takes a service item from a saved service file (passed | 206 | This method takes a service item from a saved service file (passed |
45 | 207 | from the ServiceManager) and extracts the data actually required. | 207 | from the ServiceManager) and extracts the data actually required. |
46 | 208 | 208 | ||
47 | === modified file 'openlp/core/ui/mainwindow.py' | |||
48 | --- openlp/core/ui/mainwindow.py 2009-09-19 11:25:01 +0000 | |||
49 | +++ openlp/core/ui/mainwindow.py 2009-09-19 21:45:50 +0000 | |||
50 | @@ -453,7 +453,7 @@ | |||
51 | 453 | QtGui.QMainWindow.__init__(self) | 453 | QtGui.QMainWindow.__init__(self) |
52 | 454 | self.closeEvent = self.onCloseEvent | 454 | self.closeEvent = self.onCloseEvent |
53 | 455 | self.screenList = screens | 455 | self.screenList = screens |
55 | 456 | self.oosNotSaved = False | 456 | self.serviceNotSaved = False |
56 | 457 | self.settingsmanager = SettingsManager(screens) | 457 | self.settingsmanager = SettingsManager(screens) |
57 | 458 | self.mainDisplay = MainDisplay(self, screens) | 458 | self.mainDisplay = MainDisplay(self, screens) |
58 | 459 | self.generalConfig = PluginConfig(u'General') | 459 | self.generalConfig = PluginConfig(u'General') |
59 | @@ -535,8 +535,8 @@ | |||
60 | 535 | self.plugin_helpers[u'service'] = self.ServiceManagerContents | 535 | self.plugin_helpers[u'service'] = self.ServiceManagerContents |
61 | 536 | self.plugin_helpers[u'settings'] = self.settingsForm | 536 | self.plugin_helpers[u'settings'] = self.settingsForm |
62 | 537 | self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers) | 537 | self.plugin_manager.find_plugins(pluginpath, self.plugin_helpers) |
65 | 538 | # hook methods have to happen after find_plugins. Find plugins needs the | 538 | # hook methods have to happen after find_plugins. Find plugins needs |
66 | 539 | # controllers hence the hooks have moved from setupUI() to here | 539 | # the controllers hence the hooks have moved from setupUI() to here |
67 | 540 | # Find and insert settings tabs | 540 | # Find and insert settings tabs |
68 | 541 | log.info(u'hook settings') | 541 | log.info(u'hook settings') |
69 | 542 | self.plugin_manager.hook_settings_tabs(self.settingsForm) | 542 | self.plugin_manager.hook_settings_tabs(self.settingsForm) |
70 | @@ -617,10 +617,10 @@ | |||
71 | 617 | """ | 617 | """ |
72 | 618 | Hook to close the main window and display windows on exit | 618 | Hook to close the main window and display windows on exit |
73 | 619 | """ | 619 | """ |
75 | 620 | if self.oosNotSaved == True: | 620 | if self.serviceNotSaved == True: |
76 | 621 | ret = QtGui.QMessageBox.question(None, | 621 | ret = QtGui.QMessageBox.question(None, |
77 | 622 | translate(u'mainWindow', u'Save Changes to Service?'), | 622 | translate(u'mainWindow', u'Save Changes to Service?'), |
79 | 623 | translate(u'mainWindow', u'Your service has been changed, do you want to save those changes?'), | 623 | translate(u'mainWindow', u'Your service has changed, do you want to save those changes?'), |
80 | 624 | QtGui.QMessageBox.StandardButtons( | 624 | QtGui.QMessageBox.StandardButtons( |
81 | 625 | QtGui.QMessageBox.Cancel | | 625 | QtGui.QMessageBox.Cancel | |
82 | 626 | QtGui.QMessageBox.Discard | | 626 | QtGui.QMessageBox.Discard | |
83 | @@ -629,16 +629,19 @@ | |||
84 | 629 | if ret == QtGui.QMessageBox.Save: | 629 | if ret == QtGui.QMessageBox.Save: |
85 | 630 | self.ServiceManagerContents.onSaveService() | 630 | self.ServiceManagerContents.onSaveService() |
86 | 631 | self.mainDisplay.close() | 631 | self.mainDisplay.close() |
87 | 632 | self.ServiceManagerContents.cleanUp() | ||
88 | 632 | self.cleanUp() | 633 | self.cleanUp() |
89 | 633 | event.accept() | 634 | event.accept() |
90 | 634 | elif ret == QtGui.QMessageBox.Discard: | 635 | elif ret == QtGui.QMessageBox.Discard: |
91 | 635 | self.mainDisplay.close() | 636 | self.mainDisplay.close() |
92 | 637 | self.ServiceManagerContents.cleanUp() | ||
93 | 636 | self.cleanUp() | 638 | self.cleanUp() |
94 | 637 | event.accept() | 639 | event.accept() |
95 | 638 | else: | 640 | else: |
96 | 639 | event.ignore() | 641 | event.ignore() |
97 | 640 | else: | 642 | else: |
98 | 641 | self.mainDisplay.close() | 643 | self.mainDisplay.close() |
99 | 644 | self.ServiceManagerContents.cleanUp() | ||
100 | 642 | self.cleanUp() | 645 | self.cleanUp() |
101 | 643 | event.accept() | 646 | event.accept() |
102 | 644 | 647 | ||
103 | @@ -647,21 +650,25 @@ | |||
104 | 647 | log.info(u'cleanup plugins') | 650 | log.info(u'cleanup plugins') |
105 | 648 | self.plugin_manager.finalise_plugins() | 651 | self.plugin_manager.finalise_plugins() |
106 | 649 | 652 | ||
114 | 650 | def OosChanged(self, reset=False, oosName=None): | 653 | def serviceChanged(self, reset=False, serviceName=None): |
115 | 651 | """ | 654 | """ |
116 | 652 | Hook to change the title if the OOS has been changed | 655 | Hook to change the main window title when the service changes |
117 | 653 | reset - tells if the OOS has been cleared or saved | 656 | |
118 | 654 | oosName - is the name of the OOS (if it has one) | 657 | ``reset`` |
119 | 655 | """ | 658 | Shows if the service has been cleared or saved |
120 | 656 | if not oosName: | 659 | |
121 | 660 | ``serviceName`` | ||
122 | 661 | The name of the service (if it has one) | ||
123 | 662 | """ | ||
124 | 663 | if not serviceName: | ||
125 | 657 | service_name = u'(unsaved service)' | 664 | service_name = u'(unsaved service)' |
126 | 658 | else: | 665 | else: |
128 | 659 | service_name = oosName | 666 | service_name = serviceName |
129 | 660 | if reset == True: | 667 | if reset == True: |
131 | 661 | self.oosNotSaved = False | 668 | self.serviceNotSaved = False |
132 | 662 | title = u'%s - %s' % (self.mainTitle, service_name) | 669 | title = u'%s - %s' % (self.mainTitle, service_name) |
133 | 663 | else: | 670 | else: |
135 | 664 | self.oosNotSaved = True | 671 | self.serviceNotSaved = True |
136 | 665 | title = u'%s - %s*' % (self.mainTitle, service_name) | 672 | title = u'%s - %s*' % (self.mainTitle, service_name) |
137 | 666 | self.setWindowTitle(title) | 673 | self.setWindowTitle(title) |
138 | 667 | 674 | ||
139 | 668 | 675 | ||
140 | === modified file 'openlp/core/ui/servicemanager.py' | |||
141 | --- openlp/core/ui/servicemanager.py 2009-09-19 19:37:01 +0000 | |||
142 | +++ openlp/core/ui/servicemanager.py 2009-09-19 21:45:50 +0000 | |||
143 | @@ -84,10 +84,9 @@ | |||
144 | 84 | 84 | ||
145 | 85 | class ServiceManager(QtGui.QWidget): | 85 | class ServiceManager(QtGui.QWidget): |
146 | 86 | """ | 86 | """ |
151 | 87 | Manages the orders of service. Currently this involves taking | 87 | Manages the services. This involves taking text strings from plugins and |
152 | 88 | text strings from plugins and adding them to an OOS file. In | 88 | adding them to the service. This service can then be zipped up with all |
153 | 89 | future, it will also handle zipping up all the resources used into | 89 | the resources used into one OSZ file for use on any OpenLP v2 installation. |
150 | 90 | one lump. | ||
154 | 91 | Also handles the UI tasks of moving things up and down etc. | 90 | Also handles the UI tasks of moving things up and down etc. |
155 | 92 | """ | 91 | """ |
156 | 93 | global log | 92 | global log |
157 | @@ -274,7 +273,7 @@ | |||
158 | 274 | self.serviceItems.remove(self.serviceItems[item]) | 273 | self.serviceItems.remove(self.serviceItems[item]) |
159 | 275 | self.serviceItems.insert(0, temp) | 274 | self.serviceItems.insert(0, temp) |
160 | 276 | self.repaintServiceList(0, count) | 275 | self.repaintServiceList(0, count) |
162 | 277 | self.parent.OosChanged(False, self.serviceName) | 276 | self.parent.serviceChanged(False, self.serviceName) |
163 | 278 | 277 | ||
164 | 279 | def onServiceUp(self): | 278 | def onServiceUp(self): |
165 | 280 | """ | 279 | """ |
166 | @@ -287,7 +286,7 @@ | |||
167 | 287 | self.serviceItems.remove(self.serviceItems[item]) | 286 | self.serviceItems.remove(self.serviceItems[item]) |
168 | 288 | self.serviceItems.insert(item - 1, temp) | 287 | self.serviceItems.insert(item - 1, temp) |
169 | 289 | self.repaintServiceList(item - 1, count) | 288 | self.repaintServiceList(item - 1, count) |
171 | 290 | self.parent.OosChanged(False, self.serviceName) | 289 | self.parent.serviceChanged(False, self.serviceName) |
172 | 291 | 290 | ||
173 | 292 | def onServiceDown(self): | 291 | def onServiceDown(self): |
174 | 293 | """ | 292 | """ |
175 | @@ -300,7 +299,7 @@ | |||
176 | 300 | self.serviceItems.remove(self.serviceItems[item]) | 299 | self.serviceItems.remove(self.serviceItems[item]) |
177 | 301 | self.serviceItems.insert(item + 1, temp) | 300 | self.serviceItems.insert(item + 1, temp) |
178 | 302 | self.repaintServiceList(item + 1, count) | 301 | self.repaintServiceList(item + 1, count) |
180 | 303 | self.parent.OosChanged(False, self.serviceName) | 302 | self.parent.serviceChanged(False, self.serviceName) |
181 | 304 | 303 | ||
182 | 305 | def onServiceEnd(self): | 304 | def onServiceEnd(self): |
183 | 306 | """ | 305 | """ |
184 | @@ -312,7 +311,7 @@ | |||
185 | 312 | self.serviceItems.remove(self.serviceItems[item]) | 311 | self.serviceItems.remove(self.serviceItems[item]) |
186 | 313 | self.serviceItems.insert(len(self.serviceItems), temp) | 312 | self.serviceItems.insert(len(self.serviceItems), temp) |
187 | 314 | self.repaintServiceList(len(self.serviceItems) - 1, count) | 313 | self.repaintServiceList(len(self.serviceItems) - 1, count) |
189 | 315 | self.parent.OosChanged(False, self.serviceName) | 314 | self.parent.serviceChanged(False, self.serviceName) |
190 | 316 | 315 | ||
191 | 317 | def onNewService(self): | 316 | def onNewService(self): |
192 | 318 | """ | 317 | """ |
193 | @@ -322,7 +321,7 @@ | |||
194 | 322 | self.serviceItems = [] | 321 | self.serviceItems = [] |
195 | 323 | self.serviceName = u'' | 322 | self.serviceName = u'' |
196 | 324 | self.isNew = True | 323 | self.isNew = True |
198 | 325 | self.parent.OosChanged(True, self.serviceName) | 324 | self.parent.serviceChanged(True, self.serviceName) |
199 | 326 | 325 | ||
200 | 327 | def onDeleteFromService(self): | 326 | def onDeleteFromService(self): |
201 | 328 | """ | 327 | """ |
202 | @@ -332,9 +331,9 @@ | |||
203 | 332 | if item is not -1: | 331 | if item is not -1: |
204 | 333 | self.serviceItems.remove(self.serviceItems[item]) | 332 | self.serviceItems.remove(self.serviceItems[item]) |
205 | 334 | self.repaintServiceList(0, 0) | 333 | self.repaintServiceList(0, 0) |
207 | 335 | self.parent.OosChanged(False, self.serviceName) | 334 | self.parent.serviceChanged(False, self.serviceName) |
208 | 336 | 335 | ||
210 | 337 | def repaintServiceList(self, serviceItem, serviceItemCount): | 336 | def repaintServiceList(self, serviceItem, serviceItemCount): |
211 | 338 | """ | 337 | """ |
212 | 339 | Clear the existing service list and prepaint all the items | 338 | Clear the existing service list and prepaint all the items |
213 | 340 | Used when moving items as the move takes place in supporting array, | 339 | Used when moving items as the move takes place in supporting array, |
214 | @@ -366,28 +365,29 @@ | |||
215 | 366 | 365 | ||
216 | 367 | def onSaveService(self, quick=False): | 366 | def onSaveService(self, quick=False): |
217 | 368 | """ | 367 | """ |
219 | 369 | Save the current service in a zip file | 368 | Save the current service in a zip (OSZ) file |
220 | 370 | This file contains | 369 | This file contains |
222 | 371 | * An ood which is a pickle of the service items | 370 | * An osd which is a pickle of the service items |
223 | 372 | * All image, presentation and video files needed to run the service. | 371 | * All image, presentation and video files needed to run the service. |
224 | 373 | """ | 372 | """ |
225 | 374 | if not quick or self.isNew: | 373 | if not quick or self.isNew: |
226 | 375 | filename = QtGui.QFileDialog.getSaveFileName(self, | 374 | filename = QtGui.QFileDialog.getSaveFileName(self, |
228 | 376 | u'Save Order of Service',self.config.get_last_dir() ) | 375 | u'Save Service', self.config.get_last_dir()) |
229 | 377 | else: | 376 | else: |
230 | 378 | filename = self.config.get_last_dir() | 377 | filename = self.config.get_last_dir() |
231 | 379 | if filename != u'': | 378 | if filename != u'': |
232 | 380 | splittedFile = filename.split(u'.') | 379 | splittedFile = filename.split(u'.') |
235 | 381 | if splittedFile[-1] != u'oos': | 380 | if splittedFile[-1] != u'osz': |
236 | 382 | filename = filename + u'.oos' | 381 | filename = filename + u'.osz' |
237 | 383 | filename = unicode(filename) | 382 | filename = unicode(filename) |
238 | 384 | self.isNew = False | 383 | self.isNew = False |
239 | 385 | self.config.set_last_dir(filename) | 384 | self.config.set_last_dir(filename) |
240 | 386 | service = [] | 385 | service = [] |
242 | 387 | servicefile= filename + u'.ood' | 386 | servicefile = filename + u'.osd' |
243 | 388 | zip = zipfile.ZipFile(unicode(filename), 'w') | 387 | zip = zipfile.ZipFile(unicode(filename), 'w') |
244 | 389 | for item in self.serviceItems: | 388 | for item in self.serviceItems: |
246 | 390 | service.append({u'serviceitem':item[u'data'].get_oos_repr()}) | 389 | service.append( |
247 | 390 | {u'serviceitem':item[u'data'].get_service_repr()}) | ||
248 | 391 | if item[u'data'].service_item_type == ServiceType.Image or \ | 391 | if item[u'data'].service_item_type == ServiceType.Image or \ |
249 | 392 | item[u'data'].service_item_type == ServiceType.Command: | 392 | item[u'data'].service_item_type == ServiceType.Command: |
250 | 393 | for frame in item[u'data'].frames: | 393 | for frame in item[u'data'].frames: |
251 | @@ -405,20 +405,19 @@ | |||
252 | 405 | pass #if not present do not worry | 405 | pass #if not present do not worry |
253 | 406 | name = filename.split(os.path.sep) | 406 | name = filename.split(os.path.sep) |
254 | 407 | self.serviceName = name[-1] | 407 | self.serviceName = name[-1] |
256 | 408 | self.parent.OosChanged(True, self.serviceName) | 408 | self.parent.serviceChanged(True, self.serviceName) |
257 | 409 | 409 | ||
258 | 410 | def onQuickSaveService(self): | 410 | def onQuickSaveService(self): |
259 | 411 | self.onSaveService(True) | 411 | self.onSaveService(True) |
260 | 412 | 412 | ||
261 | 413 | def onLoadService(self): | 413 | def onLoadService(self): |
262 | 414 | """ | 414 | """ |
266 | 415 | Load an existing service from disk and rebuilds the serviceitems | 415 | Load an existing service from disk and rebuild the serviceitems. All |
267 | 416 | All files retrieved from the zip file are placed in a temporary | 416 | files retrieved from the zip file are placed in a temporary directory |
268 | 417 | directory and will only be used for this service. | 417 | and will only be used for this service. |
269 | 418 | """ | 418 | """ |
273 | 419 | filename = QtGui.QFileDialog.getOpenFileName(self, | 419 | filename = QtGui.QFileDialog.getOpenFileName(self, u'Open Service', |
274 | 420 | u'Open Order of Service', self.config.get_last_dir(), | 420 | self.config.get_last_dir(), u'Services (*.osz)') |
272 | 421 | u'Services (*.oos)') | ||
275 | 422 | filename = unicode(filename) | 421 | filename = unicode(filename) |
276 | 423 | name = filename.split(os.path.sep) | 422 | name = filename.split(os.path.sep) |
277 | 424 | if filename != u'': | 423 | if filename != u'': |
278 | @@ -439,7 +438,7 @@ | |||
279 | 439 | f.write(zip.read(file)) | 438 | f.write(zip.read(file)) |
280 | 440 | f.flush() | 439 | f.flush() |
281 | 441 | f.close() | 440 | f.close() |
283 | 442 | if file_to.endswith(u'ood'): | 441 | if file_to.endswith(u'osd'): |
284 | 443 | p_file = file_to | 442 | p_file = file_to |
285 | 444 | f = open(p_file, u'r') | 443 | f = open(p_file, u'r') |
286 | 445 | items = cPickle.load(f) | 444 | items = cPickle.load(f) |
287 | @@ -448,17 +447,30 @@ | |||
288 | 448 | for item in items: | 447 | for item in items: |
289 | 449 | serviceitem = ServiceItem() | 448 | serviceitem = ServiceItem() |
290 | 450 | serviceitem.RenderManager = self.parent.RenderManager | 449 | serviceitem.RenderManager = self.parent.RenderManager |
292 | 451 | serviceitem.set_from_oos(item, self.servicePath ) | 450 | serviceitem.set_from_service(item, self.servicePath ) |
293 | 452 | self.addServiceItem(serviceitem) | 451 | self.addServiceItem(serviceitem) |
294 | 453 | try: | 452 | try: |
296 | 454 | os.remove(p_file) | 453 | if os.path.isfile(p_file): |
297 | 454 | os.remove(p_file) | ||
298 | 455 | except: | 455 | except: |
300 | 456 | log.exception(u'Failed to remove ood file') | 456 | log.exception(u'Failed to remove osd file') |
301 | 457 | except: | 457 | except: |
302 | 458 | log.exception(u'Problem loading a service file') | 458 | log.exception(u'Problem loading a service file') |
303 | 459 | self.isNew = False | 459 | self.isNew = False |
304 | 460 | self.serviceName = name[len(name) - 1] | 460 | self.serviceName = name[len(name) - 1] |
306 | 461 | self.parent.OosChanged(True, self.serviceName) | 461 | self.parent.serviceChanged(True, self.serviceName) |
307 | 462 | |||
308 | 463 | def cleanUp(self): | ||
309 | 464 | """ | ||
310 | 465 | Empties the servicePath of temporary files | ||
311 | 466 | """ | ||
312 | 467 | for file in os.listdir(self.servicePath): | ||
313 | 468 | file_path = os.path.join(self.servicePath, file) | ||
314 | 469 | try: | ||
315 | 470 | if os.path.isfile(file_path): | ||
316 | 471 | os.remove(file_path) | ||
317 | 472 | except: | ||
318 | 473 | log.exception(u'Failed to clean up servicePath') | ||
319 | 462 | 474 | ||
320 | 463 | def onThemeComboBoxSelected(self, currentIndex): | 475 | def onThemeComboBoxSelected(self, currentIndex): |
321 | 464 | """ | 476 | """ |
322 | @@ -501,7 +513,7 @@ | |||
323 | 501 | treewidgetitem1.setData(0, QtCore.Qt.UserRole, | 513 | treewidgetitem1.setData(0, QtCore.Qt.UserRole, |
324 | 502 | QtCore.QVariant(count)) | 514 | QtCore.QVariant(count)) |
325 | 503 | count = count + 1 | 515 | count = count + 1 |
327 | 504 | self.parent.OosChanged(False, self.serviceName) | 516 | self.parent.serviceChanged(False, self.serviceName) |
328 | 505 | 517 | ||
329 | 506 | def makePreview(self): | 518 | def makePreview(self): |
330 | 507 | """ | 519 | """ |
331 | 508 | 520 | ||
332 | === modified file 'openlp/core/ui/test/test_service_manager.py' | |||
333 | --- openlp/core/ui/test/test_service_manager.py 2009-09-06 13:57:32 +0000 | |||
334 | +++ openlp/core/ui/test/test_service_manager.py 2009-09-19 21:45:50 +0000 | |||
335 | @@ -19,15 +19,17 @@ | |||
336 | 19 | import time | 19 | import time |
337 | 20 | import sys | 20 | import sys |
338 | 21 | import os, os.path | 21 | import os, os.path |
339 | 22 | import logging | ||
340 | 22 | from PyQt4 import QtGui, QtCore | 23 | from PyQt4 import QtGui, QtCore |
341 | 23 | from PyQt4.QtCore import * | 24 | from PyQt4.QtCore import * |
342 | 24 | from PyQt4.QtGui import * | 25 | from PyQt4.QtGui import * |
345 | 25 | mypath=os.path.split(os.path.abspath(__file__))[0] | 26 | |
346 | 26 | sys.path.insert(0,(os.path.join(mypath, '..','..', '..','..'))) | 27 | mypath = os.path.split(os.path.abspath(__file__))[0] |
347 | 28 | sys.path.insert(0, (os.path.join(mypath, '..', '..', '..', '..'))) | ||
348 | 29 | |||
349 | 27 | from openlp.core.ui import ServiceManager | 30 | from openlp.core.ui import ServiceManager |
350 | 28 | from openlp.plugins.images.lib import ImageServiceItem | 31 | from openlp.plugins.images.lib import ImageServiceItem |
351 | 29 | 32 | ||
352 | 30 | import logging | ||
353 | 31 | logging.basicConfig(filename='test_service_manager.log', level=logging.INFO, | 33 | logging.basicConfig(filename='test_service_manager.log', level=logging.INFO, |
354 | 32 | filemode='w') | 34 | filemode='w') |
355 | 33 | 35 | ||
356 | @@ -36,69 +38,72 @@ | |||
357 | 36 | # return sys._getframe(depth).f_code.co_name | 38 | # return sys._getframe(depth).f_code.co_name |
358 | 37 | global app | 39 | global app |
359 | 38 | global log | 40 | global log |
361 | 39 | log=logging.getLogger(u'TestServiceManager') | 41 | log = logging.getLogger(u'TestServiceManager') |
362 | 42 | |||
363 | 40 | class TestServiceManager_base: | 43 | class TestServiceManager_base: |
364 | 41 | def __init__(self): | 44 | def __init__(self): |
365 | 42 | pass | 45 | pass |
366 | 43 | 46 | ||
367 | 44 | def setup_class(self): | 47 | def setup_class(self): |
369 | 45 | log.info( "class setup"+unicode(self)) | 48 | log.info( "class setup" + unicode(self)) |
370 | 46 | try: | 49 | try: |
371 | 47 | if app is None: | 50 | if app is None: |
372 | 48 | app = QtGui.QApplication([]) | 51 | app = QtGui.QApplication([]) |
373 | 49 | except UnboundLocalError: | 52 | except UnboundLocalError: |
374 | 50 | app = QtGui.QApplication([]) | 53 | app = QtGui.QApplication([]) |
375 | 51 | 54 | ||
376 | 52 | |||
377 | 53 | def teardown_class(self): | 55 | def teardown_class(self): |
378 | 54 | pass | 56 | pass |
379 | 55 | 57 | ||
380 | 56 | def setup_method(self, method): | 58 | def setup_method(self, method): |
381 | 57 | log.info(u'Setup method:' + unicode(method)) | 59 | log.info(u'Setup method:' + unicode(method)) |
385 | 58 | self.expected_answer="Don't know yet" | 60 | self.expected_answer = "Don't know yet" |
386 | 59 | self.answer=None | 61 | self.answer = None |
387 | 60 | self.s=ServiceManager(None) | 62 | self.s = ServiceManager(None) |
388 | 61 | log.info(u'--------------- Setup Done -------------') | 63 | log.info(u'--------------- Setup Done -------------') |
389 | 62 | 64 | ||
390 | 63 | def teardown_method(self, method): | 65 | def teardown_method(self, method): |
392 | 64 | self.s=None | 66 | self.s = None |
393 | 65 | 67 | ||
394 | 66 | def select_row(self, row): | 68 | def select_row(self, row): |
395 | 67 | # now select the line we just added | 69 | # now select the line we just added |
396 | 68 | # first get the index | 70 | # first get the index |
398 | 69 | i=QModelIndex(self.s.service_data.index(0,0)) | 71 | i = QModelIndex(self.s.service_data.index(0,0)) |
399 | 70 | # make a selection of it | 72 | # make a selection of it |
401 | 71 | self.sm=QItemSelectionModel(self.s.service_data) | 73 | self.sm = QItemSelectionModel(self.s.service_data) |
402 | 72 | self.sm.select(i, QItemSelectionModel.ClearAndSelect) | 74 | self.sm.select(i, QItemSelectionModel.ClearAndSelect) |
403 | 73 | log.info(unicode(self.sm.selectedIndexes())) | 75 | log.info(unicode(self.sm.selectedIndexes())) |
404 | 74 | self.s.TreeView.setSelectionModel(self.sm) | 76 | self.s.TreeView.setSelectionModel(self.sm) |
406 | 75 | log.info(u'Selected indexes = ' + unicode(self.s.TreeView.selectedIndexes())) | 77 | log.info(u'Selected indexes = ' + unicode( |
407 | 78 | self.s.TreeView.selectedIndexes())) | ||
408 | 79 | |||
409 | 76 | def test_easy(self): | 80 | def test_easy(self): |
410 | 77 | log.info(u'test_easy') | 81 | log.info(u'test_easy') |
412 | 78 | item=ImageServiceItem(None) | 82 | item = ImageServiceItem(None) |
413 | 79 | item.add(u'test.gif') | 83 | item.add(u'test.gif') |
414 | 80 | self.s.addServiceItem(item) | 84 | self.s.addServiceItem(item) |
416 | 81 | answer = self.s.oos_as_text() | 85 | answer = self.s.service_as_text() |
417 | 82 | log.info(u'Answer = ' + unicode(answer)) | 86 | log.info(u'Answer = ' + unicode(answer)) |
419 | 83 | lines=answer.split(u'\n') | 87 | lines = answer.split(u'\n') |
420 | 84 | log.info(u'lines = ' + unicode(lines)) | 88 | log.info(u'lines = ' + unicode(lines)) |
421 | 85 | assert lines[0].startswith(u'# <openlp.plugins.images.imageserviceitem.ImageServiceItem object') | 89 | assert lines[0].startswith(u'# <openlp.plugins.images.imageserviceitem.ImageServiceItem object') |
422 | 86 | assert lines[1] == "test.gif" | 90 | assert lines[1] == "test.gif" |
423 | 87 | log.info(u'done') | 91 | log.info(u'done') |
424 | 88 | 92 | ||
425 | 89 | def test_2items_as_separate_items(self): | 93 | def test_2items_as_separate_items(self): |
427 | 90 | # If nothing is selected when item is added, a new base service item is added | 94 | # If nothing is selected when item is added, a new base service item |
428 | 95 | # is added | ||
429 | 91 | log.info(u'test_2items_as_separate_items') | 96 | log.info(u'test_2items_as_separate_items') |
431 | 92 | item=ImageServiceItem(None) | 97 | item = ImageServiceItem(None) |
432 | 93 | item.add(u'test.gif') | 98 | item.add(u'test.gif') |
433 | 94 | self.s.addServiceItem(item) | 99 | self.s.addServiceItem(item) |
435 | 95 | item=ImageServiceItem(None) | 100 | item = ImageServiceItem(None) |
436 | 96 | item.add(u'test2.gif') | 101 | item.add(u'test2.gif') |
437 | 97 | item.add(u'test3.gif') | 102 | item.add(u'test3.gif') |
438 | 98 | self.s.addServiceItem(item) | 103 | self.s.addServiceItem(item) |
440 | 99 | answer = self.s.oos_as_text() | 104 | answer = self.s.service_as_text() |
441 | 100 | log.info(u'Answer = ' + unicode(answer)) | 105 | log.info(u'Answer = ' + unicode(answer)) |
443 | 101 | lines=answer.split(u'\n') | 106 | lines = answer.split(u'\n') |
444 | 102 | log.info(u'lines = ' + unicode(lines)) | 107 | log.info(u'lines = ' + unicode(lines)) |
445 | 103 | assert lines[0].startswith(u'# <openlp.plugins.images.imageserviceitem.ImageServiceItem object') | 108 | assert lines[0].startswith(u'# <openlp.plugins.images.imageserviceitem.ImageServiceItem object') |
446 | 104 | assert lines[1] == "test.gif" | 109 | assert lines[1] == "test.gif" |
447 | @@ -108,20 +113,22 @@ | |||
448 | 108 | log.info(u'done') | 113 | log.info(u'done') |
449 | 109 | 114 | ||
450 | 110 | def test_2items_merged(self): | 115 | def test_2items_merged(self): |
452 | 111 | # If the first object is selected when item is added it should be extended | 116 | # If the first object is selected when item is added it should be |
453 | 117 | # extended | ||
454 | 112 | log.info(u'test_2items_merged') | 118 | log.info(u'test_2items_merged') |
456 | 113 | item=ImageServiceItem(None) | 119 | item = ImageServiceItem(None) |
457 | 114 | item.add(u'test.gif') | 120 | item.add(u'test.gif') |
458 | 115 | self.s.addServiceItem(item) | 121 | self.s.addServiceItem(item) |
459 | 116 | self.select_row(0) | 122 | self.select_row(0) |
462 | 117 | log.info(u'Selected indexes = ' + unicode(self.s.TreeView.selectedIndexes())) | 123 | log.info(u'Selected indexes = ' + unicode( |
463 | 118 | item=ImageServiceItem(None) | 124 | self.s.TreeView.selectedIndexes())) |
464 | 125 | item = ImageServiceItem(None) | ||
465 | 119 | item.add(u'test2.gif') | 126 | item.add(u'test2.gif') |
466 | 120 | item.add(u'test3.gif') | 127 | item.add(u'test3.gif') |
467 | 121 | self.s.addServiceItem(item) | 128 | self.s.addServiceItem(item) |
469 | 122 | answer = self.s.oos_as_text() | 129 | answer = self.s.service_as_text() |
470 | 123 | log.info(u'Answer = ' + unicode(answer)) | 130 | log.info(u'Answer = ' + unicode(answer)) |
472 | 124 | lines=answer.split(u'\n') | 131 | lines = answer.split(u'\n') |
473 | 125 | log.info(u'lines = ' + unicode(lines)) | 132 | log.info(u'lines = ' + unicode(lines)) |
474 | 126 | assert lines[0].startswith(u'# <openlp.plugins.images.imageserviceitem.ImageServiceItem object') | 133 | assert lines[0].startswith(u'# <openlp.plugins.images.imageserviceitem.ImageServiceItem object') |
475 | 127 | assert lines[1] == "test.gif" | 134 | assert lines[1] == "test.gif" |
476 | @@ -138,7 +145,6 @@ | |||
477 | 138 | 145 | ||
478 | 139 | 146 | ||
479 | 140 | if __name__ == "__main__": | 147 | if __name__ == "__main__": |
480 | 141 | |||
481 | 142 | t=TestServiceManager_base() | 148 | t=TestServiceManager_base() |
482 | 143 | t.setup_class() | 149 | t.setup_class() |
483 | 144 | t.setup_method(None) | 150 | t.setup_method(None) |
484 | 145 | 151 | ||
485 | === modified file 'openlp/plugins/plugin.txt' | |||
486 | --- openlp/plugins/plugin.txt 2008-11-17 20:36:01 +0000 | |||
487 | +++ openlp/plugins/plugin.txt 2009-09-19 21:45:50 +0000 | |||
488 | @@ -9,21 +9,23 @@ | |||
489 | 9 | * Powerpoint/Openoffice Impress | 9 | * Powerpoint/Openoffice Impress |
490 | 10 | * Lyrics :) (with chords, rich text, etc...) | 10 | * Lyrics :) (with chords, rich text, etc...) |
491 | 11 | * Musical score | 11 | * Musical score |
493 | 12 | * Midi files (hmmm, that's not a thing to display, but feels like it should be there...) | 12 | * Midi files (hmmm, that's not a thing to display, but feels like it should be |
494 | 13 | there...) | ||
495 | 13 | * Audio files, CDs (hmmm again) | 14 | * Audio files, CDs (hmmm again) |
496 | 14 | * Collections of pictures | 15 | * Collections of pictures |
497 | 15 | * Alerts to members of the congregation | 16 | * Alerts to members of the congregation |
498 | 16 | ... etc. | 17 | ... etc. |
499 | 17 | 18 | ||
502 | 18 | The scope of these plugins is "things for display purposes", so | 19 | The scope of these plugins is "things for display purposes", so each needs to |
503 | 19 | each needs to be able to: | 20 | be able to: |
504 | 20 | * Render their display (on the projection screen and in a "shrunken form" | 21 | * Render their display (on the projection screen and in a "shrunken form" |
505 | 21 | for preview purposes) | 22 | for preview purposes) |
506 | 22 | 23 | ||
509 | 23 | These plugins need to be part of an OOS. This means they need to | 24 | These plugins need to be part of an service. This means they need to |
510 | 24 | * Be able to tell the OOS manager code what to put in the OOS for their "bit" | 25 | * Be able to tell the service manager code what to put in the service for their |
511 | 26 | "bit" | ||
512 | 25 | * Have a "tab" in the media manager, which they can render on request | 27 | * Have a "tab" in the media manager, which they can render on request |
514 | 26 | to allow bits to be added to the OOS (or indeed shown live) | 28 | to allow bits to be added to the service (or indeed shown live) |
515 | 27 | 29 | ||
516 | 28 | In addition, some plugins need to be able to show | 30 | In addition, some plugins need to be able to show |
517 | 29 | * How their multiple screens of data are split (eg verses) | 31 | * How their multiple screens of data are split (eg verses) |
518 | @@ -41,29 +43,29 @@ | |||
519 | 41 | * A version number | 43 | * A version number |
520 | 42 | * Helpfile? | 44 | * Helpfile? |
521 | 43 | 45 | ||
524 | 44 | Funnily enough, the core lyrics engine fits those requirements, so | 46 | Funnily enough, the core lyrics engine fits those requirements, so could |
525 | 45 | could actually form a plugin... | 47 | actually form a plugin... |
526 | 46 | 48 | ||
530 | 47 | Each OOS entry may be made up of multiple plugins (to do text on | 49 | Each service entry may be made up of multiple plugins (to do text on video), so |
531 | 48 | video), so each plugin that contributes to an OOS item will need a | 50 | each plugin that contributes to an service item will need a "layering" |
532 | 49 | "layering" priority. | 51 | priority. |
533 | 50 | 52 | ||
534 | 51 | Plugin management | 53 | Plugin management |
535 | 52 | ----------------- | 54 | ----------------- |
536 | 53 | 55 | ||
541 | 54 | Plugins will be packages within the plugins/ directory. The plugin | 56 | Plugins will be packages within the plugins/ directory. The plugin manager |
542 | 55 | manager will scan this directory when openlp loads for any class which | 57 | will scan this directory when openlp loads for any class which is based on the |
543 | 56 | is based on the base Plugin class (or should we call it the | 58 | base Plugin class (or should we call it the DisplayPlugin class to allow for |
544 | 57 | DisplayPlugin class to allow for other sorts??) | 59 | other sorts??) |
545 | 58 | 60 | ||
546 | 59 | These plugins are then queried for their capabilities/requirements and | 61 | These plugins are then queried for their capabilities/requirements and |
547 | 60 | spaces made in the prefs UI as required, and in the media manager. | 62 | spaces made in the prefs UI as required, and in the media manager. |
548 | 61 | 63 | ||
551 | 62 | The OOS manager can find out what plugins it has available (we need to | 64 | The service manager can find out what plugins it has available (we need to |
552 | 63 | report missing plugins when an OOS is loaded). | 65 | report missing plugins when an service is loaded). |
553 | 64 | 66 | ||
556 | 65 | The display manager will get a ref to a/some plugin(s) from the OOS | 67 | The display manager will get a ref to a/some plugin(s) from the service |
557 | 66 | manager when each OOS item is made live, and can then call on each to | 68 | manager when each service item is made live, and can then call on each to |
558 | 67 | render their display. | 69 | render their display. |
559 | 68 | 70 | ||
560 | 69 | Each plugin will have basic attributes for | 71 | Each plugin will have basic attributes for |
561 | @@ -78,8 +80,8 @@ | |||
562 | 78 | 80 | ||
563 | 79 | and a set of API functions for | 81 | and a set of API functions for |
564 | 80 | * media manager rendering and handling | 82 | * media manager rendering and handling |
567 | 81 | * creating OOS data | 83 | * creating service data |
568 | 82 | * being told OOS data | 84 | * being told service data |
569 | 83 | * set paint context | 85 | * set paint context |
570 | 84 | * render | 86 | * render |
571 | 85 | * selecting a screen to display | 87 | * selecting a screen to display |
Refactor services to:
- Change all references of oos to service
- Add code to clean service directory on closing OpenLP