Improve tooltip. It should show object label.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2017-09-17 10:24:34 +03:00
parent dbe1981eb5
commit 6f160ebd9c
18 changed files with 77 additions and 33 deletions

View File

@ -169,11 +169,14 @@ QString VAbstractSpline::MakeToolTip() const
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(m_id);
const QString toolTip = QString("<table>"
"<tr> <td><b>%4:</b> %5</td> </tr>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"</table>")
.arg(tr("Length"))
.arg(qApp->fromPixel(curve->GetLength()))
.arg(UnitsToStr(qApp->patternUnit(), true));
.arg(UnitsToStr(qApp->patternUnit(), true))
.arg(tr("Label"))
.arg(curve->name());
return toolTip;
}

View File

@ -390,6 +390,7 @@ QString VToolArc::MakeToolTip() const
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(m_id);
const QString toolTip = QString("<table>"
"<tr> <td><b>%10:</b> %11</td> </tr>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5 %3</td> </tr>"
"<tr> <td><b>%6:</b> %7°</td> </tr>"
@ -403,6 +404,8 @@ QString VToolArc::MakeToolTip() const
.arg(tr("Start angle"))
.arg(qApp->fromPixel(arc->GetStartAngle()))
.arg(tr("End angle"))
.arg(qApp->fromPixel(arc->GetEndAngle()));
.arg(qApp->fromPixel(arc->GetEndAngle()))
.arg(tr("Label"))
.arg(arc->name());
return toolTip;
}

View File

@ -350,6 +350,7 @@ QString VToolArcWithLength::MakeToolTip() const
const QSharedPointer<VArc> arc = VAbstractTool::data.GeometricObject<VArc>(m_id);
const QString toolTip = QString("<table>"
"<tr> <td><b>%10:</b> %11</td> </tr>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5 %3</td> </tr>"
"<tr> <td><b>%6:</b> %7°</td> </tr>"
@ -363,6 +364,8 @@ QString VToolArcWithLength::MakeToolTip() const
.arg(tr("Start angle"))
.arg(qApp->fromPixel(arc->GetStartAngle()))
.arg(tr("End angle"))
.arg(qApp->fromPixel(arc->GetEndAngle()));
.arg(qApp->fromPixel(arc->GetEndAngle()))
.arg(tr("Label"))
.arg(arc->name());
return toolTip;
}

View File

@ -463,6 +463,7 @@ QString VToolEllipticalArc::MakeToolTip() const
const QSharedPointer<VEllipticalArc> elArc = VAbstractTool::data.GeometricObject<VEllipticalArc>(m_id);
const QString toolTip = QString("<table>"
"<tr> <td><b>%12:</b> %13</td> </tr>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5 %3</td> </tr>"
"<tr> <td><b>%6:</b> %7 %3</td> </tr>"
@ -479,6 +480,8 @@ QString VToolEllipticalArc::MakeToolTip() const
.arg(tr("Start angle"))
.arg(elArc->GetStartAngle())
.arg(tr("End angle"))
.arg(elArc->GetEndAngle());
.arg(elArc->GetEndAngle())
.arg(tr("Label"))
.arg(elArc->name());
return toolTip;
}

View File

@ -74,23 +74,6 @@ void VToolCut::FullUpdateFromFile()
SetVisualization();
}
//---------------------------------------------------------------------------------------------------------------------
QString VToolCut::MakeToolTip() const
{
const QSharedPointer<VAbstractCurve> curve = VAbstractTool::data.GeometricObject<VAbstractCurve>(curveCutId);
const QString toolTip = QString("<table>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5 %3</td> </tr>"
"<tr> <td><b>%6:</b> %7°</td> </tr>"
"<tr> <td><b>%8:</b> %9°</td> </tr>"
"</table>")
.arg(tr("Length"))
.arg(qApp->fromPixel(curve->GetLength()))
.arg(UnitsToStr(qApp->patternUnit(), true));
return toolTip;
}
//---------------------------------------------------------------------------------------------------------------------
// cppcheck-suppress unusedFunction
quint32 VToolCut::getCurveCutId() const

View File

@ -66,7 +66,6 @@ public slots:
virtual void Disable(bool disable, const QString &namePP) Q_DECL_OVERRIDE;
virtual void DetailsMode(bool mode) Q_DECL_OVERRIDE;
virtual void FullUpdateFromFile() Q_DECL_OVERRIDE;
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
protected:
/** @brief formula keep formula of length */
QString formula;

View File

@ -271,7 +271,8 @@ QString VToolCutArc::MakeToolTip() const
auto ArcToolTip = [arcStr, lengthStr, startAngleStr, endAngleStr, radiusStr](QString toolTip, const VArc &arc,
const QString &arcNumber)
{
toolTip += QString("<tr> <td><b>%1:</b> %2 %3</td> </tr>"
toolTip += QString("<tr> <td><b>%10:</b> %11</td> </tr>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5 %3</td> </tr>"
"<tr> <td><b>%6:</b> %7°</td> </tr>"
"<tr> <td><b>%8:</b> %9°</td> </tr>")
@ -283,7 +284,9 @@ QString VToolCutArc::MakeToolTip() const
.arg(arcStr + arcNumber + QLatin1String(" ") + startAngleStr)
.arg(qApp->fromPixel(arc.GetStartAngle()))
.arg(arcStr + arcNumber + QLatin1String(" ") + endAngleStr)
.arg(qApp->fromPixel(arc.GetEndAngle()));
.arg(qApp->fromPixel(arc.GetEndAngle()))
.arg(arcStr + arcNumber + QLatin1String(" ") + tr("label"))
.arg(arc.name());
return toolTip;
};

View File

@ -268,14 +268,20 @@ QString VToolCutSpline::MakeToolTip() const
const QString lengthStr = tr("length");
const QString toolTip = QString("<table>"
"<tr> <td><b>%6:</b> %7</td> </tr>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%8:</b> %9</td> </tr>"
"<tr> <td><b>%4:</b> %5 %3</td> </tr>"
"</table>")
.arg(curveStr + QLatin1String("1 ") + lengthStr)
.arg(qApp->fromPixel(spline1.GetLength()))
.arg(UnitsToStr(qApp->patternUnit(), true))
.arg(curveStr + QLatin1String("2 ") + lengthStr)
.arg(qApp->fromPixel(spline2.GetLength()));
.arg(qApp->fromPixel(spline2.GetLength()))
.arg(curveStr + QLatin1String(" 1") + tr("label"))
.arg(spline1.name())
.arg(curveStr + QLatin1String(" 2") + tr("label"))
.arg(spline2.name());
return toolTip;
}

View File

@ -354,14 +354,20 @@ QString VToolCutSplinePath::MakeToolTip() const
const QString lengthStr = tr("length");
const QString toolTip = QString("<table>"
"<tr> <td><b>%6:</b> %7</td> </tr>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%8:</b> %9</td> </tr>"
"<tr> <td><b>%4:</b> %5 %3</td> </tr>"
"</table>")
.arg(curveStr + QLatin1String("1 ") + lengthStr)
.arg(qApp->fromPixel(splPath1->GetLength()))
.arg(UnitsToStr(qApp->patternUnit(), true))
.arg(curveStr + QLatin1String("2 ") + lengthStr)
.arg(qApp->fromPixel(splPath2->GetLength()));
.arg(qApp->fromPixel(splPath2->GetLength()))
.arg(curveStr + QLatin1String(" 1") + tr("label"))
.arg(splPath1->name())
.arg(curveStr + QLatin1String(" 2") + tr("label"))
.arg(splPath2->name());
delete splPath1;
delete splPath2;

View File

@ -155,6 +155,7 @@ QString VToolAlongLine::MakeToolTip() const
const QLineF curToSecond(static_cast<QPointF>(*current), static_cast<QPointF>(*secondPoint));
const QString toolTip = QString("<table>"
"<tr> <td><b>%9:</b> %10</td> </tr>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5°</td> </tr>"
"<tr> <td><b>%6:</b> %2 %3</td> </tr>"
@ -167,7 +168,9 @@ QString VToolAlongLine::MakeToolTip() const
.arg(curLine.angle())
.arg(QString("%1->%2").arg(basePoint->name(), current->name()))
.arg(QString("%1->%2").arg(current->name(), secondPoint->name()))
.arg(qApp->fromPixel(curToSecond.length()));
.arg(qApp->fromPixel(curToSecond.length()))
.arg(tr("Label"))
.arg(current->name());
return toolTip;
}

View File

@ -280,6 +280,7 @@ QString VToolHeight::MakeToolTip() const
const QLineF p2ToCur(static_cast<QPointF>(*p2Line), static_cast<QPointF>(*current));
const QString toolTip = QString("<table>"
"<tr> <td><b>%10:</b> %11</td> </tr>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5°</td> </tr>"
"<tr> <td><b>%6:</b> %7 %3</td> </tr>"
@ -293,7 +294,9 @@ QString VToolHeight::MakeToolTip() const
.arg(QString("%1->%2").arg(p1Line->name(), current->name()))
.arg(qApp->fromPixel(p1ToCur.length()))
.arg(QString("%1->%2").arg(p2Line->name(), current->name()))
.arg(qApp->fromPixel(p2ToCur.length()));
.arg(qApp->fromPixel(p2ToCur.length()))
.arg(tr("Label"))
.arg(current->name());
return toolTip;
}

View File

@ -345,6 +345,7 @@ QString VToolLineIntersectAxis::MakeToolTip() const
const QLineF curToSecond(static_cast<QPointF>(*current), static_cast<QPointF>(*secondPoint));
const QString toolTip = QString("<table>"
"<tr> <td><b>%10:</b> %11</td> </tr>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5°</td> </tr>"
"<tr> <td><b>%6:</b> %7 %3</td> </tr>"
@ -358,6 +359,8 @@ QString VToolLineIntersectAxis::MakeToolTip() const
.arg(QString("%1->%2").arg(firstPoint->name(), current->name()))
.arg(qApp->fromPixel(firstToCur.length()))
.arg(QString("%1->%2").arg(current->name(), secondPoint->name()))
.arg(qApp->fromPixel(curToSecond.length()));
.arg(qApp->fromPixel(curToSecond.length()))
.arg(tr("Label"))
.arg(current->name());
return toolTip;
}

View File

@ -152,6 +152,7 @@ QString VToolLinePoint::MakeToolTip() const
const QLineF line(static_cast<QPointF>(*first), static_cast<QPointF>(*second));
const QString toolTip = QString("<table>"
"<tr> <td><b>%6:</b> %7</td> </tr>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5°</td> </tr>"
"</table>")
@ -159,7 +160,9 @@ QString VToolLinePoint::MakeToolTip() const
.arg(qApp->fromPixel(line.length()))
.arg(UnitsToStr(qApp->patternUnit(), true))
.arg(tr("Angle"))
.arg(line.angle());
.arg(line.angle())
.arg(tr("Label"))
.arg(second->name());
return toolTip;
}

View File

@ -342,6 +342,7 @@ QString VToolShoulderPoint::MakeToolTip() const
const QLineF secondToCur(static_cast<QPointF>(*second), static_cast<QPointF>(*current));
const QString toolTip = QString("<table>"
"<tr> <td><b>%8:</b> %9</td> </tr>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5°</td> </tr>"
"<tr> <td><b>%6:</b> %7 %3</td> </tr>"
@ -352,7 +353,9 @@ QString VToolShoulderPoint::MakeToolTip() const
.arg(tr("Angle"))
.arg(firstToCur.angle())
.arg(QString("%1->%2").arg(second->name(), current->name()))
.arg(qApp->fromPixel(secondToCur.length()));
.arg(qApp->fromPixel(secondToCur.length()))
.arg(tr("Label"))
.arg(current->name());
return toolTip;
}

View File

@ -370,6 +370,19 @@ void VToolBasePoint::ReadToolAttributes(const QDomElement &domElement)
// This tool doesn't need read attributes from file.
}
//---------------------------------------------------------------------------------------------------------------------
QString VToolBasePoint::MakeToolTip() const
{
const QSharedPointer<VPointF> point = VAbstractTool::data.GeometricObject<VPointF>(m_id);
const QString toolTip = QString("<table>"
"<tr> <td><b>%1:</b> %2</td> </tr>"
"</table>")
.arg(tr("Label"))
.arg(point->name());
return toolTip;
}
//---------------------------------------------------------------------------------------------------------------------
void VToolBasePoint::ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id)
{

View File

@ -86,6 +86,7 @@ protected:
virtual void SaveOptions(QDomElement &tag, QSharedPointer<VGObject> &obj) Q_DECL_OVERRIDE;
virtual void ReadToolAttributes(const QDomElement &domElement) Q_DECL_OVERRIDE;
virtual void SetVisualization() Q_DECL_OVERRIDE {}
virtual QString MakeToolTip() const Q_DECL_OVERRIDE;
private slots:
virtual void ShowContextMenu(QGraphicsSceneContextMenuEvent *event, quint32 id=NULL_ID) Q_DECL_OVERRIDE;
private:

View File

@ -308,6 +308,7 @@ QString VToolLineIntersect::MakeToolTip() const
const QLineF curToP2L2(static_cast<QPointF>(*current), static_cast<QPointF>(*p2L2));
const QString toolTip = QString("<table>"
"<tr> <td><b>%10:</b> %11</td> </tr>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5 %3</td> </tr>"
"<tr> <td><b>%6:</b> %7 %3</td> </tr>"
@ -321,7 +322,9 @@ QString VToolLineIntersect::MakeToolTip() const
.arg(QString("%1->%2").arg(p1L2->name(), current->name()))
.arg(qApp->fromPixel(p1L2ToCur.length()))
.arg(QString("%1->%2").arg(current->name(), p2L2->name()))
.arg(qApp->fromPixel(curToP2L2.length()));
.arg(qApp->fromPixel(curToP2L2.length()))
.arg(tr("Label"))
.arg(current->name());
return toolTip;
}

View File

@ -350,6 +350,7 @@ QString VToolPointOfContact::MakeToolTip() const
const QLineF centerToCur(static_cast<QPointF>(*centerP), static_cast<QPointF>(*current));
const QString toolTip = QString("<table>"
"<tr> <td><b>%10:</b> %11</td> </tr>"
"<tr> <td><b>%1:</b> %2 %3</td> </tr>"
"<tr> <td><b>%4:</b> %5 %3</td> </tr>"
"<tr> <td><b>%6:</b> %7 %3</td> </tr>"
@ -363,7 +364,9 @@ QString VToolPointOfContact::MakeToolTip() const
.arg(QString("%1 %2->%3").arg(tr("Length"), centerP->name(), current->name()))
.arg(qApp->fromPixel(centerToCur.length()))
.arg(QString("%1 %2->%3").arg(tr("Angle"), centerP->name(), current->name()))
.arg(centerToCur.angle());
.arg(centerToCur.angle())
.arg(tr("Label"))
.arg(current->name());
return toolTip;
}