Skip to content

Commit

Permalink
[macros toolbar walkthrough] Use command manager to check for existin…
Browse files Browse the repository at this point in the history
…g macro action rather than looking through user parameters
  • Loading branch information
mwganson authored and wwmayer committed Jul 21, 2019
1 parent eac812d commit ffeb838
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 7 additions & 8 deletions src/Gui/DlgMacroExecuteImp.cpp
Expand Up @@ -465,14 +465,13 @@ Note: your changes will be applied when you next switch workbenches\n"));
/** check if user already has this macro command created, if so skip dialog 1 **/
bool hasMacroCommand = false;
QString macroMenuText;
std::vector <Base::Reference<ParameterGrp>> macroGroups =
App::GetApplication().GetParameterGroupByPath(QByteArray("User parameter:BaseApp/Macro/Macros"))->GetGroups();
for (std::vector<Base::Reference<ParameterGrp>>::iterator it = macroGroups.begin(); it != macroGroups.end(); ++it){
QString script = QString::fromUtf8((*it)->GetASCII("Script").c_str()); //macro filename
if(script == fn){
CommandManager & cCmdMgr = Application::Instance->commandManager();
std::vector<Command*> aCmds = cCmdMgr.getGroupCommands("Macros");
for (std::vector<Command*>::iterator it = aCmds.begin(); it != aCmds.end(); ++it) {
MacroCommand* mc = (MacroCommand*)(*it);
if(QString::fromLatin1(mc->getScriptName()) == fn){
hasMacroCommand = true;
macroMenuText = QString::fromUtf8((*it)->GetASCII("Menu").c_str()); //this text is in the command list in the toolbars tab
break;
macroMenuText = QString::fromLatin1(mc->getMenuText());
}
}

Expand Down Expand Up @@ -575,7 +574,7 @@ Note: your changes will be applied when you next switch workbenches\n"));
} else {
/** find the Global workbench and select it for the user **/

int globalIdx = workbenchBox->findText(tr("Global"));
int globalIdx = workbenchBox->findText(QString::fromLatin1("Global"));;
if (globalIdx != -1){
workbenchBox->setCurrentIndex(globalIdx);
setupToolbarPage->on_workbenchBox_activated(globalIdx);
Expand Down
2 changes: 1 addition & 1 deletion src/Gui/DlgToolbarsImp.cpp
Expand Up @@ -112,7 +112,7 @@ DlgCustomToolbars::DlgCustomToolbars(DlgCustomToolbars::Type t, QWidget* parent)
QStringList workbenches = Application::Instance->workbenches();
workbenches.sort();
index = 1;
workbenchBox->addItem(QApplication::windowIcon(), tr("Global"));
workbenchBox->addItem(QApplication::windowIcon(), QString::fromLatin1("Global"));
workbenchBox->setItemData(0, QVariant(QString::fromLatin1("Global")), Qt::UserRole);
for (QStringList::Iterator it = workbenches.begin(); it != workbenches.end(); ++it) {
QPixmap px = Application::Instance->workbenchIcon(*it);
Expand Down

0 comments on commit ffeb838

Please sign in to comment.