imagemanager¶
Provides the store and management for Images automatically caching them and resizing them when needed. Only one copy of each image is needed in the system. A Thread is used to convert the image to a byte array so the user does not need to wait for the conversion to happen.
-
class
openlp.core.lib.imagemanager.
Image
(path, source, background, width=-1, height=-1)[source]¶ Bases:
object
This class represents an image. To mark an image as dirty call the
ImageManager
’s_reset_image
method with the Image instance as argument.-
secondary_priority
= 0¶
-
-
class
openlp.core.lib.imagemanager.
ImageManager
[source]¶ Bases:
PyQt5.QtCore.QObject
Image Manager handles the conversion and sizing of images.
-
add_image
(path, source, background, width=-1, height=-1)[source]¶ Add image to cache if it is not already there.
-
get_image
(path, source, width=-1, height=-1)[source]¶ Return the
QImage
from the cache. If not present wait for the background thread to process it.
-
get_image_bytes
(path, source, width=-1, height=-1)[source]¶ Returns the byte string for an image. If not present wait for the background thread to process it.
-
-
class
openlp.core.lib.imagemanager.
ImageThread
(manager)[source]¶ Bases:
PyQt5.QtCore.QThread
A special Qt thread class to speed up the display of images. This is threaded so it loads the frames and generates byte stream in background.
-
class
openlp.core.lib.imagemanager.
Priority
[source]¶ Bases:
object
Enumeration class for different priorities.
Lowest
- Only the image’s byte stream has to be generated. But neither the
QImage
nor the byte stream has been requested yet. Low
- Only the image’s byte stream has to be generated. Because the image’s
QImage
has been requested previously it is reasonable to assume that the byte stream will be needed before the byte stream of other images whoseQImage
were not generated due to a request. Normal
- The image’s byte stream as well as the image has to be generated. Neither the
QImage
nor the byte stream has been requested yet. High
- The image’s byte stream as well as the image has to be generated. The
QImage
for this image has been requested. Note, this priority is only set when theQImage
has not been generated yet. Urgent
- The image’s byte stream as well as the image has to be generated. The byte stream for this image has been requested. Note, this priority is only set when the byte stream has not been generated yet.
-
High
= 1¶
-
Low
= 3¶
-
Lowest
= 4¶
-
Normal
= 2¶
-
Urgent
= 0¶
-
class
openlp.core.lib.imagemanager.
PriorityQueue
(maxsize=0)[source]¶ Bases:
queue.PriorityQueue
Customised
Queue.PriorityQueue
.Each item in the queue must be a tuple with three values. The first value is the
Image
’spriority
attribute, the second value theImage
’ssecondary_priority
attribute. The last value theImage
instance itself:(image.priority, image.secondary_priority, image)
Doing this, the
Queue.PriorityQueue
will sort the images according to their priorities, but also according to there number. However, the number only has an impact on the result if there are more images with the same priority. In such case the image which has been added earlier is privileged.