caron/PyQtForSoftimage — pull request #4 by anuska (2012-05-09 14:06:26+00:00)
Title: controling signals and events

Hello,

Here you have my changes. The main change is that the class SISignals is a singleton now, that is able to register the connected signals so it can mute and unmute the XSI events when necessary.

The class has four new methods: connect, disconnect, emit, reload. They are in the charge of process the qt signal and the xsi event.

Connect
----------------------------------------------------------

Example:
from sisignals import signals
signals.connect('siActivate', foo)

Explanation:
A registry saying that the signal 'siActivate' and the slot 'foo' are connected will be created. And if the signal hasn't been already registered, its associated xsi QtEvents_Active' will be unmuted. And of course, the most import thing, the connection will be made.

Disconnect
----------------------------------------------------------

Example:
from sisignals import signals
signals.disconnect('siActivate', foo)

Explanation:
The signal and the slot will be disconnected and if there aren't more registries related to this signal, its associated xsi event will be muted.
In this way, we can open the same dialog twice or have two different dialogs using the same signal/event.

Emit
----------------------------------------------------------

Example:
from sisignals import signals
signals.emit('siActivate', True)

Explanation:
This just emit the signal as usual. I've made it just for treat all SISignals in the same way.

Reload
-------------------------------------------------------------

Example:
from signals import signals
signal.reload()

Explanation:
Sometimes you want to clean and restart your singleton. It cleans the registry and mute all events and it is used when the QtEvents is loaded.