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.

process_updates()[source]

Flush the queue to updated any data to update

update_display()[source]

Screen has changed size so rebuild the cache to new size.

update_image_border(path, source, background, width=-1, height=-1)[source]

Border has changed so update the image affected.

update_images_border(source, background)[source]

Border has changed so update all the images affected.

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.

run()[source]

Run the thread.

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 whose QImage 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 the QImage 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’s priority attribute, the second value the Image’s secondary_priority attribute. The last value the Image 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.

modify_priority(image, new_priority)[source]

Modifies the priority of the given image.

Parameters:
  • image – The image to remove. This should be an Image instance.
  • new_priority – The image’s new priority. See the Priority class for priorities.
remove(image)[source]

Removes the given image from the queue.

Parameters:image – The image to remove. This should be an Image instance.