← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~tomasgroth/openlp/bugfixes6 into lp:openlp

 

Tomas Groth has proposed merging lp:~tomasgroth/openlp/bugfixes6 into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #1216232 in OpenLP: "OpenLyrics exporter overwrites existing files"
  https://bugs.launchpad.net/openlp/+bug/1216232
  Bug #1377283 in OpenLP: "Text in label cut off in remote settings tab"
  https://bugs.launchpad.net/openlp/+bug/1377283
  Bug #1382672 in OpenLP: "Edit button on preview toolbar disappears"
  https://bugs.launchpad.net/openlp/+bug/1382672
  Bug #1387304 in OpenLP: "Live panel width resizing / blank buttons"
  https://bugs.launchpad.net/openlp/+bug/1387304
  Bug #1390238 in OpenLP: ""Display verses on live tool bar" only works with songs"
  https://bugs.launchpad.net/openlp/+bug/1390238

For more details, see:
https://code.launchpad.net/~tomasgroth/openlp/bugfixes6/+merge/241909

Fix for overwriting files on song export + test. Fixes bug 1216232.
Only show slide-dropdown on live-slidecontroller when it is populated. Fixes bug 1390238.
Make sure that the slidecontroller toolbar layout is correctly adjusted to fit its size. Fixes bug 1387304.
Mark a song edited from preview as coming from plugin. Fixes bug 1382672
Make the settingswindow higher to make room for the new settings. Fixes bug 1377283.
-- 
https://code.launchpad.net/~tomasgroth/openlp/bugfixes6/+merge/241909
Your team OpenLP Core is requested to review the proposed merge of lp:~tomasgroth/openlp/bugfixes6 into lp:openlp.
=== modified file 'openlp/core/ui/settingsdialog.py'
--- openlp/core/ui/settingsdialog.py	2014-10-25 20:26:19 +0000
+++ openlp/core/ui/settingsdialog.py	2014-11-16 22:48:24 +0000
@@ -46,7 +46,7 @@
         """
         settings_dialog.setObjectName('settings_dialog')
         settings_dialog.setWindowIcon(build_icon(u':/icon/openlp-logo.svg'))
-        settings_dialog.resize(800, 500)
+        settings_dialog.resize(800, 700)
         self.dialog_layout = QtGui.QGridLayout(settings_dialog)
         self.dialog_layout.setObjectName('dialog_layout')
         self.dialog_layout.setMargin(8)

=== modified file 'openlp/core/ui/slidecontroller.py'
--- openlp/core/ui/slidecontroller.py	2014-11-01 07:47:26 +0000
+++ openlp/core/ui/slidecontroller.py	2014-11-16 22:48:24 +0000
@@ -683,7 +683,8 @@
         self.play_slides_loop.setChecked(False)
         self.play_slides_loop.setIcon(build_icon(':/media/media_time.png'))
         if item.is_text():
-            if Settings().value(self.main_window.songs_settings_section + '/display songbar') and self.slide_list:
+            if (Settings().value(self.main_window.songs_settings_section + '/display songbar')
+                    and not self.song_menu.menu().isEmpty()):
                 self.toolbar.set_widget_visible(['song_menu'], True)
         if item.is_capable(ItemCapabilities.CanLoop) and len(item.get_frames()) > 1:
             self.toolbar.set_widget_visible(LOOP_LIST)
@@ -691,7 +692,8 @@
             self.mediabar.show()
         self.previous_item.setVisible(not item.is_media())
         self.next_item.setVisible(not item.is_media())
-        self.set_blank_menu()
+        # The layout of the toolbar is size dependent, so make sure it fits
+        self.on_controller_size_changed(self.controller.width())
         # Work-around for OS X, hide and then show the toolbar
         # See bug #791050
         self.toolbar.show()

=== modified file 'openlp/plugins/songs/lib/mediaitem.py'
--- openlp/plugins/songs/lib/mediaitem.py	2014-07-09 12:45:54 +0000
+++ openlp/plugins/songs/lib/mediaitem.py	2014-11-16 22:48:24 +0000
@@ -339,6 +339,9 @@
                 self.remote_song = -1
                 self.remote_triggered = None
                 if item:
+                    if preview:
+                        # A song can only be edited if it comes from plugin, so we set it again for the new item.
+                        item.from_plugin = True
                     return item
         return None
 

=== modified file 'openlp/plugins/songs/lib/openlyricsexport.py'
--- openlp/plugins/songs/lib/openlyricsexport.py	2014-07-03 16:54:51 +0000
+++ openlp/plugins/songs/lib/openlyricsexport.py	2014-11-16 22:48:24 +0000
@@ -75,9 +75,14 @@
             filename = '%s (%s)' % (song.title, ', '.join([author.display_name for author in song.authors]))
             filename = clean_filename(filename)
             # Ensure the filename isn't too long for some filesystems
-            filename = '%s.xml' % filename[0:250 - len(self.save_path)]
+            filename_with_ext = '%s.xml' % filename[0:250 - len(self.save_path)]
+            # Make sure we're not overwriting an existing file
+            conflicts = 0
+            while os.path.exists(os.path.join(self.save_path, filename_with_ext)):
+                conflicts += 1
+                filename_with_ext = '%s-%d.xml' % (filename[0:247 - len(self.save_path)], conflicts)
             # Pass a file object, because lxml does not cope with some special
             # characters in the path (see lp:757673 and lp:744337).
-            tree.write(open(os.path.join(self.save_path, filename), 'wb'), encoding='utf-8', xml_declaration=True,
-                       pretty_print=True)
+            tree.write(open(os.path.join(self.save_path, filename_with_ext), 'wb'), encoding='utf-8',
+                       xml_declaration=True, pretty_print=True)
         return True

=== added file 'tests/functional/openlp_plugins/songs/test_openlyricsexport.py'
--- tests/functional/openlp_plugins/songs/test_openlyricsexport.py	1970-01-01 00:00:00 +0000
+++ tests/functional/openlp_plugins/songs/test_openlyricsexport.py	2014-11-16 22:48:24 +0000
@@ -0,0 +1,86 @@
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection                                      #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2014 Raoul Snyman                                        #
+# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan      #
+# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub,      #
+# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer.   #
+# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru,          #
+# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith,             #
+# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock,              #
+# Frode Woldsund, Martin Zibricky, Patrick Zimmermann                         #
+# --------------------------------------------------------------------------- #
+# This program is free software; you can redistribute it and/or modify it     #
+# under the terms of the GNU General Public License as published by the Free  #
+# Software Foundation; version 2 of the License.                              #
+#                                                                             #
+# This program is distributed in the hope that it will be useful, but WITHOUT #
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       #
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for    #
+# more details.                                                               #
+#                                                                             #
+# You should have received a copy of the GNU General Public License along     #
+# with this program; if not, write to the Free Software Foundation, Inc., 59  #
+# Temple Place, Suite 330, Boston, MA 02111-1307 USA                          #
+###############################################################################
+"""
+This module contains tests for the OpenLyrics song importer.
+"""
+
+import os
+import shutil
+from unittest import TestCase
+from tempfile import mkdtemp
+
+from tests.functional import MagicMock, patch
+from tests.helpers.testmixin import TestMixin
+from openlp.plugins.songs.lib.openlyricsexport import OpenLyricsExport
+from openlp.core.common import Registry
+
+
+class TestOpenLyricsExport(TestCase, TestMixin):
+    """
+    Test the functions in the :mod:`openlyricsexport` module.
+    """
+    def setUp(self):
+        """
+        Create the registry
+        """
+        Registry.create()
+        self.temp_folder = mkdtemp()
+
+    def tearDown(self):
+        """
+        Cleanup
+        """
+        shutil.rmtree(self.temp_folder)
+
+    def export_same_filename_test(self):
+        """
+        Test that files is not overwritten if songs has same title and author
+        """
+        # GIVEN: A mocked song_to_xml, 2 mocked songs, a mocked application and an OpenLyricsExport instance
+        with patch('openlp.plugins.songs.lib.openlyricsexport.OpenLyrics.song_to_xml') as mocked_song_to_xml:
+            mocked_song_to_xml.return_value = '<?xml version="1.0" encoding="UTF-8"?>\n<empty/>'
+            author = MagicMock()
+            author.display_name = 'Test Author'
+            song = MagicMock()
+            song.authors = [author]
+            song.title = 'Test Title'
+            parent = MagicMock()
+            parent.stop_export_flag = False
+            mocked_application_object = MagicMock()
+            Registry().register('application', mocked_application_object)
+            ol_export = OpenLyricsExport(parent, [song, song], self.temp_folder)
+
+            # WHEN: Doing the export
+            ol_export.do_export()
+
+            # THEN: The exporter should have created 2 files
+            self.assertTrue(os.path.exists(os.path.join(self.temp_folder,
+                                                        '%s (%s).xml' % (song.title, author.display_name))))
+            self.assertTrue(os.path.exists(os.path.join(self.temp_folder,
+                                                        '%s (%s)-1.xml' % (song.title, author.display_name))))


References