QStateMachine and dependent properties
-
setting states
@
state_downloading_ = new QState(&state_machine_);
state_downloading_->assignProperty(download_button_, "enabled", false);state_download_finished_ = new QState(state_machine_);
state_download_finished_->assignProperty(download_button_, "enabled", true);state_general_ = new QState(&state_machine_);
state_general_->assignProperty(download_button_, "enabled", true);state_loading_theme_ = new QState(&state_machine);
state_loading_theme_->assignProperty(download_button_, "enabled", false);
@setting transition
@
state_downloading_->addTransition(this, SIGNAL(download_finish()), state_download_finish_);
state_download_finished_->addTransition(loading_button_, SIGNAL(clicked()), state_loading_theme_);state_general_->addTransition(download_button_, SIGNAL(clicked()), state_downloading_);
state_general_->addTransition(loading_button_, SIGNAL(clicked()), state_loading_theme_);state_loading_theme_->addTransition(this, SIGNAL(loading_finish()), state_general_);
@The problem is, these states are asynchronous and the properties of
the download button is dependent on the states
That means something likestate_downloading_->disabled button->state_download_finished_->button_enabled
state_loading_theme_->disabled button--------------------------->still downloading and the button should be disabledI could solve this by mutex and without setting the property of the button by assignProperty
But this is ugly, do I have better choices?Thanks