[Openlp-core] [Merge] lp:~phill-ridout/openlp/fixes-IV into lp:openlp

2019-08-07 Thread noreply
The proposal to merge lp:~phill-ridout/openlp/fixes-IV into lp:openlp has been 
updated.

Status: Needs review => Merged

For more details, see:
https://code.launchpad.net/~phill-ridout/openlp/fixes-IV/+merge/371023
-- 
Your team OpenLP Core is subscribed to branch lp:openlp.

___
Mailing list: https://launchpad.net/~openlp-core
Post to : openlp-core@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openlp-core
More help   : https://help.launchpad.net/ListHelp


Re: [Openlp-core] [Merge] lp:~phill-ridout/openlp/fixes-IV into lp:openlp

2019-08-07 Thread Tim Bentley
Review: Approve


-- 
https://code.launchpad.net/~phill-ridout/openlp/fixes-IV/+merge/371023
Your team OpenLP Core is subscribed to branch lp:openlp.

___
Mailing list: https://launchpad.net/~openlp-core
Post to : openlp-core@lists.launchpad.net
Unsubscribe : https://launchpad.net/~openlp-core
More help   : https://help.launchpad.net/ListHelp


[Openlp-core] [Merge] lp:~phill-ridout/openlp/fixes-IV into lp:openlp

2019-08-06 Thread Phill
Phill has proposed merging lp:~phill-ridout/openlp/fixes-IV into lp:openlp.

Commit message:
Refactors and fixes

Requested reviews:
  OpenLP Core (openlp-core)
Related bugs:
  Bug #1600510 in OpenLP: "Deleting a songbook throws "song" attribute 
exception"
  https://bugs.launchpad.net/openlp/+bug/1600510
  Bug #1673113 in OpenLP: ""Save & Preview" Button in Song Editor behaves in a 
strange way"
  https://bugs.launchpad.net/openlp/+bug/1673113
  Bug #1799005 in OpenLP: "Searching for Bible Book of "Job" in Brazilian 
Portuguese (Jo) returns the wrong book. Returns Joshua."
  https://bugs.launchpad.net/openlp/+bug/1799005
  Bug #1832942 in OpenLP: "version 2880 advanced setting alignment"
  https://bugs.launchpad.net/openlp/+bug/1832942

For more details, see:
https://code.launchpad.net/~phill-ridout/openlp/fixes-IV/+merge/371023

Refactor `singleton` classes to use a `singleton` metaclass
Fixes for a number of reported issues
Tidy ups, and improvements as suggested by pycharm
-- 
Your team OpenLP Core is requested to review the proposed merge of 
lp:~phill-ridout/openlp/fixes-IV into lp:openlp.
=== modified file 'openlp/core/common/__init__.py'
--- openlp/core/common/__init__.py	2019-07-19 18:43:14 +
+++ openlp/core/common/__init__.py	2019-08-06 21:48:11 +
@@ -172,6 +172,21 @@
 Next = 3
 
 
+class Singleton(type):
+"""
+Provide a `Singleton` metaclass https://stackoverflow.com/questions/6760685/creating-a-singleton-in-python
+"""
+_instances = {}
+
+def __call__(cls, *args, **kwargs):
+"""
+Create a new instance if one does not already exist.
+"""
+if cls not in cls._instances:
+cls._instances[cls] = super().__call__(*args, **kwargs)
+return cls._instances[cls]
+
+
 def de_hump(name):
 """
 Change any Camel Case string to python string
@@ -385,7 +400,7 @@
 global IMAGES_FILTER
 if not IMAGES_FILTER:
 log.debug('Generating images filter.')
-formats = list(map(bytes.decode, list(map(bytes, QtGui.QImageReader.supportedImageFormats()
+formats = list(map(bytes.decode, map(bytes, QtGui.QImageReader.supportedImageFormats(
 visible_formats = '(*.{text})'.format(text='; *.'.join(formats))
 actual_formats = '(*.{text})'.format(text=' *.'.join(formats))
 IMAGES_FILTER = '{text} {visible} {actual}'.format(text=translate('OpenLP', 'Image Files'),

=== modified file 'openlp/core/common/actions.py'
--- openlp/core/common/actions.py	2019-04-13 13:00:22 +
+++ openlp/core/common/actions.py	2019-08-06 21:48:11 +
@@ -260,7 +260,7 @@
 return
 # We have to do this to ensure that the loaded shortcut list e. g. STRG+O (German) is converted to CTRL+O,
 # which is only done when we convert the strings in this way (QKeySequencet -> uncode).
-shortcuts = list(map(QtGui.QKeySequence.toString, list(map(QtGui.QKeySequence, shortcuts
+shortcuts = list(map(QtGui.QKeySequence.toString, map(QtGui.QKeySequence, shortcuts)))
 # Check the alternate shortcut first, to avoid problems when the alternate shortcut becomes the primary shortcut
 #  after removing the (initial) primary shortcut due to conflicts.
 if len(shortcuts) == 2:

=== modified file 'openlp/core/common/i18n.py'
--- openlp/core/common/i18n.py	2019-07-03 13:23:23 +
+++ openlp/core/common/i18n.py	2019-08-06 21:48:11 +
@@ -29,7 +29,7 @@
 
 from PyQt5 import QtCore, QtWidgets
 
-from openlp.core.common import is_macosx, is_win
+from openlp.core.common import Singleton, is_macosx, is_win
 from openlp.core.common.applocation import AppLocation
 from openlp.core.common.settings import Settings
 
@@ -327,22 +327,11 @@
 return LanguageManager.__qm_list__
 
 
-class UiStrings(object):
+class UiStrings(metaclass=Singleton):
 """
 Provide standard strings for objects to use.
 """
-__instance__ = None
-
-def __new__(cls):
-"""
-Override the default object creation method to return a single instance.
-"""
-if not cls.__instance__:
-cls.__instance__ = super().__new__(cls)
-cls.__instance__.load()
-return cls.__instance__
-
-def load(self):
+def __init__(self):
 """
 These strings should need a good reason to be retranslated elsewhere.
 Should some/more/less of these have an  attached?
@@ -436,6 +425,7 @@
 self.ResetLiveBG = translate('OpenLP.Ui', 'Reset live background.')
 self.RequiredShowInFooter = translate('OpenLP.Ui', 'Required, this will be displayed in footer.')
 self.Seconds = translate('OpenLP.Ui', 's', 'The abbreviated unit for seconds')
+self.SaveAndClose = translate('OpenLP.ui', translate('SongsPlugin.EditSongForm', ' && Close'))
 self.SaveAndPreview = translate('OpenLP.Ui', 'Save && Preview')
 self.Search = translate('OpenLP.Ui', 'Search')
 self.SearchThemes =