Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: replace non-empty QString constructors with QStringLiteral() #722

Merged
merged 1 commit into from
Nov 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/customdocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ bool CustomDocument::openLinkAtCursorPosition()
}

if (isLocalFilePath && convertLocalFilepathsToURLs) {
openUrl(QString("file://") + urlString);
openUrl(QStringLiteral("file://") + urlString);
} else {
openUrl(urlString);
}
Expand Down
22 changes: 11 additions & 11 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1076,11 +1076,11 @@ void MainWindow::setupEditorSettings()
emit displayFontSet(QVariant(dataToSendToView));

#if defined(Q_OS_WINDOWS)
emit platformSet(QVariant(QString("Windows")));
emit platformSet(QVariant(QStringLiteral("Windows")));
#elif defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
emit platformSet(QVariant(QString("Unix")));
emit platformSet(QVariant(QStringLiteral("Unix")));
#elif defined(Q_OS_MACOS)
emit platformSet(QVariant(QString("Apple")));
emit platformSet(QVariant(QStringLiteral("Apple")));
#endif

#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
Expand Down Expand Up @@ -1198,9 +1198,9 @@ void MainWindow::alignTextEditText()
}

QFontMetricsF fm(m_currentSelectedFont);
QString limitingStringSample =
QString("The quick brown fox jumps over the lazy dog the quick brown fox jumps over "
"the lazy dog the quick brown fox jumps over the lazy dog");
QString limitingStringSample = QStringLiteral(
"The quick brown fox jumps over the lazy dog the quick brown fox jumps over "
"the lazy dog the quick brown fox jumps over the lazy dog");
limitingStringSample.truncate(m_textEdit->lineWrapColumnOrWidth());
qreal textSamplePixelsWidth = fm.horizontalAdvance(limitingStringSample);
m_noteEditorLogic->setCurrentAdaptableEditorPadding(
Expand Down Expand Up @@ -1297,11 +1297,11 @@ void MainWindow::setupKanbanView()
ui->verticalLayout_textEdit->insertWidget(ui->verticalLayout_textEdit->indexOf(m_textEdit),
m_kanbanWidget);
# if defined(Q_OS_WINDOWS)
emit platformSet(QVariant(QString("Windows")));
emit platformSet(QVariant(QStringLiteral("Windows")));
# elif defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
emit platformSet(QVariant(QString("Unix")));
emit platformSet(QVariant(QStringLiteral("Unix")));
# elif defined(Q_OS_MACOS)
emit platformSet(QVariant(QString("Apple")));
emit platformSet(QVariant(QStringLiteral("Apple")));
# endif

QJsonObject dataToSendToView{ { "displayFont",
Expand Down Expand Up @@ -4195,9 +4195,9 @@ void MainWindow::setHeading(int level)
new_text.clear();
}
selected_text = selected_text.trimmed().remove(QRegularExpression("^#*\\s?"));
new_text += QString("#").repeated(level) + ((level == 0) ? "" : " ") + selected_text;
new_text += QStringLiteral("#").repeated(level) + ((level == 0) ? "" : " ") + selected_text;
} else {
new_text = QString("#").repeated(level) + " ";
new_text = QStringLiteral("#").repeated(level) + " ";
}
cursor.insertText(new_text);
}
Expand Down
4 changes: 2 additions & 2 deletions src/notelistview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ void NoteListView::onCustomContextMenu(QPoint point)
}
for (auto id : std::as_const(tagInNote)) {
auto tag = m_tagPool->getTag(id);
auto tagAction = new QAction(QString("✓ Remove tag ") + tag.name(), this);
auto tagAction = new QAction(QStringLiteral("✓ Remove tag ") + tag.name(), this);
connect(tagAction, &QAction::triggered, this,
[this, id, notes] { removeNotesFromTag(notes, id); });
tagAction->setIcon(createTagIcon(tag.color()));
Expand All @@ -754,7 +754,7 @@ void NoteListView::onCustomContextMenu(QPoint point)
continue;
}
auto tag = m_tagPool->getTag(id);
auto tagAction = new QAction(QString(" ") + tag.name(), this);
auto tagAction = new QAction(QStringLiteral(" ") + tag.name(), this);
connect(tagAction, &QAction::triggered, this,
[this, id, notes] { addNotesToTag(notes, id); });
tagAction->setIcon(createTagIcon(tag.color()));
Expand Down
2 changes: 1 addition & 1 deletion src/updaterwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ void UpdaterWindow::startDownload(const QUrl &url)
/* Set file name */
m_fileName = m_updater->getDownloadUrl(UPDATES_URL).split("/").last();
if (m_fileName.isEmpty()) {
m_fileName = QString("%1_Update_%2.bin")
m_fileName = QStringLiteral("%1_Update_%2.bin")
.arg(QCoreApplication::applicationName(),
m_updater->getLatestVersion(UPDATES_URL));
}
Expand Down