Skip to content

Commit 94a9cac

Browse files
refactor: replace non-empty QString constructors with QStringLiteral() (#722)
1 parent 1177ffb commit 94a9cac

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

src/customdocument.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ bool CustomDocument::openLinkAtCursorPosition()
198198
}
199199

200200
if (isLocalFilePath && convertLocalFilepathsToURLs) {
201-
openUrl(QString("file://") + urlString);
201+
openUrl(QStringLiteral("file://") + urlString);
202202
} else {
203203
openUrl(urlString);
204204
}

src/mainwindow.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,11 +1076,11 @@ void MainWindow::setupEditorSettings()
10761076
emit displayFontSet(QVariant(dataToSendToView));
10771077

10781078
#if defined(Q_OS_WINDOWS)
1079-
emit platformSet(QVariant(QString("Windows")));
1079+
emit platformSet(QVariant(QStringLiteral("Windows")));
10801080
#elif defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
1081-
emit platformSet(QVariant(QString("Unix")));
1081+
emit platformSet(QVariant(QStringLiteral("Unix")));
10821082
#elif defined(Q_OS_MACOS)
1083-
emit platformSet(QVariant(QString("Apple")));
1083+
emit platformSet(QVariant(QStringLiteral("Apple")));
10841084
#endif
10851085

10861086
#if QT_VERSION >= QT_VERSION_CHECK(6, 2, 0)
@@ -1198,9 +1198,9 @@ void MainWindow::alignTextEditText()
11981198
}
11991199

12001200
QFontMetricsF fm(m_currentSelectedFont);
1201-
QString limitingStringSample =
1202-
QString("The quick brown fox jumps over the lazy dog the quick brown fox jumps over "
1203-
"the lazy dog the quick brown fox jumps over the lazy dog");
1201+
QString limitingStringSample = QStringLiteral(
1202+
"The quick brown fox jumps over the lazy dog the quick brown fox jumps over "
1203+
"the lazy dog the quick brown fox jumps over the lazy dog");
12041204
limitingStringSample.truncate(m_textEdit->lineWrapColumnOrWidth());
12051205
qreal textSamplePixelsWidth = fm.horizontalAdvance(limitingStringSample);
12061206
m_noteEditorLogic->setCurrentAdaptableEditorPadding(
@@ -1297,11 +1297,11 @@ void MainWindow::setupKanbanView()
12971297
ui->verticalLayout_textEdit->insertWidget(ui->verticalLayout_textEdit->indexOf(m_textEdit),
12981298
m_kanbanWidget);
12991299
# if defined(Q_OS_WINDOWS)
1300-
emit platformSet(QVariant(QString("Windows")));
1300+
emit platformSet(QVariant(QStringLiteral("Windows")));
13011301
# elif defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
1302-
emit platformSet(QVariant(QString("Unix")));
1302+
emit platformSet(QVariant(QStringLiteral("Unix")));
13031303
# elif defined(Q_OS_MACOS)
1304-
emit platformSet(QVariant(QString("Apple")));
1304+
emit platformSet(QVariant(QStringLiteral("Apple")));
13051305
# endif
13061306

13071307
QJsonObject dataToSendToView{ { "displayFont",
@@ -4195,9 +4195,9 @@ void MainWindow::setHeading(int level)
41954195
new_text.clear();
41964196
}
41974197
selected_text = selected_text.trimmed().remove(QRegularExpression("^#*\\s?"));
4198-
new_text += QString("#").repeated(level) + ((level == 0) ? "" : " ") + selected_text;
4198+
new_text += QStringLiteral("#").repeated(level) + ((level == 0) ? "" : " ") + selected_text;
41994199
} else {
4200-
new_text = QString("#").repeated(level) + " ";
4200+
new_text = QStringLiteral("#").repeated(level) + " ";
42014201
}
42024202
cursor.insertText(new_text);
42034203
}

src/notelistview.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ void NoteListView::onCustomContextMenu(QPoint point)
741741
}
742742
for (auto id : std::as_const(tagInNote)) {
743743
auto tag = m_tagPool->getTag(id);
744-
auto tagAction = new QAction(QString("✓ Remove tag ") + tag.name(), this);
744+
auto tagAction = new QAction(QStringLiteral("✓ Remove tag ") + tag.name(), this);
745745
connect(tagAction, &QAction::triggered, this,
746746
[this, id, notes] { removeNotesFromTag(notes, id); });
747747
tagAction->setIcon(createTagIcon(tag.color()));
@@ -754,7 +754,7 @@ void NoteListView::onCustomContextMenu(QPoint point)
754754
continue;
755755
}
756756
auto tag = m_tagPool->getTag(id);
757-
auto tagAction = new QAction(QString(" ") + tag.name(), this);
757+
auto tagAction = new QAction(QStringLiteral(" ") + tag.name(), this);
758758
connect(tagAction, &QAction::triggered, this,
759759
[this, id, notes] { addNotesToTag(notes, id); });
760760
tagAction->setIcon(createTagIcon(tag.color()));

src/updaterwindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ void UpdaterWindow::startDownload(const QUrl &url)
294294
/* Set file name */
295295
m_fileName = m_updater->getDownloadUrl(UPDATES_URL).split("/").last();
296296
if (m_fileName.isEmpty()) {
297-
m_fileName = QString("%1_Update_%2.bin")
297+
m_fileName = QStringLiteral("%1_Update_%2.bin")
298298
.arg(QCoreApplication::applicationName(),
299299
m_updater->getLatestVersion(UPDATES_URL));
300300
}

0 commit comments

Comments
 (0)