Start: Use QStringLiteral

This commit is contained in:
Benjamin Bræstrup Sayoc
2025-02-09 18:13:46 +01:00
parent a59ad914ba
commit e2baa03d24
4 changed files with 28 additions and 28 deletions

View File

@@ -96,9 +96,9 @@ std::string getThumbnailsImage()
QString getThumbnailsName()
{
#if defined(Q_OS_LINUX)
return QString::fromLatin1("thumbnails/normal");
return QStringLiteral("thumbnails/normal");
#else
return QString::fromLatin1("FreeCADStartThumbnails");
return QStringLiteral("FreeCADStartThumbnails");
#endif
}
@@ -127,7 +127,7 @@ QString getMD5Hash(const std::string& path)
// Use MD5 hash as specified here:
// https://specifications.freedesktop.org/thumbnail-spec/0.8.0/thumbsave.html
QUrl url(QString::fromStdString(path));
url.setScheme(QString::fromLatin1("file"));
url.setScheme(QStringLiteral("file"));
QCryptographicHash hash(QCryptographicHash::Md5);
hash.addData(url.toEncoded());
QByteArray ba = hash.result().toHex();

View File

@@ -119,11 +119,11 @@ void FileCardDelegate::paint(QPainter* painter,
_widget->setProperty("state", QStringLiteral("pressed"));
if (qApp->styleSheet().isEmpty()) {
QColor color = getSelectionColor();
style = QString::fromLatin1("QWidget#thumbnailWidget {"
" border: 2px solid rgb(%1, %2, %3);"
" border-radius: 4px;"
" padding: 2px;"
"}")
style = QStringLiteral("QWidget#thumbnailWidget {"
" border: 2px solid rgb(%1, %2, %3);"
" border-radius: 4px;"
" padding: 2px;"
"}")
.arg(color.red())
.arg(color.green())
.arg(color.blue());
@@ -133,11 +133,11 @@ void FileCardDelegate::paint(QPainter* painter,
_widget->setProperty("state", QStringLiteral("hovered"));
if (qApp->styleSheet().isEmpty()) {
QColor color = getBorderColor();
style = QString::fromLatin1("QWidget#thumbnailWidget {"
" border: 2px solid rgb(%1, %2, %3);"
" border-radius: 4px;"
" padding: 2px;"
"}")
style = QStringLiteral("QWidget#thumbnailWidget {"
" border: 2px solid rgb(%1, %2, %3);"
" border-radius: 4px;"
" padding: 2px;"
"}")
.arg(color.red())
.arg(color.green())
.arg(color.blue());
@@ -145,10 +145,10 @@ void FileCardDelegate::paint(QPainter* painter,
}
else if (qApp->styleSheet().isEmpty()) {
QColor color = getBackgroundColor();
style = QString::fromLatin1("QWidget#thumbnailWidget {"
" background-color: rgb(%1, %2, %3);"
" border-radius: 8px;"
"}")
style = QStringLiteral("QWidget#thumbnailWidget {"
" background-color: rgb(%1, %2, %3);"
" border-radius: 8px;"
"}")
.arg(color.red())
.arg(color.green())
.arg(color.blue());

View File

@@ -102,7 +102,7 @@ gsl::owner<QComboBox*> GeneralSettingsWidget::createLanguageComboBox()
auto langToStr = Gui::Translator::instance()->activeLanguage();
QByteArray language = hGrp->GetASCII("Language", langToStr.c_str()).c_str();
auto comboBox = gsl::owner<QComboBox*>(new QComboBox);
comboBox->addItem(QString::fromLatin1("English"), QByteArray("English"));
comboBox->addItem(QStringLiteral("English"), QByteArray("English"));
Gui::TStringMap list = Gui::Translator::instance()->supportedLocales();
int index {1};
for (auto it = list.begin(); it != list.end(); ++it, ++index) {

View File

@@ -151,16 +151,16 @@ public:
QColor pressed(38, 162, 105); // NOLINT
pressed = getUserColor(pressed, "FileCardSelectionColor");
return QString::fromLatin1("QPushButton {"
" background-color: rgb(%1, %2, %3);"
" border-radius: 8px;"
"}"
"QPushButton:hover {"
" border: 2px solid rgb(%4, %5, %6);"
"}"
"QPushButton:pressed {"
" border: 2px solid rgb(%7, %8, %9);"
"}")
return QStringLiteral("QPushButton {"
" background-color: rgb(%1, %2, %3);"
" border-radius: 8px;"
"}"
"QPushButton:hover {"
" border: 2px solid rgb(%4, %5, %6);"
"}"
"QPushButton:pressed {"
" border: 2px solid rgb(%7, %8, %9);"
"}")
.arg(background.red())
.arg(background.green())
.arg(background.blue())