C

SafeRenderer::StateManager Class

class SafeRenderer::StateManager

The StateManager class maintains the state of the indicators. More...

Header: #include <StateManager>
Since: QtSafeRenderer 1.0

Public Functions

StateManager(SafeRenderer::QSafeAbstractWindow &window, SafeRenderer::QSafeLayout &layout, const SafeRenderer::ARGB clearColorArg = ARGB())
void addLayout(SafeRenderer::QSafeLayout *const layout)
void advanceAnimations()
void connect(const SafeRenderer::quint32 eventArg, const SafeRenderer::qchar *const itemName)
void connect(const SafeRenderer::quint32 eventArg, const SafeRenderer::quint32 itemIdArg)
SafeRenderer::quint32 getCurrentPressedItemId() const
(since QtSafeRenderer 2.0) SafeRenderer::quint32 getItemAtPosition(const SafeRenderer::qint32 xArg, const SafeRenderer::qint32 yArg) const
SafeRenderer::ItemState &getItemState(const SafeRenderer::quint32 itemIdArg, bool allowCreatingEmptyId = false) &
SafeRenderer::quint32 getLayout() const
const SafeRenderer::LayoutItem &getLayoutItem(const SafeRenderer::quint32 idArg) const
void handleConnection(const SafeRenderer::QSafeEventSystem &eventArg)
bool isInTransition() const
bool isItemInTransition(const SafeRenderer::quint32 itemIdArg) const
void releaseAllPressedItems()
bool setLayout(SafeRenderer::QSafeLayout *const layout)
void updateTouchState(const SafeRenderer::quint32 itemIdArg, const SafeRenderer::TouchState touchStateArg)

Detailed Description

The StateManager class maintains the state of the indicators.

Member Function Documentation

[explicit] StateManager::StateManager(SafeRenderer::QSafeAbstractWindow &window, SafeRenderer::QSafeLayout &layout, const SafeRenderer::ARGB clearColorArg = ARGB())

Constructs a StateManager object with the given window framebuffer, the layout default layout, and the clearColorArg clear color value.

In case of a failure, one of the following exceptions will be thrown:

void StateManager::addLayout(SafeRenderer::QSafeLayout *const layout)

Adds new layout to the state manager. At this point layout is not taken into use. Each QSafeLayout instances has an unique id which is the hash value of the layout file. This value is used in QSafeEventChangeLayout event when requesting a layout change.

In case of a failure, one of the following exceptions will be thrown:

void StateManager::advanceAnimations()

Advances animations if there are transitions ongoing. This function should be called by the animation timer. If there is no transitions ongoing this function does nothing.

void StateManager::connect(const SafeRenderer::quint32 eventArg, const SafeRenderer::qchar *const itemName)

Connects the external eventArg to the itemName layout item. itemName is the objectName of the safe item in QML.

In case of a failure, one of the following exceptions will be thrown:

ExceptionIdDescription
SafeRenderer::QStateManagerExceptionSafeRenderer::QStateManagerException::StateManagerException::ConnectionAlreadyExistsThe event is already connected.
SafeRenderer::QStateManagerExceptionSafeRenderer::QStateManagerException::StateManagerException::TooManyConnectionsThe number of connections exceeds the value defined in SafeRenderer::Constraints::MAX_NUM_OF_CONNECTIONS.
SafeRenderer::QStateManagerExceptionSafeRenderer::QStateManagerException::StateManagerException::StateNotFoundThe connected item could not be found.

An example of the QML definiton:

SafePicture {
    id: iconCoolant
    objectName: "iconCoolant"
    width: 30
    height: 30
    color: "#e41e25"
    source: "qrc:/iso-icons/iso_grs_7000_4_2426.dat"
}

You can connect the external event EventEngineTemperature to the iconCoolant item as follows:

stateManager.connect(SafeRenderer::EventEngineTemperature, "iconCoolant");

void StateManager::connect(const SafeRenderer::quint32 eventArg, const SafeRenderer::quint32 itemIdArg)

Connects the external eventArg to the itemIdArg layout item. itemIdArg is the calculated hash of the safe item objectName in QML.

In case of a failure, one of the following exceptions will be thrown:

ExceptionIdDescription
SafeRenderer::QStateManagerExceptionSafeRenderer::QStateManagerException::StateManagerException::ConnectionAlreadyExistsThe event is already connected.
SafeRenderer::QStateManagerExceptionSafeRenderer::QStateManagerException::StateManagerException::TooManyConnectionsThe number of connections exceeds the value defined in SafeRenderer::Constraints::MAX_NUM_OF_CONNECTIONS.
SafeRenderer::QStateManagerExceptionSafeRenderer::QStateManagerException::StateManagerException::StateNotFoundThe connected item could not be found.

SafeRenderer::quint32 StateManager::getCurrentPressedItemId() const

Retrieves the ID of the currently pressed item.

Returns The ID of the currently pressed item, or 0 if no item is pressed.

[since QtSafeRenderer 2.0] SafeRenderer::quint32 StateManager::getItemAtPosition(const SafeRenderer::qint32 xArg, const SafeRenderer::qint32 yArg) const

Returns the ID of the item at the xArg and yArg position. In case there are multiple items at the same position, the top-most visible item is returned.

Returns Topmost item's id. 0 if there is no visible item at the position.

This function was introduced in QtSafeRenderer 2.0.

SafeRenderer::ItemState &StateManager::getItemState(const SafeRenderer::quint32 itemIdArg, bool allowCreatingEmptyId = false) &

In case of item state for item itemIdArg is not found, QStateManagerException with exception id QStateManagerException::StateManagerException::ItemStateNotFound will be thrown.

If allowCreatingEmptyId is set, a dummy item state is created with the requested id. This is required because certain non-safe items may own state transitions, so they still require item state even if the item itself does not exist in the QSR runtime.

Returns the state of an item with id itemIdArg.

SafeRenderer::quint32 StateManager::getLayout() const

Returns the ID of the active layout. 0 in case of no active layout found.

const SafeRenderer::LayoutItem &StateManager::getLayoutItem(const SafeRenderer::quint32 idArg) const

Returns SafeRenderer::LayoutItem identified by idArg in the currently active layout.

void StateManager::handleConnection(const SafeRenderer::QSafeEventSystem &eventArg)

Handles an eventArg that can change its associated state between ON and OFF.

In case of a failure, one of the following exceptions will be thrown:

bool StateManager::isInTransition() const

Returns true if there is transitions ongoing otherwise returns false.

bool StateManager::isItemInTransition(const SafeRenderer::quint32 itemIdArg) const

Returns true if the item itemIdArg is in transtion otherwise returns false.

void StateManager::releaseAllPressedItems()

Releases all pressed items.

bool StateManager::setLayout(SafeRenderer::QSafeLayout *const layout)

Changes the current layout of StateManager to layout.

In case of a failure, one of the following exceptions will be thrown:

ExceptionIdDescription
SafeRenderer::QSafeRendererExceptionSafeRenderer::QSafeRendererException::RendererException::BitmapOufOfScreenThe bitmap does not fit inside screen area.
SafeRenderer::QSafeRendererExceptionSafeRenderer::QSafeRendererException::RendererException::InvalidBitmapPointerThe bitmap pointer is a null pointer.
SafeRenderer::QSafeRendererExceptionSafeRenderer::QSafeRendererException::RendererException::InvalidBitmapIdThe bitmap ID is 0.

Returns true if the layout change succeeded, otherwise false.

void StateManager::updateTouchState(const SafeRenderer::quint32 itemIdArg, const SafeRenderer::TouchState touchStateArg)

Updates the touch state touchStateArg of the specified item itemIdArg.

If the touchStateArg is TouchState::Pressed, it ignores the event if there is already a pressed item, ensuring that only a single item can be in the "pressed" state at any given time. If the touchStateArg is TouchState::Pressed and no item is currently pressed, it releases the currently pressed item (if any) and sets the new item as pressed. If the touchStateArg is TouchState::Released, it releases all pressed items and resets the current pressed item ID.

Throws QStateManagerException with id StateManagerException::ItemStateNotFound if item state for the itemIdArg was not found.

Available under certain Qt licenses.
Find out more.