From f647d4a1eb2da6e13e5264d7bae46d1b05abcffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Br=C3=A6strup=20Sayoc?= Date: Sun, 9 Feb 2025 18:33:01 +0100 Subject: [PATCH] Gui: Use QStringLiteral --- src/Gui/Action.cpp | 33 +++--- src/Gui/Application.cpp | 12 +- src/Gui/AutoSaver.cpp | 4 +- src/Gui/BitmapFactory.cpp | 26 ++--- src/Gui/Command.cpp | 4 +- src/Gui/CommandDoc.cpp | 8 +- src/Gui/CommandFeat.cpp | 12 +- src/Gui/CommandPyImp.cpp | 2 +- src/Gui/CommandStd.cpp | 8 +- src/Gui/CommandTest.cpp | 4 +- src/Gui/CommandView.cpp | 64 +++++------ src/Gui/DAGView/DAGFilter.cpp | 2 +- src/Gui/Dialogs/DlgAbout.cpp | 104 +++++++++--------- src/Gui/Dialogs/DlgActionsImp.cpp | 4 +- src/Gui/Dialogs/DlgAddPropertyVarSet.cpp | 6 +- src/Gui/Dialogs/DlgCheckableMessageBox.cpp | 2 +- src/Gui/Dialogs/DlgCheckableMessageBox.h | 4 +- .../Dialogs/DlgCreateNewPreferencePackImp.cpp | 2 +- src/Gui/Dialogs/DlgCustomizeImp.cpp | 2 +- src/Gui/Dialogs/DlgCustomizeSpaceball.cpp | 6 +- src/Gui/Dialogs/DlgMacroExecuteImp.cpp | 50 ++++----- src/Gui/Dialogs/DlgOnlineHelpImp.cpp | 4 +- src/Gui/Dialogs/DlgParameterImp.cpp | 32 +++--- src/Gui/Dialogs/DlgProjectUtility.cpp | 4 +- src/Gui/Dialogs/DlgPropertyLink.cpp | 10 +- .../Dialogs/DlgSettingsColorGradientImp.cpp | 2 +- src/Gui/Dialogs/DlgToolbarsImp.cpp | 8 +- src/Gui/Dialogs/DlgUnitsCalculatorImp.cpp | 14 +-- src/Gui/Document.cpp | 12 +- src/Gui/DocumentRecovery.cpp | 24 ++-- src/Gui/EditorView.cpp | 8 +- src/Gui/ExpressionBinding.cpp | 6 +- src/Gui/FileDialog.cpp | 22 ++-- src/Gui/GraphvizView.cpp | 42 +++---- src/Gui/InputField.cpp | 18 +-- src/Gui/InputVector.cpp | 2 +- src/Gui/InputVector.h | 6 +- src/Gui/Language/Translator.cpp | 6 +- src/Gui/MDIView.cpp | 4 +- src/Gui/Macro.cpp | 14 +-- src/Gui/MainWindow.cpp | 40 +++---- src/Gui/NetworkRetriever.cpp | 40 +++---- src/Gui/NotificationArea.cpp | 8 +- src/Gui/OnlineDocumentation.cpp | 12 +- src/Gui/Placement.cpp | 8 +- src/Gui/PrefWidgets.cpp | 2 +- src/Gui/PreferencePackManager.cpp | 12 +- .../DlgSettingsCacheDirectory.cpp | 30 ++--- .../DlgSettingsDocumentImp.cpp | 2 +- src/Gui/PreferencePages/DlgSettingsEditor.cpp | 2 +- .../PreferencePages/DlgSettingsGeneral.cpp | 4 +- .../DlgSettingsLightSources.cpp | 2 +- .../PreferencePages/DlgSettingsNavigation.cpp | 12 +- .../DlgSettingsWorkbenchesImp.cpp | 10 +- src/Gui/ProgressBar.cpp | 2 +- src/Gui/ProgressDialog.cpp | 2 +- src/Gui/PropertyView.cpp | 2 +- src/Gui/PythonConsole.cpp | 22 ++-- src/Gui/PythonEditor.cpp | 16 +-- src/Gui/QSint/actionpanel/actionlabel.cpp | 2 +- src/Gui/QSint/actionpanel/freecadscheme.cpp | 2 +- src/Gui/QuantitySpinBox.cpp | 8 +- src/Gui/ReportView.cpp | 8 +- src/Gui/Selection/Selection.cpp | 2 +- src/Gui/Selection/SelectionView.cpp | 36 +++--- src/Gui/SoFCCSysDragger.cpp | 6 +- src/Gui/SpinBox.cpp | 2 +- src/Gui/SplashScreen.cpp | 4 +- src/Gui/StartupProcess.cpp | 6 +- src/Gui/TextDocumentEditorView.cpp | 2 +- src/Gui/TextEdit.cpp | 4 +- src/Gui/TextureMapping.cpp | 2 +- src/Gui/Thumbnail.cpp | 2 +- src/Gui/ToolHandler.cpp | 4 +- src/Gui/Tree.cpp | 6 +- src/Gui/VectorListEditor.cpp | 2 +- src/Gui/View3DInventor.cpp | 2 +- src/Gui/ViewProviderGroupExtension.cpp | 2 +- src/Gui/WidgetFactory.cpp | 2 +- src/Gui/Widgets.cpp | 26 ++--- src/Gui/WorkbenchSelector.cpp | 8 +- src/Gui/propertyeditor/PropertyEditor.cpp | 4 +- src/Gui/propertyeditor/PropertyItem.cpp | 72 ++++++------ 83 files changed, 519 insertions(+), 520 deletions(-) diff --git a/src/Gui/Action.cpp b/src/Gui/Action.cpp index f340f7fbb6..2c940ca0a7 100644 --- a/src/Gui/Action.cpp +++ b/src/Gui/Action.cpp @@ -331,10 +331,10 @@ QString Action::createToolTip(QString helpText, helpText.resize(helpText.size() - shortcut.size()); } if (!shortcut.isEmpty()) { - shortcut = QString::fromLatin1(" (%1)").arg(shortcut); + shortcut = QStringLiteral(" (%1)").arg(shortcut); } - QString tooltip = QString::fromLatin1( + QString tooltip = QStringLiteral( "

%1%2

").arg( text.toHtmlEscaped(), shortcut.toHtmlEscaped()); @@ -371,12 +371,11 @@ QString Action::createToolTip(QString helpText, return tooltip + helpText + cmdName; } - tooltip += QString::fromLatin1( - "

"); + tooltip += QStringLiteral("

"); // If the user supplied tooltip contains line break, we shall honour it. if (helpText.indexOf(QLatin1Char('\n')) >= 0) { - tooltip += helpText.toHtmlEscaped() + QString::fromLatin1("

") ; + tooltip += helpText.toHtmlEscaped() + QStringLiteral("

") ; } else { // If not, try to end the non wrapping paragraph at some pre defined @@ -385,7 +384,7 @@ QString Action::createToolTip(QString helpText, QFontMetrics fm(font); int width = QtTools::horizontalAdvance(fm, helpText); if (width <= tipWidth) { - tooltip += helpText.toHtmlEscaped() + QString::fromLatin1("

") ; + tooltip += helpText.toHtmlEscaped() + QStringLiteral("

") ; } else { int index = tipWidth / width * helpText.size(); @@ -396,7 +395,7 @@ QString Action::createToolTip(QString helpText, } } tooltip += helpText.left(index).toHtmlEscaped() - + QString::fromLatin1("

") + + QStringLiteral("

") + helpText.right(helpText.size()-index).trimmed().toHtmlEscaped(); } } @@ -475,7 +474,7 @@ void ActionGroup::addTo(QWidget *widget) widget->addAction(action()); QToolButton* tb = widget->findChildren().constLast(); tb->setPopupMode(QToolButton::MenuButtonPopup); - tb->setObjectName(QString::fromLatin1("qt_toolbutton_menubutton")); + tb->setObjectName(QStringLiteral("qt_toolbutton_menubutton")); QList acts = groupAction()->actions(); auto menu = new QMenu(tb); menu->addActions(acts); @@ -692,7 +691,7 @@ void WorkbenchGroup::refreshWorkbenchList() action->setToolTip(tip); action->setStatusTip(tr("Select the '%1' workbench").arg(name)); if (index < 9) { - action->setShortcut(QKeySequence(QString::fromUtf8("W,%1").arg(index + 1))); + action->setShortcut(QKeySequence(QStringLiteral("W,%1").arg(index + 1))); } if (wbName.toStdString() == activeWbName) { action->setChecked(true); @@ -850,10 +849,10 @@ void RecentFilesAction::appendFile(const QString& filename) static QString numberToLabel(int number) { if (number > 0 && number < 10) { // NOLINT: *-magic-numbers - return QString::fromLatin1("&%1").arg(number); + return QStringLiteral("&%1").arg(number); } if (number == 10) { // NOLINT: *-magic-numbers - return QString::fromLatin1("1&0"); + return QStringLiteral("1&0"); } // If we have a number greater than 10, we start using the alphabet. // So 11 becomes 'A' and so on. @@ -861,10 +860,10 @@ static QString numberToLabel(int number) { constexpr char lettersEnd = lettersStart + ('Z' - 'A'); if (number >= lettersStart && number < lettersEnd) { QChar letter = QChar::fromLatin1('A' + (number - lettersStart)); - return QString::fromLatin1("%1 (&%2)").arg(number).arg(letter); + return QStringLiteral("%1 (&%2)").arg(number).arg(letter); } // Not enough accelerators to cover this number. - return QString::fromLatin1("%1").arg(number); + return QStringLiteral("%1").arg(number); } /** @@ -879,7 +878,7 @@ void RecentFilesAction::setFiles(const QStringList& files) for (int index = 0; index < numRecentFiles; index++) { QString numberLabel = numberToLabel(index + 1); QFileInfo fi(files[index]); - recentFiles[index]->setText(QString::fromLatin1("%1 %2").arg(numberLabel).arg(fi.fileName())); + recentFiles[index]->setText(QStringLiteral("%1 %2").arg(numberLabel).arg(fi.fileName())); recentFiles[index]->setStatusTip(tr("Open file %1").arg(files[index])); recentFiles[index]->setToolTip(files[index]); // set the full name that we need later for saving recentFiles[index]->setData(QVariant(index)); @@ -977,7 +976,7 @@ void RecentFilesAction::save() QList recentFiles = groupAction()->actions(); int num = std::min(count, recentFiles.count()); for (int index = 0; index < num; index++) { - QString key = QString::fromLatin1("MRU%1").arg(index); + QString key = QStringLiteral("MRU%1").arg(index); QString value = recentFiles[index]->toolTip(); if (value.isEmpty()) { break; @@ -1041,7 +1040,7 @@ void RecentMacrosAction::setFiles(const QStringList& files) for (int index = 0; index < numRecentFiles; index++) { QFileInfo fi(files[index]); QString numberLabel = numberToLabel(index + 1); - recentFiles[index]->setText(QString::fromLatin1("%1 %2").arg(numberLabel).arg(fi.completeBaseName())); + recentFiles[index]->setText(QStringLiteral("%1 %2").arg(numberLabel).arg(fi.completeBaseName())); recentFiles[index]->setToolTip(files[index]); // set the full name that we need later for saving recentFiles[index]->setData(QVariant(index)); QString accel(tr("none")); @@ -1192,7 +1191,7 @@ void RecentMacrosAction::save() QList recentFiles = groupAction()->actions(); int num = std::min(count, recentFiles.count()); for (int index = 0; index < num; index++) { - QString key = QString::fromLatin1("MRU%1").arg(index); + QString key = QStringLiteral("MRU%1").arg(index); QString value = recentFiles[index]->toolTip(); if (value.isEmpty()) { break; diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index 383c6c87d2..5a13553bf4 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -2457,22 +2457,22 @@ QString Application::replaceVariablesInQss(QString qssText) // convert them to hex. // Note: the ulong contains alpha channels so 8 hex characters when we need 6 here. - QString accentColor1 = QString::fromLatin1("#%1") + QString accentColor1 = QStringLiteral("#%1") .arg(longAccentColor1, 8, 16, QLatin1Char('0')) .toUpper() .mid(0, 7); - QString accentColor2 = QString::fromLatin1("#%1") + QString accentColor2 = QStringLiteral("#%1") .arg(longAccentColor2, 8, 16, QLatin1Char('0')) .toUpper() .mid(0, 7); - QString accentColor3 = QString::fromLatin1("#%1") + QString accentColor3 = QStringLiteral("#%1") .arg(longAccentColor3, 8, 16, QLatin1Char('0')) .toUpper() .mid(0, 7); - qssText = qssText.replace(QString::fromLatin1("@ThemeAccentColor1"), accentColor1); - qssText = qssText.replace(QString::fromLatin1("@ThemeAccentColor2"), accentColor2); - qssText = qssText.replace(QString::fromLatin1("@ThemeAccentColor3"), accentColor3); + qssText = qssText.replace(QStringLiteral("@ThemeAccentColor1"), accentColor1); + qssText = qssText.replace(QStringLiteral("@ThemeAccentColor2"), accentColor2); + qssText = qssText.replace(QStringLiteral("@ThemeAccentColor3"), accentColor3); // Base::Console().Warning("%s\n", qssText.toStdString()); return qssText; diff --git a/src/Gui/AutoSaver.cpp b/src/Gui/AutoSaver.cpp index d583ec2fe7..576ebeedbb 100644 --- a/src/Gui/AutoSaver.cpp +++ b/src/Gui/AutoSaver.cpp @@ -146,7 +146,7 @@ void AutoSaver::saveDocument(const std::string& name, AutoSaveProperty& saver) saver.dirName = dirName; // Write recovery meta file - QFile file(QString::fromLatin1("%1/fc_recovery_file.xml") + QFile file(QStringLiteral("%1/fc_recovery_file.xml") .arg(QString::fromUtf8(doc->TransientDir.getValue()))); if (file.open(QFile::WriteOnly)) { QTextStream str(&file); @@ -333,7 +333,7 @@ public: dirName = QString::fromUtf8(dir); fileName = QString::fromUtf8(file); - tmpName = QString::fromLatin1("%1.tmp%2").arg(fileName).arg(rand()); + tmpName = QStringLiteral("%1.tmp%2").arg(fileName).arg(rand()); writer.putNextEntry(tmpName.toUtf8().constData()); } ~RecoveryRunnable() override diff --git a/src/Gui/BitmapFactory.cpp b/src/Gui/BitmapFactory.cpp index 1fd92ab83e..a51178fef3 100644 --- a/src/Gui/BitmapFactory.cpp +++ b/src/Gui/BitmapFactory.cpp @@ -75,8 +75,8 @@ BitmapFactoryInst& BitmapFactoryInst::instance() } _pcSingleton->addPath(path); } - _pcSingleton->addPath(QString::fromLatin1("%1/icons").arg(QString::fromStdString(App::Application::getHomePath()))); - _pcSingleton->addPath(QString::fromLatin1("%1/icons").arg(QString::fromStdString(App::Application::getUserAppDataDir()))); + _pcSingleton->addPath(QStringLiteral("%1/icons").arg(QString::fromStdString(App::Application::getHomePath()))); + _pcSingleton->addPath(QStringLiteral("%1/icons").arg(QString::fromStdString(App::Application::getUserAppDataDir()))); _pcSingleton->addPath(QLatin1String(":/icons/")); _pcSingleton->addPath(QLatin1String(":/Icons/")); } @@ -124,22 +124,22 @@ void Gui::BitmapFactoryInst::configureUseIconTheme() void BitmapFactoryInst::addPath(const QString& path) { - QDir::addSearchPath(QString::fromLatin1("icons"), path); + QDir::addSearchPath(QStringLiteral("icons"), path); } void BitmapFactoryInst::removePath(const QString& path) { - QStringList iconPaths = QDir::searchPaths(QString::fromLatin1("icons")); + QStringList iconPaths = QDir::searchPaths(QStringLiteral("icons")); int pos = iconPaths.indexOf(path); if (pos != -1) { iconPaths.removeAt(pos); - QDir::setSearchPaths(QString::fromLatin1("icons"), iconPaths); + QDir::setSearchPaths(QStringLiteral("icons"), iconPaths); } } QStringList BitmapFactoryInst::getPaths() const { - return QDir::searchPaths(QString::fromLatin1("icons")); + return QDir::searchPaths(QStringLiteral("icons")); } QStringList BitmapFactoryInst::findIconFiles() const @@ -147,9 +147,9 @@ QStringList BitmapFactoryInst::findIconFiles() const QStringList files, filters; QList formats = QImageReader::supportedImageFormats(); for (QList::iterator it = formats.begin(); it != formats.end(); ++it) - filters << QString::fromLatin1("*.%1").arg(QString::fromLatin1(*it).toLower()); + filters << QStringLiteral("*.%1").arg(QString::fromLatin1(*it).toLower()); - QStringList paths = QDir::searchPaths(QString::fromLatin1("icons")); + QStringList paths = QDir::searchPaths(QStringLiteral("icons")); paths.removeDuplicates(); for (QStringList::Iterator pt = paths.begin(); pt != paths.end(); ++pt) { QDir d(*pt); @@ -252,11 +252,11 @@ QPixmap BitmapFactoryInst::pixmap(const char* name) const QList formats = QImageReader::supportedImageFormats(); formats.prepend("SVG"); // check first for SVG to use special import mechanism - QString fileName = QString::fromLatin1("icons:") + fn; + QString fileName = QStringLiteral("icons:") + fn; if (!loadPixmap(fileName, icon)) { // Go through supported file formats for (QList::iterator fm = formats.begin(); fm != formats.end(); ++fm) { - QString path = QString::fromLatin1("%1.%2").arg(fileName, + QString path = QStringLiteral("%1.%2").arg(fileName, QString::fromLatin1((*fm).toLower().constData())); if (loadPixmap(path, icon)) { break; @@ -286,7 +286,7 @@ QPixmap BitmapFactoryInst::pixmapFromSvg(const char* name, const QSizeF& size, // try to find it in the 'icons' search paths if (iconPath.isEmpty()) { - QString fileName = QString::fromLatin1("icons:") + fn; + QString fileName = QStringLiteral("icons:") + fn; QFileInfo fi(fileName); if (fi.exists()) { iconPath = fi.filePath(); @@ -328,8 +328,8 @@ QPixmap BitmapFactoryInst::pixmapFromSvg(const QByteArray& originalContents, con for ( const auto &colorToColor : colorMapping ) { ulong fromColor = colorToColor.first; ulong toColor = colorToColor.second; - QString fromColorString = QString::fromLatin1(":#%1;").arg(fromColor, 6, 16, QChar::fromLatin1('0')); - QString toColorString = QString::fromLatin1(":#%1;").arg(toColor, 6, 16, QChar::fromLatin1('0')); + QString fromColorString = QStringLiteral(":#%1;").arg(fromColor, 6, 16, QChar::fromLatin1('0')); + QString toColorString = QStringLiteral(":#%1;").arg(toColor, 6, 16, QChar::fromLatin1('0')); stringContents = stringContents.replace(fromColorString, toColorString); } QByteArray contents = stringContents.toUtf8(); diff --git a/src/Gui/Command.cpp b/src/Gui/Command.cpp index c2ac117e14..5fb02b32bc 100644 --- a/src/Gui/Command.cpp +++ b/src/Gui/Command.cpp @@ -1079,7 +1079,7 @@ Action * GroupCommand::createAction() { for(auto &v : cmds) { if(!v.first) - pcAction->addAction(QString::fromLatin1(""))->setSeparator(true); + pcAction->addAction(QStringLiteral(""))->setSeparator(true); else v.first->addToGroup(pcAction); } @@ -1175,7 +1175,7 @@ void MacroCommand::activated(int iMsg) d = QDir(QString::fromUtf8(cMacroPath.c_str())); } else { - QString dirstr = QString::fromStdString(App::Application::getHomePath()) + QString::fromLatin1("Macro"); + QString dirstr = QString::fromStdString(App::Application::getHomePath()) + QStringLiteral("Macro"); d = QDir(dirstr); } diff --git a/src/Gui/CommandDoc.cpp b/src/Gui/CommandDoc.cpp index ed3dd7339d..6d9274b69a 100644 --- a/src/Gui/CommandDoc.cpp +++ b/src/Gui/CommandDoc.cpp @@ -638,7 +638,7 @@ void StdCmdExportDependencyGraph::activated(int iMsg) { Q_UNUSED(iMsg); App::Document* doc = App::GetApplication().getActiveDocument(); - QString format = QString::fromLatin1("%1 (*.gv)").arg(Gui::GraphvizView::tr("Graphviz format")); + QString format = QStringLiteral("%1 (*.gv)").arg(Gui::GraphvizView::tr("Graphviz format")); QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(), Gui::GraphvizView::tr("Export graph"), QString(), format); if (!fn.isEmpty()) { QFile file(fn); @@ -679,7 +679,7 @@ void StdCmdNew::activated(int iMsg) { Q_UNUSED(iMsg); QString cmd; - cmd = QString::fromLatin1("App.newDocument()"); + cmd = QStringLiteral("App.newDocument()"); runCommand(Command::Doc,cmd.toUtf8()); doCommand(Command::Gui,"Gui.activeDocument().activeView().viewDefaultOrientation()"); @@ -1401,7 +1401,7 @@ void StdCmdDelete::activated(int iMsg) else label = QLatin1String(parent->getNameInDocument()); if(parent->Label.getStrValue() != parent->getNameInDocument()) - label += QString::fromLatin1(" (%1)").arg( + label += QStringLiteral(" (%1)").arg( QString::fromUtf8(parent->Label.getValue())); affectedLabels.insert(label); if(affectedLabels.size()>=10) { @@ -1467,7 +1467,7 @@ void StdCmdDelete::activated(int iMsg) e.ReportException(); } catch (...) { QMessageBox::critical(getMainWindow(), QObject::tr("Delete failed"), - QString::fromLatin1("Unknown error")); + QStringLiteral("Unknown error")); } commitCommand(); Gui::getMainWindow()->setUpdatesEnabled(true); diff --git a/src/Gui/CommandFeat.cpp b/src/Gui/CommandFeat.cpp index 4f42511030..de54763b75 100644 --- a/src/Gui/CommandFeat.cpp +++ b/src/Gui/CommandFeat.cpp @@ -244,30 +244,30 @@ void StdCmdSendToPythonConsole::activated(int iMsg) // clear variables from previous run, if any QString cmd = QLatin1String("try:\n del(doc,lnk,obj,shp,sub,subs)\nexcept Exception:\n pass\n"); Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1()); - cmd = QString::fromLatin1("doc = App.getDocument(\"%1\")").arg(docname); + cmd = QStringLiteral("doc = App.getDocument(\"%1\")").arg(docname); Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1()); //support links if (obj->isDerivedFrom()) { - cmd = QString::fromLatin1("lnk = doc.getObject(\"%1\")").arg(objname); + cmd = QStringLiteral("lnk = doc.getObject(\"%1\")").arg(objname); Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1()); - cmd = QString::fromLatin1("obj = lnk.getLinkedObject()"); + cmd = QStringLiteral("obj = lnk.getLinkedObject()"); Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1()); const auto link = static_cast(obj); obj = link->getLinkedObject(); } else { - cmd = QString::fromLatin1("obj = doc.getObject(\"%1\")").arg(objname); + cmd = QStringLiteral("obj = doc.getObject(\"%1\")").arg(objname); Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1()); } if (obj->isDerivedFrom()) { const auto geoObj = static_cast(obj); const App::PropertyGeometry* geo = geoObj->getPropertyOfGeometry(); if (geo){ - cmd = QString::fromLatin1("shp = obj.") + QLatin1String(geo->getName()); //"Shape", "Mesh", "Points", etc. + cmd = QStringLiteral("shp = obj.") + QLatin1String(geo->getName()); //"Shape", "Mesh", "Points", etc. Gui::Command::runCommand(Gui::Command::Gui, cmd.toLatin1()); if (sels[0].hasSubNames()) { std::vector subnames = sels[0].getSubNames(); QString subname = QString::fromLatin1(subnames[0].c_str()); - cmd = QString::fromLatin1("sub = obj.getSubObject(\"%1\")").arg(subname); + cmd = QStringLiteral("sub = obj.getSubObject(\"%1\")").arg(subname); Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1()); if (subnames.size() > 1) { std::ostringstream strm; diff --git a/src/Gui/CommandPyImp.cpp b/src/Gui/CommandPyImp.cpp index 57d6b9bac2..048b88bb1e 100644 --- a/src/Gui/CommandPyImp.cpp +++ b/src/Gui/CommandPyImp.cpp @@ -100,7 +100,7 @@ PyObject* CommandPy::listByShortcut(PyObject *args) for (Command* c : cmds) { Action* action = c->getAction(); if (action) { - QString spc = QString::fromLatin1(" "); + QString spc = QStringLiteral(" "); if (Base::asBoolean(bIsRegularExp)) { QRegularExpression re(QString::fromLatin1(shortcut_to_find), QRegularExpression::CaseInsensitiveOption); if (!re.isValid()) { diff --git a/src/Gui/CommandStd.cpp b/src/Gui/CommandStd.cpp index fca4486f29..d48a784e63 100644 --- a/src/Gui/CommandStd.cpp +++ b/src/Gui/CommandStd.cpp @@ -358,7 +358,7 @@ void StdCmdRestartInSafeMode::activated(int iMsg) { QStringList args = QApplication::arguments(); args.pop_front(); - auto const safeModeArgument = QString::fromLatin1("--safe-mode"); + auto const safeModeArgument = QStringLiteral("--safe-mode"); if (!args.contains(safeModeArgument)) { args.append(safeModeArgument); } @@ -534,7 +534,7 @@ StdCmdOnlineHelp::StdCmdOnlineHelp() void StdCmdOnlineHelp::activated(int iMsg) { Q_UNUSED(iMsg); - Gui::getMainWindow()->showDocumentation(QString::fromLatin1("Online_Help_Startpage")); + Gui::getMainWindow()->showDocumentation(QStringLiteral("Online_Help_Startpage")); } //=========================================================================== @@ -885,8 +885,8 @@ Gui::Action * StdCmdUserEditMode::createAction() QAction* act = pcAction->addAction(QString()); auto modeName = QString::fromStdString(uem.second.first).remove(QChar::fromLatin1('&')); act->setCheckable(true); - act->setIcon(BitmapFactory().iconFromTheme(qPrintable(QString::fromLatin1("Std_UserEditMode")+modeName))); - act->setObjectName(QString::fromLatin1("Std_UserEditMode")+modeName); + act->setIcon(BitmapFactory().iconFromTheme(qPrintable(QStringLiteral("Std_UserEditMode")+modeName))); + act->setObjectName(QStringLiteral("Std_UserEditMode")+modeName); act->setWhatsThis(QString::fromLatin1(getWhatsThis())); act->setToolTip(QString::fromStdString(uem.second.second)); diff --git a/src/Gui/CommandTest.cpp b/src/Gui/CommandTest.cpp index 0a86fa47a7..00f3888803 100644 --- a/src/Gui/CommandTest.cpp +++ b/src/Gui/CommandTest.cpp @@ -70,8 +70,8 @@ void Std_TestQM::activated(int iMsg) { Q_UNUSED(iMsg); QStringList files = QFileDialog::getOpenFileNames(getMainWindow(), - QString::fromLatin1("Test translation"), QString(), - QString::fromLatin1("Translation (*.qm)")); + QStringLiteral("Test translation"), QString(), + QStringLiteral("Translation (*.qm)")); if (!files.empty()) { Translator::instance()->activateLanguage("English"); QList i18n = qApp->findChildren(); diff --git a/src/Gui/CommandView.cpp b/src/Gui/CommandView.cpp index 10746f1a11..04fe6742ae 100644 --- a/src/Gui/CommandView.cpp +++ b/src/Gui/CommandView.cpp @@ -339,19 +339,19 @@ Action * StdCmdFreezeViews::createAction() saveView->setWhatsThis(QString::fromLatin1(getWhatsThis())); QAction* loadView = pcAction->addAction(QObject::tr("&Load views...")); loadView->setWhatsThis(QString::fromLatin1(getWhatsThis())); - pcAction->addAction(QString::fromLatin1(""))->setSeparator(true); + pcAction->addAction(QStringLiteral(""))->setSeparator(true); freezeView = pcAction->addAction(QObject::tr("F&reeze view")); freezeView->setShortcut(QString::fromLatin1(getAccel())); freezeView->setWhatsThis(QString::fromLatin1(getWhatsThis())); clearView = pcAction->addAction(QObject::tr("&Clear views")); clearView->setWhatsThis(QString::fromLatin1(getWhatsThis())); - separator = pcAction->addAction(QString::fromLatin1("")); + separator = pcAction->addAction(QStringLiteral("")); separator->setSeparator(true); offset = pcAction->actions().count(); // allow up to 50 views for (int i=0; iaddAction(QString::fromLatin1(""))->setVisible(false); + pcAction->addAction(QStringLiteral(""))->setVisible(false); return pcAction; } @@ -394,7 +394,7 @@ void StdCmdFreezeViews::activated(int iMsg) (*it)->setToolTip(QString::fromLatin1(ppReturn)); (*it)->setVisible(true); if (index < 10) { - (*it)->setShortcut(QKeySequence(QString::fromLatin1("CTRL+%1").arg(index))); + (*it)->setShortcut(QKeySequence(QStringLiteral("CTRL+%1").arg(index))); } break; } @@ -410,7 +410,7 @@ void StdCmdFreezeViews::activated(int iMsg) // Activate a view QList acts = pcAction->actions(); QString data = acts[iMsg]->toolTip(); - QString send = QString::fromLatin1("SetCamera %1").arg(data); + QString send = QStringLiteral("SetCamera %1").arg(data); getGuiApplication()->sendMsgToActiveView(send.toLatin1()); } } @@ -419,7 +419,7 @@ void StdCmdFreezeViews::onSaveViews() { // Save the views to an XML file QString fn = FileDialog::getSaveFileName(getMainWindow(), QObject::tr("Save frozen views"), - QString(), QString::fromLatin1("%1 (*.cam)").arg(QObject::tr("Frozen views"))); + QString(), QStringLiteral("%1 (*.cam)").arg(QObject::tr("Frozen views"))); if (fn.isEmpty()) return; QFile file(fn); @@ -440,11 +440,11 @@ void StdCmdFreezeViews::onSaveViews() // remove the first line because it's a comment like '#Inventor V2.1 ascii' QString viewPos; if (!data.isEmpty()) { - QStringList lines = data.split(QString::fromLatin1("\n")); + QStringList lines = data.split(QStringLiteral("\n")); if (lines.size() > 1) { lines.pop_front(); } - viewPos = lines.join(QString::fromLatin1(" ")); + viewPos = lines.join(QStringLiteral(" ")); } str << " \n"; @@ -469,7 +469,7 @@ void StdCmdFreezeViews::onRestoreViews() // Restore the views from an XML file QString fn = FileDialog::getOpenFileName(getMainWindow(), QObject::tr("Restore frozen views"), - QString(), QString::fromLatin1("%1 (*.cam)").arg(QObject::tr("Frozen views"))); + QString(), QStringLiteral("%1 (*.cam)").arg(QObject::tr("Frozen views"))); if (fn.isEmpty()) return; QFile file(fn); @@ -500,19 +500,19 @@ void StdCmdFreezeViews::onRestoreViews() } bool ok; - int scheme = root.attribute(QString::fromLatin1("SchemaVersion")).toInt(&ok); + int scheme = root.attribute(QStringLiteral("SchemaVersion")).toInt(&ok); if (!ok) return; // SchemeVersion "1" if (scheme == 1) { // read the views, ignore the attribute 'Count' - QDomElement child = root.firstChildElement(QString::fromLatin1("Views")); - QDomElement views = child.firstChildElement(QString::fromLatin1("Camera")); + QDomElement child = root.firstChildElement(QStringLiteral("Views")); + QDomElement views = child.firstChildElement(QStringLiteral("Camera")); QStringList cameras; while (!views.isNull()) { - QString setting = views.attribute(QString::fromLatin1("settings")); + QString setting = views.attribute(QStringLiteral("settings")); cameras << setting; - views = views.nextSiblingElement(QString::fromLatin1("Camera")); + views = views.nextSiblingElement(QStringLiteral("Camera")); } // use this rather than the attribute 'Count' because it could be @@ -533,7 +533,7 @@ void StdCmdFreezeViews::onRestoreViews() acts[i+offset]->setToolTip(setting); acts[i+offset]->setVisible(true); if (i < 9) { - acts[i+offset]->setShortcut(QKeySequence(QString::fromLatin1("CTRL+%1").arg(i+1))); + acts[i+offset]->setShortcut(QKeySequence(QStringLiteral("CTRL+%1").arg(i+1))); } } @@ -668,44 +668,44 @@ Gui::Action * StdCmdDrawStyle::createAction() a0->setCheckable(true); a0->setIcon(BitmapFactory().iconFromTheme("DrawStyleAsIs")); a0->setChecked(true); - a0->setObjectName(QString::fromLatin1("Std_DrawStyleAsIs")); - a0->setShortcut(QKeySequence(QString::fromUtf8("V,1"))); + a0->setObjectName(QStringLiteral("Std_DrawStyleAsIs")); + a0->setShortcut(QKeySequence(QStringLiteral("V,1"))); a0->setWhatsThis(QString::fromLatin1(getWhatsThis())); QAction* a1 = pcAction->addAction(QString()); a1->setCheckable(true); a1->setIcon(BitmapFactory().iconFromTheme("DrawStylePoints")); - a1->setObjectName(QString::fromLatin1("Std_DrawStylePoints")); - a1->setShortcut(QKeySequence(QString::fromUtf8("V,2"))); + a1->setObjectName(QStringLiteral("Std_DrawStylePoints")); + a1->setShortcut(QKeySequence(QStringLiteral("V,2"))); a1->setWhatsThis(QString::fromLatin1(getWhatsThis())); QAction* a2 = pcAction->addAction(QString()); a2->setCheckable(true); a2->setIcon(BitmapFactory().iconFromTheme("DrawStyleWireFrame")); - a2->setObjectName(QString::fromLatin1("Std_DrawStyleWireframe")); - a2->setShortcut(QKeySequence(QString::fromUtf8("V,3"))); + a2->setObjectName(QStringLiteral("Std_DrawStyleWireframe")); + a2->setShortcut(QKeySequence(QStringLiteral("V,3"))); a2->setWhatsThis(QString::fromLatin1(getWhatsThis())); QAction* a3 = pcAction->addAction(QString()); a3->setCheckable(true); a3->setIcon(BitmapFactory().iconFromTheme("DrawStyleHiddenLine")); - a3->setObjectName(QString::fromLatin1("Std_DrawStyleHiddenLine")); - a3->setShortcut(QKeySequence(QString::fromUtf8("V,4"))); + a3->setObjectName(QStringLiteral("Std_DrawStyleHiddenLine")); + a3->setShortcut(QKeySequence(QStringLiteral("V,4"))); a3->setWhatsThis(QString::fromLatin1(getWhatsThis())); QAction* a4 = pcAction->addAction(QString()); a4->setCheckable(true); a4->setIcon(BitmapFactory().iconFromTheme("DrawStyleNoShading")); - a4->setObjectName(QString::fromLatin1("Std_DrawStyleNoShading")); - a4->setShortcut(QKeySequence(QString::fromUtf8("V,5"))); + a4->setObjectName(QStringLiteral("Std_DrawStyleNoShading")); + a4->setShortcut(QKeySequence(QStringLiteral("V,5"))); a4->setWhatsThis(QString::fromLatin1(getWhatsThis())); QAction* a5 = pcAction->addAction(QString()); a5->setCheckable(true); a5->setIcon(BitmapFactory().iconFromTheme("DrawStyleShaded")); - a5->setObjectName(QString::fromLatin1("Std_DrawStyleShaded")); - a5->setShortcut(QKeySequence(QString::fromUtf8("V,6"))); + a5->setObjectName(QStringLiteral("Std_DrawStyleShaded")); + a5->setShortcut(QKeySequence(QStringLiteral("V,6"))); a5->setWhatsThis(QString::fromLatin1(getWhatsThis())); QAction* a6 = pcAction->addAction(QString()); a6->setCheckable(true); a6->setIcon(BitmapFactory().iconFromTheme("DrawStyleFlatLines")); - a6->setObjectName(QString::fromLatin1("Std_DrawStyleFlatLines")); - a6->setShortcut(QKeySequence(QString::fromUtf8("V,7"))); + a6->setObjectName(QStringLiteral("Std_DrawStyleFlatLines")); + a6->setShortcut(QKeySequence(QStringLiteral("V,7"))); a6->setWhatsThis(QString::fromLatin1(getWhatsThis())); pcAction->setIcon(a0->icon()); @@ -1959,7 +1959,7 @@ void StdViewScreenShot::activated(int iMsg) QStringList filter; QString selFilter; for (QStringList::Iterator it = formats.begin(); it != formats.end(); ++it) { - filter << QString::fromLatin1("%1 %2 (*.%3)").arg((*it).toUpper(), + filter << QStringLiteral("%1 %2 (*.%3)").arg((*it).toUpper(), QObject::tr("files"), (*it).toLower()); if (ext == *it) selFilter = filter.last(); @@ -2121,8 +2121,8 @@ void StdViewLoadImage::activated(int iMsg) QFileDialog dialog(Gui::getMainWindow()); dialog.setWindowTitle(QObject::tr("Choose an image file to open")); dialog.setMimeTypeFilters(mimeTypeFilters); - dialog.selectMimeTypeFilter(QString::fromLatin1("image/png")); - dialog.setDefaultSuffix(QString::fromLatin1("png")); + dialog.selectMimeTypeFilter(QStringLiteral("image/png")); + dialog.setDefaultSuffix(QStringLiteral("png")); dialog.setAcceptMode(QFileDialog::AcceptOpen); dialog.setOption(QFileDialog::DontUseNativeDialog); diff --git a/src/Gui/DAGView/DAGFilter.cpp b/src/Gui/DAGView/DAGFilter.cpp index 57bc3915af..e331d52d2e 100644 --- a/src/Gui/DAGView/DAGFilter.cpp +++ b/src/Gui/DAGView/DAGFilter.cpp @@ -31,7 +31,7 @@ using namespace Gui; using namespace DAG; -FilterBase::FilterBase() : name(QString::fromLatin1("empty name")) +FilterBase::FilterBase() : name(QStringLiteral("empty name")) { } diff --git a/src/Gui/Dialogs/DlgAbout.cpp b/src/Gui/Dialogs/DlgAbout.cpp index 3c25f6b731..8a1808333f 100644 --- a/src/Gui/Dialogs/DlgAbout.cpp +++ b/src/Gui/Dialogs/DlgAbout.cpp @@ -68,7 +68,7 @@ static QString prettyProductInfoWrapper() #if QT_VERSION < QT_VERSION_CHECK(6, 5, 0) #ifdef FC_OS_MACOSX auto macosVersionFile = - QString::fromUtf8("/System/Library/CoreServices/.SystemVersionPlatform.plist"); + QStringLiteral("/System/Library/CoreServices/.SystemVersionPlatform.plist"); auto fi = QFileInfo(macosVersionFile); if (fi.exists() && fi.isReadable()) { auto plistFile = QFile(macosVersionFile); @@ -78,10 +78,10 @@ static QString prettyProductInfoWrapper() if (line.contains("ProductUserVisibleVersion")) { auto nextLine = plistFile.readLine(); if (nextLine.contains("")) { - QRegularExpression re(QString::fromUtf8("\\s*(.*)")); + QRegularExpression re(QStringLiteral("\\s*(.*)")); auto matches = re.match(QString::fromUtf8(nextLine)); if (matches.hasMatch()) { - productName = QString::fromUtf8("macOS ") + matches.captured(1); + productName = QStringLiteral("macOS ") + matches.captured(1); break; } } @@ -92,22 +92,22 @@ static QString prettyProductInfoWrapper() #endif #ifdef FC_OS_WIN64 QSettings regKey { - QString::fromUtf8("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), + QStringLiteral("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"), QSettings::NativeFormat}; - if (regKey.contains(QString::fromUtf8("CurrentBuildNumber"))) { - auto buildNumber = regKey.value(QString::fromUtf8("CurrentBuildNumber")).toInt(); + if (regKey.contains(QStringLiteral("CurrentBuildNumber"))) { + auto buildNumber = regKey.value(QStringLiteral("CurrentBuildNumber")).toInt(); if (buildNumber > 0) { if (buildNumber < 9200) { - productName = QString::fromUtf8("Windows 7 build %1").arg(buildNumber); + productName = QStringLiteral("Windows 7 build %1").arg(buildNumber); } else if (buildNumber < 10240) { - productName = QString::fromUtf8("Windows 8 build %1").arg(buildNumber); + productName = QStringLiteral("Windows 8 build %1").arg(buildNumber); } else if (buildNumber < 22000) { - productName = QString::fromUtf8("Windows 10 build %1").arg(buildNumber); + productName = QStringLiteral("Windows 10 build %1").arg(buildNumber); } else { - productName = QString::fromUtf8("Windows 11 build %1").arg(buildNumber); + productName = QStringLiteral("Windows 11 build %1").arg(buildNumber); } } } @@ -211,7 +211,7 @@ QPixmap AboutDialog::aboutImage() const { // See if we have a custom About screen image set QPixmap about_image; - QFileInfo fi(QString::fromLatin1("images:about_image.png")); + QFileInfo fi(QStringLiteral("images:about_image.png")); if (fi.isFile() && fi.exists()) { about_image.load(fi.filePath(), "PNG"); } @@ -251,7 +251,7 @@ void AboutDialog::setupLabels() #endif // avoid overriding user set style sheet if (qApp->styleSheet().isEmpty()) { - setStyleSheet(QString::fromLatin1("Gui--Dialog--AboutDialog QLabel {font-size: %1pt;}") + setStyleSheet(QStringLiteral("Gui--Dialog--AboutDialog QLabel {font-size: %1pt;}") .arg(fontSize)); } @@ -272,41 +272,41 @@ void AboutDialog::setupLabels() // gets replaced to "FreeCAD", for example QString author = ui->labelAuthor->text(); - author.replace(QString::fromLatin1("Unknown Application"), exeName); - author.replace(QString::fromLatin1("(c) Unknown Author"), banner); + author.replace(QStringLiteral("Unknown Application"), exeName); + author.replace(QStringLiteral("(c) Unknown Author"), banner); ui->labelAuthor->setText(author); ui->labelAuthor->setUrl(mturl); if (qApp->styleSheet().isEmpty()) { - ui->labelAuthor->setStyleSheet(QString::fromLatin1( + ui->labelAuthor->setStyleSheet(QStringLiteral( "Gui--UrlLabel {color: #0000FF;text-decoration: underline;font-weight: 600;}")); } QString version = ui->labelBuildVersion->text(); - version.replace(QString::fromLatin1("Unknown"), - QString::fromLatin1("%1.%2.%3%4").arg(major, minor, point, suffix)); + version.replace(QStringLiteral("Unknown"), + QStringLiteral("%1.%2.%3%4").arg(major, minor, point, suffix)); ui->labelBuildVersion->setText(version); QString revision = ui->labelBuildRevision->text(); - revision.replace(QString::fromLatin1("Unknown"), build); + revision.replace(QStringLiteral("Unknown"), build); ui->labelBuildRevision->setText(revision); QString date = ui->labelBuildDate->text(); - date.replace(QString::fromLatin1("Unknown"), disda); + date.replace(QStringLiteral("Unknown"), disda); ui->labelBuildDate->setText(date); QString os = ui->labelBuildOS->text(); - os.replace(QString::fromLatin1("Unknown"), prettyProductInfoWrapper()); + os.replace(QStringLiteral("Unknown"), prettyProductInfoWrapper()); ui->labelBuildOS->setText(os); QString architecture = ui->labelBuildRunArchitecture->text(); if (QSysInfo::buildCpuArchitecture() == QSysInfo::currentCpuArchitecture()) { - architecture.replace(QString::fromLatin1("Unknown"), QSysInfo::buildCpuArchitecture()); + architecture.replace(QStringLiteral("Unknown"), QSysInfo::buildCpuArchitecture()); } else { architecture.replace( - QString::fromLatin1("Unknown"), - QString::fromLatin1("%1 (running on: %2)") + QStringLiteral("Unknown"), + QStringLiteral("%1 (running on: %2)") .arg(QSysInfo::buildCpuArchitecture(), QSysInfo::currentCpuArchitecture())); } ui->labelBuildRunArchitecture->setText(architecture); @@ -315,7 +315,7 @@ void AboutDialog::setupLabels() it = config.find("BuildRevisionBranch"); if (it != config.end()) { QString branch = ui->labelBuildBranch->text(); - branch.replace(QString::fromLatin1("Unknown"), QString::fromStdString(it->second)); + branch.replace(QStringLiteral("Unknown"), QString::fromStdString(it->second)); ui->labelBuildBranch->setText(branch); } else { @@ -328,7 +328,7 @@ void AboutDialog::setupLabels() if (it != config.end()) { QString hash = ui->labelBuildHash->text(); hash.replace( - QString::fromLatin1("Unknown"), + QStringLiteral("Unknown"), QString::fromStdString(it->second).left(7)); // Use the 7-char abbreviated hash ui->labelBuildHash->setText(hash); if (auto url_itr = config.find("BuildRepositoryURL"); url_itr != config.end()) { @@ -338,15 +338,15 @@ void AboutDialog::setupLabels() url = url.left(space); // Strip off the branch information to get just the repo } - if (url == QString::fromUtf8("Unknown")) { - url = QString::fromUtf8("https://github.com/FreeCAD/FreeCAD"); // Just take a guess + if (url == QStringLiteral("Unknown")) { + url = QStringLiteral("https://github.com/FreeCAD/FreeCAD"); // Just take a guess } // This may only create valid URLs for Github, but some other hosts use the same format // so give it a shot... - auto https = url.replace(QString::fromUtf8("git://"), QString::fromUtf8("https://")); - https.replace(QString::fromUtf8(".git"), QString::fromUtf8("")); - ui->labelBuildHash->setUrl(https + QString::fromUtf8("/commit/") + auto https = url.replace(QStringLiteral("git://"), QStringLiteral("https://")); + https.replace(QStringLiteral(".git"), QStringLiteral("")); + ui->labelBuildHash->setUrl(https + QStringLiteral("/commit/") + QString::fromStdString(it->second)); } } @@ -366,26 +366,26 @@ void AboutDialog::showCredits() } auto tab_credits = new QWidget(); - tab_credits->setObjectName(QString::fromLatin1("tab_credits")); + tab_credits->setObjectName(QStringLiteral("tab_credits")); ui->tabWidget->addTab(tab_credits, tr("Credits")); auto hlayout = new QVBoxLayout(tab_credits); auto textField = new QTextBrowser(tab_credits); textField->setOpenExternalLinks(true); hlayout->addWidget(textField); - QString creditsHTML = QString::fromLatin1("

"); + QString creditsHTML = QStringLiteral("

"); //: Header for bgbsww creditsHTML += tr("This version of FreeCAD is dedicated to the memory of Brad McLean, aka bgbsww."); //: Header for the Credits tab of the About screen - creditsHTML += QString::fromLatin1("

"); + creditsHTML += QStringLiteral("

"); creditsHTML += tr("Credits"); - creditsHTML += QString::fromLatin1("

"); + creditsHTML += QStringLiteral("

"); creditsHTML += tr("FreeCAD would not be possible without the contributions of"); - creditsHTML += QString::fromLatin1(":

"); + creditsHTML += QStringLiteral(":

"); //: Header for the list of individual people in the Credits list. creditsHTML += tr("Individuals"); - creditsHTML += QString::fromLatin1("

    "); + creditsHTML += QStringLiteral("
      "); QTextStream stream(&creditsFile); #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) @@ -394,37 +394,37 @@ void AboutDialog::showCredits() QString line; while (stream.readLineInto(&line)) { if (!line.isEmpty()) { - if (line == QString::fromLatin1("Firms")) { - creditsHTML += QString::fromLatin1("

    "); + if (line == QStringLiteral("Firms")) { + creditsHTML += QStringLiteral("

"); //: Header for the list of companies/organizations in the Credits list. creditsHTML += tr("Organizations"); - creditsHTML += QString::fromLatin1("

    "); + creditsHTML += QStringLiteral("
      "); } else { - creditsHTML += QString::fromLatin1("
    • ") + line + QString::fromLatin1("
    • "); + creditsHTML += QStringLiteral("
    • ") + line + QStringLiteral("
    • "); } } } - creditsHTML += QString::fromLatin1("
    "); + creditsHTML += QStringLiteral("
"); textField->setHtml(creditsHTML); } void AboutDialog::showLicenseInformation() { - QString licenseFileURL = QString::fromLatin1("%1/LICENSE.html") + QString licenseFileURL = QStringLiteral("%1/LICENSE.html") .arg(QString::fromStdString(App::Application::getHelpDir())); QFile licenseFile(licenseFileURL); if (licenseFile.open(QIODevice::ReadOnly | QIODevice::Text)) { QString licenseHTML = QString::fromUtf8(licenseFile.readAll()); const auto placeholder = - QString::fromUtf8(""); + QStringLiteral(""); licenseHTML.replace(placeholder, getAdditionalLicenseInformation()); ui->tabWidget->removeTab(1); // Hide the license placeholder widget auto tab_license = new QWidget(); - tab_license->setObjectName(QString::fromLatin1("tab_license")); + tab_license->setObjectName(QStringLiteral("tab_license")); ui->tabWidget->addTab(tab_license, tr("License")); auto hlayout = new QVBoxLayout(tab_license); auto textField = new QTextBrowser(tab_license); @@ -438,7 +438,7 @@ void AboutDialog::showLicenseInformation() QString info(QLatin1String("SUCH DAMAGES.
")); info += getAdditionalLicenseInformation(); QString lictext = ui->textBrowserLicense->toHtml(); - lictext.replace(QString::fromLatin1("SUCH DAMAGES.
"), info); + lictext.replace(QStringLiteral("SUCH DAMAGES.
"), info); ui->textBrowserLicense->setHtml(lictext); } } @@ -450,7 +450,7 @@ QString AboutDialog::getAdditionalLicenseInformation() const // and add an
tag at the end to nicely separate license blocks QString info; #ifdef _USE_3DCONNEXION_SDK - info += QString::fromUtf8( + info += QStringLiteral( "

3D Mouse Support

" "

Development tools and related technology provided under license from 3Dconnexion.
" "Copyright © 1992–2012 3Dconnexion. All rights reserved.

" @@ -462,7 +462,7 @@ QString AboutDialog::getAdditionalLicenseInformation() const void AboutDialog::showLibraryInformation() { auto tab_library = new QWidget(); - tab_library->setObjectName(QString::fromLatin1("tab_library")); + tab_library->setObjectName(QStringLiteral("tab_library")); ui->tabWidget->addTab(tab_library, tr("Libraries")); auto hlayout = new QVBoxLayout(tab_library); auto textField = new QTextBrowser(tab_library); @@ -470,7 +470,7 @@ void AboutDialog::showLibraryInformation() textField->setOpenLinks(false); hlayout->addWidget(textField); - QString baseurl = QString::fromLatin1("file:///%1/ThirdPartyLibraries.html") + QString baseurl = QStringLiteral("file:///%1/ThirdPartyLibraries.html") .arg(QString::fromStdString(App::Application::getHelpDir())); textField->setSource(QUrl(baseurl)); @@ -485,7 +485,7 @@ void AboutDialog::showCollectionInformation() } auto tab_collection = new QWidget(); - tab_collection->setObjectName(QString::fromLatin1("tab_collection")); + tab_collection->setObjectName(QStringLiteral("tab_collection")); ui->tabWidget->addTab(tab_collection, tr("Collection")); auto hlayout = new QVBoxLayout(tab_collection); auto textField = new QTextBrowser(tab_collection); @@ -504,7 +504,7 @@ void AboutDialog::showPrivacyPolicy() } auto text = QString::fromUtf8(policyFile.readAll()); auto tabPrivacyPolicy = new QWidget(); - tabPrivacyPolicy->setObjectName(QString::fromLatin1("tabPrivacyPolicy")); + tabPrivacyPolicy->setObjectName(QStringLiteral("tabPrivacyPolicy")); ui->tabWidget->addTab(tabPrivacyPolicy, tr("Privacy Policy")); auto hLayout = new QVBoxLayout(tabPrivacyPolicy); auto textField = new QTextBrowser(tabPrivacyPolicy); @@ -528,7 +528,7 @@ void AboutDialog::linkActivated(const QUrl& link) QString fragment = link.fragment(); if (fragment.startsWith(QLatin1String("_Toc"))) { QString prefix = fragment.mid(4); - title = QString::fromLatin1("%1 %2").arg(prefix, title); + title = QStringLiteral("%1 %2").arg(prefix, title); } licenseView->setWindowTitle(title); getMainWindow()->addWindow(licenseView); @@ -561,7 +561,7 @@ void AboutDialog::addModuleInfo(QTextStream& str, const QString& modPath, bool& QChar::fromLatin1(' ')); str << " (Malformed metadata: " << what << ")"; } - QFileInfo disablingFile(mod.absoluteFilePath(), QString::fromLatin1("ADDON_DISABLED")); + QFileInfo disablingFile(mod.absoluteFilePath(), QStringLiteral("ADDON_DISABLED")); if (disablingFile.exists()) { str << " (Disabled)"; } diff --git a/src/Gui/Dialogs/DlgActionsImp.cpp b/src/Gui/Dialogs/DlgActionsImp.cpp index 0bd33c804a..42ec839db5 100644 --- a/src/Gui/Dialogs/DlgActionsImp.cpp +++ b/src/Gui/Dialogs/DlgActionsImp.cpp @@ -73,7 +73,7 @@ DlgCustomActionsImp::DlgCustomActionsImp(QWidget* parent) } QString systemMacroDirStr = - QString::fromStdString(App::Application::getHomePath()) + QString::fromLatin1("Macro"); + QString::fromStdString(App::Application::getHomePath()) + QStringLiteral("Macro"); d = QDir(systemMacroDirStr, QLatin1String("*.FCMacro *.py")); if (d.exists()) { for (unsigned int i = 0; i < d.count(); i++) { @@ -483,7 +483,7 @@ void IconDialog::onAddIconPath() QStringList filters; QList formats = QImageReader::supportedImageFormats(); for (const auto& format : formats) { - filters << QString::fromLatin1("*.%1").arg( + filters << QStringLiteral("*.%1").arg( QString::fromLatin1(format).toLower()); } QDir d(path); diff --git a/src/Gui/Dialogs/DlgAddPropertyVarSet.cpp b/src/Gui/Dialogs/DlgAddPropertyVarSet.cpp index 9588527464..312666ded2 100644 --- a/src/Gui/Dialogs/DlgAddPropertyVarSet.cpp +++ b/src/Gui/Dialogs/DlgAddPropertyVarSet.cpp @@ -69,7 +69,7 @@ DlgAddPropertyVarSet::~DlgAddPropertyVarSet() = default; void DlgAddPropertyVarSet::initializeGroup() { - comboBoxGroup.setObjectName(QString::fromUtf8("comboBoxGroup")); + comboBoxGroup.setObjectName(QStringLiteral("comboBoxGroup")); comboBoxGroup.setInsertPolicy(QComboBox::InsertAtTop); comboBoxGroup.setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); auto formLayout = qobject_cast(layout()); @@ -253,7 +253,7 @@ void DlgAddPropertyVarSet::addEditor(PropertyEditor::PropertyItem* propertyItem, })); propertyItem->setEditorData(editor.get(), QVariant()); editor->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); - editor->setObjectName(QString::fromUtf8("editor")); + editor->setObjectName(QStringLiteral("editor")); auto formLayout = qobject_cast(layout()); formLayout->setWidget(3, QFormLayout::FieldRole, editor.get()); @@ -433,7 +433,7 @@ void DlgAddPropertyVarSet::checkGroup() { critical(QObject::tr("Invalid name"), QObject::tr("The group name must only contain alpha numericals,\n" "underscore, and must not start with a digit.")); - comboBoxGroup.setEditText(QString::fromUtf8("Base")); + comboBoxGroup.setEditText(QStringLiteral("Base")); throw CreatePropertyException("Invalid name"); } } diff --git a/src/Gui/Dialogs/DlgCheckableMessageBox.cpp b/src/Gui/Dialogs/DlgCheckableMessageBox.cpp index 072be58316..c326c739aa 100644 --- a/src/Gui/Dialogs/DlgCheckableMessageBox.cpp +++ b/src/Gui/Dialogs/DlgCheckableMessageBox.cpp @@ -44,7 +44,7 @@ namespace Gui { namespace Dialog { QByteArray toParamEntry(QString name) { - name.replace(QString::fromLatin1(" "), QString::fromLatin1("_")); + name.replace(QStringLiteral(" "), QStringLiteral("_")); return name.toLatin1(); } diff --git a/src/Gui/Dialogs/DlgCheckableMessageBox.h b/src/Gui/Dialogs/DlgCheckableMessageBox.h index da268fb99a..443bf54ba7 100644 --- a/src/Gui/Dialogs/DlgCheckableMessageBox.h +++ b/src/Gui/Dialogs/DlgCheckableMessageBox.h @@ -104,11 +104,11 @@ public: /// It shows a dialog with header and message provided and a checkbox in check state with the message provided. /// It uses a parameter in path "User parameter:BaseApp/CheckMessages" derived from the header test, defaulting to false, /// to store the status of the checkbox, when the user exits the modal dialog. - static void showMessage(const QString& header, const QString& message, bool check = false, const QString& checkText = QString::fromLatin1("Don't show me again")); + static void showMessage(const QString& header, const QString& message, bool check = false, const QString& checkText = QStringLiteral("Don't show me again")); /// Same as showMessage above, but it checks the specific preference path and parameter provided, defaulting to entryDefault value if the parameter is not present. static void showMessage(const QString& header, const QString& message, const QString& prefPath, const QString& paramEntry, bool entryDefault = false, - bool check = false, const QString& checkText = QString::fromLatin1("Don't show me again")); + bool check = false, const QString& checkText = QStringLiteral("Don't show me again")); private Q_SLOTS: void slotClicked(QAbstractButton *b); diff --git a/src/Gui/Dialogs/DlgCreateNewPreferencePackImp.cpp b/src/Gui/Dialogs/DlgCreateNewPreferencePackImp.cpp index e9b0577ca5..a811b78e49 100644 --- a/src/Gui/Dialogs/DlgCreateNewPreferencePackImp.cpp +++ b/src/Gui/Dialogs/DlgCreateNewPreferencePackImp.cpp @@ -49,7 +49,7 @@ DlgCreateNewPreferencePackImp::DlgCreateNewPreferencePackImp(QWidget* parent) { ui->setupUi(this); - QRegularExpression validNames(QString::fromUtf8(R"([^/\\?%*:|"<>]+)")); + QRegularExpression validNames(QStringLiteral(R"([^/\\?%*:|"<>]+)")); _nameValidator.setRegularExpression(validNames); ui->lineEdit->setValidator(&_nameValidator); ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); diff --git a/src/Gui/Dialogs/DlgCustomizeImp.cpp b/src/Gui/Dialogs/DlgCustomizeImp.cpp index df6614d84b..e35382ecb6 100644 --- a/src/Gui/Dialogs/DlgCustomizeImp.cpp +++ b/src/Gui/Dialogs/DlgCustomizeImp.cpp @@ -79,7 +79,7 @@ DlgCustomizeImp::DlgCustomizeImp(QWidget* parent, Qt::WindowFlags fl) customLayout->addLayout( layout, 1, 0 ); tabWidget = new QTabWidget( this ); - tabWidget->setObjectName(QString::fromLatin1("Gui__Dialog__TabWidget"));//so we can find it in DlgMacroExecuteImp + tabWidget->setObjectName(QStringLiteral("Gui__Dialog__TabWidget"));//so we can find it in DlgMacroExecuteImp // make sure that pages are ready to create GetWidgetFactorySupplier(); diff --git a/src/Gui/Dialogs/DlgCustomizeSpaceball.cpp b/src/Gui/Dialogs/DlgCustomizeSpaceball.cpp index 8630d7a688..5336840d02 100644 --- a/src/Gui/Dialogs/DlgCustomizeSpaceball.cpp +++ b/src/Gui/Dialogs/DlgCustomizeSpaceball.cpp @@ -282,7 +282,7 @@ QString ButtonModel::getLabel(const int &number) const GetGroup(numberString.toLatin1())-> GetASCII("Description","")); if (desc.length()) - desc = QString::fromUtf8(" \"") + desc + QString::fromUtf8("\""); + desc = QStringLiteral(" \"") + desc + QStringLiteral("\""); return tr("Button %1").arg(number + 1) + desc; } else return tr("Out Of Range"); @@ -492,7 +492,7 @@ CommandNode* CommandModel::nodeFromIndex(const QModelIndex &index) const void CommandModel::goAddMacro(const QByteArray ¯oName) { - QModelIndexList indexList(this->match(this->index(0,0), Qt::UserRole, QVariant(QString::fromLatin1("Macros")), + QModelIndexList indexList(this->match(this->index(0,0), Qt::UserRole, QVariant(QStringLiteral("Macros")), 1, Qt::MatchWrap | Qt::MatchRecursive)); QModelIndex macrosIndex; if (indexList.empty()) @@ -500,7 +500,7 @@ void CommandModel::goAddMacro(const QByteArray ¯oName) //this is the first macro and we have to add the Macros item. //figure out where to insert it. Should be in the command groups now. QStringList groups = orderedGroups(); - int location(groups.indexOf(QString::fromLatin1("Macros"))); + int location(groups.indexOf(QStringLiteral("Macros"))); if (location == -1) location = groups.size(); //add row diff --git a/src/Gui/Dialogs/DlgMacroExecuteImp.cpp b/src/Gui/Dialogs/DlgMacroExecuteImp.cpp index bf15b39e82..4822c6df75 100644 --- a/src/Gui/Dialogs/DlgMacroExecuteImp.cpp +++ b/src/Gui/Dialogs/DlgMacroExecuteImp.cpp @@ -265,7 +265,7 @@ void DlgMacroExecuteImp::fillUpList() fillUpListForDir(this->macroPath, false); QString dirstr = - QString::fromStdString(App::Application::getHomePath()) + QString::fromLatin1("Macro"); + QString::fromStdString(App::Application::getHomePath()) + QStringLiteral("Macro"); fillUpListForDir(dirstr, true); auto& config = App::Application::Config(); @@ -432,7 +432,7 @@ void DlgMacroExecuteImp::onEditButtonClicked() auto mitem = static_cast(item); QDir dir(mitem->dirPath); - QString file = QString::fromLatin1("%1/%2").arg(dir.absolutePath(), item->text(0)); + QString file = QStringLiteral("%1/%2").arg(dir.absolutePath(), item->text(0)); auto editor = new PythonEditor(); editor->setWindowIcon(Gui::BitmapFactory().iconFromTheme("applications-python")); auto edit = new PythonEditorView(editor, getMainWindow()); @@ -445,7 +445,7 @@ void DlgMacroExecuteImp::onEditButtonClicked() if (mitem->systemWide) { editor->setReadOnly(true); QString shownName; - shownName = QString::fromLatin1("%1[*] - [%2]").arg(item->text(0), tr("Read-only")); + shownName = QStringLiteral("%1[*] - [%2]").arg(item->text(0), tr("Read-only")); edit->setWindowTitle(shownName); } close(); @@ -505,7 +505,7 @@ void DlgMacroExecuteImp::onCreateButtonClicked() auto edit = new PythonEditorView(editor, getMainWindow()); edit->open(fi.absoluteFilePath()); getMainWindow()->appendRecentMacro(fi.absoluteFilePath()); - edit->setWindowTitle(QString::fromLatin1("%1[*]").arg(fn)); + edit->setWindowTitle(QStringLiteral("%1[*]").arg(fn)); edit->resize(400, 300); getMainWindow()->addWindow(edit); close(); @@ -627,14 +627,14 @@ Note: your changes will be applied when you next switch workbenches\n")); /** title is normally "Customize" **/ dlg.setWindowTitle(tr("Walkthrough, dialog 1 of 2")); - tabWidget = dlg.findChild(QString::fromLatin1("Gui__Dialog__TabWidget")); + tabWidget = dlg.findChild(QStringLiteral("Gui__Dialog__TabWidget")); if (!tabWidget) { std::cerr << "Toolbar walkthrough error: Unable to find tabwidget" << std::endl; return; } auto setupCustomMacrosPage = - tabWidget->findChild(QString::fromLatin1("Gui__Dialog__DlgCustomActions")); + tabWidget->findChild(QStringLiteral("Gui__Dialog__DlgCustomActions")); if (!setupCustomMacrosPage) { std::cerr << "Toolbar walkthrough error: Unable to find setupCustomMacrosPage" << std::endl; @@ -643,7 +643,7 @@ Note: your changes will be applied when you next switch workbenches\n")); tabWidget->setCurrentWidget(setupCustomMacrosPage); auto groupBox7 = - setupCustomMacrosPage->findChild(QString::fromLatin1("GroupBox7")); + setupCustomMacrosPage->findChild(QStringLiteral("GroupBox7")); if (!groupBox7) { Base::Console().Warning("Toolbar walkthrough: Unable to find groupBox7\n"); // just warn when not a fatal error @@ -652,20 +652,20 @@ Note: your changes will be applied when you next switch workbenches\n")); /** normally the groupbox title is "Setup Custom Macros", but we change it here **/ groupBox7->setTitle(tr("Walkthrough instructions: Fill in missing fields (optional) " "then click Add, then Close")); - groupBox7->setStyleSheet(QString::fromLatin1("QGroupBox::title {color:red}")); + groupBox7->setStyleSheet(QStringLiteral("QGroupBox::title {color:red}")); } auto buttonAddAction = - setupCustomMacrosPage->findChild(QString::fromLatin1("buttonAddAction")); + setupCustomMacrosPage->findChild(QStringLiteral("buttonAddAction")); if (!buttonAddAction) { Base::Console().Warning("Toolbar walkthrough: Unable to find buttonAddAction\n"); } else { - buttonAddAction->setStyleSheet(QString::fromLatin1("color:red")); + buttonAddAction->setStyleSheet(QStringLiteral("color:red")); } auto macroListBox = - setupCustomMacrosPage->findChild(QString::fromLatin1("actionMacros")); + setupCustomMacrosPage->findChild(QStringLiteral("actionMacros")); if (!macroListBox) { Base::Console().Warning("Toolbar walkthrough: Unable to find actionMacros combo box\n"); } @@ -676,7 +676,7 @@ Note: your changes will be applied when you next switch workbenches\n")); } auto menuText = - setupCustomMacrosPage->findChild(QString::fromLatin1("actionMenu")); + setupCustomMacrosPage->findChild(QStringLiteral("actionMenu")); if (!menuText) { Base::Console().Warning("Toolbar walkthrough: Unable to find actionMenu menuText\n"); } @@ -694,7 +694,7 @@ Note: your changes will be applied when you next switch workbenches\n")); : tr("Walkthrough, dialog 2 of 2")); tabWidget = nullptr; - tabWidget = dlg.findChild(QString::fromLatin1("Gui__Dialog__TabWidget")); + tabWidget = dlg.findChild(QStringLiteral("Gui__Dialog__TabWidget")); if (!tabWidget) { std::cerr << "Toolbar walkthrough: Unable to find tabWidget Gui__Dialog__TabWidget" << std::endl; @@ -702,7 +702,7 @@ Note: your changes will be applied when you next switch workbenches\n")); } auto setupToolbarPage = tabWidget->findChild( - QString::fromLatin1("Gui__Dialog__DlgCustomToolbars")); + QStringLiteral("Gui__Dialog__DlgCustomToolbars")); if (!setupToolbarPage) { std::cerr << "Toolbar walkthrough: Unable to find setupToolbarPage Gui__Dialog__DlgCustomToolbars" @@ -712,12 +712,12 @@ Note: your changes will be applied when you next switch workbenches\n")); tabWidget->setCurrentWidget(setupToolbarPage); auto moveActionRightButton = - setupToolbarPage->findChild(QString::fromLatin1("moveActionRightButton")); + setupToolbarPage->findChild(QStringLiteral("moveActionRightButton")); if (!moveActionRightButton) { Base::Console().Warning("Toolbar walkthrough: Unable to find moveActionRightButton\n"); } else { - moveActionRightButton->setStyleSheet(QString::fromLatin1("background-color: red")); + moveActionRightButton->setStyleSheet(QStringLiteral("background-color: red")); } /** tailor instructions depending on whether user already has custom toolbar created * if not, they need to click New button to create one first @@ -726,14 +726,14 @@ Note: your changes will be applied when you next switch workbenches\n")); QString instructions2 = tr("Walkthrough instructions: Select macro from list, then click right arrow button (->), then Close."); auto workbenchBox = - setupToolbarPage->findChild(QString::fromLatin1("workbenchBox")); + setupToolbarPage->findChild(QStringLiteral("workbenchBox")); if (!workbenchBox) { Base::Console().Warning("Toolbar walkthrough: Unable to find workbenchBox\n"); } else { /** find the Global workbench and select it for the user **/ - int globalIdx = workbenchBox->findData(QString::fromLatin1("Global")); + int globalIdx = workbenchBox->findData(QStringLiteral("Global")); if (globalIdx != -1) { workbenchBox->setCurrentIndex(globalIdx); setupToolbarPage->activateWorkbenchBox(globalIdx); @@ -744,12 +744,12 @@ Note: your changes will be applied when you next switch workbenches\n")); if (!hasCustomToolbar) { auto newButton = - setupToolbarPage->findChild(QString::fromLatin1("newButton")); + setupToolbarPage->findChild(QStringLiteral("newButton")); if (!newButton) { Base::Console().Warning("Toolbar walkthrough: Unable to find newButton\n"); } else { - newButton->setStyleSheet(QString::fromLatin1("color:red")); + newButton->setStyleSheet(QStringLiteral("color:red")); instructions2 = tr("Walkthrough instructions: Click New, select macro, then right arrow (->) " "button, then Close."); } @@ -758,17 +758,17 @@ Note: your changes will be applied when you next switch workbenches\n")); /** "label" normally says "Note: the changes become active the next time you load the * appropriate workbench" **/ - auto label = setupToolbarPage->findChild(QString::fromLatin1("label")); + auto label = setupToolbarPage->findChild(QStringLiteral("label")); if (!label) { Base::Console().Warning("Toolbar walkthrough: Unable to find label\n"); } else { label->setText(instructions2); - label->setStyleSheet(QString::fromLatin1("color:red")); + label->setStyleSheet(QStringLiteral("color:red")); } /** find Macros category and select it for the user **/ - auto categoryBox = setupToolbarPage->findChild(QString::fromLatin1("categoryBox")); + auto categoryBox = setupToolbarPage->findChild(QStringLiteral("categoryBox")); if (!categoryBox) { Base::Console().Warning("Toolbar walkthrough: Unable to find categoryBox\n"); } @@ -784,7 +784,7 @@ Note: your changes will be applied when you next switch workbenches\n")); /** expand custom toolbar items **/ auto toolbarTreeWidget = - setupToolbarPage->findChild(QString::fromLatin1("toolbarTreeWidget")); + setupToolbarPage->findChild(QStringLiteral("toolbarTreeWidget")); if (!toolbarTreeWidget) { Base::Console().Warning("Toolbar walkthrough: Unable to find toolbarTreeWidget\n"); } @@ -797,7 +797,7 @@ Note: your changes will be applied when you next switch workbenches\n")); **/ QTimer::singleShot(500, [=]() { auto commandTreeWidget = - setupToolbarPage->findChild(QString::fromLatin1("commandTreeWidget")); + setupToolbarPage->findChild(QStringLiteral("commandTreeWidget")); if (!commandTreeWidget) { Base::Console().Warning("Toolbar walkthrough: Unable to find commandTreeWidget\n"); } diff --git a/src/Gui/Dialogs/DlgOnlineHelpImp.cpp b/src/Gui/Dialogs/DlgOnlineHelpImp.cpp index e0b8e9982a..94f0808b98 100644 --- a/src/Gui/Dialogs/DlgOnlineHelpImp.cpp +++ b/src/Gui/Dialogs/DlgOnlineHelpImp.cpp @@ -49,7 +49,7 @@ DlgOnlineHelpImp::DlgOnlineHelpImp( QWidget* parent ) { ui->setupUi(this); - ui->prefStartPage->setFilter(QString::fromLatin1("%1 (*.html *.htm)").arg(tr("HTML files"))); + ui->prefStartPage->setFilter(QStringLiteral("%1 (*.html *.htm)").arg(tr("HTML files"))); if (ui->prefStartPage->fileName().isEmpty()) { ui->prefStartPage->setFileName(getStartpage()); } @@ -69,7 +69,7 @@ DlgOnlineHelpImp::~DlgOnlineHelpImp() = default; QString DlgOnlineHelpImp::getStartpage() { QDir docdir = QDir(QString::fromUtf8(App::Application::getHelpDir().c_str())); - return docdir.absoluteFilePath(QString::fromUtf8("Start_Page.html")); + return docdir.absoluteFilePath(QStringLiteral("Start_Page.html")); } void DlgOnlineHelpImp::saveSettings() diff --git a/src/Gui/Dialogs/DlgParameterImp.cpp b/src/Gui/Dialogs/DlgParameterImp.cpp index 50a5e1501b..c33cfd1aa2 100644 --- a/src/Gui/Dialogs/DlgParameterImp.cpp +++ b/src/Gui/Dialogs/DlgParameterImp.cpp @@ -224,7 +224,7 @@ void DlgParameterImp::onFindGroupTtextChanged(const QString& SearchStr) } else { // Set red background to indicate no matching - QString styleSheet = QString::fromLatin1(" QLineEdit {\n" + QString styleSheet = QStringLiteral(" QLineEdit {\n" " background-color: rgb(221,144,161);\n" " }\n"); ui->findGroupLE->setStyleSheet(styleSheet); @@ -610,7 +610,7 @@ void ParameterGroup::onExportToFile() QString file = FileDialog::getSaveFileName(this, tr("Export parameter to file"), QString(), - QString::fromLatin1("XML (*.FCParam)")); + QStringLiteral("XML (*.FCParam)")); if (!file.isEmpty()) { QTreeWidgetItem* item = currentItem(); if (item && item->isSelected()) { @@ -626,7 +626,7 @@ void ParameterGroup::onImportFromFile() QString file = FileDialog::getOpenFileName(this, tr("Import parameter from file"), QString(), - QString::fromLatin1("XML (*.FCParam)")); + QStringLiteral("XML (*.FCParam)")); if (!file.isEmpty()) { QTreeWidgetItem* item = currentItem(); if (item && item->isSelected()) { @@ -989,7 +989,7 @@ void ParameterValue::onCreateBoolItem() } QStringList list; - list << QString::fromLatin1("true") << QString::fromLatin1("false"); + list << QStringLiteral("true") << QStringLiteral("false"); QString val = QInputDialog::getItem(this, QObject::tr("New boolean item"), QObject::tr("Choose an item:"), @@ -1138,7 +1138,7 @@ ParameterText::ParameterText(QTreeWidget* parent, { setIcon(0, BitmapFactory().iconFromTheme("Param_Text")); setText(0, label); - setText(1, QString::fromLatin1("Text")); + setText(1, QStringLiteral("Text")); setText(2, QString::fromUtf8(value)); } @@ -1187,8 +1187,8 @@ ParameterInt::ParameterInt(QTreeWidget* parent, { setIcon(0, BitmapFactory().iconFromTheme("Param_Int")); setText(0, label); - setText(1, QString::fromLatin1("Integer")); - setText(2, QString::fromLatin1("%1").arg(value)); + setText(1, QStringLiteral("Integer")); + setText(2, QStringLiteral("%1").arg(value)); } ParameterInt::~ParameterInt() = default; @@ -1206,7 +1206,7 @@ void ParameterInt::changeValue() &ok, Qt::MSWindowsFixedSizeDialogHint); if (ok) { - setText(2, QString::fromLatin1("%1").arg(num)); + setText(2, QStringLiteral("%1").arg(num)); _hcGrp->SetInt(text(0).toLatin1(), (long)num); } } @@ -1238,8 +1238,8 @@ ParameterUInt::ParameterUInt(QTreeWidget* parent, { setIcon(0, BitmapFactory().iconFromTheme("Param_UInt")); setText(0, label); - setText(1, QString::fromLatin1("Unsigned")); - setText(2, QString::fromLatin1("%1").arg(value)); + setText(1, QStringLiteral("Unsigned")); + setText(2, QStringLiteral("%1").arg(value)); } ParameterUInt::~ParameterUInt() = default; @@ -1260,7 +1260,7 @@ void ParameterUInt::changeValue() unsigned long num = value.toULong(&ok); if (ok) { - setText(2, QString::fromLatin1("%1").arg(num)); + setText(2, QStringLiteral("%1").arg(num)); _hcGrp->SetUnsigned(text(0).toLatin1(), (unsigned long)num); } } @@ -1293,8 +1293,8 @@ ParameterFloat::ParameterFloat(QTreeWidget* parent, { setIcon(0, BitmapFactory().iconFromTheme("Param_Float")); setText(0, label); - setText(1, QString::fromLatin1("Float")); - setText(2, QString::fromLatin1("%1").arg(value)); + setText(1, QStringLiteral("Float")); + setText(2, QStringLiteral("%1").arg(value)); } ParameterFloat::~ParameterFloat() = default; @@ -1312,7 +1312,7 @@ void ParameterFloat::changeValue() &ok, Qt::MSWindowsFixedSizeDialogHint); if (ok) { - setText(2, QString::fromLatin1("%1").arg(num)); + setText(2, QStringLiteral("%1").arg(num)); _hcGrp->SetFloat(text(0).toLatin1(), num); } } @@ -1344,7 +1344,7 @@ ParameterBool::ParameterBool(QTreeWidget* parent, { setIcon(0, BitmapFactory().iconFromTheme("Param_Bool")); setText(0, label); - setText(1, QString::fromLatin1("Boolean")); + setText(1, QStringLiteral("Boolean")); setText(2, QString::fromLatin1((value ? "true" : "false"))); } @@ -1354,7 +1354,7 @@ void ParameterBool::changeValue() { bool ok; QStringList list; - list << QString::fromLatin1("true") << QString::fromLatin1("false"); + list << QStringLiteral("true") << QStringLiteral("false"); int pos = (text(2) == list[0] ? 0 : 1); QString txt = QInputDialog::getItem(treeWidget(), diff --git a/src/Gui/Dialogs/DlgProjectUtility.cpp b/src/Gui/Dialogs/DlgProjectUtility.cpp index 1a3da5315f..eb340dbf1d 100644 --- a/src/Gui/Dialogs/DlgProjectUtility.cpp +++ b/src/Gui/Dialogs/DlgProjectUtility.cpp @@ -47,7 +47,7 @@ DlgProjectUtility::DlgProjectUtility(QWidget* parent, Qt::WindowFlags fl) ui->setupUi(this); connect(ui->extractButton, &QPushButton::clicked, this, &DlgProjectUtility::extractButton); connect(ui->createButton, &QPushButton::clicked, this, &DlgProjectUtility::createButton); - ui->extractSource->setFilter(QString::fromLatin1("%1 (*.FCStd)").arg(tr("Project file"))); + ui->extractSource->setFilter(QStringLiteral("%1 (*.FCStd)").arg(tr("Project file"))); } /** @@ -85,7 +85,7 @@ void DlgProjectUtility::createButton() return; } - dest = QDir(dest).absoluteFilePath(QString::fromUtf8("project.fcstd")); + dest = QDir(dest).absoluteFilePath(QStringLiteral("project.fcstd")); bool openFile = ui->checkLoadProject->isChecked(); tryCreateArchive(source, dest, openFile); diff --git a/src/Gui/Dialogs/DlgPropertyLink.cpp b/src/Gui/Dialogs/DlgPropertyLink.cpp index 4736c86ac9..0417c688da 100644 --- a/src/Gui/Dialogs/DlgPropertyLink.cpp +++ b/src/Gui/Dialogs/DlgPropertyLink.cpp @@ -173,16 +173,16 @@ DlgPropertyLink::formatObject(App::Document* ownerDoc, App::DocumentObject* obj, if (obj->Label.getStrValue() == obj->getNameInDocument()) { return QLatin1String(objName); } - return QString::fromLatin1("%1 (%2)").arg(QLatin1String(objName), + return QStringLiteral("%1 (%2)").arg(QLatin1String(objName), QString::fromUtf8(obj->Label.getValue())); } auto sobj = obj->getSubObject(sub); if (!sobj || sobj->Label.getStrValue() == sobj->getNameInDocument()) { - return QString::fromLatin1("%1.%2").arg(QLatin1String(objName), QString::fromUtf8(sub)); + return QStringLiteral("%1.%2").arg(QLatin1String(objName), QString::fromUtf8(sub)); } - return QString::fromLatin1("%1.%2 (%3)") + return QStringLiteral("%1.%2 (%3)") .arg(QLatin1String(objName), QString::fromUtf8(sub), QString::fromUtf8(sobj->Label.getValue())); @@ -226,7 +226,7 @@ QString DlgPropertyLink::formatLinks(App::Document* ownerDoc, QList 3 ? " ..." : "")); @@ -239,7 +239,7 @@ QString DlgPropertyLink::formatLinks(App::Document* ownerDoc, QList 3 ? " ..." : "")); } diff --git a/src/Gui/Dialogs/DlgSettingsColorGradientImp.cpp b/src/Gui/Dialogs/DlgSettingsColorGradientImp.cpp index f63a5fc0fc..23f3a4856e 100644 --- a/src/Gui/Dialogs/DlgSettingsColorGradientImp.cpp +++ b/src/Gui/Dialogs/DlgSettingsColorGradientImp.cpp @@ -69,7 +69,7 @@ DlgSettingsColorGradientImp::DlgSettingsColorGradientImp(const App::ColorGradien // assure that the LineEdit is as wide to contain numbers with 4 digits and 6 decimals QFontMetrics fm(ui->floatLineEditMax->font()); ui->floatLineEditMax->setMinimumWidth( - QtTools::horizontalAdvance(fm, QString::fromLatin1("-8000.000000"))); + QtTools::horizontalAdvance(fm, QStringLiteral("-8000.000000"))); setColorModelNames(cg.getColorModelNames()); setProfile(cg.getProfile()); diff --git a/src/Gui/Dialogs/DlgToolbarsImp.cpp b/src/Gui/Dialogs/DlgToolbarsImp.cpp index 65ce63c0e2..33edb6d115 100644 --- a/src/Gui/Dialogs/DlgToolbarsImp.cpp +++ b/src/Gui/Dialogs/DlgToolbarsImp.cpp @@ -84,7 +84,7 @@ DlgCustomToolbars::DlgCustomToolbars(DlgCustomToolbars::Type t, QWidget* parent) workbenches.sort(); int index = 1; ui->workbenchBox->addItem(QApplication::windowIcon(), tr("Global")); - ui->workbenchBox->setItemData(0, QVariant(QString::fromLatin1("Global")), Qt::UserRole); + ui->workbenchBox->setItemData(0, QVariant(QStringLiteral("Global")), Qt::UserRole); for (const auto& workbench : workbenches) { QPixmap px = Application::Instance->workbenchIcon(workbench); QString mt = Application::Instance->workbenchMenuText(workbench); @@ -265,7 +265,7 @@ void DlgCustomToolbars::exportCustomToolbars(const QByteArray& workbench) CommandManager& rMgr = Application::Instance->commandManager(); for (int i = 0; i < ui->toolbarTreeWidget->topLevelItemCount(); i++) { QTreeWidgetItem* toplevel = ui->toolbarTreeWidget->topLevelItem(i); - QString groupName = QString::fromLatin1("Custom_%1").arg(i + 1); + QString groupName = QStringLiteral("Custom_%1").arg(i + 1); QByteArray toolbarName = toplevel->text(0).toUtf8(); ParameterGrp::handle hToolGrp = hGrp->GetGroup(groupName.toLatin1()); hToolGrp->SetASCII("Name", toolbarName.constData()); @@ -439,7 +439,7 @@ void DlgCustomToolbars::onNewButtonClicked() { bool ok; QString text = - QString::fromLatin1("Custom%1").arg(ui->toolbarTreeWidget->topLevelItemCount() + 1); + QStringLiteral("Custom%1").arg(ui->toolbarTreeWidget->topLevelItemCount() + 1); text = QInputDialog::getText(this, tr("New toolbar"), tr("Toolbar name:"), @@ -678,7 +678,7 @@ void DlgCustomToolbarsImp::setActionGroup(QAction* action, const QList QMenu* menu = tb->menu(); if (!menu) { tb->setPopupMode(QToolButton::MenuButtonPopup); - tb->setObjectName(QString::fromLatin1("qt_toolbutton_menubutton")); + tb->setObjectName(QStringLiteral("qt_toolbutton_menubutton")); auto menu = new QMenu(tb); menu->addActions(group); tb->setMenu(menu); diff --git a/src/Gui/Dialogs/DlgUnitsCalculatorImp.cpp b/src/Gui/Dialogs/DlgUnitsCalculatorImp.cpp index 255b4d5704..f63e080e2e 100644 --- a/src/Gui/Dialogs/DlgUnitsCalculatorImp.cpp +++ b/src/Gui/Dialogs/DlgUnitsCalculatorImp.cpp @@ -51,7 +51,7 @@ DlgUnitsCalculator::DlgUnitsCalculator(QWidget* parent, Qt::WindowFlags fl) ui->setupUi(this); this->setAttribute(Qt::WA_DeleteOnClose); - ui->comboBoxScheme->addItem(QString::fromLatin1("Preference system"), static_cast(-1)); + ui->comboBoxScheme->addItem(QStringLiteral("Preference system"), static_cast(-1)); int num = static_cast(Base::UnitSystem::NumUnitSystemTypes); for (int i = 0; i < num; i++) { QString item = Base::UnitsApi::getDescription(static_cast(i)); @@ -83,8 +83,8 @@ DlgUnitsCalculator::DlgUnitsCalculator(QWidget* parent, Qt::WindowFlags fl) ui->ValueInput->setParamGrpPath(QByteArray("User parameter:BaseApp/History/UnitsCalculator")); // set a default that also illustrates how the dialog works - ui->ValueInput->setText(QString::fromLatin1("1 cm")); - ui->UnitInput->setText(QString::fromLatin1("in")); + ui->ValueInput->setText(QStringLiteral("1 cm")); + ui->UnitInput->setText(QStringLiteral("in")); units << Base::Unit::Acceleration << Base::Unit::AmountOfSubstance << Base::Unit::Angle << Base::Unit::Area << Base::Unit::Density << Base::Unit::CurrentDensity @@ -137,10 +137,10 @@ void DlgUnitsCalculator::valueChanged(const Base::Quantity& quant) // first check the unit, if it is invalid, getTypeString() outputs an empty string // explicitly check for "ee" like in "eeV" because this would trigger an exception in Base::Unit // since it expects then a scientific notation number like "1e3" - if ((ui->UnitInput->text().mid(0, 2) == QString::fromLatin1("ee")) + if ((ui->UnitInput->text().mid(0, 2) == QStringLiteral("ee")) || Base::Unit(ui->UnitInput->text().toStdString()).getTypeString().empty()) { ui->ValueOutput->setText( - QString::fromLatin1("%1 %2").arg(tr("unknown unit:"), ui->UnitInput->text())); + QStringLiteral("%1 %2").arg(tr("unknown unit:"), ui->UnitInput->text())); ui->pushButton_Copy->setEnabled(false); } else { // the unit is valid @@ -167,7 +167,7 @@ void DlgUnitsCalculator::valueChanged(const Base::Quantity& quant) val = QLocale().toString(value, 'f', Base::UnitsApi::getDecimals()); } // create the output string - QString out = QString::fromLatin1("%1 %2").arg(val, ui->UnitInput->text()); + QString out = QStringLiteral("%1 %2").arg(val, ui->UnitInput->text()); ui->ValueOutput->setText(out); ui->pushButton_Copy->setEnabled(true); } @@ -191,7 +191,7 @@ void DlgUnitsCalculator::copy() void DlgUnitsCalculator::returnPressed() { if (ui->pushButton_Copy->isEnabled()) { - ui->textEdit->append(ui->ValueInput->text() + QString::fromLatin1(" = ") + ui->textEdit->append(ui->ValueInput->text() + QStringLiteral(" = ") + ui->ValueOutput->text()); ui->ValueInput->pushToHistory(); } diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index a07fe8d2aa..432214d4de 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -1298,7 +1298,7 @@ static bool checkCanonicalPath(const std::map &docs) auto docName = [](App::Document *doc) -> QString { if (doc->Label.getStrValue() == doc->getName()) return QString::fromLatin1(doc->getName()); - return QString::fromLatin1("%1 (%2)").arg(QString::fromUtf8(doc->Label.getValue()), + return QStringLiteral("%1 (%2)").arg(QString::fromUtf8(doc->Label.getValue()), QString::fromLatin1(doc->getName())); }; int count = 0; @@ -1458,7 +1458,7 @@ bool Document::saveAs() } QString fn = FileDialog::getSaveFileName(getMainWindow(), QObject::tr("Save %1 Document").arg(exe), name, - QString::fromLatin1("%1 %2 (*.FCStd)").arg(exe, QObject::tr("Document"))); + QStringLiteral("%1 %2 (*.FCStd)").arg(exe, QObject::tr("Document"))); if (!fn.isEmpty()) { QFileInfo fi; @@ -1544,7 +1544,7 @@ void Document::saveAll() catch (const Base::Exception& e) { QMessageBox::critical(getMainWindow(), QObject::tr("Failed to save document") + - QString::fromLatin1(": %1").arg(QString::fromUtf8(doc->getName())), + QStringLiteral(": %1").arg(QString::fromUtf8(doc->getName())), QString::fromLatin1(e.what())); break; } @@ -2029,7 +2029,7 @@ MDIView *Document::createView(const Base::Type& typeId) view3D->getViewer()->removeViewProvider(getViewProvider(obj)); const char* name = getDocument()->Label.getValue(); - QString title = QString::fromLatin1("%1 : %2[*]") + QString title = QStringLiteral("%1 : %2[*]") .arg(QString::fromUtf8(name)).arg(d->_iWinCount++); view3D->setWindowTitle(title); @@ -2260,7 +2260,7 @@ bool Document::canClose (bool checkModify, bool checkLink) getActiveView(), QObject::tr("Document not saved"), QObject::tr("The document%1 could not be saved. Do you want to cancel closing it?") - .arg(docName?(QString::fromUtf8(" ")+QString::fromUtf8(docName)):QString()), + .arg(docName?(QStringLiteral(" ")+QString::fromUtf8(docName)):QString()), QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard); if (ret == QMessageBox::Discard) @@ -2593,7 +2593,7 @@ bool Document::checkTransactionID(bool undo, int iSteps) { str << " " << doc->getName() << "\n"; } int ret = QMessageBox::warning(getMainWindow(), undo ? QObject::tr("Undo") : QObject::tr("Redo"), - QString::fromLatin1("%1,\n%2%3").arg( + QStringLiteral("%1,\n%2%3").arg( QObject::tr("There are grouped transactions in the following documents with " "other preceding transactions"), QString::fromStdString(str.str()), diff --git a/src/Gui/DocumentRecovery.cpp b/src/Gui/DocumentRecovery.cpp index 9685f25393..e4ae5a94b0 100644 --- a/src/Gui/DocumentRecovery.cpp +++ b/src/Gui/DocumentRecovery.cpp @@ -212,7 +212,7 @@ QString DocumentRecovery::createProjectFile(const QString& documentXml) { QString source = documentXml; QFileInfo fi(source); - QString dest = fi.dir().absoluteFilePath(QString::fromLatin1("fc_recovery_file.fcstd")); + QString dest = fi.dir().absoluteFilePath(QStringLiteral("fc_recovery_file.fcstd")); std::stringstream str; str << doctools << "\n"; @@ -412,16 +412,16 @@ DocumentRecoveryPrivate::Info DocumentRecoveryPrivate::getRecoveryInfo(const QFi if (doc_dir.exists(QLatin1String("fc_recovery_file.xml"))) { XmlConfig cfg = readXmlFile(info.xmlFile); - if (cfg.contains(QString::fromLatin1("Label"))) { - info.label = cfg[QString::fromLatin1("Label")]; + if (cfg.contains(QStringLiteral("Label"))) { + info.label = cfg[QStringLiteral("Label")]; } - if (cfg.contains(QString::fromLatin1("FileName"))) { - info.fileName = cfg[QString::fromLatin1("FileName")]; + if (cfg.contains(QStringLiteral("FileName"))) { + info.fileName = cfg[QStringLiteral("FileName")]; } - if (cfg.contains(QString::fromLatin1("Status"))) { - QString status = cfg[QString::fromLatin1("Status")]; + if (cfg.contains(QStringLiteral("Status"))) { + QString status = cfg[QStringLiteral("Status")]; if (status == QLatin1String("Deprecated")) info.status = DocumentRecoveryPrivate::Overage; else if (status == QLatin1String("Success")) @@ -474,9 +474,9 @@ DocumentRecoveryPrivate::XmlConfig DocumentRecoveryPrivate::readXmlFile(const QS file.close(); QVector filter; - filter << QString::fromLatin1("Label"); - filter << QString::fromLatin1("FileName"); - filter << QString::fromLatin1("Status"); + filter << QStringLiteral("Label"); + filter << QStringLiteral("FileName"); + filter << QStringLiteral("Status"); QDomElement child; if (!root.isNull()) { @@ -590,7 +590,7 @@ void DocumentRecoveryFinder::checkDocumentDirs(QDir& tmp, const QList } else { int countDeletedDocs = 0; - QString recovery_files = QString::fromLatin1("fc_recovery_files"); + QString recovery_files = QStringLiteral("fc_recovery_files"); for (QList::const_iterator it = dirs.cbegin(); it != dirs.cend(); ++it) { QDir doc_dir(it->absoluteFilePath()); doc_dir.setFilter(QDir::NoDotAndDotDot|QDir::AllEntries); @@ -646,7 +646,7 @@ bool DocumentRecoveryFinder::showRecoveryDialogIfNeeded() void DocumentRecoveryHandler::checkForPreviousCrashes(const std::function&, const QString&)> & callableFunc) const { QDir tmp = QString::fromUtf8(App::Application::getUserCachePath().c_str()); - tmp.setNameFilters(QStringList() << QString::fromLatin1("*.lock")); + tmp.setNameFilters(QStringList() << QStringLiteral("*.lock")); tmp.setFilter(QDir::Files); QString exeName = QString::fromStdString(App::Application::getExecutableName()); diff --git a/src/Gui/EditorView.cpp b/src/Gui/EditorView.cpp index 8eefb03515..f0ac94567a 100644 --- a/src/Gui/EditorView.cpp +++ b/src/Gui/EditorView.cpp @@ -370,7 +370,7 @@ bool EditorView::saveAs() this, QObject::tr("Save Macro"), QString(), - QString::fromLatin1("%1 (*.FCMacro);;Python (*.py)").arg(tr("FreeCAD macro"))); + QStringLiteral("%1 (*.FCMacro);;Python (*.py)").arg(tr("FreeCAD macro"))); if (fn.isEmpty()) { return false; } @@ -503,7 +503,7 @@ void EditorView::printPdf() FileDialog::getSaveFileName(this, tr("Export PDF"), QString(), - QString::fromLatin1("%1 (*.pdf)").arg(tr("PDF file"))); + QStringLiteral("%1 (*.pdf)").arg(tr("PDF file"))); if (!filename.isEmpty()) { QPrinter printer(QPrinter::ScreenResolution); // setPdfVersion sets the printied PDF Version to comply with PDF/A-1b, more details under: @@ -541,7 +541,7 @@ void EditorView::setCurrentFileName(const QString& fileName) shownName = tr("untitled[*]"); } else { - shownName = QString::fromLatin1("%1[*]").arg(name); + shownName = QStringLiteral("%1[*]").arg(name); } shownName += tr(" - Editor"); setWindowTitle(shownName); @@ -894,7 +894,7 @@ void SearchBar::findText(bool skip, bool next, const QString& str) QString styleSheet; if (!found) { - styleSheet = QString::fromLatin1(" QLineEdit {\n" + styleSheet = QStringLiteral(" QLineEdit {\n" " background-color: rgb(221,144,161);\n" " }\n"); } diff --git a/src/Gui/ExpressionBinding.cpp b/src/Gui/ExpressionBinding.cpp index d6d8972ef8..b5163cb443 100644 --- a/src/Gui/ExpressionBinding.cpp +++ b/src/Gui/ExpressionBinding.cpp @@ -281,7 +281,7 @@ ExpressionWidget::ExpressionWidget() = default; QPixmap ExpressionWidget::getIcon(const char* name, const QSize& size) const { - QString key = QString::fromLatin1("%1_%2x%3") + QString key = QStringLiteral("%1_%2x%3") .arg(QString::fromLatin1(name)) .arg(size.width()) .arg(size.height()); @@ -308,8 +308,8 @@ void ExpressionWidget::makeLabel(QLineEdit* le) iconLabel->setCursor(Qt::ArrowCursor); QPixmap pixmap = getIcon(":/icons/bound-expression-unset.svg", QSize(iconHeight, iconHeight)); iconLabel->setPixmap(pixmap); - iconLabel->setStyleSheet(QString::fromLatin1("QLabel { border: none; padding: 0px; padding-top: %2px; width: %1px; height: %1px }").arg(iconHeight).arg(frameWidth/2)); + iconLabel->setStyleSheet(QStringLiteral("QLabel { border: none; padding: 0px; padding-top: %2px; width: %1px; height: %1px }").arg(iconHeight).arg(frameWidth/2)); iconLabel->hide(); iconLabel->setExpressionText(QString()); - le->setStyleSheet(QString::fromLatin1("QLineEdit { padding-right: %1px } ").arg(iconHeight+frameWidth)); + le->setStyleSheet(QStringLiteral("QLineEdit { padding-right: %1px } ").arg(iconHeight+frameWidth)); } diff --git a/src/Gui/FileDialog.cpp b/src/Gui/FileDialog.cpp index 978f825dd1..353672461a 100644 --- a/src/Gui/FileDialog.cpp +++ b/src/Gui/FileDialog.cpp @@ -118,7 +118,7 @@ QList FileDialog::fetchSidebarUrls() bool FileDialog::hasSuffix(const QString& ext) const { - QRegularExpression rx(QString::fromLatin1("\\*.(%1)\\W").arg(ext), QRegularExpression::CaseInsensitiveOption); + QRegularExpression rx(QStringLiteral("\\*.(%1)\\W").arg(ext), QRegularExpression::CaseInsensitiveOption); QStringList filters = nameFilters(); for (const auto & str : filters) { if (rx.match(str).hasMatch()) { @@ -142,9 +142,9 @@ void FileDialog::accept() // #0001928: do not add a suffix if a file with suffix is entered // #0002209: make sure that the entered suffix is part of one of the filters if (!ext.isEmpty() && (suffix.isEmpty() || !hasSuffix(suffix))) { - file = QString::fromLatin1("%1.%2").arg(file, ext); + file = QStringLiteral("%1.%2").arg(file, ext); // That's the built-in line edit - auto fileNameEdit = this->findChild(QString::fromLatin1("fileNameEdit")); + auto fileNameEdit = this->findChild(QStringLiteral("fileNameEdit")); if (fileNameEdit) fileNameEdit->setText(file); } @@ -514,10 +514,10 @@ void FileOptionsDialog::accept() if (ext.isEmpty()) setDefaultSuffix(suf); else if (ext.toLower() != suf.toLower()) { - fn = QString::fromLatin1("%1.%2").arg(fn, suf); + fn = QStringLiteral("%1.%2").arg(fn, suf); selectFile(fn); // That's the built-in line edit (fixes Debian bug #811200) - auto fileNameEdit = this->findChild(QString::fromLatin1("fileNameEdit")); + auto fileNameEdit = this->findChild(QStringLiteral("fileNameEdit")); if (fileNameEdit) fileNameEdit->setText(fn); } @@ -617,7 +617,7 @@ QIcon FileIconProvider::icon(const QFileInfo & info) const auto urlToThumbnail = [](const QString& filename) { QString hash = QString::fromLatin1(QCryptographicHash::hash(filename.toUtf8(), QCryptographicHash::Md5).toHex()); QString cache = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation); - return QString::fromLatin1("%1/thumbnails/normal/%2.png").arg(cache, hash); + return QStringLiteral("%1/thumbnails/normal/%2.png").arg(cache, hash); }; auto iconFromFile = [](const QString& filename) { @@ -627,7 +627,7 @@ QIcon FileIconProvider::icon(const QFileInfo & info) const return icon; } - return QIcon(QString::fromLatin1(":/icons/freecad-doc.png")); + return QIcon(QStringLiteral(":/icons/freecad-doc.png")); }; if (info.suffix().toLower() == QLatin1String("fcstd")) { @@ -637,7 +637,7 @@ QIcon FileIconProvider::icon(const QFileInfo & info) const return iconFromFile(thumb); } else if (info.suffix().toLower().startsWith(QLatin1String("fcstd"))) { - QIcon icon(QString::fromLatin1(":/icons/freecad-doc.png")); + QIcon icon(QStringLiteral(":/icons/freecad-doc.png")); QIcon darkIcon; int w = QApplication::style()->pixelMetric(QStyle::PM_ListViewIconSize); darkIcon.addPixmap(icon.pixmap(w, w, QIcon::Disabled, QIcon::Off), QIcon::Normal, QIcon::Off); @@ -673,7 +673,7 @@ FileChooser::FileChooser ( QWidget * parent ) completer = new QCompleter ( this ); completer->setMaxVisibleItems( 12 ); fs_model = new QFileSystemModel( completer ); - fs_model->setRootPath(QString::fromUtf8("")); + fs_model->setRootPath(QStringLiteral("")); completer->setModel( fs_model ); lineEdit->setCompleter( completer ); @@ -884,7 +884,7 @@ SelectModule::SelectModule (const QString& type, const SelectModule::Dict& types module = module.left(match.capturedStart()); } - button->setText(QString::fromLatin1("%1 (%2)").arg(filter, module)); + button->setText(QStringLiteral("%1 (%2)").arg(filter, module)); button->setObjectName(it.value()); gridLayout1->addWidget(button, index, 0, 1, 1); group->addButton(button, index); @@ -902,7 +902,7 @@ SelectModule::SelectModule (const QString& type, const SelectModule::Dict& types hboxLayout->addItem(spacerItem1); buttonBox = new QDialogButtonBox(this); - buttonBox->setObjectName(QString::fromUtf8("buttonBox")); + buttonBox->setObjectName(QStringLiteral("buttonBox")); buttonBox->setStandardButtons(QDialogButtonBox::Open | QDialogButtonBox::Cancel); buttonBox->button(QDialogButtonBox::Open)->setEnabled(false); diff --git a/src/Gui/GraphvizView.cpp b/src/Gui/GraphvizView.cpp index fa51ccdf5b..f7acbc3e99 100644 --- a/src/Gui/GraphvizView.cpp +++ b/src/Gui/GraphvizView.cpp @@ -285,15 +285,15 @@ void GraphvizView::updateSvgItem(const App::Document &doc) args << QLatin1String("-Granksep=2") << QLatin1String("-Goutputorder=edgesfirst") << QLatin1String("-Gsplines=ortho") << QLatin1String("-Tsvg"); flatArgs << QLatin1String("-c2 -l2"); - auto dot = QString::fromLatin1("dot"); - auto unflatten = QString::fromLatin1("unflatten"); + auto dot = QStringLiteral("dot"); + auto unflatten = QStringLiteral("unflatten"); auto path = QString::fromUtf8(hGrp->GetASCII("Graphviz").c_str()); bool pathChanged = false; QDir dir; if (!path.isEmpty()) { dir = QDir(path); - dot = dir.filePath(QString::fromLatin1("dot")); - unflatten = dir.filePath(QString::fromLatin1("unflatten")); + dot = dir.filePath(QStringLiteral("dot")); + unflatten = dir.filePath(QStringLiteral("unflatten")); } dotProc->setEnvironment(QProcess::systemEnvironment()); flatProc->setEnvironment(QProcess::systemEnvironment()); @@ -305,7 +305,7 @@ void GraphvizView::updateSvgItem(const App::Document &doc) if (!dotProc->waitForStarted()) { int ret = QMessageBox::warning(Gui::getMainWindow(), tr("Graphviz not found"), - QString::fromLatin1("%1 " + QStringLiteral("%1 " "%2" "

%3

") .arg(tr("Graphviz couldn't be found on your system."), @@ -324,8 +324,8 @@ void GraphvizView::updateSvgItem(const App::Document &doc) } else { dir = QDir(path); - dot = dir.filePath(QString::fromLatin1("dot")); - unflatten = dir.filePath(QString::fromLatin1("unflatten")); + dot = dir.filePath(QStringLiteral("dot")); + unflatten = dir.filePath(QStringLiteral("unflatten")); pathChanged = true; } } @@ -391,7 +391,7 @@ QByteArray GraphvizView::exportGraph(const QString& format) ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Paths"); QProcess dotProc, flatProc; QStringList args, flatArgs; - args << QString::fromLatin1("-T%1").arg(format); + args << QStringLiteral("-T%1").arg(format); flatArgs << QLatin1String("-c2 -l2"); #ifdef FC_OS_LINUX @@ -401,11 +401,11 @@ QByteArray GraphvizView::exportGraph(const QString& format) #endif #ifdef FC_OS_WIN32 - QString exe = QString::fromLatin1("\"%1/dot\"").arg(path); - QString unflatten = QString::fromLatin1("\"%1/unflatten\"").arg(path); + QString exe = QStringLiteral("\"%1/dot\"").arg(path); + QString unflatten = QStringLiteral("\"%1/unflatten\"").arg(path); #else - QString exe = QString::fromLatin1("%1/dot").arg(path); - QString unflatten = QString::fromLatin1("%1/unflatten").arg(path); + QString exe = QStringLiteral("%1/dot").arg(path); + QString unflatten = QStringLiteral("%1/unflatten").arg(path); #endif dotProc.setEnvironment(QProcess::systemEnvironment()); @@ -442,13 +442,13 @@ bool GraphvizView::onMsg(const char* pMsg, const char**) { if (strcmp("Save",pMsg) == 0 || strcmp("SaveAs",pMsg) == 0) { QList< QPair > formatMap; - formatMap << qMakePair(QString::fromLatin1("%1 (*.gv)").arg(tr("Graphviz format")), QString::fromLatin1("gv")); - formatMap << qMakePair(QString::fromLatin1("%1 (*.png)").arg(tr("PNG format")), QString::fromLatin1("png")); - formatMap << qMakePair(QString::fromLatin1("%1 (*.bmp)").arg(tr("Bitmap format")), QString::fromLatin1("bmp")); - formatMap << qMakePair(QString::fromLatin1("%1 (*.gif)").arg(tr("GIF format")), QString::fromLatin1("gif")); - formatMap << qMakePair(QString::fromLatin1("%1 (*.jpg)").arg(tr("JPG format")), QString::fromLatin1("jpg")); - formatMap << qMakePair(QString::fromLatin1("%1 (*.svg)").arg(tr("SVG format")), QString::fromLatin1("svg")); - formatMap << qMakePair(QString::fromLatin1("%1 (*.pdf)").arg(tr("PDF format")), QString::fromLatin1("pdf")); + formatMap << qMakePair(QStringLiteral("%1 (*.gv)").arg(tr("Graphviz format")), QStringLiteral("gv")); + formatMap << qMakePair(QStringLiteral("%1 (*.png)").arg(tr("PNG format")), QStringLiteral("png")); + formatMap << qMakePair(QStringLiteral("%1 (*.bmp)").arg(tr("Bitmap format")), QStringLiteral("bmp")); + formatMap << qMakePair(QStringLiteral("%1 (*.gif)").arg(tr("GIF format")), QStringLiteral("gif")); + formatMap << qMakePair(QStringLiteral("%1 (*.jpg)").arg(tr("JPG format")), QStringLiteral("jpg")); + formatMap << qMakePair(QStringLiteral("%1 (*.svg)").arg(tr("SVG format")), QStringLiteral("svg")); + formatMap << qMakePair(QStringLiteral("%1 (*.pdf)").arg(tr("PDF format")), QStringLiteral("pdf")); QStringList filter; for (const auto & it : std::as_const(formatMap)) { @@ -523,7 +523,7 @@ void GraphvizView::print(QPrinter* printer) QPainter p(printer); QRect rect = printer->pageLayout().paintRectPixels(printer->resolution()); view->scene()->render(&p, rect); - //QByteArray buffer = exportGraph(QString::fromLatin1("svg")); + //QByteArray buffer = exportGraph(QStringLiteral("svg")); //QSvgRenderer svg(buffer); //svg.render(&p, rect); p.end(); @@ -543,7 +543,7 @@ void GraphvizView::print() void GraphvizView::printPdf() { QStringList filter; - filter << QString::fromLatin1("%1 (*.pdf)").arg(tr("PDF format")); + filter << QStringLiteral("%1 (*.pdf)").arg(tr("PDF format")); QString selectedFilter; QString fn = Gui::FileDialog::getSaveFileName(this, tr("Export graph"), QString(), filter.join(QLatin1String(";;")), &selectedFilter); diff --git a/src/Gui/InputField.cpp b/src/Gui/InputField.cpp index 642b16a58a..0d432566a9 100644 --- a/src/Gui/InputField.cpp +++ b/src/Gui/InputField.cpp @@ -88,11 +88,11 @@ InputField::InputField(QWidget * parent) iconLabel->setCursor(Qt::ArrowCursor); QPixmap pixmap = getValidationIcon(":/icons/button_valid.svg", QSize(sizeHint().height(),sizeHint().height())); iconLabel->setPixmap(pixmap); - iconLabel->setStyleSheet(QString::fromLatin1("QLabel { border: none; padding: 0px; }")); + iconLabel->setStyleSheet(QStringLiteral("QLabel { border: none; padding: 0px; }")); iconLabel->hide(); connect(this, &QLineEdit::textChanged, this, &InputField::updateIconLabel); int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); - setStyleSheet(QString::fromLatin1("QLineEdit { padding-right: %1px } ").arg(iconLabel->sizeHint().width() + frameWidth + 1)); + setStyleSheet(QStringLiteral("QLineEdit { padding-right: %1px } ").arg(iconLabel->sizeHint().width() + frameWidth + 1)); QSize msz = minimumSizeHint(); setMinimumSize(qMax(msz.width(), iconLabel->sizeHint().height() + frameWidth * 2 + 2), qMax(msz.height(), iconLabel->sizeHint().height() + frameWidth * 2 + 2)); @@ -143,7 +143,7 @@ bool InputField::apply() QPixmap InputField::getValidationIcon(const char* name, const QSize& size) const { - QString key = QString::fromLatin1("%1_%2x%3") + QString key = QStringLiteral("%1_%2x%3") .arg(QString::fromLatin1(name)) .arg(size.width()) .arg(size.height()); @@ -192,7 +192,7 @@ void InputField::contextMenuEvent(QContextMenuEvent *event) { QMenu *editMenu = createStandardContextMenu(); editMenu->setTitle(tr("Edit")); - auto menu = new QMenu(QString::fromLatin1("InputFieldContextmenu")); + auto menu = new QMenu(QStringLiteral("InputFieldContextmenu")); menu->addMenu(editMenu); menu->addSeparator(); @@ -274,7 +274,7 @@ void InputField::newInput(const QString & text) if(!actUnit.isEmpty() && !res.getUnit().isEmpty() && actUnit != res.getUnit()){ QPixmap pixmap = getValidationIcon(":/icons/button_invalid.svg", QSize(sizeHint().height(),sizeHint().height())); iconLabel->setPixmap(pixmap); - Q_EMIT parseError(QString::fromLatin1("Wrong unit")); + Q_EMIT parseError(QStringLiteral("Wrong unit")); validInput = false; return; } @@ -474,7 +474,7 @@ QString InputField::rawText() const std::string unit; double value = actQuantity.getValue(); actQuantity.getUserString(factor, unit); - return QString::fromLatin1("%1 %2").arg(value / factor).arg(QString::fromStdString(unit)); + return QStringLiteral("%1 %2").arg(value / factor).arg(QString::fromStdString(unit)); } /// expects the string in C locale and internally converts it into the OS-specific locale @@ -595,7 +595,7 @@ void InputField::setHistorySize(int i) void InputField::selectNumber() { - QString expr = QString::fromLatin1("^([%1%2]?[0-9\\%3]*)\\%4?([0-9]+(%5[%1%2]?[0-9]+)?)") + QString expr = QStringLiteral("^([%1%2]?[0-9\\%3]*)\\%4?([0-9]+(%5[%1%2]?[0-9]+)?)") .arg(locale().negativeSign()) .arg(locale().positiveSign()) .arg(locale().groupSeparator()) @@ -676,7 +676,7 @@ void InputField::keyPressEvent(QKeyEvent *event) double dFactor; std::string unitStr; actQuantity.getUserString(dFactor, unitStr); - this->setText(QString::fromUtf8("%L1 %2").arg(val).arg(QString::fromStdString(unitStr))); + this->setText(QStringLiteral("%L1 %2").arg(val).arg(QString::fromStdString(unitStr))); event->accept(); } @@ -702,7 +702,7 @@ void InputField::wheelEvent (QWheelEvent * event) std::string unitStr; actQuantity.getUserString(dFactor, unitStr); - this->setText(QString::fromUtf8("%L1 %2").arg(val).arg(QString::fromStdString(unitStr))); + this->setText(QStringLiteral("%L1 %2").arg(val).arg(QString::fromStdString(unitStr))); selectNumber(); event->accept(); } diff --git a/src/Gui/InputVector.cpp b/src/Gui/InputVector.cpp index 9220a23df2..141583b994 100644 --- a/src/Gui/InputVector.cpp +++ b/src/Gui/InputVector.cpp @@ -158,7 +158,7 @@ void LocationWidget::setDirection(const Base::Vector3d& dir) } // add a new item before the very last item - QString display = QString::fromLatin1("(%1,%2,%3)") + QString display = QStringLiteral("(%1,%2,%3)") .arg(dir.x) .arg(dir.y) .arg(dir.z); diff --git a/src/Gui/InputVector.h b/src/Gui/InputVector.h index 89dc54c3fc..17419500c7 100644 --- a/src/Gui/InputVector.h +++ b/src/Gui/InputVector.h @@ -204,7 +204,7 @@ private: } // add a new item before the very last item - QString display = QString::fromLatin1("(%1,%2,%3)") + QString display = QStringLiteral("(%1,%2,%3)") .arg(dir.x) .arg(dir.y) .arg(dir.z); @@ -322,7 +322,7 @@ public: } // add a new item before the very last item - QString display = QString::fromLatin1("(%1,%2,%3)") + QString display = QStringLiteral("(%1,%2,%3)") .arg(dir.x) .arg(dir.y) .arg(dir.z); @@ -503,7 +503,7 @@ public: } // add a new item before the very last item - QString display = QString::fromLatin1("(%1,%2,%3)") + QString display = QStringLiteral("(%1,%2,%3)") .arg(dir.x) .arg(dir.y) .arg(dir.z); diff --git a/src/Gui/Language/Translator.cpp b/src/Gui/Language/Translator.cpp index cbe8422492..cdfd257a4c 100644 --- a/src/Gui/Language/Translator.cpp +++ b/src/Gui/Language/Translator.cpp @@ -182,7 +182,7 @@ Translator::Translator() auto entries = hGrp->GetASCII("AdditionalLanguageDomainEntries", ""); // The format of the entries is "Language Name 1"="code1";"Language Name 2"="code2";... // Example: "Romanian"="ro";"Polish"="pl"; - QRegularExpression matchingRE(QString::fromUtf8("\"(.*[^\\s]+.*)\"\\s*=\\s*\"([^\\s]+)\";?")); + QRegularExpression matchingRE(QStringLiteral("\"(.*[^\\s]+.*)\"\\s*=\\s*\"([^\\s]+)\";?")); auto matches = matchingRE.globalMatch(QString::fromStdString(entries)); while (matches.hasNext()) { QRegularExpressionMatch match = matches.next(); @@ -223,7 +223,7 @@ TStringMap Translator::supportedLocales() const for (const auto& domainMap : d->mapLanguageTopLevelDomain) { for (const auto& directoryName : std::as_const(d->paths)) { QDir dir(directoryName); - QString filter = QString::fromLatin1("*_%1.qm").arg(QString::fromStdString(domainMap.second)); + QString filter = QStringLiteral("*_%1.qm").arg(QString::fromStdString(domainMap.second)); QStringList fileNames = dir.entryList(QStringList(filter), QDir::Files, QDir::Name); if (!fileNames.isEmpty()) { d->mapSupportedLocales[domainMap.first] = domainMap.second; @@ -309,7 +309,7 @@ void Translator::addPath(const QString& path) void Translator::installQMFiles(const QDir& dir, const char* locale) { - QString filter = QString::fromLatin1("*_%1.qm").arg(QLatin1String(locale)); + QString filter = QStringLiteral("*_%1.qm").arg(QLatin1String(locale)); QStringList fileNames = dir.entryList(QStringList(filter), QDir::Files, QDir::Name); for (const auto &it : fileNames){ bool ok=false; diff --git a/src/Gui/MDIView.cpp b/src/Gui/MDIView.cpp index 8a420a29c5..5568d3a429 100644 --- a/src/Gui/MDIView.cpp +++ b/src/Gui/MDIView.cpp @@ -169,7 +169,7 @@ void MDIView::onRelabel(Gui::Document *pDoc) } else { cap = QString::fromUtf8(pDoc->getDocument()->Label.getValue()); - cap = QString::fromLatin1("%1[*]").arg(cap); + cap = QStringLiteral("%1[*]").arg(cap); setWindowTitle(cap); } } @@ -258,7 +258,7 @@ void MDIView::print() void MDIView::printPdf() { QString filename = FileDialog::getSaveFileName(this, tr("Export PDF"), QString(), - QString::fromLatin1("%1 (*.pdf)").arg(tr("PDF file"))); + QStringLiteral("%1 (*.pdf)").arg(tr("PDF file"))); if (!filename.isEmpty()) { QPrinter printer(QPrinter::ScreenResolution); // setPdfVersion sets the printied PDF Version to comply with PDF/A-1b, more details under: https://www.kdab.com/creating-pdfa-documents-qt/ diff --git a/src/Gui/Macro.cpp b/src/Gui/Macro.cpp index 32549ca763..7428cccbc3 100644 --- a/src/Gui/Macro.cpp +++ b/src/Gui/Macro.cpp @@ -84,7 +84,7 @@ bool MacroFile::commit() str.setCodec("UTF-8"); #endif QStringList import; - import << QString::fromLatin1("import FreeCAD"); + import << QStringLiteral("import FreeCAD"); QStringList body; for (const auto& it : std::as_const(this->macroInProgress)) { @@ -99,14 +99,14 @@ bool MacroFile::commit() } QString header; - header += QString::fromLatin1("# -*- coding: utf-8 -*-\n\n"); - header += QString::fromLatin1("# Macro Begin: "); + header += QStringLiteral("# -*- coding: utf-8 -*-\n\n"); + header += QStringLiteral("# Macro Begin: "); header += this->macroName; - header += QString::fromLatin1(" +++++++++++++++++++++++++++++++++++++++++++++++++\n"); + header += QStringLiteral(" +++++++++++++++++++++++++++++++++++++++++++++++++\n"); - QString footer = QString::fromLatin1("# Macro End: "); + QString footer = QStringLiteral("# Macro End: "); footer += this->macroName; - footer += QString::fromLatin1(" +++++++++++++++++++++++++++++++++++++++++++++++++\n"); + footer += QStringLiteral(" +++++++++++++++++++++++++++++++++++++++++++++++++\n"); // write the data to the text file str << header; @@ -329,7 +329,7 @@ void MacroManager::addToOutput(LineType type, const char* line) void MacroManager::setModule(const char* sModule) { if (macroFile.isOpen() && sModule && *sModule != '\0') { - macroFile.append(QString::fromLatin1("import %1").arg(QString::fromLatin1(sModule))); + macroFile.append(QStringLiteral("import %1").arg(QString::fromLatin1(sModule))); } } diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp index cdb6bda72f..a315a2209a 100644 --- a/src/Gui/MainWindow.cpp +++ b/src/Gui/MainWindow.cpp @@ -366,7 +366,7 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f) tab->setTabsClosable(true); // The tabs might be very wide tab->setExpanding(false); - tab->setObjectName(QString::fromLatin1("mdiAreaTabBar")); + tab->setObjectName(QStringLiteral("mdiAreaTabBar")); } d->mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); d->mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); @@ -377,7 +377,7 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f) d->mdiArea->setBackground(QBrush(QColor(160,160,160))); setCentralWidget(d->mdiArea); - statusBar()->setObjectName(QString::fromLatin1("statusBar")); + statusBar()->setObjectName(QStringLiteral("statusBar")); connect(statusBar(), &QStatusBar::messageChanged, this, &MainWindow::statusMessageChanged); // labels and progressbar @@ -401,24 +401,24 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f) if(notificationAreaEnabled) { NotificationArea* notificationArea = new NotificationArea(statusBar()); - notificationArea->setObjectName(QString::fromLatin1("notificationArea")); + notificationArea->setObjectName(QStringLiteral("notificationArea")); notificationArea->setStyleSheet(QStringLiteral("text-align:left;")); statusBar()->addPermanentWidget(notificationArea); } // clears the action label d->actionTimer = new QTimer( this ); - d->actionTimer->setObjectName(QString::fromLatin1("actionTimer")); + d->actionTimer->setObjectName(QStringLiteral("actionTimer")); connect(d->actionTimer, &QTimer::timeout, d->actionLabel, &QLabel::clear); // clear status type d->statusTimer = new QTimer( this ); - d->statusTimer->setObjectName(QString::fromLatin1("statusTimer")); + d->statusTimer->setObjectName(QStringLiteral("statusTimer")); connect(d->statusTimer, &QTimer::timeout, this, &MainWindow::clearStatus); // update gui timer d->activityTimer = new QTimer(this); - d->activityTimer->setObjectName(QString::fromLatin1("activityTimer")); + d->activityTimer->setObjectName(QStringLiteral("activityTimer")); connect(d->activityTimer, &QTimer::timeout, this, &MainWindow::_updateActions); d->activityTimer->setSingleShot(false); d->activityTimer->start(150); @@ -1317,16 +1317,16 @@ void MainWindow::onWindowsMenuAboutToShow() QAction* action = actions.at(index); QString text; QString title = child->windowTitle(); - int lastIndex = title.lastIndexOf(QString::fromLatin1("[*]")); + int lastIndex = title.lastIndexOf(QStringLiteral("[*]")); if (lastIndex > 0) { title = title.left(lastIndex); if (child->isWindowModified()) - title = QString::fromLatin1("%1*").arg(title); + title = QStringLiteral("%1*").arg(title); } if (index < 9) - text = QString::fromLatin1("&%1 %2").arg(index+1).arg(title); + text = QStringLiteral("&%1 %2").arg(index+1).arg(title); else - text = QString::fromLatin1("%1 %2").arg(index+1).arg(title); + text = QStringLiteral("%1 %2").arg(index+1).arg(title); action->setText(text); action->setVisible(true); action->setChecked(child == active); @@ -1591,7 +1591,7 @@ void MainWindow::delayedStartup() void MainWindow::appendRecentFile(const QString& filename) { auto recent = this->findChild - (QString::fromLatin1("recentFiles")); + (QStringLiteral("recentFiles")); if (recent) { recent->appendFile(filename); } @@ -1600,7 +1600,7 @@ void MainWindow::appendRecentFile(const QString& filename) void MainWindow::appendRecentMacro(const QString& filename) { auto recent = this->findChild - (QString::fromLatin1("recentMacros")); + (QStringLiteral("recentMacros")); if (recent) { recent->appendFile(filename); } @@ -2155,7 +2155,7 @@ void MainWindow::changeEvent(QEvent *e) void MainWindow::clearStatus() { d->currentStatusType = 100; - statusBar()->setStyleSheet(QString::fromLatin1("#statusBar{}")); + statusBar()->setStyleSheet(QStringLiteral("#statusBar{}")); } void MainWindow::statusMessageChanged() { @@ -2214,7 +2214,7 @@ void MainWindow::showStatus(int type, const QString& message) statusBar()->setStyleSheet(d->status->wrn); break; case MainWindow::Pane: - statusBar()->setStyleSheet(QString::fromLatin1("#statusBar{}")); + statusBar()->setStyleSheet(QStringLiteral("#statusBar{}")); break; default: statusBar()->setStyleSheet(d->status->msg); @@ -2313,11 +2313,11 @@ void MainWindow::setWindowTitle(const QString& string) } if (SafeMode::SafeModeEnabled()) { - title = QString::fromUtf8("%1 (%2)").arg(title, tr("Safe Mode")); + title = QStringLiteral("%1 (%2)").arg(title, tr("Safe Mode")); } if (!string.isEmpty()) { - title = QString::fromUtf8("[*] %1 - %2").arg(string, title); + title = QStringLiteral("[*] %1 - %2").arg(string, title); } QMainWindow::setWindowTitle(title); @@ -2328,9 +2328,9 @@ void MainWindow::setWindowTitle(const QString& string) StatusBarObserver::StatusBarObserver() : WindowParameter("OutputWindow") { - msg = QString::fromLatin1("#statusBar{color: #000000}"); // black - wrn = QString::fromLatin1("#statusBar{color: #ffaa00}"); // orange - err = QString::fromLatin1("#statusBar{color: #ff0000}"); // red + msg = QStringLiteral("#statusBar{color: #000000}"); // black + wrn = QStringLiteral("#statusBar{color: #ffaa00}"); // orange + err = QStringLiteral("#statusBar{color: #ff0000}"); // red Base::Console().AttachObserver(this); getWindowParameter()->Attach(this); getWindowParameter()->NotifyAll(); @@ -2345,7 +2345,7 @@ void MainWindow::setWindowTitle(const QString& string) void StatusBarObserver::OnChange(Base::Subject & rCaller, const char* sReason) { ParameterGrp& rclGrp = ((ParameterGrp&)rCaller); - auto format = QString::fromLatin1("#statusBar{color: %1}"); + auto format = QStringLiteral("#statusBar{color: %1}"); if (strcmp(sReason, "colorText") == 0) { unsigned long col = rclGrp.GetUnsigned(sReason); this->msg = format.arg(App::Color::fromPackedRGB(col).name()); diff --git a/src/Gui/NetworkRetriever.cpp b/src/Gui/NetworkRetriever.cpp index 47ffa5856f..989f1856fd 100644 --- a/src/Gui/NetworkRetriever.cpp +++ b/src/Gui/NetworkRetriever.cpp @@ -241,15 +241,15 @@ bool NetworkRetriever::startDownload( const QString& startUrl ) if ( !d->proxy.isEmpty() ) { QStringList env = wget->environment(); - env << QString::fromLatin1("http_proxy=%1").arg(d->proxy); - env << QString::fromLatin1("ftp_proxy=%1").arg(d->proxy); + env << QStringLiteral("http_proxy=%1").arg(d->proxy); + env << QStringLiteral("ftp_proxy=%1").arg(d->proxy); wget->setEnvironment(env); } else { QStringList env = wget->environment(); - env.removeAll(QString::fromLatin1("http_proxy=%1").arg(d->proxy)); - env.removeAll(QString::fromLatin1("ftp_proxy=%1").arg(d->proxy)); + env.removeAll(QStringLiteral("http_proxy=%1").arg(d->proxy)); + env.removeAll(QStringLiteral("ftp_proxy=%1").arg(d->proxy)); wget->setEnvironment(env); } @@ -278,43 +278,43 @@ bool NetworkRetriever::startDownload( const QString& startUrl ) { if ( !d->user.isEmpty() ) { - wgetArguments << QString::fromLatin1("--proxy-user=%1").arg( d->user ); + wgetArguments << QStringLiteral("--proxy-user=%1").arg( d->user ); if ( !d->passwd.isEmpty() ) { - wgetArguments << QString::fromLatin1("--proxy-passwd=%1").arg( d->passwd ); + wgetArguments << QStringLiteral("--proxy-passwd=%1").arg( d->passwd ); } } } // output file if ( !d->outputFile.isEmpty() ) - wgetArguments << QString::fromLatin1("--output-document=%1").arg( d->outputFile ); + wgetArguments << QStringLiteral("--output-document=%1").arg( d->outputFile ); // timestamping enabled -> update newer files only if ( d->timeStamp ) - wgetArguments << QString::fromLatin1("-N"); + wgetArguments << QStringLiteral("-N"); // get all needed image files if ( d->img ) - wgetArguments << QString::fromLatin1("-p"); + wgetArguments << QStringLiteral("-p"); // follow relative links only if ( d->folRel ) - wgetArguments<< QString::fromLatin1("-L"); + wgetArguments<< QStringLiteral("-L"); if ( d->recurse ) { - wgetArguments << QString::fromLatin1("-r"); - wgetArguments << QString::fromLatin1("--level=%1").arg( d->level ); + wgetArguments << QStringLiteral("-r"); + wgetArguments << QStringLiteral("--level=%1").arg( d->level ); } if ( d->nop ) - wgetArguments << QString::fromLatin1("-np"); + wgetArguments << QStringLiteral("-np"); // convert absolute links in to relative if ( d->convert ) - wgetArguments << QString::fromLatin1("-k"); + wgetArguments << QStringLiteral("-k"); // number of tries - wgetArguments << QString::fromLatin1("--tries=%1").arg( d->tries ); + wgetArguments << QStringLiteral("--tries=%1").arg( d->tries ); // use HTML file extension if ( d->html ) - wgetArguments << QString::fromLatin1("-E"); + wgetArguments << QStringLiteral("-E"); // start URL wgetArguments << startUrl; @@ -327,10 +327,10 @@ bool NetworkRetriever::startDownload( const QString& startUrl ) QDir::setCurrent(d->dir); } - wget->start(QString::fromLatin1("wget"), wgetArguments); + wget->start(QStringLiteral("wget"), wgetArguments); QDir::setCurrent( cwd ); #else - wget->start(QString::fromLatin1("wget"), wgetArguments); + wget->start(QStringLiteral("wget"), wgetArguments); #endif return wget->state() == QProcess::Running; @@ -374,7 +374,7 @@ void NetworkRetriever::wgetFinished(int exitCode, QProcess::ExitStatus status) bool NetworkRetriever::testWget() { QProcess proc; - proc.setProgram(QString::fromLatin1("wget")); + proc.setProgram(QStringLiteral("wget")); proc.start(); bool ok = proc.state() == QProcess::Running; proc.kill(); @@ -484,7 +484,7 @@ void StdCmdDownloadOnlineHelp::activated(int iMsg) // set output directory QString path = QString::fromStdString(App::Application::getHomePath()); - path += QString::fromLatin1("/doc/"); + path += QStringLiteral("/doc/"); ParameterGrp::handle hURLGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/OnlineHelp"); path = QString::fromUtf8(hURLGrp->GetASCII( "DownloadLocation", path.toLatin1() ).c_str()); diff --git a/src/Gui/NotificationArea.cpp b/src/Gui/NotificationArea.cpp index edade8d749..0925013a70 100644 --- a/src/Gui/NotificationArea.cpp +++ b/src/Gui/NotificationArea.cpp @@ -1134,7 +1134,7 @@ void NotificationArea::showInNotificationArea() // We update the message with the most recent up to maxOpenNotifications QString msgw = - QString::fromLatin1( + QStringLiteral( " \

\ \ @@ -1149,7 +1149,7 @@ void NotificationArea::showInNotificationArea() if (currentlynotifying > pImp->maxOpenNotifications) { msgw += - QString::fromLatin1( + QStringLiteral( " \ \ \ @@ -1187,7 +1187,7 @@ void NotificationArea::showInNotificationArea() convertFromPlainText(item->getMessage(), Qt::WhiteSpaceMode::WhiteSpaceNormal); msgw += - QString::fromLatin1( + QStringLiteral( " \ \ \ @@ -1233,7 +1233,7 @@ void NotificationArea::showInNotificationArea() i++; } - msgw += QString::fromLatin1("

"); + msgw += QStringLiteral("

"); NotificationBox::Options options = NotificationBox::Options::RestrictAreaToReference; diff --git a/src/Gui/OnlineDocumentation.cpp b/src/Gui/OnlineDocumentation.cpp index 9c101ac1f0..e35486ebf3 100644 --- a/src/Gui/OnlineDocumentation.cpp +++ b/src/Gui/OnlineDocumentation.cpp @@ -169,7 +169,7 @@ QByteArray PythonOnlineHelp::loadHelpPage(const QString& filename) const QByteArray PythonOnlineHelp::fileNotFound() const { const int pageNotFound = 404; - QString contentType = QString::fromLatin1( + QString contentType = QStringLiteral( "text/html\r\n" "\r\n" "Error" @@ -189,11 +189,11 @@ QByteArray PythonOnlineHelp::fileNotFound() const "" "\r\n"); - QString header = QString::fromLatin1("content-type: %1\r\n").arg(contentType); + QString header = QStringLiteral("content-type: %1\r\n").arg(contentType); QString http(QLatin1String("HTTP/1.1 %1 %2\r\n%3\r\n")); QString httpResponseHeader = - http.arg(pageNotFound).arg(QString::fromLatin1("File not found"), header); + http.arg(pageNotFound).arg(QStringLiteral("File not found"), header); QByteArray res = httpResponseHeader.toLatin1(); return res; @@ -203,7 +203,7 @@ QByteArray PythonOnlineHelp::loadFailed(const QString& error) const { const int pageNotFound = 404; QString contentType = - QString::fromLatin1( + QStringLiteral( "text/html\r\n" "\r\n" "Error" @@ -222,11 +222,11 @@ QByteArray PythonOnlineHelp::loadFailed(const QString& error) const "\r\n") .arg(error); - QString header = QString::fromLatin1("content-type: %1\r\n").arg(contentType); + QString header = QStringLiteral("content-type: %1\r\n").arg(contentType); QString http(QLatin1String("HTTP/1.1 %1 %2\r\n%3\r\n")); QString httpResponseHeader = - http.arg(pageNotFound).arg(QString::fromLatin1("File not found"), header); + http.arg(pageNotFound).arg(QStringLiteral("File not found"), header); QByteArray res = httpResponseHeader.toLatin1(); return res; diff --git a/src/Gui/Placement.cpp b/src/Gui/Placement.cpp index 7f7cbf74a6..5e63bb3558 100644 --- a/src/Gui/Placement.cpp +++ b/src/Gui/Placement.cpp @@ -338,7 +338,7 @@ void PlacementHandler::applyPlacement(const App::DocumentObject* obj, const QStr QString PlacementHandler::getIncrementalPlacement(const App::DocumentObject* obj, const QString& data) const { - return QString::fromLatin1( + return QStringLiteral( R"(App.getDocument("%1").%2.%3=%4.multiply(App.getDocument("%1").%2.%3))") .arg(QString::fromLatin1(obj->getDocument()->getName()), QString::fromLatin1(obj->getNameInDocument()), @@ -348,7 +348,7 @@ QString PlacementHandler::getIncrementalPlacement(const App::DocumentObject* obj QString PlacementHandler::getSimplePlacement(const App::DocumentObject* obj, const QString& data) const { - return QString::fromLatin1( + return QStringLiteral( "App.getDocument(\"%1\").%2.%3=%4") .arg(QString::fromLatin1(obj->getDocument()->getName()), QString::fromLatin1(obj->getNameInDocument()), @@ -1036,7 +1036,7 @@ QString Placement::getPlacementFromEulerAngles() const Base::Vector3d pos = getPositionData(); Base::Vector3d ypr = getAnglesData(); Base::Vector3d cnt = getCenterData(); - return QString::fromLatin1( + return QStringLiteral( "App.Placement(App.Vector(%1,%2,%3), App.Rotation(%4,%5,%6), App.Vector(%7,%8,%9))") .arg(pos.x) .arg(pos.y) @@ -1055,7 +1055,7 @@ QString Placement::getPlacementFromAxisWithAngle() const Base::Vector3d cnt = getCenterData(); Base::Vector3d dir = getDirection(); double angle = ui->angle->value().getValue(); - return QString::fromLatin1( + return QStringLiteral( "App.Placement(App.Vector(%1,%2,%3), App.Rotation(App.Vector(%4,%5,%6),%7), App.Vector(%8,%9,%10))") .arg(pos.x) .arg(pos.y) diff --git a/src/Gui/PrefWidgets.cpp b/src/Gui/PrefWidgets.cpp index f22dc64dfe..abd41dda7c 100644 --- a/src/Gui/PrefWidgets.cpp +++ b/src/Gui/PrefWidgets.cpp @@ -709,7 +709,7 @@ void PrefQuantitySpinBox::contextMenuEvent(QContextMenuEvent *event) QMenu *editMenu = lineEdit()->createStandardContextMenu(); editMenu->setTitle(tr("Edit")); - std::unique_ptr menu(new QMenu(QString::fromLatin1("PrefQuantitySpinBox"))); + std::unique_ptr menu(new QMenu(QStringLiteral("PrefQuantitySpinBox"))); menu->addMenu(editMenu); menu->addSeparator(); diff --git a/src/Gui/PreferencePackManager.cpp b/src/Gui/PreferencePackManager.cpp index 45d471ff27..56581e9a4d 100644 --- a/src/Gui/PreferencePackManager.cpp +++ b/src/Gui/PreferencePackManager.cpp @@ -69,17 +69,17 @@ PreferencePack::PreferencePack(const fs::path& path, const App::Metadata& metada throw std::runtime_error{ "Cannot access " + path.string() }; } - auto qssPaths = QDir::searchPaths(QString::fromUtf8("qss")); - auto cssPaths = QDir::searchPaths(QString::fromUtf8("css")); - auto overlayPaths = QDir::searchPaths(QString::fromUtf8("overlay")); + auto qssPaths = QDir::searchPaths(QStringLiteral("qss")); + auto cssPaths = QDir::searchPaths(QStringLiteral("css")); + auto overlayPaths = QDir::searchPaths(QStringLiteral("overlay")); qssPaths.append(QString::fromStdString(Base::FileInfo::pathToString(_path))); cssPaths.append(QString::fromStdString(Base::FileInfo::pathToString(_path))); overlayPaths.append(QString::fromStdString(Base::FileInfo::pathToString(_path) + "/overlay")); - QDir::setSearchPaths(QString::fromUtf8("qss"), qssPaths); - QDir::setSearchPaths(QString::fromUtf8("css"), cssPaths); - QDir::setSearchPaths(QString::fromUtf8("overlay"), overlayPaths); + QDir::setSearchPaths(QStringLiteral("qss"), qssPaths); + QDir::setSearchPaths(QStringLiteral("css"), cssPaths); + QDir::setSearchPaths(QStringLiteral("overlay"), overlayPaths); } std::string PreferencePack::name() const diff --git a/src/Gui/PreferencePages/DlgSettingsCacheDirectory.cpp b/src/Gui/PreferencePages/DlgSettingsCacheDirectory.cpp index 0fb60854eb..0c395195e6 100644 --- a/src/Gui/PreferencePages/DlgSettingsCacheDirectory.cpp +++ b/src/Gui/PreferencePages/DlgSettingsCacheDirectory.cpp @@ -63,12 +63,12 @@ DlgSettingsCacheDirectory::DlgSettingsCacheDirectory(QWidget* parent) QString path = QString::fromStdString(App::Application::getUserCachePath()); ui->cacheLocation->setText(path); - ui->comboBoxLimit->addItem(QString::fromLatin1("100 MB"), 100); - ui->comboBoxLimit->addItem(QString::fromLatin1("300 MB"), 300); - ui->comboBoxLimit->addItem(QString::fromLatin1("500 MB"), 500); - ui->comboBoxLimit->addItem(QString::fromLatin1("1 GB"), 1024); - ui->comboBoxLimit->addItem(QString::fromLatin1("2 GB"), 2048); - ui->comboBoxLimit->addItem(QString::fromLatin1("3 GB"), 3072); + ui->comboBoxLimit->addItem(QStringLiteral("100 MB"), 100); + ui->comboBoxLimit->addItem(QStringLiteral("300 MB"), 300); + ui->comboBoxLimit->addItem(QStringLiteral("500 MB"), 500); + ui->comboBoxLimit->addItem(QStringLiteral("1 GB"), 1024); + ui->comboBoxLimit->addItem(QStringLiteral("2 GB"), 2048); + ui->comboBoxLimit->addItem(QStringLiteral("3 GB"), 3072); connect(ui->pushButtonCheck, &QPushButton::clicked, this, &DlgSettingsCacheDirectory::runCheck); connect(ui->openButton, &QPushButton::clicked, this, &DlgSettingsCacheDirectory::openDirectory); @@ -92,7 +92,7 @@ void DlgSettingsCacheDirectory::loadSettings() // if not found then add a new item with this value if (index < 0) { - ui->comboBoxLimit->addItem(QString::fromLatin1("%1 MB").arg(limit), limit); + ui->comboBoxLimit->addItem(QStringLiteral("%1 MB").arg(limit), limit); index = ui->comboBoxLimit->count() - 1; } ui->comboBoxLimit->setCurrentIndex(index); @@ -208,7 +208,7 @@ bool ApplicationCache::periodicCheckOfSize() const QString application = QString::fromStdString(App::Application::getExecutableName()); QSettings settings(vendor, application); - QString key = QString::fromLatin1("LastCacheCheck"); + QString key = QStringLiteral("LastCacheCheck"); QDate date = settings.value(key).toDate(); QDate now = QDate::currentDate(); @@ -245,7 +245,7 @@ bool ApplicationCache::performAction(qint64 total) QString warn = tr("Warning: Please make sure that this is the only running %1 instance " "and that no documents are opened as this may result into data loss!").arg(QCoreApplication::applicationName()); - msgBox.setText(QString::fromLatin1("%1 %2\n\n\n%3").arg(hint, ask, warn)); + msgBox.setText(QStringLiteral("%1 %2\n\n\n%3").arg(hint, ask, warn)); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No | QMessageBox::Open); msgBox.setDefaultButton(QMessageBox::No); @@ -286,7 +286,7 @@ void ApplicationCache::clearDirectory(const QString& path) { // Add the transient directories and the lock files to the ignore list QDir tmp = QString::fromUtf8(App::Application::getUserCachePath().c_str()); - tmp.setNameFilters(QStringList() << QString::fromLatin1("*.lock")); + tmp.setNameFilters(QStringList() << QStringLiteral("*.lock")); tmp.setFilter(QDir::Files); QList dirs; @@ -347,10 +347,10 @@ qint64 ApplicationCache::toBytes(unsigned int sizeInMB) QString ApplicationCache::toString(qint64 size) { - QStringList units = {QString::fromLatin1("Bytes"), - QString::fromLatin1("KB"), - QString::fromLatin1("MB"), - QString::fromLatin1("GB")}; + QStringList units = {QStringLiteral("Bytes"), + QStringLiteral("KB"), + QStringLiteral("MB"), + QStringLiteral("GB")}; int i; double outputSize = size; for (i=0; iprefSaveTransaction->hide(); ui->prefDiscardTransaction->hide(); - QString tip = QString::fromLatin1("

%1

" + QString tip = QStringLiteral("

%1

" "

%2: %Y%m%d-%H%M%S

" "

%3: C++ strftime" "

").arg(tr("The format of the date to use."), tr("Default"), tr("Format")); diff --git a/src/Gui/PreferencePages/DlgSettingsEditor.cpp b/src/Gui/PreferencePages/DlgSettingsEditor.cpp index 0dda987761..4ccde4fdab 100644 --- a/src/Gui/PreferencePages/DlgSettingsEditor.cpp +++ b/src/Gui/PreferencePages/DlgSettingsEditor.cpp @@ -253,7 +253,7 @@ void DlgSettingsEditor::loadSettings() ui->radioSpaces->onRestore(); setEditorTabWidth(ui->tabSize->value()); - ui->textEdit1->setPlainText(QString::fromLatin1("# Short Python sample\n" + ui->textEdit1->setPlainText(QStringLiteral("# Short Python sample\n" "import sys\n" "\n" "def foo(begin, end):\n" diff --git a/src/Gui/PreferencePages/DlgSettingsGeneral.cpp b/src/Gui/PreferencePages/DlgSettingsGeneral.cpp index e4f57f0e0d..48a0a25855 100644 --- a/src/Gui/PreferencePages/DlgSettingsGeneral.cpp +++ b/src/Gui/PreferencePages/DlgSettingsGeneral.cpp @@ -322,7 +322,7 @@ void DlgSettingsGeneral::loadSettings() int index = 1; TStringMap list = Translator::instance()->supportedLocales(); ui->Languages->clear(); - ui->Languages->addItem(QString::fromLatin1("English"), QByteArray("English")); + ui->Languages->addItem(QStringLiteral("English"), QByteArray("English")); for (auto it = list.begin(); it != list.end(); ++it, index++) { QByteArray lang = it->first.c_str(); QString langname = QString::fromLatin1(lang.constData()); @@ -739,7 +739,7 @@ void DlgSettingsGeneral::onImportConfigClicked() auto path = fs::path(QFileDialog::getOpenFileName(this, tr("Choose a FreeCAD config file to import"), QString(), - QString::fromUtf8("*.cfg")).toStdString()); + QStringLiteral("*.cfg")).toStdString()); if (!path.empty()) { // Create a name from the filename: auto packName = path.filename().stem().string(); diff --git a/src/Gui/PreferencePages/DlgSettingsLightSources.cpp b/src/Gui/PreferencePages/DlgSettingsLightSources.cpp index 563d203b1e..fd1701e92a 100644 --- a/src/Gui/PreferencePages/DlgSettingsLightSources.cpp +++ b/src/Gui/PreferencePages/DlgSettingsLightSources.cpp @@ -233,7 +233,7 @@ void DlgSettingsLightSources::saveDirection() if (lightDragger) { const SbRotation rotation = lightDragger->rotation.getValue(); const SbVec3f dir = getDirectionVector(rotation); - const QString headlightDir = QString::fromLatin1("(%1,%2,%3)").arg(dir[0]).arg(dir[1]).arg(dir[2]); + const QString headlightDir = QStringLiteral("(%1,%2,%3)").arg(dir[0]).arg(dir[1]).arg(dir[2]); ParameterGrp::handle grp = ui->sliderIntensity1->getWindowParameter(); diff --git a/src/Gui/PreferencePages/DlgSettingsNavigation.cpp b/src/Gui/PreferencePages/DlgSettingsNavigation.cpp index b1bb46d6ea..a1df77b0a8 100644 --- a/src/Gui/PreferencePages/DlgSettingsNavigation.cpp +++ b/src/Gui/PreferencePages/DlgSettingsNavigation.cpp @@ -285,21 +285,21 @@ void DlgSettingsNavigation::onMouseButtonClicked() ui->comboNavigationStyle->itemData(ui->comboNavigationStyle->currentIndex(), Qt::UserRole); void* instance = Base::Type::createInstanceByName((const char*)data.toByteArray()); std::unique_ptr ns(static_cast(instance)); - uimb.groupBox->setTitle(uimb.groupBox->title() + QString::fromLatin1(" ") + uimb.groupBox->setTitle(uimb.groupBox->title() + QStringLiteral(" ") + ui->comboNavigationStyle->currentText()); QString descr; descr = qApp->translate((const char*)data.toByteArray(),ns->mouseButtons(NavigationStyle::SELECTION)); descr.replace(QLatin1String("\n"), QLatin1String("

")); - uimb.selectionLabel->setText(QString::fromLatin1("%1").arg(descr)); + uimb.selectionLabel->setText(QStringLiteral("%1").arg(descr)); descr = qApp->translate((const char*)data.toByteArray(),ns->mouseButtons(NavigationStyle::PANNING)); descr.replace(QLatin1String("\n"), QLatin1String("

")); - uimb.panningLabel->setText(QString::fromLatin1("%1").arg(descr)); + uimb.panningLabel->setText(QStringLiteral("%1").arg(descr)); descr = qApp->translate((const char*)data.toByteArray(),ns->mouseButtons(NavigationStyle::DRAGGING)); descr.replace(QLatin1String("\n"), QLatin1String("

")); - uimb.rotationLabel->setText(QString::fromLatin1("%1").arg(descr)); + uimb.rotationLabel->setText(QStringLiteral("%1").arg(descr)); descr = qApp->translate((const char*)data.toByteArray(),ns->mouseButtons(NavigationStyle::ZOOMING)); descr.replace(QLatin1String("\n"), QLatin1String("

")); - uimb.zoomingLabel->setText(QString::fromLatin1("%1").arg(descr)); + uimb.zoomingLabel->setText(QStringLiteral("%1").arg(descr)); dlg.exec(); } @@ -416,7 +416,7 @@ CameraDialog::CameraDialog(QWidget* parent) auto currentViewButton = new QPushButton(this); currentViewButton->setText(tr("Current view")); - currentViewButton->setObjectName(QString::fromLatin1("currentView")); + currentViewButton->setObjectName(QStringLiteral("currentView")); layout->addWidget(currentViewButton, 4, 1, 2, 1); connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept); diff --git a/src/Gui/PreferencePages/DlgSettingsWorkbenchesImp.cpp b/src/Gui/PreferencePages/DlgSettingsWorkbenchesImp.cpp index b91c19a614..99b15a0659 100644 --- a/src/Gui/PreferencePages/DlgSettingsWorkbenchesImp.cpp +++ b/src/Gui/PreferencePages/DlgSettingsWorkbenchesImp.cpp @@ -111,7 +111,7 @@ wbListItem::wbListItem(const QString& wbName, bool enabled, bool startupWb, bool textLabel->setEnabled(enableCheckBox->isChecked()); // 4: shortcut - shortcutLabel = new QLabel(QString::fromLatin1("(W, %1)").arg(index + 1), this); + shortcutLabel = new QLabel(QStringLiteral("(W, %1)").arg(index + 1), this); shortcutLabel->setToolTip(tr("Shortcut to activate this workbench.")); shortcutLabel->setEnabled(enableCheckBox->isChecked()); shortcutLabel->setVisible(index < 9); @@ -188,7 +188,7 @@ void wbListItem::setStartupWb(bool val) void wbListItem::setShortcutLabel(int index) { - shortcutLabel->setText(QString::fromLatin1("(W, %1)").arg(index + 1)); + shortcutLabel->setText(QStringLiteral("(W, %1)").arg(index + 1)); shortcutLabel->setVisible(index < 9); } @@ -593,9 +593,9 @@ void DlgSettingsWorkbenchesImp::setStartWorkbenchComboItems() } { // add special workbench to selection - QPixmap px = Application::Instance->workbenchIcon(QString::fromLatin1("NoneWorkbench")); - QString key = QString::fromLatin1(""); - QString value = QString::fromLatin1("$LastModule"); + QPixmap px = Application::Instance->workbenchIcon(QStringLiteral("NoneWorkbench")); + QString key = QStringLiteral(""); + QString value = QStringLiteral("$LastModule"); if (px.isNull()) { ui->AutoloadModuleCombo->addItem(key, QVariant(value)); } diff --git a/src/Gui/ProgressBar.cpp b/src/Gui/ProgressBar.cpp index d8e5897756..cffff2082e 100644 --- a/src/Gui/ProgressBar.cpp +++ b/src/Gui/ProgressBar.cpp @@ -295,7 +295,7 @@ void SequencerBar::showRemainingTime() QTime time( 0,0, 0); time = time.addSecs( rest/1000 ); QString remain = Gui::ProgressBar::tr("Remaining: %1").arg(time.toString()); - QString status = QString::fromLatin1("%1\t[%2]").arg(txt, remain); + QString status = QStringLiteral("%1\t[%2]").arg(txt, remain); if (thr != currentThread) { QMetaObject::invokeMethod(getMainWindow(), "showMessage", diff --git a/src/Gui/ProgressDialog.cpp b/src/Gui/ProgressDialog.cpp index 3f596d62ab..90f531fb92 100644 --- a/src/Gui/ProgressDialog.cpp +++ b/src/Gui/ProgressDialog.cpp @@ -217,7 +217,7 @@ void SequencerDialog::showRemainingTime() QTime time( 0,0, 0); time = time.addSecs( rest/1000 ); QString remain = Gui::ProgressDialog::tr("Remaining: %1").arg(time.toString()); - QString status = QString::fromLatin1("%1\t[%2]").arg(txt, remain); + QString status = QStringLiteral("%1\t[%2]").arg(txt, remain); if (thr != currentThread) { QMetaObject::invokeMethod(d->dlg, "setLabelText", diff --git a/src/Gui/PropertyView.cpp b/src/Gui/PropertyView.cpp index ee33bd8ca7..9f1094243e 100644 --- a/src/Gui/PropertyView.cpp +++ b/src/Gui/PropertyView.cpp @@ -79,7 +79,7 @@ PropertyView::PropertyView(QWidget *parent) connect(timer, &QTimer::timeout, this, &PropertyView::onTimer); tabs = new QTabWidget (this); - tabs->setObjectName(QString::fromUtf8("propertyTab")); + tabs->setObjectName(QStringLiteral("propertyTab")); tabs->setTabPosition(QTabWidget::South); pLayout->addWidget(tabs, 0, 0); diff --git a/src/Gui/PythonConsole.cpp b/src/Gui/PythonConsole.cpp index f6b566c5a4..bed38eb94f 100644 --- a/src/Gui/PythonConsole.cpp +++ b/src/Gui/PythonConsole.cpp @@ -468,7 +468,7 @@ PythonConsole::PythonConsole(QWidget *parent) const char* version = PyUnicode_AsUTF8(PySys_GetObject("version")); const char* platform = PyUnicode_AsUTF8(PySys_GetObject("platform")); - d->info = QString::fromLatin1("Python %1 on %2\n" + d->info = QStringLiteral("Python %1 on %2\n" "Type 'help', 'copyright', 'credits' or 'license' for more information.") .arg(QString::fromLatin1(version), QString::fromLatin1(platform)); d->output = d->info; @@ -609,7 +609,7 @@ void PythonConsole::keyPressEvent(QKeyEvent * e) if (!inputStrg.isEmpty()) { d->history.append( QLatin1String("# ") + inputStrg ); //< put commented string to history ... - inputLineBegin.insertText( QString::fromLatin1("# ") ); //< and comment it on console + inputLineBegin.insertText( QStringLiteral("# ") ); //< and comment it on console setTextCursor( inputLineBegin ); printPrompt(d->interpreter->hasPendingInput() //< print adequate prompt ? PythonConsole::Incomplete @@ -753,10 +753,10 @@ void PythonConsole::printPrompt(PythonConsole::Prompt mode) switch (mode) { case PythonConsole::Incomplete: - cursor.insertText(QString::fromLatin1("... ")); + cursor.insertText(QStringLiteral("... ")); break; case PythonConsole::Complete: - cursor.insertText(QString::fromLatin1(">>> ")); + cursor.insertText(QStringLiteral(">>> ")); break; default: break; @@ -806,7 +806,7 @@ void PythonConsole::runSource(const QString& line) } if (d->interpreter->isOccupied()) { - insertPythonError(QString::fromLatin1("Previous command still running!")); + insertPythonError(QStringLiteral("Previous command still running!")); return; } @@ -1000,7 +1000,7 @@ void PythonConsole::dropEvent (QDropEvent * e) for (int i=0; i> action; - printStatement(QString::fromLatin1("Gui.runCommand(\"%1\")").arg(action)); + printStatement(QStringLiteral("Gui.runCommand(\"%1\")").arg(action)); } e->setDropAction(Qt::CopyAction); @@ -1305,7 +1305,7 @@ void PythonConsole::contextMenuEvent ( QContextMenuEvent * e ) bool mayPasteHere = cursorBeyond( this->textCursor(), this->inputBegin() ); a = menu.addAction(tr("&Copy"), this, &PythonConsole::copy); - a->setShortcut(QKeySequence(QString::fromLatin1("CTRL+C"))); + a->setShortcut(QKeySequence(QStringLiteral("CTRL+C"))); a->setEnabled(textCursor().hasSelection()); a = menu.addAction(tr("&Copy command"), this, &PythonConsole::onCopyCommand); @@ -1325,12 +1325,12 @@ void PythonConsole::contextMenuEvent ( QContextMenuEvent * e ) menu.addSeparator(); a = menu.addAction(tr("&Paste"), this, &PythonConsole::paste); - a->setShortcut(QKeySequence(QString::fromLatin1("CTRL+V"))); + a->setShortcut(QKeySequence(QStringLiteral("CTRL+V"))); const QMimeData *md = QApplication::clipboard()->mimeData(); a->setEnabled( mayPasteHere && md && canInsertFromMimeData(md)); a = menu.addAction(tr("Select All"), this, &PythonConsole::selectAll); - a->setShortcut(QKeySequence(QString::fromLatin1("CTRL+A"))); + a->setShortcut(QKeySequence(QStringLiteral("CTRL+A"))); a->setEnabled(!document()->isEmpty()); a = menu.addAction(tr("Clear console"), this, &PythonConsole::onClearConsole); @@ -1365,7 +1365,7 @@ void PythonConsole::onSaveHistoryAs() QString cMacroPath = QString::fromUtf8(getDefaultParameter()->GetGroup( "Macro" )-> GetASCII("MacroPath",App::Application::getUserMacroDir().c_str()).c_str()); QString fn = FileDialog::getSaveFileName(this, tr("Save History"), cMacroPath, - QString::fromLatin1("%1 (*.FCMacro *.py)").arg(tr("Macro Files"))); + QStringLiteral("%1 (*.FCMacro *.py)").arg(tr("Macro Files"))); if (!fn.isEmpty()) { int dot = fn.indexOf(QLatin1Char('.')); if (dot != -1) { @@ -1385,7 +1385,7 @@ void PythonConsole::onSaveHistoryAs() void PythonConsole::onInsertFileName() { QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), tr("Insert file name"), QString(), - QString::fromLatin1("%1 (*.*)").arg(tr("All Files"))); + QStringLiteral("%1 (*.*)").arg(tr("All Files"))); if ( !fn.isEmpty() ) { insertPlainText(fn); } diff --git a/src/Gui/PythonEditor.cpp b/src/Gui/PythonEditor.cpp index 3da59a5ce9..02251ec59f 100644 --- a/src/Gui/PythonEditor.cpp +++ b/src/Gui/PythonEditor.cpp @@ -74,13 +74,13 @@ PythonEditor::PythonEditor(QWidget* parent) // set accelerators auto comment = new QShortcut(this); - comment->setKey(QKeySequence(QString::fromLatin1("ALT+C"))); + comment->setKey(QKeySequence(QStringLiteral("ALT+C"))); auto uncomment = new QShortcut(this); - uncomment->setKey(QKeySequence(QString::fromLatin1("ALT+U"))); + uncomment->setKey(QKeySequence(QStringLiteral("ALT+U"))); auto execInConsole = new QShortcut(this); - execInConsole->setKey(QKeySequence(QString::fromLatin1("ALT+SHIFT+P"))); + execInConsole->setKey(QKeySequence(QStringLiteral("ALT+SHIFT+P"))); connect(comment, &QShortcut::activated, this, &PythonEditor::onComment); connect(uncomment, &QShortcut::activated, this, &PythonEditor::onUncomment); @@ -175,12 +175,12 @@ void PythonEditor::contextMenuEvent ( QContextMenuEvent * e ) if (!isReadOnly()) { menu->addSeparator(); QAction* comment = menu->addAction( tr("Comment"), this, &PythonEditor::onComment); - comment->setShortcut(QKeySequence(QString::fromLatin1("ALT+C"))); + comment->setShortcut(QKeySequence(QStringLiteral("ALT+C"))); QAction* uncomment = menu->addAction( tr("Uncomment"), this, &PythonEditor::onUncomment); - uncomment->setShortcut(QKeySequence(QString::fromLatin1("ALT+U"))); + uncomment->setShortcut(QKeySequence(QStringLiteral("ALT+U"))); QAction* execInConsole = menu->addAction( tr("Execute in console"), this, &PythonEditor::onExecuteInConsole); - execInConsole->setShortcut(QKeySequence(QString::fromLatin1("ALT+Shift+P"))); + execInConsole->setShortcut(QKeySequence(QStringLiteral("ALT+Shift+P"))); } menu->exec(e->globalPos()); @@ -199,8 +199,8 @@ void PythonEditor::keyPressEvent(QKeyEvent* e) ParameterGrp::handle hPrefGrp = getWindowParameter(); int indent = hPrefGrp->GetInt( "IndentSize", 4 ); bool space = hPrefGrp->GetBool( "Spaces", true ); - QString ch = space ? QString::fromLatin1(" ") - : QString::fromLatin1("\t"); + QString ch = space ? QStringLiteral(" ") + : QStringLiteral("\t"); QTextCursor cursor = textCursor(); QString currentLineText = cursor.block().text(); diff --git a/src/Gui/QSint/actionpanel/actionlabel.cpp b/src/Gui/QSint/actionpanel/actionlabel.cpp index 7b1e60d951..e2e893fd47 100644 --- a/src/Gui/QSint/actionpanel/actionlabel.cpp +++ b/src/Gui/QSint/actionpanel/actionlabel.cpp @@ -85,7 +85,7 @@ QSize ActionLabel::sizeHint() const QString s(text()); bool empty = s.isEmpty(); if (empty) - s = QString::fromLatin1("XXXX"); + s = QStringLiteral("XXXX"); QFontMetrics fm = fontMetrics(); QSize sz = fm.size(Qt::TextShowMnemonic, s); w += sz.width(); diff --git a/src/Gui/QSint/actionpanel/freecadscheme.cpp b/src/Gui/QSint/actionpanel/freecadscheme.cpp index 74a3db76c8..3c22f30de8 100644 --- a/src/Gui/QSint/actionpanel/freecadscheme.cpp +++ b/src/Gui/QSint/actionpanel/freecadscheme.cpp @@ -271,7 +271,7 @@ QString SystemPanelScheme::systemStyle(const QPalette& p) const QColor actionSelectedText = p.color(QPalette::Active, QPalette::ButtonText); QColor actionSelectedBorder = p.color(QPalette::Active, QPalette::Highlight); - QString style = QString::fromLatin1( + QString style = QStringLiteral( "QSint--ActionGroup QFrame[class='header'] {" "border: 1px solid transparent;" "background-color: %1;" diff --git a/src/Gui/QuantitySpinBox.cpp b/src/Gui/QuantitySpinBox.cpp index e881db68a2..63383a1fb4 100644 --- a/src/Gui/QuantitySpinBox.cpp +++ b/src/Gui/QuantitySpinBox.cpp @@ -173,7 +173,7 @@ public: //Prep for expression parser //This regex matches chunks between +,-,$,^ accounting for matching parenthesis. - QRegularExpression chunkRe(QString::fromUtf8("(?<=^|[\\+\\-])((\\((?>[^()]|(?2))*\\))|[^\\+\\-\n])*(?=$|[\\+\\-])")); + QRegularExpression chunkRe(QStringLiteral("(?<=^|[\\+\\-])((\\((?>[^()]|(?2))*\\))|[^\\+\\-\n])*(?=$|[\\+\\-])")); QRegularExpressionMatchIterator expressionChunk = chunkRe.globalMatch(copy); unsigned int lengthOffset = 0; while (expressionChunk.hasNext()) { @@ -198,7 +198,7 @@ public: if (fixUnitsMatch.lastCapturedIndex() == 2 || (fixUnitsMatch.lastCapturedIndex() == 3 && fixUnitsMatch.captured(3).isEmpty())){ QString matchUnits = fixUnitsMatch.captured(1); QString matchNumbers = fixUnitsMatch.captured(2); - copyChunk.replace(matchUnits+matchNumbers, QString::fromUtf8(")")+matchUnits+QString::fromUtf8("1(*")+matchNumbers); + copyChunk.replace(matchUnits+matchNumbers, QStringLiteral(")")+matchUnits+QStringLiteral("1(*")+matchNumbers); } } @@ -208,7 +208,7 @@ public: QRegularExpressionMatch match = unitsRe.match(copyChunk); if (!match.hasMatch() && !copyChunk.isEmpty()) //If no units are found, use default units - copyChunk.prepend(QString::fromUtf8(")")+reverseUnitStr+QString::fromUtf8("1(*")); // Add units to the end of chunk *(1unit) + copyChunk.prepend(QStringLiteral(")")+reverseUnitStr+QStringLiteral("1(*")); // Add units to the end of chunk *(1unit) } std::reverse(copyChunk.begin(), copyChunk.end()); @@ -923,7 +923,7 @@ void QuantitySpinBox::clear() void QuantitySpinBox::selectNumber() { - QString expr = QString::fromLatin1("^([%1%2]?[0-9\\%3]*)\\%4?([0-9]+(%5[%1%2]?[0-9]+)?)") + QString expr = QStringLiteral("^([%1%2]?[0-9\\%3]*)\\%4?([0-9]+(%5[%1%2]?[0-9]+)?)") .arg(locale().negativeSign()) .arg(locale().positiveSign()) .arg(locale().groupSeparator()) diff --git a/src/Gui/ReportView.cpp b/src/Gui/ReportView.cpp index d81540f79b..7a61bb5933 100644 --- a/src/Gui/ReportView.cpp +++ b/src/Gui/ReportView.cpp @@ -64,7 +64,7 @@ ReportView::ReportView( QWidget* parent ) tabLayout->setContentsMargins( 0, 0, 0, 0 ); tabWidget = new QTabWidget( this ); - tabWidget->setObjectName(QString::fromUtf8("tabWidget")); + tabWidget->setObjectName(QStringLiteral("tabWidget")); tabWidget->setTabPosition(QTabWidget::South); tabWidget->setTabShape(QTabWidget::Rounded); tabLayout->addWidget( tabWidget, 0, 0 ); @@ -511,7 +511,7 @@ void ReportOutput::SendLog(const std::string& notifiername, const std::string& m if (style == ReportHighlighter::LogText) { if (messageSize > 0 && qMsg.size()>messageSize) { qMsg.truncate(messageSize); - qMsg += QString::fromLatin1("...\n"); + qMsg += QStringLiteral("...\n"); } } @@ -658,7 +658,7 @@ void ReportOutput::contextMenuEvent ( QContextMenuEvent * e ) QAction* copy = menu->addAction(copyStr, this, &ReportOutput::copy); copy->setShortcut(QKeySequence(QKeySequence::Copy)); copy->setEnabled(textCursor().hasSelection()); - QIcon icon = QIcon::fromTheme(QString::fromLatin1("edit-copy")); + QIcon icon = QIcon::fromTheme(QStringLiteral("edit-copy")); if (!icon.isNull()) copy->setIcon(icon); @@ -678,7 +678,7 @@ void ReportOutput::contextMenuEvent ( QContextMenuEvent * e ) void ReportOutput::onSaveAs() { QString fn = QFileDialog::getSaveFileName(this, tr("Save Report Output"), QString(), - QString::fromLatin1("%1 (*.txt *.log)").arg(tr("Plain Text Files"))); + QStringLiteral("%1 (*.txt *.log)").arg(tr("Plain Text Files"))); if (!fn.isEmpty()) { QFileInfo fi(fn); if (fi.completeSuffix().isEmpty()) diff --git a/src/Gui/Selection/Selection.cpp b/src/Gui/Selection/Selection.cpp index bef006fd72..b8fdab737e 100644 --- a/src/Gui/Selection/Selection.cpp +++ b/src/Gui/Selection/Selection.cpp @@ -637,7 +637,7 @@ int SelectionSingleton::setPreselect(const char* pDocName, const char* pObjectNa } else { msg = QCoreApplication::translate("SelectionFilter","Not allowed:"); } - msg.append(QString::fromLatin1(" %1.%2.%3 ") + msg.append(QStringLiteral(" %1.%2.%3 ") .arg(QString::fromLatin1(pDocName), QString::fromLatin1(pObjectName), QString::fromLatin1(pSubName))); diff --git a/src/Gui/Selection/SelectionView.cpp b/src/Gui/Selection/SelectionView.cpp index 3e705a2491..469f8d0f72 100644 --- a/src/Gui/Selection/SelectionView.cpp +++ b/src/Gui/Selection/SelectionView.cpp @@ -74,12 +74,12 @@ SelectionView::SelectionView(Gui::Document* pcDocument, QWidget* parent) QToolButton* clearButton = new QToolButton(this); clearButton->setFixedSize(18, 21); clearButton->setCursor(Qt::ArrowCursor); - clearButton->setStyleSheet(QString::fromUtf8("QToolButton {margin-bottom:1px}")); + clearButton->setStyleSheet(QStringLiteral("QToolButton {margin-bottom:1px}")); clearButton->setIcon(BitmapFactory().pixmap(":/icons/edit-cleartext.svg")); clearButton->setToolTip(tr("Clears the search field")); clearButton->setAutoRaise(true); countLabel = new QLabel(this); - countLabel->setText(QString::fromUtf8("0")); + countLabel->setText(QStringLiteral("0")); countLabel->setToolTip(tr("The number of selected items")); hLayout->addWidget(searchBox); hLayout->addWidget(clearButton, 0, Qt::AlignRight); @@ -337,7 +337,7 @@ void SelectionView::select(QListWidgetItem* item) // Gui::Selection().clearSelection(); Gui::Command::runCommand(Gui::Command::Gui, "Gui.Selection.clearSelection()"); // Gui::Selection().addSelection(elements[0].toLatin1(),elements[1].toLatin1(),0); - QString cmd = QString::fromLatin1( + QString cmd = QStringLiteral( R"(Gui.Selection.addSelection(App.getDocument("%1").getObject("%2")))") .arg(elements[0], elements[1]); Gui::Command::runCommand(Gui::Command::Gui, cmd.toLatin1()); @@ -359,7 +359,7 @@ void SelectionView::deselect() } // Gui::Selection().rmvSelection(elements[0].toLatin1(),elements[1].toLatin1(),0); - QString cmd = QString::fromLatin1( + QString cmd = QStringLiteral( R"(Gui.Selection.removeSelection(App.getDocument("%1").getObject("%2")))") .arg(elements[0], elements[1]); try { @@ -398,14 +398,14 @@ void SelectionView::toggleSelect(QListWidgetItem* item) } QString cmd; if (Gui::Selection().isSelected(docname, objname, subname)) { - cmd = QString::fromLatin1("Gui.Selection.removeSelection(" + cmd = QStringLiteral("Gui.Selection.removeSelection(" "App.getDocument('%1').getObject('%2'),'%3')") .arg(QString::fromLatin1(docname), QString::fromLatin1(objname), QString::fromLatin1(subname)); } else { - cmd = QString::fromLatin1("Gui.Selection.addSelection(" + cmd = QStringLiteral("Gui.Selection.addSelection(" "App.getDocument('%1').getObject('%2'),'%3',%4,%5,%6)") .arg(QString::fromLatin1(docname), QString::fromLatin1(objname), @@ -448,7 +448,7 @@ void SelectionView::preselect(QListWidgetItem* item) *end = 0; } } - QString cmd = QString::fromLatin1("Gui.Selection.setPreselection(" + QString cmd = QStringLiteral("Gui.Selection.setPreselection(" "App.getDocument('%1').getObject('%2'),'%3',tp=2)") .arg(QString::fromLatin1(docname), QString::fromLatin1(objname), @@ -493,7 +493,7 @@ void SelectionView::touch() if (elements.size() < 2) { return; } - QString cmd = QString::fromLatin1(R"(App.getDocument("%1").getObject("%2").touch())") + QString cmd = QStringLiteral(R"(App.getDocument("%1").getObject("%2").touch())") .arg(elements[0], elements[1]); try { Gui::Command::runCommand(Gui::Command::Doc, cmd.toLatin1()); @@ -515,7 +515,7 @@ void SelectionView::toPython() } try { - QString cmd = QString::fromLatin1(R"(obj = App.getDocument("%1").getObject("%2"))") + QString cmd = QStringLiteral(R"(obj = App.getDocument("%1").getObject("%2"))") .arg(elements[0], elements[1]); Gui::Command::runCommand(Gui::Command::Gui, cmd.toLatin1()); if (elements.length() > 2) { @@ -523,12 +523,12 @@ void SelectionView::toPython() App::DocumentObject* obj = doc->getObject(elements[1].toLatin1()); QString property = getProperty(obj); - cmd = QString::fromLatin1(R"(shp = App.getDocument("%1").getObject("%2").%3)") + cmd = QStringLiteral(R"(shp = App.getDocument("%1").getObject("%2").%3)") .arg(elements[0], elements[1], property); Gui::Command::runCommand(Gui::Command::Gui, cmd.toLatin1()); if (supportPart(obj, elements[2])) { - cmd = QString::fromLatin1(R"(elt = App.getDocument("%1").getObject("%2").%3.%4)") + cmd = QStringLiteral(R"(elt = App.getDocument("%1").getObject("%2").%3.%4)") .arg(elements[0], elements[1], property, elements[2]); Gui::Command::runCommand(Gui::Command::Gui, cmd.toLatin1()); } @@ -555,7 +555,7 @@ void SelectionView::showPart() try { Gui::Command::addModule(Gui::Command::Gui, module.toLatin1()); QString cmd = - QString::fromLatin1(R"(%1.show(App.getDocument("%2").getObject("%3").%4.%5))") + QStringLiteral(R"(%1.show(App.getDocument("%2").getObject("%3").%4.%5))") .arg(module, elements[0], elements[1], property, elements[2]); Gui::Command::runCommand(Gui::Command::Gui, cmd.toLatin1()); } @@ -637,27 +637,27 @@ void SelectionView::onItemContextMenu(const QPoint& point) QAction* selectAction = menu.addAction(tr("Select only"), this, [&] { this->select(nullptr); }); - selectAction->setIcon(QIcon::fromTheme(QString::fromLatin1("view-select"))); + selectAction->setIcon(QIcon::fromTheme(QStringLiteral("view-select"))); selectAction->setToolTip(tr("Selects only this object")); QAction* deselectAction = menu.addAction(tr("Deselect"), this, &SelectionView::deselect); - deselectAction->setIcon(QIcon::fromTheme(QString::fromLatin1("view-unselectable"))); + deselectAction->setIcon(QIcon::fromTheme(QStringLiteral("view-unselectable"))); deselectAction->setToolTip(tr("Deselects this object")); QAction* zoomAction = menu.addAction(tr("Zoom fit"), this, &SelectionView::zoom); - zoomAction->setIcon(QIcon::fromTheme(QString::fromLatin1("zoom-fit-best"))); + zoomAction->setIcon(QIcon::fromTheme(QStringLiteral("zoom-fit-best"))); zoomAction->setToolTip(tr("Selects and fits this object in the 3D window")); QAction* gotoAction = menu.addAction(tr("Go to selection"), this, &SelectionView::treeSelect); gotoAction->setToolTip(tr("Selects and locates this object in the tree view")); QAction* touchAction = menu.addAction(tr("Mark to recompute"), this, &SelectionView::touch); - touchAction->setIcon(QIcon::fromTheme(QString::fromLatin1("view-refresh"))); + touchAction->setIcon(QIcon::fromTheme(QStringLiteral("view-refresh"))); touchAction->setToolTip(tr("Mark this object to be recomputed")); QAction* toPythonAction = menu.addAction(tr("To Python console"), this, &SelectionView::toPython); - toPythonAction->setIcon(QIcon::fromTheme(QString::fromLatin1("applications-python"))); + toPythonAction->setIcon(QIcon::fromTheme(QStringLiteral("applications-python"))); toPythonAction->setToolTip( tr("Reveals this object and its subelements in the Python console.")); @@ -666,7 +666,7 @@ void SelectionView::onItemContextMenu(const QPoint& point) // subshape-specific entries QAction* showPart = menu.addAction(tr("Duplicate subshape"), this, &SelectionView::showPart); - showPart->setIcon(QIcon(QString::fromLatin1(":/icons/ClassBrowser/member.svg"))); + showPart->setIcon(QIcon(QStringLiteral(":/icons/ClassBrowser/member.svg"))); showPart->setToolTip(tr("Creates a standalone copy of this subshape in the document")); } menu.exec(selectionView->mapToGlobal(point)); diff --git a/src/Gui/SoFCCSysDragger.cpp b/src/Gui/SoFCCSysDragger.cpp index 3d4ad6b650..39130d3b9e 100644 --- a/src/Gui/SoFCCSysDragger.cpp +++ b/src/Gui/SoFCCSysDragger.cpp @@ -357,7 +357,7 @@ void TDragger::drag() Base::Unit::Length); QString message = - QString::fromLatin1("%1 %2").arg(QObject::tr("Translation:"), QString::fromStdString(quantity.getUserString())); + QStringLiteral("%1 %2").arg(QObject::tr("Translation:"), QString::fromStdString(quantity.getUserString())); getMainWindow()->showMessage(message, 3000); } @@ -642,7 +642,7 @@ void TPlanarDragger::drag() * translationIncrement.getValue(), Base::Unit::Length); - QString message = QString::fromLatin1("%1 %2, %3") + QString message = QStringLiteral("%1 %2, %3") .arg(QObject::tr("Translation XY:"), QString::fromStdString(quantityX.getUserString()), QString::fromStdString(quantityY.getUserString())); @@ -970,7 +970,7 @@ void RDragger::drag() Base::Unit::Angle); QString message = - QString::fromLatin1("%1 %2").arg(QObject::tr("Rotation:"), QString::fromStdString(quantity.getUserString())); + QStringLiteral("%1 %2").arg(QObject::tr("Rotation:"), QString::fromStdString(quantity.getUserString())); getMainWindow()->showMessage(message, 3000); } diff --git a/src/Gui/SpinBox.cpp b/src/Gui/SpinBox.cpp index df16236b5d..cd11ec052c 100644 --- a/src/Gui/SpinBox.cpp +++ b/src/Gui/SpinBox.cpp @@ -68,7 +68,7 @@ void ExpressionSpinBox::bind(const App::ObjectIdentifier &_path) void ExpressionSpinBox::showIcon() { int frameWidth = spinbox->style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth); - lineedit->setStyleSheet(QString::fromLatin1("QLineEdit { padding-right: %1px } ").arg(iconLabel->sizeHint().width() + frameWidth + 1)); + lineedit->setStyleSheet(QStringLiteral("QLineEdit { padding-right: %1px } ").arg(iconLabel->sizeHint().width() + frameWidth + 1)); iconLabel->show(); } diff --git a/src/Gui/SplashScreen.cpp b/src/Gui/SplashScreen.cpp index 74f6768048..92bac0563c 100644 --- a/src/Gui/SplashScreen.cpp +++ b/src/Gui/SplashScreen.cpp @@ -260,7 +260,7 @@ QPixmap SplashScreen::splashImage() { // search in the UserAppData dir as very first QPixmap splash_image; - QFileInfo fi(QString::fromLatin1("images:splash_image.png")); + QFileInfo fi(QStringLiteral("images:splash_image.png")); if (fi.isFile() && fi.exists()) { splash_image.load(fi.filePath(), "PNG"); } @@ -316,7 +316,7 @@ QPixmap SplashScreen::splashImage() QString minor = QString::fromStdString(App::Application::Config()["BuildVersionMinor"]); QString point = QString::fromStdString(App::Application::Config()["BuildVersionPoint"]); QString suffix = QString::fromStdString(App::Application::Config()["BuildVersionSuffix"]); - QString version = QString::fromLatin1("%1.%2.%3%4").arg(major, minor, point, suffix); + QString version = QStringLiteral("%1.%2.%3%4").arg(major, minor, point, suffix); QString position, fontFamily; std::map::const_iterator te = diff --git a/src/Gui/StartupProcess.cpp b/src/Gui/StartupProcess.cpp index e992c2d37c..3d7141cbe3 100644 --- a/src/Gui/StartupProcess.cpp +++ b/src/Gui/StartupProcess.cpp @@ -135,7 +135,7 @@ void StartupProcess::setStyleSheetPaths() (App::Application::getUserAppDataDir() + "Gui/Stylesheets/").c_str()) << QString::fromUtf8((App::Application::getResourceDir() + "Gui/Stylesheets/").c_str()) << QLatin1String(":/stylesheets"); - QDir::setSearchPaths(QString::fromLatin1("qss"), qssPaths); + QDir::setSearchPaths(QStringLiteral("qss"), qssPaths); // setup the search paths for Qt overlay style sheets QStringList qssOverlayPaths; qssOverlayPaths << QString::fromUtf8((App::Application::getUserAppDataDir() @@ -152,7 +152,7 @@ void StartupProcess::setImagePaths() imagePaths << QString::fromUtf8((App::Application::getUserAppDataDir() + "Gui/images").c_str()) << QString::fromUtf8((App::Application::getUserAppDataDir() + "pixmaps").c_str()) << QLatin1String(":/icons"); - QDir::setSearchPaths(QString::fromLatin1("images"), imagePaths); + QDir::setSearchPaths(QStringLiteral("images"), imagePaths); } void StartupProcess::registerEventType() @@ -165,7 +165,7 @@ void StartupProcess::setThemePaths() { #if !defined(Q_OS_LINUX) QIcon::setThemeSearchPaths(QIcon::themeSearchPaths() - << QString::fromLatin1(":/icons/FreeCAD-default")); + << QStringLiteral(":/icons/FreeCAD-default")); #endif ParameterGrp::handle hTheme = App::GetApplication().GetParameterGroupByPath( diff --git a/src/Gui/TextDocumentEditorView.cpp b/src/Gui/TextDocumentEditorView.cpp index ef859f6a76..c9b40768e4 100644 --- a/src/Gui/TextDocumentEditorView.cpp +++ b/src/Gui/TextDocumentEditorView.cpp @@ -115,7 +115,7 @@ void TextDocumentEditorView::textChanged() void TextDocumentEditorView::labelChanged() { - setWindowTitle(QString::fromUtf8(textDocument->Label.getValue()) + QString::fromLatin1("[*]")); + setWindowTitle(QString::fromUtf8(textDocument->Label.getValue()) + QStringLiteral("[*]")); } void TextDocumentEditorView::refresh() diff --git a/src/Gui/TextEdit.cpp b/src/Gui/TextEdit.cpp index 5e19327e10..68ae0efd99 100644 --- a/src/Gui/TextEdit.cpp +++ b/src/Gui/TextEdit.cpp @@ -60,7 +60,7 @@ TextEdit::TextEdit(QWidget* parent) //Note: Set the correct context to this shortcut as we may use several instances of this //class at a time auto shortcut = new QShortcut(this); - shortcut->setKey(QKeySequence(QString::fromLatin1("CTRL+Space"))); + shortcut->setKey(QKeySequence(QStringLiteral("CTRL+Space"))); shortcut->setContext(Qt::WidgetShortcut); connect(shortcut, &QShortcut::activated, this, &TextEdit::complete); @@ -502,7 +502,7 @@ void PythonTextEditor::keyPressEvent (QKeyEvent * e) bool space = hPrefGrp->GetBool("Spaces", true); int indent = hPrefGrp->GetInt( "IndentSize", 4 ); QString ch = space ? QString(indent, QLatin1Char(' ')) - : QString::fromLatin1("\t"); + : QStringLiteral("\t"); QTextCursor cursor = textCursor(); if (!cursor.hasSelection()) { diff --git a/src/Gui/TextureMapping.cpp b/src/Gui/TextureMapping.cpp index eefaeaa0a7..72a5e565dd 100644 --- a/src/Gui/TextureMapping.cpp +++ b/src/Gui/TextureMapping.cpp @@ -65,7 +65,7 @@ TextureMapping::TextureMapping(QWidget* parent, Qt::WindowFlags fl) QStringList formats; QList qtformats = QImageReader::supportedImageFormats(); for (const auto & it : qtformats) { - formats << QString::fromLatin1("*.%1").arg(QLatin1String(it)); + formats << QStringLiteral("*.%1").arg(QLatin1String(it)); } ui->fileChooser->setFilter(tr("Image files (%1)").arg(formats.join(QLatin1String(" ")))); diff --git a/src/Gui/Thumbnail.cpp b/src/Gui/Thumbnail.cpp index c822e26c09..fed843fc83 100644 --- a/src/Gui/Thumbnail.cpp +++ b/src/Gui/Thumbnail.cpp @@ -113,7 +113,7 @@ void Thumbnail::SaveDocFile (Base::Writer &writer) const if (!px.isNull()) { // according to specification add some meta-information to the image qint64 mt = QDateTime::currentDateTimeUtc().toSecsSinceEpoch(); - QString mtime = QString::fromLatin1("%1").arg(mt); + QString mtime = QStringLiteral("%1").arg(mt); img.setText(QLatin1String("Software"), qApp->applicationName()); img.setText(QLatin1String("Thumb::Mimetype"), QLatin1String("application/x-extension-fcstd")); img.setText(QLatin1String("Thumb::MTime"), mtime); diff --git a/src/Gui/ToolHandler.cpp b/src/Gui/ToolHandler.cpp index 30e92c705b..606e2527be 100644 --- a/src/Gui/ToolHandler.cpp +++ b/src/Gui/ToolHandler.cpp @@ -48,7 +48,7 @@ using namespace Gui; QString ToolHandler::getCrosshairCursorSVGName() const { - return QString::fromLatin1("None"); + return QStringLiteral("None"); } bool ToolHandler::activate() @@ -230,7 +230,7 @@ void ToolHandler::updateCursor() { auto cursorstring = getCrosshairCursorSVGName(); - if (cursorstring != QString::fromLatin1("None")) { + if (cursorstring != QStringLiteral("None")) { setCrosshairCursor(cursorstring); } } diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 6dc75a87ec..03473cc240 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -439,7 +439,7 @@ TreeWidgetItemDelegate::TreeWidgetItemDelegate(QObject* parent) : QStyledItemDelegate(parent) { artificial = new QTreeView(qobject_cast(parent)); - artificial->setObjectName(QString::fromLatin1("DocumentTreeItems")); + artificial->setObjectName(QStringLiteral("DocumentTreeItems")); artificial->setFixedSize(0, 0); // ensure that it does not render } @@ -1201,7 +1201,7 @@ void TreeWidget::onCreateGroup() if (this->contextItem->type() == DocumentType) { auto docitem = static_cast(this->contextItem); App::Document* doc = docitem->document()->getDocument(); - QString cmd = QString::fromLatin1("App.getDocument(\"%1\").addObject" + QString cmd = QStringLiteral("App.getDocument(\"%1\").addObject" "(\"App::DocumentObjectGroup\",\"Group\").Label=\"%2\"") .arg(QString::fromLatin1(doc->getName()), name); Gui::Command::runCommand(Gui::Command::App, cmd.toUtf8()); @@ -1211,7 +1211,7 @@ void TreeWidget::onCreateGroup() (this->contextItem); App::DocumentObject* obj = objitem->object()->getObject(); App::Document* doc = obj->getDocument(); - QString cmd = QString::fromLatin1("App.getDocument(\"%1\").getObject(\"%2\")" + QString cmd = QStringLiteral("App.getDocument(\"%1\").getObject(\"%2\")" ".newObject(\"App::DocumentObjectGroup\",\"Group\").Label=\"%3\"") .arg(QString::fromLatin1(doc->getName()), QString::fromLatin1(obj->getNameInDocument()), diff --git a/src/Gui/VectorListEditor.cpp b/src/Gui/VectorListEditor.cpp index 7b43f63167..9450145b7f 100644 --- a/src/Gui/VectorListEditor.cpp +++ b/src/Gui/VectorListEditor.cpp @@ -116,7 +116,7 @@ QVariant VectorTableModel::data(const QModelIndex &index, int role) const d = vectors[r].z; if (role == Qt::DisplayRole) { - QString str = QString::fromLatin1("%1").arg(d, 0, 'f', decimals); + QString str = QStringLiteral("%1").arg(d, 0, 'f', decimals); return str; } diff --git a/src/Gui/View3DInventor.cpp b/src/Gui/View3DInventor.cpp index 1364dc3b06..87e9615046 100644 --- a/src/Gui/View3DInventor.cpp +++ b/src/Gui/View3DInventor.cpp @@ -250,7 +250,7 @@ void View3DInventor::print() void View3DInventor::printPdf() { QString filename = FileDialog::getSaveFileName(this, tr("Export PDF"), QString(), - QString::fromLatin1("%1 (*.pdf)").arg(tr("PDF file"))); + QStringLiteral("%1 (*.pdf)").arg(tr("PDF file"))); if (!filename.isEmpty()) { Gui::WaitCursor wc; QPrinter printer(QPrinter::ScreenResolution); diff --git a/src/Gui/ViewProviderGroupExtension.cpp b/src/Gui/ViewProviderGroupExtension.cpp index bbeb686cb2..e42bdacd4e 100644 --- a/src/Gui/ViewProviderGroupExtension.cpp +++ b/src/Gui/ViewProviderGroupExtension.cpp @@ -103,7 +103,7 @@ void ViewProviderGroupExtension::extensionDropObject(App::DocumentObject* obj) { // build Python command for execution QString cmd; - cmd = QString::fromLatin1("App.getDocument(\"%1\").getObject(\"%2\").addObject(" + cmd = QStringLiteral("App.getDocument(\"%1\").getObject(\"%2\").addObject(" "App.getDocument(\"%1\").getObject(\"%3\"))") .arg(QString::fromLatin1(doc->getName()), QString::fromLatin1(grp->getNameInDocument()), diff --git a/src/Gui/WidgetFactory.cpp b/src/Gui/WidgetFactory.cpp index 20c0450759..82ee5d2f27 100644 --- a/src/Gui/WidgetFactory.cpp +++ b/src/Gui/WidgetFactory.cpp @@ -493,7 +493,7 @@ bool PyResource::connect(const char* sender, const char* signal, PyObject* cb) QList list = myDlg->findChildren(); QList::const_iterator it = list.cbegin(); QObject *obj; - QString sigStr = QString::fromLatin1("2%1").arg(QString::fromLatin1(signal)); + QString sigStr = QStringLiteral("2%1").arg(QString::fromLatin1(signal)); while ( it != list.cend() ) { obj = *it; diff --git a/src/Gui/Widgets.cpp b/src/Gui/Widgets.cpp index 0d9b7383a5..3d326ee782 100644 --- a/src/Gui/Widgets.cpp +++ b/src/Gui/Widgets.cpp @@ -94,7 +94,7 @@ void CommandIconView::startDrag (Qt::DropActions supportedActions) } auto mimeData = new QMimeData; - mimeData->setData(QString::fromLatin1("text/x-action-items"), itemData); + mimeData->setData(QStringLiteral("text/x-action-items"), itemData); auto drag = new QDrag(this); drag->setMimeData(mimeData); @@ -428,7 +428,7 @@ void AccelLineEdit::keyPressEvent (QKeyEvent * e) txtLine.clear(); break; default: - txtLine += QString::fromLatin1(","); + txtLine += QStringLiteral(","); break; } } @@ -524,7 +524,7 @@ void ModifierLineEdit::keyPressEvent (QKeyEvent * e) ClearLineEdit::ClearLineEdit (QWidget * parent) : QLineEdit(parent) { - clearAction = this->addAction(QIcon(QString::fromLatin1(":/icons/edit-cleartext.svg")), + clearAction = this->addAction(QIcon(QStringLiteral(":/icons/edit-cleartext.svg")), QLineEdit::TrailingPosition); connect(clearAction, &QAction::triggered, this, &ClearLineEdit::clear); connect(this, &QLineEdit::textChanged, this, &ClearLineEdit::updateClearButton); @@ -943,7 +943,7 @@ void StatefulLabel::registerState(const QString& state, const QColor& color, { QString css; if (color.isValid()) - css = QString::fromUtf8("Gui--StatefulLabel{ color : rgba(%1,%2,%3,%4) ;}").arg(color.red()).arg(color.green()).arg(color.blue()).arg(color.alpha()); + css = QStringLiteral("Gui--StatefulLabel{ color : rgba(%1,%2,%3,%4) ;}").arg(color.red()).arg(color.green()).arg(color.blue()).arg(color.alpha()); _availableStates[state] = { css, preferenceName }; } @@ -952,10 +952,10 @@ void StatefulLabel::registerState(const QString& state, const QColor& fg, const { QString colorEntries; if (fg.isValid()) - colorEntries.append(QString::fromUtf8("color : rgba(%1,%2,%3,%4);").arg(fg.red()).arg(fg.green()).arg(fg.blue()).arg(fg.alpha())); + colorEntries.append(QStringLiteral("color : rgba(%1,%2,%3,%4);").arg(fg.red()).arg(fg.green()).arg(fg.blue()).arg(fg.alpha())); if (bg.isValid()) - colorEntries.append(QString::fromUtf8("background-color : rgba(%1,%2,%3,%4);").arg(bg.red()).arg(bg.green()).arg(bg.blue()).arg(bg.alpha())); - QString css = QString::fromUtf8("Gui--StatefulLabel{ %1 }").arg(colorEntries); + colorEntries.append(QStringLiteral("background-color : rgba(%1,%2,%3,%4);").arg(bg.red()).arg(bg.green()).arg(bg.blue()).arg(bg.alpha())); + QString css = QStringLiteral("Gui--StatefulLabel{ %1 }").arg(colorEntries); _availableStates[state] = { css, preferenceName }; } @@ -1010,7 +1010,7 @@ void StatefulLabel::setState(QString state) // Convert the stored Uint into usable color data: unsigned int col = unsignedEntry.second; QColor qcolor(App::Color::fromPackedRGB(col)); - this->setStyleSheet(QString::fromUtf8("Gui--StatefulLabel{ color : rgba(%1,%2,%3,%4) ;}").arg(qcolor.red()).arg(qcolor.green()).arg(qcolor.blue()).arg(qcolor.alpha())); + this->setStyleSheet(QStringLiteral("Gui--StatefulLabel{ color : rgba(%1,%2,%3,%4) ;}").arg(qcolor.red()).arg(qcolor.green()).arg(qcolor.blue()).arg(qcolor.alpha())); _styleCache[state] = this->styleSheet(); return; } @@ -1020,7 +1020,7 @@ void StatefulLabel::setState(QString state) auto availableStringPrefs = _parameterGroup->GetASCIIMap(); for (const auto& stringEntry : availableStringPrefs) { if (stringEntry.first == entry->second.preferenceString) { - QString css = QString::fromUtf8("Gui--StatefulLabel{ %1 }").arg(QString::fromStdString(stringEntry.second)); + QString css = QStringLiteral("Gui--StatefulLabel{ %1 }").arg(QString::fromStdString(stringEntry.second)); this->setStyleSheet(css); _styleCache[state] = this->styleSheet(); return; @@ -1409,7 +1409,7 @@ public: if (edit) { QString inputText = edit->toPlainText(); if (!inputText.isEmpty()) // let pass empty input, regardless of the type, so user can void the value - lines = inputText.split(QString::fromLatin1("\n")); + lines = inputText.split(QStringLiteral("\n")); } if (!lines.isEmpty()) { if (type == 1) { // floats @@ -1483,7 +1483,7 @@ void LabelEditor::setText(const QString& s) { this->plainText = s; - QString text = QString::fromLatin1("[%1]").arg(this->plainText); + QString text = QStringLiteral("[%1]").arg(this->plainText); lineEdit->setText(text); } @@ -1506,7 +1506,7 @@ void LabelEditor::changeText() connect(buttonBox, &QDialogButtonBox::rejected, dlg, &PropertyListDialog::reject); connect(dlg, &PropertyListDialog::accepted, this, [&] { QString inputText = edit->toPlainText(); - QString text = QString::fromLatin1("[%1]").arg(inputText); + QString text = QStringLiteral("[%1]").arg(inputText); lineEdit->setText(text); }); @@ -1578,7 +1578,7 @@ void ExpLineEdit::bind(const ObjectIdentifier& _path) { ExpressionBinding::bind(_path); int frameWidth = style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth); - setStyleSheet(QString::fromLatin1("QLineEdit { padding-right: %1px } ").arg(iconLabel->sizeHint().width() + frameWidth + 1)); + setStyleSheet(QStringLiteral("QLineEdit { padding-right: %1px } ").arg(iconLabel->sizeHint().width() + frameWidth + 1)); iconLabel->show(); } diff --git a/src/Gui/WorkbenchSelector.cpp b/src/Gui/WorkbenchSelector.cpp index 88c552adc6..72e02d42fd 100644 --- a/src/Gui/WorkbenchSelector.cpp +++ b/src/Gui/WorkbenchSelector.cpp @@ -108,7 +108,7 @@ WorkbenchTabWidget::WorkbenchTabWidget(WorkbenchGroup* aGroup, QWidget* parent) setToolTip(aGroup->toolTip()); setStatusTip(aGroup->action()->statusTip()); setWhatsThis(aGroup->action()->whatsThis()); - setObjectName(QString::fromLatin1("WbTabBar")); + setObjectName(QStringLiteral("WbTabBar")); tabBar = new WbTabBar(this); moreButton = new QToolButton(this); @@ -125,7 +125,7 @@ WorkbenchTabWidget::WorkbenchTabWidget(WorkbenchGroup* aGroup, QWidget* parent) moreButton->setToolButtonStyle(Qt::ToolButtonIconOnly); moreButton->setPopupMode(QToolButton::InstantPopup); moreButton->setMenu(new QMenu(moreButton)); - moreButton->setObjectName(QString::fromLatin1("WbTabBarMore")); + moreButton->setObjectName(QStringLiteral("WbTabBarMore")); if (parent->inherits("QToolBar")) { // when toolbar is created it is not yet placed in its designated area @@ -404,7 +404,7 @@ void WorkbenchTabWidget::buildPrefMenu() // Add disabled workbenches, sorted alphabetically. for (auto action : wbActionGroup->getDisabledWbActions()) { - if (action->text() == QString::fromLatin1("")) { + if (action->text() == QStringLiteral("")) { continue; } @@ -416,7 +416,7 @@ void WorkbenchTabWidget::buildPrefMenu() QAction* preferencesAction = menu->addAction(tr("Preferences")); connect(preferencesAction, &QAction::triggered, this, []() { Gui::Dialog::DlgPreferencesImp cDlg(getMainWindow()); - cDlg.activateGroupPage(QString::fromUtf8("Workbenches"), 0); + cDlg.activateGroupPage(QStringLiteral("Workbenches"), 0); cDlg.exec(); }); } diff --git a/src/Gui/propertyeditor/PropertyEditor.cpp b/src/Gui/propertyeditor/PropertyEditor.cpp index 270f505c45..6dfa5db131 100644 --- a/src/Gui/propertyeditor/PropertyEditor.cpp +++ b/src/Gui/propertyeditor/PropertyEditor.cpp @@ -794,7 +794,7 @@ void PropertyEditor::contextMenuEvent(QContextMenuEvent*) menu.addSeparator(); // the subMenu is allocated on the heap but managed by menu. - auto subMenu = new QMenu(QString::fromLatin1("Status"), &menu); + auto subMenu = new QMenu(QStringLiteral("Status"), &menu); QAction* action; QString text; @@ -811,7 +811,7 @@ void PropertyEditor::contextMenuEvent(QContextMenuEvent*) do { \ _ACTION_SETUP(_name); \ if (propType & App::Prop_##_name) { \ - action->setText(text + QString::fromLatin1(" *")); \ + action->setText(text + QStringLiteral(" *")); \ action->setChecked(true); \ } \ } while (0) diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index 5ac0b03a2c..8d95ef7d84 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -386,7 +386,7 @@ QVariant PropertyItem::decoration(const QVariant& value) const QString PropertyItem::asNone(const Py::Object& pyobj) const { Q_UNUSED(pyobj) - return QString::fromUtf8(""); + return QStringLiteral(""); } QString PropertyItem::asString(const Py::Object& pyobj) const @@ -685,7 +685,7 @@ QVariant PropertyItem::dataProperty(int role) const } if (role == Qt::ToolTipRole) { QString type = - QString::fromLatin1("Type: %1\nName: %2") + QStringLiteral("Type: %1\nName: %2") .arg(QString::fromLatin1(propertyItems[0]->getTypeId().getName()), objectName()); QString doc = PropertyItem::toolTip(propertyItems[0]).toString(); @@ -999,7 +999,7 @@ QVariant PropertyIntegerItem::toString(const QVariant& v) const if (hasExpression()) { string += - QString::fromLatin1(" ( %1 )").arg(QString::fromStdString(getExpressionString())); + QStringLiteral(" ( %1 )").arg(QString::fromStdString(getExpressionString())); } return {string}; @@ -1081,7 +1081,7 @@ QVariant PropertyIntegerConstraintItem::toString(const QVariant& v) const if (hasExpression()) { string += - QString::fromLatin1(" ( %1 )").arg(QString::fromStdString(getExpressionString())); + QStringLiteral(" ( %1 )").arg(QString::fromStdString(getExpressionString())); } return {string}; @@ -1100,7 +1100,7 @@ QVariant PropertyFloatItem::toString(const QVariant& prop) const QString data = QLocale().toString(value, 'f', decimals()); if (hasExpression()) { - data += QString::fromLatin1(" ( %1 )").arg(QString::fromStdString(getExpressionString())); + data += QStringLiteral(" ( %1 )").arg(QString::fromStdString(getExpressionString())); } return {data}; @@ -1426,7 +1426,7 @@ public: if (data.canConvert()) { const Base::Vector3d& value = data.value(); - QString str = QString::fromLatin1("(%1, %2, %3)") + QString str = QStringLiteral("(%1, %2, %3)") .arg(value.x, 0, 'f', decimals) .arg(value.y, 0, 'f', decimals) .arg(value.z, 0, 'f', decimals); @@ -1468,12 +1468,12 @@ QVariant PropertyVectorItem::toString(const QVariant& prop) const { QLocale loc; const Base::Vector3d& value = prop.value(); - QString data = QString::fromLatin1("[%1 %2 %3]") + QString data = QStringLiteral("[%1 %2 %3]") .arg(loc.toString(value.x, 'f', lowPrec), loc.toString(value.y, 'f', lowPrec), loc.toString(value.z, 'f', lowPrec)); if (hasExpression()) { - data += QString::fromLatin1(" ( %1 )").arg(QString::fromStdString(getExpressionString())); + data += QStringLiteral(" ( %1 )").arg(QString::fromStdString(getExpressionString())); } return {data}; } @@ -1492,7 +1492,7 @@ void PropertyVectorItem::setValue(const QVariant& value) return; } const Base::Vector3d& val = value.value(); - QString data = QString::fromLatin1("(%1, %2, %3)") + QString data = QStringLiteral("(%1, %2, %3)") .arg(val.x, 0, 'g', highPrec) .arg(val.y, 0, 'g', highPrec) .arg(val.z, 0, 'g', highPrec); @@ -1519,7 +1519,7 @@ void PropertyVectorItem::setEditorData(QWidget* editor, const QVariant& data) co QLocale loc; auto le = qobject_cast(editor); const Base::Vector3d& value = data.value(); - QString text = QString::fromLatin1("[%1 %2 %3]") + QString text = QStringLiteral("[%1 %2 %3]") .arg(loc.toString(value.x, 'f', lowPrec), loc.toString(value.y, 'f', lowPrec), loc.toString(value.z, 'f', lowPrec)); @@ -1657,10 +1657,10 @@ void VectorListWidget::showValue(const QVariant& d) QString data; const QList& value = d.value>(); if (value.isEmpty()) { - data = QString::fromLatin1("[]"); + data = QStringLiteral("[]"); } else { - data = QString::fromLatin1("[%1 %2 %3], ...") + data = QStringLiteral("[%1 %2 %3], ...") .arg(loc.toString(value[0].x, 'f', lowPrec), loc.toString(value[0].y, 'f', lowPrec), loc.toString(value[0].z, 'f', lowPrec)); @@ -1679,17 +1679,17 @@ QVariant PropertyVectorListItem::toString(const QVariant& prop) const QString data; const QList& value = prop.value>(); if (value.isEmpty()) { - data = QString::fromLatin1("[]"); + data = QStringLiteral("[]"); } else { - data = QString::fromLatin1("[%1 %2 %3], ...") + data = QStringLiteral("[%1 %2 %3], ...") .arg(loc.toString(value[0].x, 'f', lowPrec), loc.toString(value[0].y, 'f', lowPrec), loc.toString(value[0].z, 'f', lowPrec)); } if (hasExpression()) { - data += QString::fromLatin1(" ( %1 )").arg(QString::fromStdString(getExpressionString())); + data += QStringLiteral(" ( %1 )").arg(QString::fromStdString(getExpressionString())); } return {data}; } @@ -1715,7 +1715,7 @@ void PropertyVectorListItem::setValue(const QVariant& value) QTextStream str(&data); str << "["; for (const auto& it : val) { - str << QString::fromLatin1("(%1, %2, %3), ") + str << QStringLiteral("(%1, %2, %3), ") .arg(it.x, 0, 'g', highPrec) .arg(it.y, 0, 'g', highPrec) .arg(it.z, 0, 'g', highPrec); @@ -1971,7 +1971,7 @@ QVariant PropertyMatrixItem::toString(const QVariant& prop) const QLocale loc; const Base::Matrix4D& value = prop.value(); // NOLINTBEGIN - QString text = QString::fromLatin1("[%1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 %12 %13 %14 %15 %16]") + QString text = QStringLiteral("[%1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 %12 %13 %14 %15 %16]") .arg(loc.toString(value[0][0], 'f', lowPrec), //(unsigned short usNdx) loc.toString(value[0][1], 'f', lowPrec), loc.toString(value[0][2], 'f', lowPrec), @@ -2016,7 +2016,7 @@ void PropertyMatrixItem::setValue(const QVariant& value) const Base::Matrix4D& val = value.value(); // NOLINTBEGIN QString data = - QString::fromLatin1( + QStringLiteral( "FreeCAD.Matrix(%1, %2, %3, %4, %5, %6, %7, %8, %9, %10, %11, %12, %13, %14, %15, %16)") .arg(val[0][0], 0, 'g', highPrec) .arg(val[0][1], 0, 'g', highPrec) @@ -2053,7 +2053,7 @@ void PropertyMatrixItem::setEditorData(QWidget* editor, const QVariant& data) co auto le = qobject_cast(editor); const Base::Matrix4D& value = data.value(); // NOLINTBEGIN - QString text = QString::fromLatin1("[%1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 %12 %13 %14 %15 %16]") + QString text = QStringLiteral("[%1 %2 %3 %4 %5 %6 %7 %8 %9 %10 %11 %12 %13 %14 %15 %16]") .arg(loc.toString(value[0][0], 'f', lowPrec), //(unsigned short usNdx) loc.toString(value[0][1], 'f', lowPrec), loc.toString(value[0][2], 'f', lowPrec), @@ -2515,7 +2515,7 @@ QVariant PropertyRotationItem::toolTip(const App::Property* prop) const QLocale loc; QString data = - QString::fromUtf8("Axis: (%1 %2 %3)\n" + QStringLiteral("Axis: (%1 %2 %3)\n" "Angle: %4") .arg(loc.toString(dir.x, 'f', decimals()), loc.toString(dir.y, 'f', decimals()), @@ -2534,7 +2534,7 @@ QVariant PropertyRotationItem::toString(const QVariant& prop) const QLocale loc; QString data = - QString::fromUtf8("[(%1 %2 %3); %4]") + QStringLiteral("[(%1 %2 %3); %4]") .arg(loc.toString(dir.x, 'f', lowPrec), loc.toString(dir.y, 'f', lowPrec), loc.toString(dir.z, 'f', lowPrec), @@ -2819,7 +2819,7 @@ QVariant PropertyPlacementItem::toolTip(const App::Property* prop) const QLocale loc; QString data = - QString::fromUtf8("Axis: (%1 %2 %3)\n" + QStringLiteral("Axis: (%1 %2 %3)\n" "Angle: %4\n" "Position: (%5 %6 %7)") .arg(loc.toString(dir.x, 'f', decimals()), @@ -2844,7 +2844,7 @@ QVariant PropertyPlacementItem::toString(const QVariant& prop) const QLocale loc; QString data = - QString::fromUtf8("[(%1 %2 %3); %4; (%5 %6 %7)]") + QStringLiteral("[(%1 %2 %3); %4; (%5 %6 %7)]") .arg(loc.toString(dir.x, 'f', lowPrec), loc.toString(dir.y, 'f', lowPrec), loc.toString(dir.z, 'f', lowPrec), @@ -2993,7 +2993,7 @@ void PropertyEnumItem::setValue(const QVariant& value) ss << "["; for (const auto& it : values) { QString text(it); - text.replace(QString::fromUtf8("'"), QString::fromUtf8("\\'")); + text.replace(QStringLiteral("'"), QStringLiteral("\\'")); std::string str = Base::Tools::escapedUnicodeFromUtf8(text.toUtf8()); str = Base::InterpreterSingleton::strToPython(str); @@ -3231,7 +3231,7 @@ QVariant PropertyStringListItem::toString(const QVariant& prop) const list.append(QLatin1String("...")); } - QString text = QString::fromUtf8("[%1]").arg(list.join(QLatin1String(","))); + QString text = QStringLiteral("[%1]").arg(list.join(QLatin1String(","))); return {text}; } @@ -3307,7 +3307,7 @@ QVariant PropertyFloatListItem::toString(const QVariant& prop) const list = list.mid(0, size); list.append(QLatin1String("...")); } - QString text = QString::fromUtf8("[%1]").arg(list.join(QLatin1String(","))); + QString text = QStringLiteral("[%1]").arg(list.join(QLatin1String(","))); return {text}; } @@ -3385,7 +3385,7 @@ QVariant PropertyIntegerListItem::toString(const QVariant& prop) const list = list.mid(0, size); list.append(QLatin1String("...")); } - QString text = QString::fromUtf8("[%1]").arg(list.join(QLatin1String(","))); + QString text = QStringLiteral("[%1]").arg(list.join(QLatin1String(","))); return {text}; } @@ -3445,7 +3445,7 @@ QVariant PropertyColorItem::toString(const QVariant& prop) const { auto value = prop.value(); QString color = - QString::fromLatin1("[%1, %2, %3]").arg(value.red()).arg(value.green()).arg(value.blue()); + QStringLiteral("[%1, %2, %3]").arg(value.red()).arg(value.green()).arg(value.blue()); return {color}; } @@ -3464,7 +3464,7 @@ void PropertyColorItem::setValue(const QVariant& value) } auto col = value.value(); QString data = - QString::fromLatin1("(%1,%2,%3)").arg(col.red()).arg(col.green()).arg(col.blue()); + QStringLiteral("(%1,%2,%3)").arg(col.red()).arg(col.green()).arg(col.blue()); setPropertyValue(data); } @@ -3715,7 +3715,7 @@ QVariant PropertyMaterialItem::toString(const QVariant& prop) const auto val = prop.value(); QColor value = val.diffuseColor; QString color = - QString::fromLatin1("[%1, %2, %3]").arg(value.red()).arg(value.green()).arg(value.blue()); + QStringLiteral("[%1, %2, %3]").arg(value.red()).arg(value.green()).arg(value.blue()); return {color}; } @@ -3729,7 +3729,7 @@ QVariant PropertyMaterialItem::toolTip(const App::Property* prop) const auto sc = value.specularColor.asValue(); auto ec = value.emissiveColor.asValue(); - QString data = QString::fromUtf8("Diffuse color: [%1, %2, %3]\n" + QString data = QStringLiteral("Diffuse color: [%1, %2, %3]\n" "Ambient color: [%4, %5, %6]\n" "Specular color: [%7, %8, %9]\n" "Emissive color: [%10, %11, %12]\n" @@ -3788,7 +3788,7 @@ void PropertyMaterialItem::setValue(const QVariant& value) float s = mat.shininess; float t = mat.transparency; - QString data = QString::fromLatin1("App.Material(" + QString data = QStringLiteral("App.Material(" "DiffuseColor=(%1,%2,%3)," "AmbientColor=(%4,%5,%6)," "SpecularColor=(%7,%8,%9)," @@ -4197,7 +4197,7 @@ QVariant PropertyMaterialListItem::toString(const QVariant& prop) const auto mat = list[0].value(); QColor value = mat.diffuseColor; QString color = - QString::fromLatin1("[%1, %2, %3]").arg(value.red()).arg(value.green()).arg(value.blue()); + QStringLiteral("[%1, %2, %3]").arg(value.red()).arg(value.green()).arg(value.blue()); return {color}; } @@ -4217,7 +4217,7 @@ QVariant PropertyMaterialListItem::toolTip(const App::Property* prop) const auto sc = value.specularColor.asValue(); auto ec = value.emissiveColor.asValue(); - QString data = QString::fromUtf8("Diffuse color: [%1, %2, %3]\n" + QString data = QStringLiteral("Diffuse color: [%1, %2, %3]\n" "Ambient color: [%4, %5, %6]\n" "Specular color: [%7, %8, %9]\n" "Emissive color: [%10, %11, %12]\n" @@ -4295,7 +4295,7 @@ void PropertyMaterialListItem::setValue(const QVariant& value) float s = mat.shininess; float t = mat.transparency; - QString item = QString::fromLatin1("App.Material(" + QString item = QStringLiteral("App.Material(" "DiffuseColor=(%1,%2,%3)," "AmbientColor=(%4,%5,%6)," "SpecularColor=(%7,%8,%9)," @@ -4612,7 +4612,7 @@ void LinkLabel::updatePropertyLink() auto& sobj = links.front(); link = QVariant::fromValue(sobj); QString linkcolor = QApplication::palette().color(QPalette::Link).name(); - text = QString::fromLatin1("" "

"