Skip to content

Commit

Permalink
refactor: replace non-empty QString constructors with QStringLiteral() (
Browse files Browse the repository at this point in the history
  • Loading branch information
Integral-Tech authored Dec 27, 2024
1 parent 0974d52 commit 49b54e5
Show file tree
Hide file tree
Showing 37 changed files with 146 additions and 146 deletions.
10 changes: 5 additions & 5 deletions src/common/ColorThemeWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ QString ColorThemeWorker::save(const QJsonDocument &theme, const QString &themeN
continue;
}
if (cutterSpecificOptions.contains(it.key())) {
fOut.write(QString("#~%1 rgb:%2\n")
fOut.write(QStringLiteral("#~%1 rgb:%2\n")
.arg(it.key(), color.name(QColor::HexArgb).remove('#'))
.toUtf8());
} else {
fOut.write(QString("ec %1 rgb:%2\n")
fOut.write(QStringLiteral("ec %1 rgb:%2\n")
.arg(it.key(), color.name(QColor::HexRgb).remove('#'))
.toUtf8());
}
Expand Down Expand Up @@ -146,9 +146,9 @@ QJsonDocument ColorThemeWorker::getTheme(const QString &themeName) const
QString curr = Config()->getColorTheme();

if (themeName != curr) {
Core()->cmdRaw(QString("eco %1").arg(themeName));
Core()->cmdRaw(QStringLiteral("eco %1").arg(themeName));
theme = Core()->cmdj("ecj").object().toVariantMap();
Core()->cmdRaw(QString("eco %1").arg(curr));
Core()->cmdRaw(QStringLiteral("eco %1").arg(curr));
} else {
theme = Core()->cmdj("ecj").object().toVariantMap();
}
Expand Down Expand Up @@ -294,7 +294,7 @@ bool ColorThemeWorker::isFileTheme(const QString &filePath, bool *ok) const
.join('|')
.replace(".", "\\.");

QString pattern = QString("((ec\\s+(%1)\\s+(((rgb:|#)[0-9a-fA-F]{3,8})|(%2))))\\s*")
QString pattern = QStringLiteral("((ec\\s+(%1)\\s+(((rgb:|#)[0-9a-fA-F]{3,8})|(%2))))\\s*")
.arg(options)
.arg(colors);
// The below construct mimics the behaviour of QRegexP::exactMatch(), which
Expand Down
2 changes: 1 addition & 1 deletion src/common/Configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ QSyntaxHighlighter *Configuration::createSyntaxHighlighter(QTextDocument *docume

QString Configuration::getLogoFile()
{
return windowColorIsDark() ? QString(":/img/iaito-o-light.svg") : QString(":/img/iaito-o.svg");
return windowColorIsDark() ? QStringLiteral(":/img/iaito-o-light.svg") : QStringLiteral(":/img/iaito-o.svg");
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/common/Helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ QByteArray applyColorToSvg(const QByteArray &data, QColor color)
static const QRegularExpression styleRegExp(
"(?:style=\".*fill:(.*?);.*?\")|(?:fill=\"(.*?)\")");

QString replaceStr = QString("#%1").arg(color.rgb() & 0xffffff, 6, 16, QLatin1Char('0'));
QString replaceStr = QStringLiteral("#%1").arg(color.rgb() & 0xffffff, 6, 16, QLatin1Char('0'));
int replaceStrLen = replaceStr.length();

QString xml = QString::fromUtf8(data);
Expand Down
4 changes: 2 additions & 2 deletions src/common/JsonModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ QVariant JsonModel::data(const QModelIndex &index, int role) const

if (role == Qt::DisplayRole) {
if (index.column() == 0)
return QString("%1").arg(item->key());
return QStringLiteral("%1").arg(item->key());

if (index.column() == 1)
return QString("%1").arg(item->value());
return QStringLiteral("%1").arg(item->value());
}

return QVariant();
Expand Down
10 changes: 5 additions & 5 deletions src/common/RichTextPainter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,28 +103,28 @@ void RichTextPainter::htmlRichText(const List &richText, QString &textHtml, QStr
textHtml += "<span>";
break;
case FlagColor: // color only
textHtml += QString("<span style=\"color:%1\">").arg(curRichText.textColor.name());
textHtml += QStringLiteral("<span style=\"color:%1\">").arg(curRichText.textColor.name());
break;
case FlagBackground: // background only
if (curRichText.textBackground
!= Qt::transparent) // QColor::name() returns "#000000" for
// transparent color. That's not desired. Leave
// it blank.
textHtml += QString("<span style=\"background-color:%1\">")
textHtml += QStringLiteral("<span style=\"background-color:%1\">")
.arg(curRichText.textBackground.name());
else
textHtml += QString("<span>");
textHtml += QStringLiteral("<span>");
break;
case FlagAll: // color+background
if (curRichText.textBackground
!= Qt::transparent) // QColor::name() returns "#000000" for
// transparent color. That's not desired. Leave
// it blank.
textHtml
+= QString("<span style=\"color:%1; background-color:%2\">")
+= QStringLiteral("<span style=\"color:%1; background-color:%2\">")
.arg(curRichText.textColor.name(), curRichText.textBackground.name());
else
textHtml += QString("<span style=\"color:%1\">").arg(curRichText.textColor.name());
textHtml += QStringLiteral("<span style=\"color:%1\">").arg(curRichText.textColor.name());
break;
}
if (curRichText.highlight) // Underline highlighted token
Expand Down
10 changes: 5 additions & 5 deletions src/common/UpdateWorker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void UpdateWorker::download(QString filename, QString version)

QNetworkRequest request;
request.setAttribute(QNetworkRequest::RedirectPolicyAttribute, true);
QUrl url(QString("https://github.com/radareorg/iaito/releases/"
QUrl url(QStringLiteral("https://github.com/radareorg/iaito/releases/"
"download/v%1/%2")
.arg(version)
.arg(getRepositoryFileName()));
Expand All @@ -79,7 +79,7 @@ void UpdateWorker::showUpdateDialog(bool showDontCheckForUpdatesButton)
tr("There is an update available for Iaito.<br/>") + "<b>" + tr("Current version:")
+ "</b> " IAITO_VERSION_FULL "<br/>" + "<b>" + tr("Latest version:") + "</b> "
+ latestVersion.toString() + "<br/><br/>" + tr("For update, please check the link:<br/>")
+ QString("<a href=\"https://github.com/radareorg/iaito/releases/tag/v%1\">"
+ QStringLiteral("<a href=\"https://github.com/radareorg/iaito/releases/tag/v%1\">"
"https://github.com/radareorg/iaito/releases/tag/v%1</a><br/>")
.arg(latestVersion.toString())
+ tr("or click \"Download\" to download latest version of Iaito."));
Expand All @@ -100,15 +100,15 @@ void UpdateWorker::showUpdateDialog(bool showDontCheckForUpdatesButton)
QString fullFileName = QFileDialog::getSaveFileName(
nullptr,
tr("Choose directory for downloading"),
QString("%1").arg(r_file_home(NULL)) + QDir::separator() + getRepositoryFileName(),
QString("%1 (*.%1)").arg(getRepositeryExt()));
QStringLiteral("%1").arg(r_file_home(NULL)) + QDir::separator() + getRepositoryFileName(),
QStringLiteral("%1 (*.%1)").arg(getRepositeryExt()));
#else
QString fullFileName = QFileDialog::getSaveFileName(
nullptr,
tr("Choose directory for downloading"),
QStandardPaths::writableLocation(QStandardPaths::HomeLocation) + QDir::separator()
+ getRepositoryFileName(),
QString("%1 (*.%1)").arg(getRepositeryExt()));
QStringLiteral("%1 (*.%1)").arg(getRepositeryExt()));
#endif
if (!fullFileName.isEmpty()) {
QProgressDialog progressDial(tr("Downloading update..."), tr("Cancel"), 0, 100);
Expand Down
Loading

0 comments on commit 49b54e5

Please sign in to comment.