forked from openlp/openlp
cleaned core/lib/init
This commit is contained in:
parent
692cab71b7
commit
a70ef917fc
@ -49,9 +49,8 @@ class ServiceItemContext(object):
|
|||||||
|
|
||||||
class ImageSource(object):
|
class ImageSource(object):
|
||||||
"""
|
"""
|
||||||
This enumeration class represents different image sources. An image sources
|
This enumeration class represents different image sources. An image sources states where an image is used. This
|
||||||
states where an image is used. This enumeration class is need in the context
|
enumeration class is need in the context of the :class:~openlp.core.lib.imagemanager`.
|
||||||
of the :class:~openlp.core.lib.imagemanager`.
|
|
||||||
|
|
||||||
``ImagePlugin``
|
``ImagePlugin``
|
||||||
This states that an image is being used by the image plugin.
|
This states that an image is being used by the image plugin.
|
||||||
@ -73,8 +72,8 @@ class MediaType(object):
|
|||||||
|
|
||||||
class SlideLimits(object):
|
class SlideLimits(object):
|
||||||
"""
|
"""
|
||||||
Provides an enumeration for behaviour of OpenLP at the end limits of each
|
Provides an enumeration for behaviour of OpenLP at the end limits of each service item when pressing the up/down
|
||||||
service item when pressing the up/down arrow keys
|
arrow keys
|
||||||
"""
|
"""
|
||||||
End = 1
|
End = 1
|
||||||
Wrap = 2
|
Wrap = 2
|
||||||
@ -83,8 +82,7 @@ class SlideLimits(object):
|
|||||||
|
|
||||||
class ServiceItemAction(object):
|
class ServiceItemAction(object):
|
||||||
"""
|
"""
|
||||||
Provides an enumeration for the required action moving between service
|
Provides an enumeration for the required action moving between service items by left/right arrow keys
|
||||||
items by left/right arrow keys
|
|
||||||
"""
|
"""
|
||||||
Previous = 1
|
Previous = 1
|
||||||
PreviousLastSlide = 2
|
PreviousLastSlide = 2
|
||||||
@ -92,32 +90,28 @@ class ServiceItemAction(object):
|
|||||||
|
|
||||||
|
|
||||||
def translate(context, text, comment=None, encoding=QtCore.QCoreApplication.CodecForTr, n=-1,
|
def translate(context, text, comment=None, encoding=QtCore.QCoreApplication.CodecForTr, n=-1,
|
||||||
translate=QtCore.QCoreApplication.translate):
|
qt_translate=QtCore.QCoreApplication.translate):
|
||||||
"""
|
"""
|
||||||
A special shortcut method to wrap around the Qt4 translation functions.
|
A special shortcut method to wrap around the Qt4 translation functions. This abstracts the translation procedure so
|
||||||
This abstracts the translation procedure so that we can change it if at a
|
that we can change it if at a later date if necessary, without having to redo the whole of OpenLP.
|
||||||
later date if necessary, without having to redo the whole of OpenLP.
|
|
||||||
|
|
||||||
``context``
|
``context``
|
||||||
The translation context, used to give each string a context or a
|
The translation context, used to give each string a context or a namespace.
|
||||||
namespace.
|
|
||||||
|
|
||||||
``text``
|
``text``
|
||||||
The text to put into the translation tables for translation.
|
The text to put into the translation tables for translation.
|
||||||
|
|
||||||
``comment``
|
``comment``
|
||||||
An identifying string for when the same text is used in different roles
|
An identifying string for when the same text is used in different roles within the same context.
|
||||||
within the same context.
|
|
||||||
"""
|
"""
|
||||||
return translate(context, text, comment, encoding, n)
|
return qt_translate(context, text, comment, encoding, n)
|
||||||
|
|
||||||
|
|
||||||
def get_text_file_string(text_file):
|
def get_text_file_string(text_file):
|
||||||
"""
|
"""
|
||||||
Open a file and return its content as unicode string. If the supplied file
|
Open a file and return its content as unicode string. If the supplied file name is not a file then the function
|
||||||
name is not a file then the function returns False. If there is an error
|
returns False. If there is an error loading the file or the content can't be decoded then the function will return
|
||||||
loading the file or the content can't be decoded then the function will
|
None.
|
||||||
return None.
|
|
||||||
|
|
||||||
``textfile``
|
``textfile``
|
||||||
The name of the file.
|
The name of the file.
|
||||||
@ -141,28 +135,26 @@ def get_text_file_string(text_file):
|
|||||||
return content_string
|
return content_string
|
||||||
|
|
||||||
|
|
||||||
def str_to_bool(stringvalue):
|
def str_to_bool(string_value):
|
||||||
"""
|
"""
|
||||||
Convert a string version of a boolean into a real boolean.
|
Convert a string version of a boolean into a real boolean.
|
||||||
|
|
||||||
``stringvalue``
|
``string_value``
|
||||||
The string value to examine and convert to a boolean type.
|
The string value to examine and convert to a boolean type.
|
||||||
"""
|
"""
|
||||||
if isinstance(stringvalue, bool):
|
if isinstance(string_value, bool):
|
||||||
return stringvalue
|
return string_value
|
||||||
return unicode(stringvalue).strip().lower() in (u'true', u'yes', u'y')
|
return unicode(string_value).strip().lower() in (u'true', u'yes', u'y')
|
||||||
|
|
||||||
|
|
||||||
def build_icon(icon):
|
def build_icon(icon):
|
||||||
"""
|
"""
|
||||||
Build a QIcon instance from an existing QIcon, a resource location, or a
|
Build a QIcon instance from an existing QIcon, a resource location, or a physical file location. If the icon is a
|
||||||
physical file location. If the icon is a QIcon instance, that icon is
|
QIcon instance, that icon is simply returned. If not, it builds a QIcon instance from the resource or file name.
|
||||||
simply returned. If not, it builds a QIcon instance from the resource or
|
|
||||||
file name.
|
|
||||||
|
|
||||||
``icon``
|
``icon``
|
||||||
The icon to build. This can be a QIcon, a resource string in the form
|
The icon to build. This can be a QIcon, a resource string in the form ``:/resource/file.png``, or a file
|
||||||
``:/resource/file.png``, or a file location like ``/path/to/file.png``.
|
location like ``/path/to/file.png``.
|
||||||
"""
|
"""
|
||||||
button_icon = QtGui.QIcon()
|
button_icon = QtGui.QIcon()
|
||||||
if isinstance(icon, QtGui.QIcon):
|
if isinstance(icon, QtGui.QIcon):
|
||||||
@ -179,8 +171,7 @@ def build_icon(icon):
|
|||||||
|
|
||||||
def image_to_byte(image):
|
def image_to_byte(image):
|
||||||
"""
|
"""
|
||||||
Resize an image to fit on the current screen for the web and returns
|
Resize an image to fit on the current screen for the web and returns it as a byte stream.
|
||||||
it as a byte stream.
|
|
||||||
|
|
||||||
``image``
|
``image``
|
||||||
The image to converted.
|
The image to converted.
|
||||||
@ -198,8 +189,7 @@ def image_to_byte(image):
|
|||||||
|
|
||||||
def create_thumb(image_path, thumb_path, return_icon=True, size=None):
|
def create_thumb(image_path, thumb_path, return_icon=True, size=None):
|
||||||
"""
|
"""
|
||||||
Create a thumbnail from the given image path and depending on
|
Create a thumbnail from the given image path and depending on ``return_icon`` it returns an icon from this thumb.
|
||||||
``return_icon`` it returns an icon from this thumb.
|
|
||||||
|
|
||||||
``image_path``
|
``image_path``
|
||||||
The image file to create the icon from.
|
The image file to create the icon from.
|
||||||
@ -208,12 +198,10 @@ def create_thumb(image_path, thumb_path, return_icon=True, size=None):
|
|||||||
The filename to save the thumbnail to.
|
The filename to save the thumbnail to.
|
||||||
|
|
||||||
``return_icon``
|
``return_icon``
|
||||||
States if an icon should be build and returned from the thumb. Defaults
|
States if an icon should be build and returned from the thumb. Defaults to ``True``.
|
||||||
to ``True``.
|
|
||||||
|
|
||||||
``size``
|
``size``
|
||||||
Allows to state a own size to use. Defaults to ``None``, which means
|
Allows to state a own size to use. Defaults to ``None``, which means that a default height of 88 is used.
|
||||||
that a default height of 88 is used.
|
|
||||||
"""
|
"""
|
||||||
ext = os.path.splitext(thumb_path)[1].lower()
|
ext = os.path.splitext(thumb_path)[1].lower()
|
||||||
reader = QtGui.QImageReader(image_path)
|
reader = QtGui.QImageReader(image_path)
|
||||||
@ -234,9 +222,8 @@ def create_thumb(image_path, thumb_path, return_icon=True, size=None):
|
|||||||
|
|
||||||
def validate_thumb(file_path, thumb_path):
|
def validate_thumb(file_path, thumb_path):
|
||||||
"""
|
"""
|
||||||
Validates whether an file's thumb still exists and if is up to date.
|
Validates whether an file's thumb still exists and if is up to date. **Note**, you must **not** call this function,
|
||||||
**Note**, you must **not** call this function, before checking the
|
before checking the existence of the file.
|
||||||
existence of the file.
|
|
||||||
|
|
||||||
``file_path``
|
``file_path``
|
||||||
The path to the file. The file **must** exist!
|
The path to the file. The file **must** exist!
|
||||||
@ -359,10 +346,9 @@ def check_directory_exists(directory, do_not_log=False):
|
|||||||
|
|
||||||
def create_separated_list(stringlist):
|
def create_separated_list(stringlist):
|
||||||
"""
|
"""
|
||||||
Returns a string that represents a join of a list of strings with a
|
Returns a string that represents a join of a list of strings with a localized separator. This function corresponds
|
||||||
localized separator. This function corresponds to
|
to QLocale::createSeparatedList which was introduced in Qt 4.8 and implements the algorithm from
|
||||||
QLocale::createSeparatedList which was introduced in Qt 4.8 and implements
|
http://www.unicode.org/reports/tr35/#ListPatterns
|
||||||
the algorithm from http://www.unicode.org/reports/tr35/#ListPatterns
|
|
||||||
|
|
||||||
``stringlist``
|
``stringlist``
|
||||||
List of unicode strings
|
List of unicode strings
|
||||||
|
Loading…
Reference in New Issue
Block a user