Fixed a refactoring damage: the application mode indicator did not follow programmatic changes.

This commit is contained in:
Matthias Koefferlein 2020-04-05 14:01:44 +02:00
parent 4cdb76a33e
commit d1f1cf3031
3 changed files with 14 additions and 1 deletions

View File

@ -1850,7 +1850,7 @@ MainWindow::select_mode (int m)
std::vector<std::string> items = menu ()->items ("@toolbar");
for (std::vector<std::string>::const_iterator i = items.begin (); i != items.end (); ++i) {
Action *a = menu ()->action (*i);
if (a->qaction ()->isCheckable() && a->qaction ()->data ().toInt () == m_mode) {
if (a->is_checkable() && a->is_for_mode (m_mode)) {
a->set_checked (true);
break;
}

View File

@ -301,6 +301,14 @@ public:
*/
virtual void triggered ();
/**
* @brief Returns true, if the action is associated with a specific mode ID
*/
virtual bool is_for_mode (int /*mode_id*/) const
{
return false;
}
/**
* @brief Get the underlying QAction object
*

View File

@ -131,6 +131,11 @@ public:
}
}
bool is_for_mode (int mode_id) const
{
return mode_id == m_mode;
}
private:
Dispatcher *mp_dispatcher;
int m_mode;