Skip to content

Commit

Permalink
Attacher: use the new strings in UI
Browse files Browse the repository at this point in the history
* user-friendly mode names
* tooltips
  • Loading branch information
DeepSOIC committed Apr 21, 2016
1 parent 314617f commit cdc507f
Showing 1 changed file with 6 additions and 40 deletions.
46 changes: 6 additions & 40 deletions src/Mod/PartDesign/Gui/TaskDatumParameters.cpp
Expand Up @@ -49,6 +49,7 @@
#include <Mod/Part/App/PrimitiveFeature.h>
#include <Mod/Part/App/DatumFeature.h>
#include <Mod/PartDesign/App/Body.h>
#include <Mod/Part/Gui/AttacherTexts.h>

#include "ReferenceSelection.h"
#include "Utils.h"
Expand Down Expand Up @@ -232,50 +233,13 @@ TaskDatumParameters::TaskDatumParameters(ViewProviderDatum *DatumView,QWidget *p
DatumView->setPickable(false);
}

QString getShTypeText(eRefType type)
{
//get rid of flags in type
type = eRefType(type & (rtFlagHasPlacement - 1));

const char* eRefTypeStrings[] = {
QT_TR_NOOP("Any"),
QT_TR_NOOP("Vertex"),
QT_TR_NOOP("Edge"),
QT_TR_NOOP("Face"),

QT_TR_NOOP("Line"),
QT_TR_NOOP("Curve"),
QT_TR_NOOP("Circle"),
QT_TR_NOOP("Conic"),
QT_TR_NOOP("Ellipse"),
QT_TR_NOOP("Parabola"),
QT_TR_NOOP("Hyperbola"),

QT_TR_NOOP("Plane"),
QT_TR_NOOP("Sphere"),
QT_TR_NOOP("Revolve"),
QT_TR_NOOP("Cylinder"),
QT_TR_NOOP("Torus"),
QT_TR_NOOP("Cone"),
//
QT_TR_NOOP("Object"),
QT_TR_NOOP("Solid"),
QT_TR_NOOP("Wire"),
NULL
};

if (type >= 0 && type < rtDummy_numberOfShapeTypes)
if (eRefTypeStrings[int(type)])
return QObject::tr(eRefTypeStrings[int(type)]);
throw Base::Exception("getShTypeText: type value is wrong, or a string is missing in the list");
}

const QString makeHintText(std::set<eRefType> hint)
{
QString result;
for (std::set<eRefType>::const_iterator t = hint.begin(); t != hint.end(); t++) {
QString tText;
tText = getShTypeText(*t);
tText = AttacherGui::getShapeTypeText(*t);
result += QString::fromLatin1(result.size() == 0 ? "" : "/") + tText;
}

Expand Down Expand Up @@ -691,12 +655,14 @@ void TaskDatumParameters::updateListOfModes(eMapMode curMode)
if (modesInList.size()>0) {
for (size_t i = 0 ; i < modesInList.size() ; ++i){
eMapMode mmode = modesInList[i];
ui->listOfModes->addItem(QString::fromLatin1(AttachEngine::eMapModeStrings[mmode]));
std::vector<QString> mstr = AttacherGui::getUIStrings(pcDatum->attacher().getTypeId(),mmode);
ui->listOfModes->addItem(mstr[0]);
QListWidgetItem* item = ui->listOfModes->item(i);
item->setToolTip(mstr[1]);
if (mmode == curMode)
iSelect = ui->listOfModes->item(i);
if (mmode == suggMode){
//make it bold
QListWidgetItem* item = ui->listOfModes->item(i);
assert (item);
QFont fnt = item->font();
fnt.setBold(true);
Expand Down

0 comments on commit cdc507f

Please sign in to comment.