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:
parent
4f5534a87a
commit
615d037de0
|
@ -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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -170,6 +170,10 @@ public:
|
|||
|
||||
protected:
|
||||
void customEvent(QEvent* e);
|
||||
|
||||
private:
|
||||
void add_workbench(QString wb, int i);
|
||||
|
||||
};
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
|
|
|
@ -55,6 +55,7 @@ DlgWorkbenchesImp::DlgWorkbenchesImp(QWidget* parent)
|
|||
lw_disabled_workbenches->setSortingEnabled(true);
|
||||
|
||||
QStringList enabled_wbs_list = load_enabled_workbenches();
|
||||
QStringList disabled_wbs_list = load_disabled_workbenches();
|
||||
QStringList workbenches = Application::Instance->workbenches();
|
||||
|
||||
for (QStringList::Iterator it = enabled_wbs_list.begin(); it != enabled_wbs_list.end(); ++it) {
|
||||
|
@ -65,8 +66,11 @@ DlgWorkbenchesImp::DlgWorkbenchesImp(QWidget* parent)
|
|||
}
|
||||
}
|
||||
for (QStringList::Iterator it = workbenches.begin(); it != workbenches.end(); ++it) {
|
||||
if (!enabled_wbs_list.contains(*it)){
|
||||
if (disabled_wbs_list.contains(*it)){
|
||||
add_workbench(lw_disabled_workbenches, *it);
|
||||
} else if (!enabled_wbs_list.contains(*it)){
|
||||
qDebug() << "Adding unknown " << *it << "workbench.";
|
||||
add_workbench(lw_enabled_workbenches, *it);
|
||||
}
|
||||
}
|
||||
lw_enabled_workbenches->setCurrentRow(0);
|
||||
|
@ -109,7 +113,7 @@ void DlgWorkbenchesImp::changeEvent(QEvent *e)
|
|||
|
||||
void DlgWorkbenchesImp::hideEvent(QHideEvent * event)
|
||||
{
|
||||
save_enabled_workbenches();
|
||||
save_workbenches();
|
||||
}
|
||||
|
||||
void DlgWorkbenchesImp::onAddMacroAction(const QByteArray& macro)
|
||||
|
@ -209,9 +213,23 @@ QStringList DlgWorkbenchesImp::load_enabled_workbenches()
|
|||
return enabled_wbs_list;
|
||||
}
|
||||
|
||||
void DlgWorkbenchesImp::save_enabled_workbenches()
|
||||
QStringList DlgWorkbenchesImp::load_disabled_workbenches()
|
||||
{
|
||||
QString disabled_wbs;
|
||||
QStringList disabled_wbs_list;
|
||||
ParameterGrp::handle hGrp;
|
||||
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Workbenches");
|
||||
disabled_wbs = QString::fromStdString(hGrp->GetASCII("Disabled", ""));
|
||||
disabled_wbs_list = disabled_wbs.split(QLatin1String(","), QString::SkipEmptyParts);
|
||||
|
||||
return disabled_wbs_list;
|
||||
}
|
||||
|
||||
void DlgWorkbenchesImp::save_workbenches()
|
||||
{
|
||||
QString enabled_wbs;
|
||||
QString disabled_wbs;
|
||||
ParameterGrp::handle hGrp;
|
||||
|
||||
hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Workbenches");
|
||||
|
@ -227,6 +245,13 @@ void DlgWorkbenchesImp::save_enabled_workbenches()
|
|||
}
|
||||
}
|
||||
hGrp->SetASCII("Enabled", enabled_wbs.toAscii());
|
||||
|
||||
for (int i = 0; i < lw_disabled_workbenches->count(); i++) {
|
||||
QVariant item_data = lw_disabled_workbenches->item(i)->data(Qt::UserRole);
|
||||
QString name = item_data.toString();
|
||||
disabled_wbs.append(name + QString::fromAscii(","));
|
||||
}
|
||||
hGrp->SetASCII("Disabled", disabled_wbs.toAscii());
|
||||
}
|
||||
|
||||
#include "moc_DlgWorkbenchesImp.cpp"
|
||||
|
|
|
@ -38,6 +38,7 @@ public:
|
|||
DlgWorkbenchesImp(QWidget* parent = 0);
|
||||
~DlgWorkbenchesImp();
|
||||
static QStringList load_enabled_workbenches();
|
||||
static QStringList load_disabled_workbenches();
|
||||
static const QString all_workbenches;
|
||||
|
||||
protected:
|
||||
|
@ -60,7 +61,7 @@ private:
|
|||
void add_workbench(QListWidgetCustom *lw, const QString& it);
|
||||
void move_workbench(QListWidgetCustom *lwc_dest,
|
||||
QListWidgetItem *wi);
|
||||
void save_enabled_workbenches();
|
||||
void save_workbenches();
|
||||
void shift_workbench(bool up);
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user