App: Add workbenches with unknown status to enabled list

Newly installed workbenches are not on enabled nor disabled list, so
they were treated as disabled. That behaviur could be confusing for
the user as a newly installed workbench was not shouwing up on the
workbench list. This commit changes that behaviour and new workbenches
are enabled by default.

Reported-by: r-frank
Signed-off-by: Przemo Firszt <przemo@firszt.eu>
This commit is contained in:
Przemo Firszt
2015-05-27 21:10:09 +01:00
committed by wmayer
parent 4f5534a87a
commit 615d037de0
4 changed files with 56 additions and 31 deletions

View File

@@ -516,40 +516,35 @@ void WorkbenchGroup::addTo(QWidget *w)
}
}
void WorkbenchGroup::refreshWorkbenchList()
{
QString active = QString::fromAscii(WorkbenchManager::instance()->active()->name().c_str());
QStringList items = Application::Instance->workbenches();
QStringList enabled_wbs_list = DlgWorkbenchesImp::load_enabled_workbenches();
QList<QAction*> workbenches = _group->actions();
int numWorkbenches = std::min<int>(workbenches.count(), items.count());
int i=0;
for (QStringList::Iterator it = enabled_wbs_list.begin(); it != enabled_wbs_list.end(); ++it, i++) {
QString s = *it;
QString name = Application::Instance->workbenchMenuText(*it);
QPixmap px = Application::Instance->workbenchIcon(*it);
QString tip = Application::Instance->workbenchToolTip(*it);
workbenches[i]->setObjectName(*it);
void WorkbenchGroup::add_workbench(QString wb, int i) {
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);
workbenches[i]->setToolTip(tip);
workbenches[i]->setStatusTip(tr("Select the '%1' workbench").arg(name));
workbenches[i]->setVisible(false);
workbenches[i]->setVisible(true);
// Note: See remark at WorkbenchComboBox::onWorkbenchActivated
// Calling setChecked() here causes to uncheck the current item
// item in comboboxes these action were added to.
//if (items[i] == active)
//workbenches[i]->setChecked(true);
}
void WorkbenchGroup::refreshWorkbenchList()
{
QStringList items = Application::Instance->workbenches();
QStringList enabled_wbs_list = DlgWorkbenchesImp::load_enabled_workbenches();
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++) {
add_workbench(*it, i);
}
// if less workbenches than actions
for (int index = numWorkbenches; index < workbenches.count(); index++) {
workbenches[index]->setObjectName(QString());
workbenches[index]->setIcon(QIcon());
workbenches[index]->setText(QString());
workbenches[index]->setVisible(false);
for (QStringList::Iterator it = items.begin(); it != items.end(); ++it) {
if (!disabled_wbs_list.contains(*it) && !enabled_wbs_list.contains(*it)){
add_workbench(*it, i);
i++;
}
}
}