Navigation Menu

Skip to content

Commit

Permalink
+ filter out removed workbenches
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jun 10, 2015
1 parent 4a7419c commit 5040a97
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
29 changes: 22 additions & 7 deletions src/Gui/Action.cpp
Expand Up @@ -516,12 +516,13 @@ void WorkbenchGroup::addTo(QWidget *w)
}
}

void WorkbenchGroup::addWorkbench(const QString& wb, int i)
void WorkbenchGroup::setWorkbenchData(int i, const QString& wb)
{
QList<QAction*> workbenches = _group->actions();
QString name = Application::Instance->workbenchMenuText(wb);
QPixmap px = Application::Instance->workbenchIcon(wb);
QString tip = Application::Instance->workbenchToolTip(wb);

workbenches[i]->setObjectName(wb);
workbenches[i]->setIcon(px);
workbenches[i]->setText(name);
Expand All @@ -537,16 +538,30 @@ void WorkbenchGroup::refreshWorkbenchList()
QStringList disabled_wbs_list = DlgWorkbenchesImp::load_disabled_workbenches();
int i=0;

for (QStringList::Iterator it = enabled_wbs_list.begin(); it != enabled_wbs_list.end(); ++it, i++) {
addWorkbench(*it, i);
// Go through the list of enabled workbenches and verify that they really exist because
// it might be possible that a workbench has been removed after setting up the list of
// enabled workbenches.
for (QStringList::Iterator it = enabled_wbs_list.begin(); it != enabled_wbs_list.end(); ++it) {
int index = items.indexOf(*it);
if (index >= 0) {
setWorkbenchData(i++, *it);
items.removeAt(index);
}
}

for (QStringList::Iterator it = items.begin(); it != items.end(); ++it) {
if (!disabled_wbs_list.contains(*it) && !enabled_wbs_list.contains(*it)){
addWorkbench(*it, i);
i++;
// Filter out the actively disabled workbenches
for (QStringList::Iterator it = disabled_wbs_list.begin(); it != disabled_wbs_list.end(); ++it) {
int index = items.indexOf(*it);
if (index >= 0) {
items.removeAt(index);
}
}

// Now add the remaining workbenches of 'items'. They have been added to the application
// after setting up the list of enabled workbenches.
for (QStringList::Iterator it = items.begin(); it != items.end(); ++it) {
setWorkbenchData(i++, *it);
}
}

void WorkbenchGroup::customEvent( QEvent* e )
Expand Down
2 changes: 1 addition & 1 deletion src/Gui/Action.h
Expand Up @@ -172,7 +172,7 @@ class GuiExport WorkbenchGroup : public ActionGroup
void customEvent(QEvent* e);

private:
void addWorkbench(const QString& wb, int i);
void setWorkbenchData(int i, const QString& wb);
};

// --------------------------------------------------------------------
Expand Down

0 comments on commit 5040a97

Please sign in to comment.