It would be nicer the state were inside a class rather than global like this. 

Perhaps a class for the trainer functionality, which is then a member of the dialog? If you need something to hold the state even then the dialog isn't visible then it can be a member of the main window.

The same comment applies for the other two tools.