Hi
The IMode interface has two functions related to mode icons:
- modeIcon() used to retrieve the icon to show.
- setModeIcon(), which can be used to set the icon of the mode. Note that the implementation of IMode needs to manually re-implement this function if the mode need to allow changing of its icon. By default, the function does nothing. The "Session Log" mode supports changing of its icon, thus it has an implementation of this function.
However, the ModeManager only gets the icon when its initialized. Therefore you need to call setModeIcon() before initializing the mode manager. To support your request, support must be added to allow the mode implementation to emit a signal to notify that its icon changed, and the ModeManager needs to connect to this. However, because the IMode interface does not inherit QObject we cannot add such a signal on the interface itself. I suggest that a modeIconChanged() virtual abstract function needs to be added. All modes must implement it as a signal, even if they don't re-implement setModeIcon().
This would mean that all application's which implement IMode must be updated to add this signal. However, I think it might be a worthwhile change for the next Qtilities release (v1.5). What do you think? An alternative would be to add a function on ModeManager which tells it to refresh the icon for a given IMode interface, maybe a better approach?
In terms of doing the overlay, something like the following should work to overlay something in the bottom left corner for example:
QPixmap pixmap(my_mode->modeIcon().pixmap(48,48));
QPixmap result(48, 48);
result.fill(Qt::transparent);
QPainter painter(&result);
painter.drawPixmap(0, 0, pixmap);
QPixmap overlay("path_to_overlay_image");
painter.drawPixmap(result.width()-1-overlay.width(), result.height()-1-overlay.height(), overlay);
my_mode->setModeIcon(QIcon(result));
I won't be able to add built-in support for the Session Log mode at the moment, but would support you if you want to give it a try.