forked from openlp/openlp
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. bzr-revno: 2447
This commit is contained in:
commit
93706f8d99
@ -46,7 +46,7 @@ class Ui_SettingsDialog(object):
|
||||
"""
|
||||
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)
|
||||
|
@ -683,7 +683,8 @@ class SlideController(DisplayController, RegistryProperties):
|
||||
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 @@ class SlideController(DisplayController, RegistryProperties):
|
||||
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()
|
||||
|
@ -339,6 +339,9 @@ class SongMediaItem(MediaManagerItem):
|
||||
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
|
||||
|
||||
|
@ -75,9 +75,14 @@ class OpenLyricsExport(RegistryProperties):
|
||||
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
|
||||
|
@ -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))))
|
Loading…
Reference in New Issue
Block a user