Separate tool tips for the tool groups.

This commit is contained in:
Roman Telezhynskyi 2023-10-25 16:55:19 +03:00
parent 77024cd188
commit 8e2c0bc7ef
3 changed files with 45 additions and 1 deletions

View File

@ -1845,6 +1845,11 @@ void MainWindow::changeEvent(QEvent *event)
ToolBarOption(); ToolBarOption();
if (VApplication::VApp()->ValentinaSettings()->IsUseToolGroups())
{
ToolBarDrawTools();
}
UpdateWindowTitle(); UpdateWindowTitle();
emit m_sceneDetails->LanguageChanged(); emit m_sceneDetails->LanguageChanged();
} }
@ -3058,6 +3063,7 @@ void MainWindow::ToolBarDrawTools()
auto *linePointTool = new VToolButtonPopup(this); auto *linePointTool = new VToolButtonPopup(this);
linePointTool->setMenu(linePointToolMenu); linePointTool->setMenu(linePointToolMenu);
linePointTool->setDefaultAction(ui->actionEndLineTool); linePointTool->setDefaultAction(ui->actionEndLineTool);
linePointTool->SetToolGroupTooltip(tr("Point at a given distance tools"));
ui->toolBarPointTools->addWidget(linePointTool); ui->toolBarPointTools->addWidget(linePointTool);
} }
@ -3071,6 +3077,7 @@ void MainWindow::ToolBarDrawTools()
auto *angleLinePointTool = new VToolButtonPopup(this); auto *angleLinePointTool = new VToolButtonPopup(this);
angleLinePointTool->setMenu(angleLinePointToolMenu); angleLinePointTool->setMenu(angleLinePointToolMenu);
angleLinePointTool->setDefaultAction(ui->actionNormalTool); angleLinePointTool->setDefaultAction(ui->actionNormalTool);
angleLinePointTool->SetToolGroupTooltip(tr("Perpendicular/Bisector tools"));
ui->toolBarPointTools->addWidget(angleLinePointTool); ui->toolBarPointTools->addWidget(angleLinePointTool);
} }
@ -3083,6 +3090,7 @@ void MainWindow::ToolBarDrawTools()
auto *lineIntersectionPointTool = new VToolButtonPopup(this); auto *lineIntersectionPointTool = new VToolButtonPopup(this);
lineIntersectionPointTool->setMenu(lineIntersectionPointToolMenu); lineIntersectionPointTool->setMenu(lineIntersectionPointToolMenu);
lineIntersectionPointTool->setDefaultAction(ui->actionPointOfIntersectionTool); lineIntersectionPointTool->setDefaultAction(ui->actionPointOfIntersectionTool);
lineIntersectionPointTool->SetToolGroupTooltip(tr("Point at the intersections of lins/axis tools"));
ui->toolBarPointTools->addWidget(lineIntersectionPointTool); ui->toolBarPointTools->addWidget(lineIntersectionPointTool);
} }
@ -3095,6 +3103,7 @@ void MainWindow::ToolBarDrawTools()
auto *specialPointTool = new VToolButtonPopup(this); auto *specialPointTool = new VToolButtonPopup(this);
specialPointTool->setMenu(specialPointToolMenu); specialPointTool->setMenu(specialPointToolMenu);
specialPointTool->setDefaultAction(ui->actionShoulderPointTool); specialPointTool->setDefaultAction(ui->actionShoulderPointTool);
specialPointTool->SetToolGroupTooltip(tr("Triangular tools"));
ui->toolBarPointTools->addWidget(specialPointTool); ui->toolBarPointTools->addWidget(specialPointTool);
} }
@ -3108,6 +3117,7 @@ void MainWindow::ToolBarDrawTools()
auto *axisPointTool = new VToolButtonPopup(this); auto *axisPointTool = new VToolButtonPopup(this);
axisPointTool->setMenu(axisPointToolMenu); axisPointTool->setMenu(axisPointToolMenu);
axisPointTool->setDefaultAction(ui->actionLineIntersectAxisTool); axisPointTool->setDefaultAction(ui->actionLineIntersectAxisTool);
axisPointTool->SetToolGroupTooltip(tr("Point intersecting with axis tools"));
ui->toolBarPointTools->addWidget(axisPointTool); ui->toolBarPointTools->addWidget(axisPointTool);
} }
@ -3121,6 +3131,7 @@ void MainWindow::ToolBarDrawTools()
auto *curveSegmentPointTool = new VToolButtonPopup(this); auto *curveSegmentPointTool = new VToolButtonPopup(this);
curveSegmentPointTool->setMenu(curveSegmentPointToolMenu); curveSegmentPointTool->setMenu(curveSegmentPointToolMenu);
curveSegmentPointTool->setDefaultAction(ui->actionSplineCutPointTool); curveSegmentPointTool->setDefaultAction(ui->actionSplineCutPointTool);
curveSegmentPointTool->SetToolGroupTooltip(tr("Point segementing curves/arcs tools"));
ui->toolBarPointTools->addWidget(curveSegmentPointTool); ui->toolBarPointTools->addWidget(curveSegmentPointTool);
} }
@ -3134,6 +3145,7 @@ void MainWindow::ToolBarDrawTools()
auto *curveIntersectionPointTool = new VToolButtonPopup(this); auto *curveIntersectionPointTool = new VToolButtonPopup(this);
curveIntersectionPointTool->setMenu(curveIntersectionPointToolMenu); curveIntersectionPointTool->setMenu(curveIntersectionPointToolMenu);
curveIntersectionPointTool->setDefaultAction(ui->actionIntersectionCurvesTool); curveIntersectionPointTool->setDefaultAction(ui->actionIntersectionCurvesTool);
curveIntersectionPointTool->SetToolGroupTooltip(tr("Points interecting with 2 curves/arcs/circles tools"));
ui->toolBarPointTools->addWidget(curveIntersectionPointTool); ui->toolBarPointTools->addWidget(curveIntersectionPointTool);
} }
@ -3147,6 +3159,8 @@ void MainWindow::ToolBarDrawTools()
auto *tangentPointTool = new VToolButtonPopup(this); auto *tangentPointTool = new VToolButtonPopup(this);
tangentPointTool->setMenu(tangentPointToolMenu); tangentPointTool->setMenu(tangentPointToolMenu);
tangentPointTool->setDefaultAction(ui->actionPointFromArcAndTangentTool); tangentPointTool->setDefaultAction(ui->actionPointFromArcAndTangentTool);
tangentPointTool->SetToolGroupTooltip(
tr("Points intersecting with arcs/curves and tangents/segments tools"));
ui->toolBarPointTools->addWidget(tangentPointTool); ui->toolBarPointTools->addWidget(tangentPointTool);
} }
@ -3201,6 +3215,7 @@ void MainWindow::ToolBarDrawTools()
auto *curvePointTool = new VToolButtonPopup(this); auto *curvePointTool = new VToolButtonPopup(this);
curvePointTool->setMenu(curveToolMenu); curvePointTool->setMenu(curveToolMenu);
curvePointTool->setDefaultAction(ui->actionSplineTool); curvePointTool->setDefaultAction(ui->actionSplineTool);
curvePointTool->SetToolGroupTooltip(tr("Curves and arcs tools"));
ui->toolBarCurveTools->addWidget(curvePointTool); ui->toolBarCurveTools->addWidget(curvePointTool);
} }
@ -3230,6 +3245,7 @@ void MainWindow::ToolBarDrawTools()
auto *symmetryTool = new VToolButtonPopup(this); auto *symmetryTool = new VToolButtonPopup(this);
symmetryTool->setMenu(symmetryToolMenu); symmetryTool->setMenu(symmetryToolMenu);
symmetryTool->setDefaultAction(ui->actionFlippingByAxisTool); symmetryTool->setDefaultAction(ui->actionFlippingByAxisTool);
symmetryTool->SetToolGroupTooltip(tr("Flipping objects tools"));
ui->toolBarOperationTools->addWidget(symmetryTool); ui->toolBarOperationTools->addWidget(symmetryTool);
} }
@ -3242,6 +3258,7 @@ void MainWindow::ToolBarDrawTools()
auto *transformTool = new VToolButtonPopup(this); auto *transformTool = new VToolButtonPopup(this);
transformTool->setMenu(transformToolMenu); transformTool->setMenu(transformToolMenu);
transformTool->setDefaultAction(ui->actionRotationTool); transformTool->setDefaultAction(ui->actionRotationTool);
transformTool->SetToolGroupTooltip(tr("Rotating/moving objects tools"));
ui->toolBarOperationTools->addWidget(transformTool); ui->toolBarOperationTools->addWidget(transformTool);
} }
@ -3276,6 +3293,7 @@ void MainWindow::ToolBarDrawTools()
auto *detailTool = new VToolButtonPopup(this); auto *detailTool = new VToolButtonPopup(this);
detailTool->setMenu(detailToolMenu); detailTool->setMenu(detailToolMenu);
detailTool->setDefaultAction(ui->actionUnionDetailsTool); detailTool->setDefaultAction(ui->actionUnionDetailsTool);
detailTool->SetToolGroupTooltip(tr("Merge/duplicate pieces tools"));
ui->toolBarDetailTools->addWidget(detailTool); ui->toolBarDetailTools->addWidget(detailTool);
} }
@ -3290,6 +3308,7 @@ void MainWindow::ToolBarDrawTools()
auto *detailTool = new VToolButtonPopup(this); auto *detailTool = new VToolButtonPopup(this);
detailTool->setMenu(internalDetailItemToolMenu); detailTool->setMenu(internalDetailItemToolMenu);
detailTool->setDefaultAction(ui->actionInternalPathTool); detailTool->setDefaultAction(ui->actionInternalPathTool);
detailTool->SetToolGroupTooltip(tr("Adding objects for Details mode tools"));
ui->toolBarDetailTools->addWidget(detailTool); ui->toolBarDetailTools->addWidget(detailTool);
} }

View File

@ -34,5 +34,13 @@ VToolButtonPopup::VToolButtonPopup(QWidget *parent)
: QToolButton(parent) : QToolButton(parent)
{ {
setPopupMode(QToolButton::MenuButtonPopup); setPopupMode(QToolButton::MenuButtonPopup);
QObject::connect(this, &QToolButton::triggered, this, &QToolButton::setDefaultAction); QObject::connect(this, &QToolButton::triggered, this,
[this](QAction *action)
{
setDefaultAction(action);
if (!m_toolGroupTooltip.isEmpty())
{
setToolTip(m_toolGroupTooltip);
}
});
} }

View File

@ -42,8 +42,25 @@ public:
explicit VToolButtonPopup(QWidget *parent = nullptr); explicit VToolButtonPopup(QWidget *parent = nullptr);
~VToolButtonPopup() override = default; ~VToolButtonPopup() override = default;
auto GetToolGroupTooltip() const -> QString;
void SetToolGroupTooltip(const QString &toolGroupTooltip);
private: private:
Q_DISABLE_COPY_MOVE(VToolButtonPopup) // NOLINT Q_DISABLE_COPY_MOVE(VToolButtonPopup) // NOLINT
QString m_toolGroupTooltip{};
}; };
//---------------------------------------------------------------------------------------------------------------------
inline auto VToolButtonPopup::GetToolGroupTooltip() const -> QString
{
return m_toolGroupTooltip;
}
//---------------------------------------------------------------------------------------------------------------------
inline void VToolButtonPopup::SetToolGroupTooltip(const QString &toolGroupTooltip)
{
m_toolGroupTooltip = toolGroupTooltip;
}
#endif // VTOOLBUTTONPOPUP_H #endif // VTOOLBUTTONPOPUP_H