Status: | Merged | ||||||||
---|---|---|---|---|---|---|---|---|---|
Merged at revision: | not available | ||||||||
Proposed branch: | lp:~trb143/openlp/bugfixes | ||||||||
Merge into: | lp:openlp | ||||||||
Diff against target: | None lines | ||||||||
To merge this branch: | bzr merge lp:~trb143/openlp/bugfixes | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Raoul Snyman | Approve | ||
Review via email: mp+10577@code.launchpad.net |
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
Tim Bentley (trb143) wrote : | # |
Revision history for this message
Raoul Snyman (raoul-snyman) : | # |
review:
Approve
lp:~trb143/openlp/bugfixes
updated
- 510. By Tim Bentley
-
Many fixes and corrections
Adding Presentation code (start)
Add error message to code
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'openlp/core/lib/event.py' |
2 | --- openlp/core/lib/event.py 2009-08-12 04:57:24 +0000 |
3 | +++ openlp/core/lib/event.py 2009-08-15 07:33:01 +0000 |
4 | @@ -45,7 +45,7 @@ |
5 | """ |
6 | Provides an Event class to encapsulate events within openlp.org. |
7 | """ |
8 | - def __init__(self, event_type, sender, payload=None): |
9 | + def __init__(self, sender, event_type=EventType.Default, payload=None): |
10 | self.event_type = event_type |
11 | self.payload = payload |
12 | self.sender = sender |
13 | |
14 | === modified file 'openlp/core/lib/plugin.py' |
15 | --- openlp/core/lib/plugin.py 2009-08-12 04:57:24 +0000 |
16 | +++ openlp/core/lib/plugin.py 2009-08-15 11:02:24 +0000 |
17 | @@ -122,7 +122,6 @@ |
18 | self.log = logging.getLogger(self.name) |
19 | self.preview_controller = plugin_helpers[u'preview'] |
20 | self.live_controller = plugin_helpers[u'live'] |
21 | - self.theme_manager = plugin_helpers[u'theme'] |
22 | self.event_manager = plugin_helpers[u'event'] |
23 | self.render_manager = plugin_helpers[u'render'] |
24 | self.service_manager = plugin_helpers[u'service'] |
25 | @@ -132,6 +131,7 @@ |
26 | def check_pre_conditions(self): |
27 | """ |
28 | Provides the Plugin with a handle to check if it can be loaded. |
29 | + Failing Preconditions does not stop a settings Tab being created |
30 | |
31 | Returns True or False. |
32 | """ |
33 | |
34 | === modified file 'openlp/core/lib/pluginmanager.py' |
35 | --- openlp/core/lib/pluginmanager.py 2009-08-13 20:02:38 +0000 |
36 | +++ openlp/core/lib/pluginmanager.py 2009-08-15 07:55:16 +0000 |
37 | @@ -93,18 +93,20 @@ |
38 | for p in plugin_classes: |
39 | try: |
40 | plugin = p(self.plugin_helpers) |
41 | - log.debug(u'loaded plugin %s with helpers', unicode(p)) |
42 | - log.debug(u'Plugin: %s', unicode(p)) |
43 | - pList = {u'name': plugin.name, u'version':plugin.version, u'status': u'Inactive'} |
44 | - if plugin.check_pre_conditions(): |
45 | - log.debug(u'Appending %s ', unicode(p)) |
46 | - plugin_objects.append(plugin) |
47 | - eventmanager.register(plugin) |
48 | - pList[u'status'] = u'Active' |
49 | - self.plugin_list.append(pList) |
50 | + log.debug(u'Loaded plugin %s with helpers', unicode(p)) |
51 | + |
52 | + plugin_objects.append(plugin) |
53 | except TypeError: |
54 | log.error(u'loaded plugin %s has no helpers', unicode(p)) |
55 | - self.plugins = sorted(plugin_objects, self.order_by_weight) |
56 | + plugins_list = sorted(plugin_objects, self.order_by_weight) |
57 | + for plugin in plugins_list: |
58 | + pList = {u'plugin': plugin, u'status': u'Inactive'} |
59 | + if plugin.check_pre_conditions(): |
60 | + log.debug(u'Plugin %s active', unicode(plugin.name)) |
61 | + eventmanager.register(plugin) |
62 | + pList[u'status'] = u'Active' |
63 | + self.plugins.append(pList) |
64 | + |
65 | |
66 | def order_by_weight(self, x, y): |
67 | """ |
68 | @@ -127,10 +129,11 @@ |
69 | The Media Manager itself. |
70 | """ |
71 | for plugin in self.plugins: |
72 | - media_manager_item = plugin.get_media_manager_item() |
73 | - if media_manager_item is not None: |
74 | - log.debug(u'Inserting media manager item from %s' % plugin.name) |
75 | - mediatoolbox.addItem(media_manager_item, plugin.icon, media_manager_item.title) |
76 | + if plugin[u'status'] == u'Active': |
77 | + media_manager_item = plugin[u'plugin'].get_media_manager_item() |
78 | + if media_manager_item is not None: |
79 | + log.debug(u'Inserting media manager item from %s' % plugin[u'plugin'].name) |
80 | + mediatoolbox.addItem(media_manager_item, plugin[u'plugin'].icon, media_manager_item.title) |
81 | |
82 | def hook_settings_tabs(self, settingsform=None): |
83 | """ |
84 | @@ -141,12 +144,12 @@ |
85 | Defaults to *None*. The settings form to add tabs to. |
86 | """ |
87 | for plugin in self.plugins: |
88 | - settings_tab = plugin.get_settings_tab() |
89 | + settings_tab = plugin[u'plugin'].get_settings_tab() |
90 | if settings_tab is not None: |
91 | - log.debug(u'Inserting settings tab item from %s' % plugin.name) |
92 | + log.debug(u'Inserting settings tab item from %s' % plugin[u'plugin'].name) |
93 | settingsform.addTab(settings_tab) |
94 | else: |
95 | - log.debug(u'No settings in %s' % plugin.name) |
96 | + log.debug(u'No settings in %s' % plugin[u'plugin'].name) |
97 | |
98 | def hook_import_menu(self, import_menu): |
99 | """ |
100 | @@ -157,7 +160,8 @@ |
101 | The Import menu. |
102 | """ |
103 | for plugin in self.plugins: |
104 | - plugin.add_import_menu_item(import_menu) |
105 | + if plugin[u'status'] == u'Active': |
106 | + plugin[u'plugin'].add_import_menu_item(import_menu) |
107 | |
108 | def hook_export_menu(self, export_menu): |
109 | """ |
110 | @@ -168,7 +172,8 @@ |
111 | The Export menu. |
112 | """ |
113 | for plugin in self.plugins: |
114 | - plugin.add_export_menu_item(export_menu) |
115 | + if plugin[u'status'] == u'Active': |
116 | + plugin[u'plugin'].add_export_menu_item(export_menu) |
117 | |
118 | def initialise_plugins(self): |
119 | """ |
120 | @@ -176,7 +181,8 @@ |
121 | initialise themselves. |
122 | """ |
123 | for plugin in self.plugins: |
124 | - plugin.initialise() |
125 | + if plugin[u'status'] == u'Active': |
126 | + plugin[u'plugin'].initialise() |
127 | |
128 | def finalise_plugins(self): |
129 | """ |
130 | @@ -184,4 +190,5 @@ |
131 | clean themselves up |
132 | """ |
133 | for plugin in self.plugins: |
134 | - plugin.finalise() |
135 | + if plugin[u'status'] == u'Active': |
136 | + plugin[u'plugin'].finalise() |
137 | |
138 | === modified file 'openlp/core/ui/mainwindow.py' |
139 | --- openlp/core/ui/mainwindow.py 2009-08-14 19:12:14 +0000 |
140 | +++ openlp/core/ui/mainwindow.py 2009-08-15 11:02:24 +0000 |
141 | @@ -468,7 +468,6 @@ |
142 | self.plugin_helpers[u'preview'] = self.PreviewController |
143 | self.plugin_helpers[u'live'] = self.LiveController |
144 | self.plugin_helpers[u'event'] = self.EventManager |
145 | - self.plugin_helpers[u'theme'] = self.ThemeManagerContents |
146 | self.plugin_helpers[u'render'] = self.RenderManager |
147 | self.plugin_helpers[u'service'] = self.ServiceManagerContents |
148 | self.plugin_helpers[u'settings'] = self.settingsForm |
149 | @@ -596,8 +595,7 @@ |
150 | |
151 | def handle_event(self, event): |
152 | if event.event_type == EventType.ThemeListChanged: |
153 | - themes = self.ThemeManagerContents.getThemes() |
154 | - self.ServiceManagerContents.updateThemeList(themes) |
155 | - self.settingsForm.ThemesTab.updateThemeList(themes) |
156 | + self.ServiceManagerContents.updateThemeList(event.payload) |
157 | + self.settingsForm.ThemesTab.updateThemeList(event.payload) |
158 | self.DefaultThemeLabel.setText(self.defaultThemeText + \ |
159 | self.ThemeManagerContents.getDefault()) |
160 | |
161 | === modified file 'openlp/core/ui/plugindialoglistform.py' |
162 | --- openlp/core/ui/plugindialoglistform.py 2009-08-14 16:26:22 +0000 |
163 | +++ openlp/core/ui/plugindialoglistform.py 2009-08-15 19:10:59 +0000 |
164 | @@ -58,12 +58,14 @@ |
165 | """ |
166 | Load the plugin details into the screen |
167 | """ |
168 | - for plugin in self.parent.plugin_manager.plugin_list: |
169 | + #self.PluginViewList.clear() |
170 | + self.PluginViewList.setRowCount(0) |
171 | + for plugin in self.parent.plugin_manager.plugins: |
172 | row = self.PluginViewList.rowCount() |
173 | self.PluginViewList.setRowCount(row + 1) |
174 | - item1 = QtGui.QTableWidgetItem(plugin[u'name']) |
175 | + item1 = QtGui.QTableWidgetItem(plugin[u'plugin'].name) |
176 | item1.setTextAlignment(QtCore.Qt.AlignVCenter) |
177 | - item2 = QtGui.QTableWidgetItem(plugin[u'version']) |
178 | + item2 = QtGui.QTableWidgetItem(plugin[u'plugin'].version) |
179 | item2.setTextAlignment(QtCore.Qt.AlignVCenter) |
180 | item3 = QtGui.QTableWidgetItem(translate(u'PluginForm', plugin[u'status'])) |
181 | item3.setTextAlignment(QtCore.Qt.AlignVCenter) |
182 | |
183 | === modified file 'openlp/core/ui/servicemanager.py' |
184 | --- openlp/core/ui/servicemanager.py 2009-08-12 04:57:24 +0000 |
185 | +++ openlp/core/ui/servicemanager.py 2009-08-15 07:33:01 +0000 |
186 | @@ -488,7 +488,7 @@ |
187 | link = event.mimeData() |
188 | if link.hasText(): |
189 | plugin = event.mimeData().text() |
190 | - self.parent.EventManager.post_event(Event(EventType.LoadServiceItem, u'ServiceManager', plugin)) |
191 | + self.parent.EventManager.post_event(Event(u'ServiceManager', EventType.LoadServiceItem, plugin)) |
192 | |
193 | def updateThemeList(self, theme_list): |
194 | """ |
195 | |
196 | === modified file 'openlp/core/ui/thememanager.py' |
197 | --- openlp/core/ui/thememanager.py 2009-08-12 04:57:24 +0000 |
198 | +++ openlp/core/ui/thememanager.py 2009-08-15 07:33:01 +0000 |
199 | @@ -184,7 +184,7 @@ |
200 | self.pushThemes() |
201 | |
202 | def pushThemes(self): |
203 | - self.parent.EventManager.post_event(Event(EventType.ThemeListChanged,u'ThemeManager')) |
204 | + self.parent.EventManager.post_event(Event(u'ThemeManager', EventType.ThemeListChanged, self.getThemes())) |
205 | |
206 | def getThemes(self): |
207 | return self.themelist |
208 | |
209 | === modified file 'openlp/plugins/bibles/bibleplugin.py' |
210 | --- openlp/plugins/bibles/bibleplugin.py 2009-08-12 04:57:24 +0000 |
211 | +++ openlp/plugins/bibles/bibleplugin.py 2009-08-15 07:33:01 +0000 |
212 | @@ -81,5 +81,5 @@ |
213 | log.debug(u'Handle event called with event %s with payload %s'%(event.event_type, event.payload)) |
214 | if event.event_type == EventType.ThemeListChanged: |
215 | log.debug(u'New Theme request received') |
216 | - self.bibles_tab.updateThemeList(self.theme_manager.getThemes()) |
217 | + self.bibles_tab.updateThemeList(event.payload) |
218 | return Plugin.handle_event(self, event) |
219 | |
220 | === modified file 'openlp/plugins/bibles/forms/bibleimportform.py' |
221 | --- openlp/plugins/bibles/forms/bibleimportform.py 2009-07-09 05:15:26 +0000 |
222 | +++ openlp/plugins/bibles/forms/bibleimportform.py 2009-08-15 07:55:16 +0000 |
223 | @@ -47,6 +47,7 @@ |
224 | self.bibleplugin = bibleplugin |
225 | self.bible_type = None |
226 | self.barmax = 0 |
227 | + self.tabWidget.setCurrentIndex(0) |
228 | self.AddressEdit.setText(self.config.get_config(u'proxy_address', u'')) |
229 | self.UsernameEdit.setText(self.config.get_config(u'proxy_username',u'')) |
230 | self.PasswordEdit.setText(self.config.get_config(u'proxy_password',u'')) |
231 | |
232 | === modified file 'openlp/plugins/bibles/lib/mediaitem.py' |
233 | --- openlp/plugins/bibles/lib/mediaitem.py 2009-08-05 17:59:37 +0000 |
234 | +++ openlp/plugins/bibles/lib/mediaitem.py 2009-08-15 11:02:24 +0000 |
235 | @@ -25,30 +25,14 @@ |
236 | from PyQt4 import QtCore, QtGui |
237 | |
238 | from openlp.core.lib import translate, ServiceItem, MediaManagerItem, \ |
239 | - Receiver, contextMenuAction, contextMenuSeparator |
240 | + Receiver, contextMenuAction, contextMenuSeparator, BaseListWithDnD |
241 | from openlp.plugins.bibles.forms import BibleImportForm |
242 | from openlp.plugins.bibles.lib.manager import BibleMode |
243 | |
244 | -class BibleList(QtGui.QListWidget): |
245 | - |
246 | - def __init__(self,parent=None,name=None): |
247 | - QtGui.QListView.__init__(self,parent) |
248 | - |
249 | - def mouseMoveEvent(self, event): |
250 | - """ |
251 | - Drag and drop event does not care what data is selected |
252 | - as the recepient will use events to request the data move |
253 | - just tell it what plugin to call |
254 | - """ |
255 | - if event.buttons() != QtCore.Qt.LeftButton: |
256 | - return |
257 | - drag = QtGui.QDrag(self) |
258 | - mimeData = QtCore.QMimeData() |
259 | - drag.setMimeData(mimeData) |
260 | - mimeData.setText(u'Bibles') |
261 | - dropAction = drag.start(QtCore.Qt.CopyAction) |
262 | - if dropAction == QtCore.Qt.CopyAction: |
263 | - self.close() |
264 | +class BibleListView(BaseListWithDnD): |
265 | + def __init__(self, parent=None): |
266 | + self.PluginName = u'Bibles' |
267 | + BaseListWithDnD.__init__(self, parent) |
268 | |
269 | class BibleMediaItem(MediaManagerItem): |
270 | """ |
271 | @@ -201,7 +185,7 @@ |
272 | self.SearchTabWidget.addTab(self.AdvancedTab, u'Advanced') |
273 | # Add the search tab widget to the page layout |
274 | self.PageLayout.addWidget(self.SearchTabWidget) |
275 | - self.ListView = BibleList() |
276 | + self.ListView = BibleListView() |
277 | self.ListView.setAlternatingRowColors(True) |
278 | self.ListView.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) |
279 | self.ListView.setDragEnabled(True) |
280 | |
281 | === modified file 'openlp/plugins/custom/customplugin.py' |
282 | --- openlp/plugins/custom/customplugin.py 2009-08-12 04:57:24 +0000 |
283 | +++ openlp/plugins/custom/customplugin.py 2009-08-15 07:33:01 +0000 |
284 | @@ -57,5 +57,5 @@ |
285 | log.debug(u'Handle event called with event %s with payload %s'%(event.event_type, event.payload)) |
286 | if event.event_type == EventType.ThemeListChanged: |
287 | log.debug(u'New Theme request received') |
288 | - self.edit_custom_form.loadThemes(self.theme_manager.getThemes()) |
289 | + self.edit_custom_form.loadThemes(event.payload) |
290 | return Plugin.handle_event(self, event) |
291 | |
292 | === modified file 'openlp/plugins/custom/lib/mediaitem.py' |
293 | --- openlp/plugins/custom/lib/mediaitem.py 2009-07-04 05:52:30 +0000 |
294 | +++ openlp/plugins/custom/lib/mediaitem.py 2009-08-15 11:02:24 +0000 |
295 | @@ -21,28 +21,12 @@ |
296 | |
297 | from PyQt4 import QtCore, QtGui |
298 | |
299 | -from openlp.core.lib import MediaManagerItem, SongXMLParser, ServiceItem, translate, contextMenuAction, contextMenuSeparator |
300 | - |
301 | -class CustomList(QtGui.QListWidget): |
302 | - |
303 | - def __init__(self,parent=None,name=None): |
304 | - QtGui.QListView.__init__(self,parent) |
305 | - |
306 | - def mouseMoveEvent(self, event): |
307 | - """ |
308 | - Drag and drop event does not care what data is selected |
309 | - as the recepient will use events to request the data move |
310 | - just tell it what plugin to call |
311 | - """ |
312 | - if event.buttons() != QtCore.Qt.LeftButton: |
313 | - return |
314 | - drag = QtGui.QDrag(self) |
315 | - mimeData = QtCore.QMimeData() |
316 | - drag.setMimeData(mimeData) |
317 | - mimeData.setText(u'Custom') |
318 | - dropAction = drag.start(QtCore.Qt.CopyAction) |
319 | - if dropAction == QtCore.Qt.CopyAction: |
320 | - self.close() |
321 | +from openlp.core.lib import MediaManagerItem, SongXMLParser, ServiceItem, translate, contextMenuAction, contextMenuSeparator, BaseListWithDnD |
322 | + |
323 | +class CustomListView(BaseListWithDnD): |
324 | + def __init__(self, parent=None): |
325 | + self.PluginName = u'Custom' |
326 | + BaseListWithDnD.__init__(self, parent) |
327 | |
328 | class CustomMediaItem(MediaManagerItem): |
329 | """ |
330 | @@ -95,7 +79,7 @@ |
331 | translate(u'CustomMediaItem',u'Add Custom To Service'), |
332 | translate(u'CustomMediaItem',u'Add the selected Custom(s) to the service'), |
333 | u':/system/system_add.png', self.onCustomAddClick, u'CustomAddItem') |
334 | - # Add the Customlist widget |
335 | + # Add the CustomListView widget |
336 | self.CustomWidget = QtGui.QWidget(self) |
337 | sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) |
338 | sizePolicy.setHorizontalStretch(0) |
339 | @@ -105,7 +89,7 @@ |
340 | self.CustomWidget.setObjectName(u'CustomWidget') |
341 | # Add the Custom widget to the page layout |
342 | self.PageLayout.addWidget(self.CustomWidget) |
343 | - self.ListView = CustomList() |
344 | + self.ListView = CustomListView() |
345 | self.ListView.setAlternatingRowColors(True) |
346 | self.ListView.setDragEnabled(True) |
347 | self.PageLayout.addWidget(self.ListView) |
348 | @@ -129,9 +113,9 @@ |
349 | translate(u'CustomMediaItem',u'&Add to Service'), self.onCustomAddClick)) |
350 | |
351 | def initialise(self): |
352 | - self.loadCustomList(self.parent.custommanager.get_all_slides()) |
353 | + self.loadCustomListView(self.parent.custommanager.get_all_slides()) |
354 | |
355 | - def loadCustomList(self, list): |
356 | + def loadCustomListView(self, list): |
357 | self.ListView.clear() |
358 | for CustomSlide in list: |
359 | custom_name = QtGui.QListWidgetItem(CustomSlide.title) |
360 | |
361 | === modified file 'openlp/plugins/media/lib/mediaitem.py' |
362 | --- openlp/plugins/media/lib/mediaitem.py 2009-07-04 05:52:30 +0000 |
363 | +++ openlp/plugins/media/lib/mediaitem.py 2009-08-15 11:02:24 +0000 |
364 | @@ -32,7 +32,6 @@ |
365 | |
366 | from openlp.plugins.media.lib import MediaTab |
367 | from openlp.plugins.media.lib import FileListData |
368 | -# from listwithpreviews import ListWithPreviews |
369 | from openlp.core.lib import MediaManagerItem, ServiceItem, translate, BaseListWithDnD, buildIcon |
370 | |
371 | class MediaListView(BaseListWithDnD): |
372 | |
373 | === modified file 'openlp/plugins/presentations/lib/presentationtab.py' |
374 | --- openlp/plugins/presentations/lib/presentationtab.py 2009-08-14 19:12:14 +0000 |
375 | +++ openlp/plugins/presentations/lib/presentationtab.py 2009-08-15 19:10:59 +0000 |
376 | @@ -93,4 +93,3 @@ |
377 | def save(self): |
378 | self.config.set_config(u'Powerpoint', unicode(self.PowerpointCheckBox.checkState())) |
379 | self.config.set_config(u'Impress', unicode(self.ImpressCheckBox.checkState())) |
380 | - print self.PowerpointCheckBox.checkState(), unicode(self.PowerpointCheckBox.checkState()) |
381 | |
382 | === modified file 'openlp/plugins/presentations/presentationplugin.py' |
383 | --- openlp/plugins/presentations/presentationplugin.py 2009-08-14 19:12:14 +0000 |
384 | +++ openlp/plugins/presentations/presentationplugin.py 2009-08-15 19:10:59 +0000 |
385 | @@ -67,12 +67,12 @@ |
386 | """ |
387 | log.debug('check_pre_conditions') |
388 | |
389 | - if int(self.config.get_config(u'Powerpoint', 0)) == 2: |
390 | + if int(self.config.get_config(u'Impress', 0)) == 2: |
391 | try: |
392 | #Check to see if we have uno installed |
393 | import uno |
394 | - #openoffice = impressController() |
395 | - self.registerControllers(u'Impress', None) |
396 | + openoffice = impressController() |
397 | + self.registerControllers(u'Impress', openoffice) |
398 | except: |
399 | pass |
400 | #If we have no controllers disable plugin |
401 | @@ -80,3 +80,10 @@ |
402 | return True |
403 | else: |
404 | return False |
405 | + |
406 | + def finalise(self): |
407 | + log.debug(u'Finalise') |
408 | + print self.controllers |
409 | + for controller in self.controllers: |
410 | + print controller |
411 | + self.controllers[controller].kill() |
412 | |
413 | === modified file 'openlp/plugins/remotes/remoteplugin.py' |
414 | --- openlp/plugins/remotes/remoteplugin.py 2009-08-14 17:41:29 +0000 |
415 | +++ openlp/plugins/remotes/remoteplugin.py 2009-08-15 07:33:01 +0000 |
416 | @@ -56,9 +56,9 @@ |
417 | log.info(u'Sending event %s ', datagram) |
418 | pos = datagram.find(u':') |
419 | event = unicode(datagram[:pos].lower()) |
420 | - payload = unicode(datagram[pos + 1:]) |
421 | + |
422 | if event == u'alert': |
423 | - self.event_manager.post_event(Event(EventType.TriggerAlert, u'RemotePlugin', payload)) |
424 | + self.event_manager.post_event(Event(u'RemotePlugin', EventType.TriggerAlert , unicode(datagram[pos + 1:]))) |
425 | |
426 | |
427 | |
428 | |
429 | === modified file 'openlp/plugins/songs/forms/editsongform.py' |
430 | --- openlp/plugins/songs/forms/editsongform.py 2009-08-14 16:12:40 +0000 |
431 | +++ openlp/plugins/songs/forms/editsongform.py 2009-08-15 19:19:34 +0000 |
432 | @@ -23,7 +23,7 @@ |
433 | from PyQt4 import Qt, QtCore, QtGui |
434 | |
435 | from openlp.core.lib import SongXMLBuilder, SongXMLParser, Event, \ |
436 | - EventType, EventManager |
437 | + EventType, EventManager, translate |
438 | from openlp.plugins.songs.forms import EditVerseForm |
439 | from openlp.plugins.songs.lib.models import Song |
440 | from editsongdialog import Ui_EditSongDialog |
441 | @@ -299,22 +299,26 @@ |
442 | log.debug(u'Validate Song') |
443 | # Lets be nice and assume the data is correct. |
444 | valid = True |
445 | + message = u'' |
446 | if len(self.TitleEditItem.displayText()) == 0: |
447 | valid = False |
448 | self.TitleEditItem.setStyleSheet(u'background-color: red; color: white') |
449 | + message = translate(u'SongFormDialog', u'You need to enter a song title \n') |
450 | else: |
451 | self.TitleEditItem.setStyleSheet(u'') |
452 | if self.VerseListWidget.count() == 0: |
453 | valid = False |
454 | self.VerseListWidget.setStyleSheet(u'background-color: red; color: white') |
455 | + message = message + translate(u'SongFormDialog', u'You need to enter some verse text \n') |
456 | else: |
457 | self.VerseListWidget.setStyleSheet(u'') |
458 | if self.AuthorsListView.count() == 0: |
459 | valid = False |
460 | self.AuthorsListView.setStyleSheet(u'background-color: red; color: white') |
461 | + message = message + translate(u'SongFormDialog', u'You need to provide an author') |
462 | else: |
463 | self.AuthorsListView.setStyleSheet(u'') |
464 | - return valid |
465 | + return valid, message |
466 | |
467 | def on_TitleEditItem_lostFocus(self): |
468 | self.song.title = self.TitleEditItem.text() |
469 | @@ -345,7 +349,11 @@ |
470 | |
471 | def accept(self): |
472 | log.debug(u'accept') |
473 | - if not self._validate_song(): |
474 | + valid , message = self._validate_song() |
475 | + if not valid: |
476 | + QtGui.QMessageBox.critical(self, |
477 | + translate(u'SongFormDialog', u'Error'), message, |
478 | + QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) |
479 | return |
480 | self.song.title = unicode(self.TitleEditItem.displayText()) |
481 | self.song.copyright = unicode(self.CopyrightEditItem.displayText()) |
482 | @@ -356,7 +364,7 @@ |
483 | self.processTitle() |
484 | self.songmanager.save_song(self.song) |
485 | if self.title_change: |
486 | - self.eventmanager.post_event(Event(EventType.LoadSongList, u'EditSongForm')) |
487 | + self.eventmanager.post_event(Event(u'EditSongForm', EventType.LoadSongList)) |
488 | self.close() |
489 | |
490 | def processLyrics(self): |
491 | |
492 | === modified file 'openlp/plugins/songs/lib/mediaitem.py' |
493 | --- openlp/plugins/songs/lib/mediaitem.py 2009-08-06 13:17:36 +0000 |
494 | +++ openlp/plugins/songs/lib/mediaitem.py 2009-08-15 11:02:24 +0000 |
495 | @@ -22,29 +22,13 @@ |
496 | from PyQt4 import QtCore, QtGui |
497 | |
498 | from openlp.core.lib import MediaManagerItem, translate, ServiceItem, \ |
499 | - SongXMLParser, contextMenuAction, contextMenuSeparator |
500 | + SongXMLParser, contextMenuAction, contextMenuSeparator, BaseListWithDnD |
501 | from openlp.plugins.songs.forms import EditSongForm, SongMaintenanceForm |
502 | |
503 | -class SongList(QtGui.QListWidget): |
504 | - |
505 | - def __init__(self, parent=None, name=None): |
506 | - QtGui.QListWidget.__init__(self,parent) |
507 | - |
508 | - def mouseMoveEvent(self, event): |
509 | - """ |
510 | - Drag and drop event does not care what data is selected |
511 | - as the recepient will use events to request the data move |
512 | - just tell it what plugin to call |
513 | - """ |
514 | - if event.buttons() != QtCore.Qt.LeftButton: |
515 | - return |
516 | - drag = QtGui.QDrag(self) |
517 | - mimeData = QtCore.QMimeData() |
518 | - drag.setMimeData(mimeData) |
519 | - mimeData.setText(u'Song') |
520 | - dropAction = drag.start(QtCore.Qt.CopyAction) |
521 | - if dropAction == QtCore.Qt.CopyAction: |
522 | - self.close() |
523 | +class SongListView(BaseListWithDnD): |
524 | + def __init__(self, parent=None): |
525 | + self.PluginName = u'Song' |
526 | + BaseListWithDnD.__init__(self, parent) |
527 | |
528 | class SongMediaItem(MediaManagerItem): |
529 | """ |
530 | @@ -97,7 +81,7 @@ |
531 | self.addToolbarButton(translate(u'SongMediaItem', u'Song Maintenance'), |
532 | translate(u'SongMediaItem', u'Maintain the lists of authors, topics and books'), |
533 | ':/songs/song_maintenance.png', self.onSongMaintenanceClick, 'SongMaintenanceItem') |
534 | - ## Add the songlist widget ## |
535 | + ## Add the SongListView widget ## |
536 | # Create the tab widget |
537 | self.SongWidget = QtGui.QWidget(self) |
538 | sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) |
539 | @@ -128,7 +112,7 @@ |
540 | self.SearchLayout.addWidget(self.SearchTextButton, 3, 2, 1, 1) |
541 | # Add the song widget to the page layout |
542 | self.PageLayout.addWidget(self.SongWidget) |
543 | - self.ListView = SongList() |
544 | + self.ListView = SongListView() |
545 | self.ListView.setAlternatingRowColors(True) |
546 | self.ListView.setDragEnabled(True) |
547 | self.ListView.setObjectName(u'ListView') |
548 | |
549 | === modified file 'openlp/plugins/songs/songsplugin.py' |
550 | --- openlp/plugins/songs/songsplugin.py 2009-08-12 04:57:24 +0000 |
551 | +++ openlp/plugins/songs/songsplugin.py 2009-08-15 07:33:01 +0000 |
552 | @@ -136,7 +136,7 @@ |
553 | log.debug(u'Handle event called with event %s' % event.event_type) |
554 | if event.event_type == EventType.ThemeListChanged: |
555 | log.debug(u'New Theme request received') |
556 | - self.media_item.edit_song_form.loadThemes(self.theme_manager.getThemes()) |
557 | + self.media_item.edit_song_form.loadThemes(event.payload) |
558 | if event.event_type == EventType.LoadSongList : |
559 | log.debug(u'Load Load Song List Item received') |
560 | self.media_item.displayResultsSong(self.songmanager.get_songs()) |
Changes which have been stacked up for the last week and are still valid.