From 4ed902e07fddc068d331ab2934dbaaec388cf5e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Br=C3=A6strup=20Sayoc?= Date: Sun, 9 Feb 2025 18:17:43 +0100 Subject: [PATCH] Fem: Use QStringLiteral --- src/Mod/Fem/Gui/AppFemGuiPy.cpp | 2 +- src/Mod/Fem/Gui/TaskFemConstraintBearing.cpp | 2 +- .../Fem/Gui/TaskFemConstraintDisplacement.cpp | 6 ++-- .../Gui/TaskFemConstraintFluidBoundary.cpp | 30 +++++++++---------- src/Mod/Fem/Gui/TaskFemConstraintForce.cpp | 2 +- src/Mod/Fem/Gui/TaskFemConstraintGear.cpp | 2 +- src/Mod/Fem/Gui/TaskPostBoxes.cpp | 8 ++--- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/Mod/Fem/Gui/AppFemGuiPy.cpp b/src/Mod/Fem/Gui/AppFemGuiPy.cpp index a68ad07f9d..e446ac45d9 100644 --- a/src/Mod/Fem/Gui/AppFemGuiPy.cpp +++ b/src/Mod/Fem/Gui/AppFemGuiPy.cpp @@ -150,7 +150,7 @@ private: Gui::getMainWindow()->addWindow(edit); QFont font = editor->font(); - font.setFamily(QString::fromLatin1("Arial")); + font.setFamily(QStringLiteral("Arial")); editor->setFont(font); } diff --git a/src/Mod/Fem/Gui/TaskFemConstraintBearing.cpp b/src/Mod/Fem/Gui/TaskFemConstraintBearing.cpp index e3169174cd..72d355449c 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintBearing.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintBearing.cpp @@ -349,7 +349,7 @@ bool TaskDlgFemConstraintBearing::accept() std::string locobj = parameterBearing->getLocationObject().data(); if (!locname.empty()) { - QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])"); + QString buf = QStringLiteral("(App.ActiveDocument.%1,[\"%2\"])"); buf = buf.arg(QString::fromStdString(locname)); buf = buf.arg(QString::fromStdString(locobj)); Gui::Command::doCommand(Gui::Command::Doc, diff --git a/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp b/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp index 56a390b8b6..69538df7fe 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintDisplacement.cpp @@ -409,21 +409,21 @@ std::string TaskFemConstraintDisplacement::get_spinzRotation() const std::string TaskFemConstraintDisplacement::get_xFormula() const { QString xFormula = ui->DisplacementXFormulaLE->text(); - xFormula.replace(QString::fromLatin1("\""), QString::fromLatin1("\\\"")); + xFormula.replace(QStringLiteral("\""), QStringLiteral("\\\"")); return xFormula.toStdString(); } std::string TaskFemConstraintDisplacement::get_yFormula() const { QString yFormula = ui->DisplacementYFormulaLE->text(); - yFormula.replace(QString::fromLatin1("\""), QString::fromLatin1("\\\"")); + yFormula.replace(QStringLiteral("\""), QStringLiteral("\\\"")); return yFormula.toStdString(); } std::string TaskFemConstraintDisplacement::get_zFormula() const { QString zFormula = ui->DisplacementZFormulaLE->text(); - zFormula.replace(QString::fromLatin1("\""), QString::fromLatin1("\\\"")); + zFormula.replace(QStringLiteral("\""), QStringLiteral("\\\"")); return zFormula.toStdString(); } diff --git a/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp b/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp index 3c597136ce..fedea39960 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintFluidBoundary.cpp @@ -387,31 +387,31 @@ void TaskFemConstraintFluidBoundary::updateBoundaryTypeUI() // Update subtypes, any change here should be written back to FemConstraintFluidBoundary.cpp if (boundaryType == "wall") { - ui->labelBoundaryValue->setText(QString::fromUtf8("velocity (m/s)")); + ui->labelBoundaryValue->setText(QStringLiteral("velocity (m/s)")); ui->tabBasicBoundary->setEnabled(false); pcConstraint->Subtype.setEnums(WallSubtypes); } else if (boundaryType == "interface") { - ui->labelBoundaryValue->setText(QString::fromUtf8("value not needed")); + ui->labelBoundaryValue->setText(QStringLiteral("value not needed")); ui->tabBasicBoundary->setEnabled(false); pcConstraint->Subtype.setEnums(InterfaceSubtypes); } else if (boundaryType == "freestream") { ui->tabBasicBoundary->setEnabled(false); - ui->labelBoundaryValue->setText(QString::fromUtf8("value not needed")); + ui->labelBoundaryValue->setText(QStringLiteral("value not needed")); ui->tabBasicBoundary->setEnabled(false); pcConstraint->Subtype.setEnums(FreestreamSubtypes); } else if (boundaryType == "inlet") { ui->tabBasicBoundary->setEnabled(true); pcConstraint->Subtype.setEnums(InletSubtypes); - ui->labelBoundaryValue->setText(QString::fromUtf8("Pressure [Pa]")); // default to pressure + ui->labelBoundaryValue->setText(QStringLiteral("Pressure [Pa]")); // default to pressure pcConstraint->Reversed.setValue(true); // inlet must point into volume } else if (boundaryType == "outlet") { ui->tabBasicBoundary->setEnabled(true); pcConstraint->Subtype.setEnums(OutletSubtypes); - ui->labelBoundaryValue->setText(QString::fromUtf8("Pressure [Pa]")); + ui->labelBoundaryValue->setText(QStringLiteral("Pressure [Pa]")); pcConstraint->Reversed.setValue(false); // outlet must point outward } else { @@ -437,49 +437,49 @@ void TaskFemConstraintFluidBoundary::updateSubtypeUI() if (boundaryType == "inlet" || boundaryType == "outlet") { ui->tabBasicBoundary->setEnabled(true); if (subtype == "totalPressure" || subtype == "staticPressure") { - ui->labelBoundaryValue->setText(QString::fromUtf8("pressure [Pa]")); + ui->labelBoundaryValue->setText(QStringLiteral("pressure [Pa]")); ui->buttonDirection->setEnabled(false); ui->lineDirection->setEnabled(false); } else if (subtype == "uniformVelocity") { - ui->labelBoundaryValue->setText(QString::fromUtf8("velocity [m/s]")); + ui->labelBoundaryValue->setText(QStringLiteral("velocity [m/s]")); ui->buttonDirection->setEnabled(true); ui->lineDirection->setEnabled(true); } else if (subtype == "massFlowrate") { - ui->labelBoundaryValue->setText(QString::fromUtf8("flowrate [kg/s]")); + ui->labelBoundaryValue->setText(QStringLiteral("flowrate [kg/s]")); ui->buttonDirection->setEnabled(false); ui->lineDirection->setEnabled(false); } else if (subtype == "volumetricFlowRate") { - ui->labelBoundaryValue->setText(QString::fromUtf8("flowrate [m3/s]")); + ui->labelBoundaryValue->setText(QStringLiteral("flowrate [m3/s]")); ui->buttonDirection->setEnabled(false); ui->lineDirection->setEnabled(false); } else { - ui->labelBoundaryValue->setText(QString::fromUtf8("unspecific")); + ui->labelBoundaryValue->setText(QStringLiteral("unspecific")); ui->tabBasicBoundary->setEnabled(false); } } else if (boundaryType == "wall") { if (subtype == "moving") { - ui->labelBoundaryValue->setText(QString::fromUtf8("moving speed (m/s)")); + ui->labelBoundaryValue->setText(QStringLiteral("moving speed (m/s)")); ui->tabBasicBoundary->setEnabled(true); ui->buttonDirection->setEnabled(false); // moving speed must be parallel to wall ui->lineDirection->setEnabled(false); } else if (subtype == "slip") { - ui->labelBoundaryValue->setText(QString::fromUtf8("not needed")); + ui->labelBoundaryValue->setText(QStringLiteral("not needed")); ui->tabBasicBoundary->setEnabled(false); } else if (subtype == "partialSlip") { - ui->labelBoundaryValue->setText(QString::fromUtf8("slip ratio(0~1)")); + ui->labelBoundaryValue->setText(QStringLiteral("slip ratio(0~1)")); ui->tabBasicBoundary->setEnabled(true); ui->buttonDirection->setEnabled(false); ui->lineDirection->setEnabled(false); } else { - ui->labelBoundaryValue->setText(QString::fromUtf8("unspecific")); + ui->labelBoundaryValue->setText(QStringLiteral("unspecific")); ui->tabBasicBoundary->setEnabled(false); } } @@ -1016,7 +1016,7 @@ bool TaskDlgFemConstraintFluidBoundary::accept() std::string dirobj = boundary->getDirectionObject().data(); if (!dirname.empty()) { - QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])"); + QString buf = QStringLiteral("(App.ActiveDocument.%1,[\"%2\"])"); buf = buf.arg(QString::fromStdString(dirname)); buf = buf.arg(QString::fromStdString(dirobj)); Gui::Command::doCommand(Gui::Command::Doc, diff --git a/src/Mod/Fem/Gui/TaskFemConstraintForce.cpp b/src/Mod/Fem/Gui/TaskFemConstraintForce.cpp index 283c8d8ad9..41fd4079fa 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintForce.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintForce.cpp @@ -434,7 +434,7 @@ bool TaskDlgFemConstraintForce::accept() std::string scale = "1"; if (!dirname.empty()) { - QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])"); + QString buf = QStringLiteral("(App.ActiveDocument.%1,[\"%2\"])"); buf = buf.arg(QString::fromStdString(dirname)); buf = buf.arg(QString::fromStdString(dirobj)); Gui::Command::doCommand(Gui::Command::Doc, diff --git a/src/Mod/Fem/Gui/TaskFemConstraintGear.cpp b/src/Mod/Fem/Gui/TaskFemConstraintGear.cpp index f1a68d685b..3a116dff1c 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintGear.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintGear.cpp @@ -298,7 +298,7 @@ bool TaskDlgFemConstraintGear::accept() std::string dirobj = parameterGear->getDirectionObject().data(); if (!dirname.empty()) { - QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])"); + QString buf = QStringLiteral("(App.ActiveDocument.%1,[\"%2\"])"); buf = buf.arg(QString::fromStdString(dirname)); buf = buf.arg(QString::fromStdString(dirobj)); Gui::Command::doCommand(Gui::Command::Doc, diff --git a/src/Mod/Fem/Gui/TaskPostBoxes.cpp b/src/Mod/Fem/Gui/TaskPostBoxes.cpp index 8fff98bfaf..fff5725a15 100644 --- a/src/Mod/Fem/Gui/TaskPostBoxes.cpp +++ b/src/Mod/Fem/Gui/TaskPostBoxes.cpp @@ -390,7 +390,7 @@ TaskPostDisplay::TaskPostDisplay(ViewProviderFemPostObject* view, QWidget* paren int trans = getTypedView()->Transparency.getValue(); // sync the trancparency slider ui->Transparency->setValue(trans); - ui->Transparency->setToolTip(QString::number(trans) + QString::fromLatin1(" %")); + ui->Transparency->setToolTip(QString::number(trans) + QStringLiteral(" %")); } TaskPostDisplay::~TaskPostDisplay() = default; @@ -441,9 +441,9 @@ void TaskPostDisplay::onVectorModeActivated(int i) void TaskPostDisplay::onTransparencyValueChanged(int i) { getTypedView()->Transparency.setValue(i); - ui->Transparency->setToolTip(QString::number(i) + QString::fromLatin1(" %")); + ui->Transparency->setToolTip(QString::number(i) + QStringLiteral(" %")); // highlight the tooltip - QToolTip::showText(QCursor::pos(), QString::number(i) + QString::fromLatin1(" %"), nullptr); + QToolTip::showText(QCursor::pos(), QString::number(i) + QStringLiteral(" %"), nullptr); } void TaskPostDisplay::applyPythonCode() @@ -1228,7 +1228,7 @@ void TaskPostDataAtPoint::showValue(double pointValue, const char* unitStr) QString value = QString::fromStdString(toString(pointValue)); QString unit = QString::fromUtf8(unitStr); - ui->ValueAtPoint->setText(QString::fromLatin1("%1 %2").arg(value, unit)); + ui->ValueAtPoint->setText(QStringLiteral("%1 %2").arg(value, unit)); QString field = ui->Field->currentText(); QString posX = ui->centerX->text();