Merge pull request #4788 from 0penBrain/UserEditMode

Gui: add user edit mode (default edit mode set by user)
This commit is contained in:
Yorik van Havre
2021-09-02 11:50:03 +02:00
committed by GitHub
14 changed files with 1591 additions and 7 deletions

View File

@@ -1244,6 +1244,50 @@ void Application::tryClose(QCloseEvent * e)
}
}
int Application::getUserEditMode(const std::string &mode) const
{
if (mode.empty()) {
return userEditMode;
}
for (auto const &uem : userEditModes) {
if (uem.second == mode) {
return uem.first;
}
}
return -1;
}
std::string Application::getUserEditModeName(int mode) const
{
if (mode == -1) {
return userEditModes.at(userEditMode);
}
if (userEditModes.find(mode) != userEditModes.end()) {
return userEditModes.at(mode);
}
return "";
}
bool Application::setUserEditMode(int mode)
{
if (userEditModes.find(mode) != userEditModes.end() && userEditMode != mode) {
userEditMode = mode;
this->signalUserEditModeChanged(userEditMode);
return true;
}
return false;
}
bool Application::setUserEditMode(const std::string &mode)
{
for (auto const &uem : userEditModes) {
if (uem.second == mode) {
return setUserEditMode(uem.first);
}
}
return false;
}
/**
* Activate the matching workbench to the registered workbench handler with name \a name.
* The handler must be an instance of a class written in Python.