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 Nov 5, 2024
1 parent a19c369 commit 0564aba
Show file tree
Hide file tree
Showing 69 changed files with 346 additions and 334 deletions.
2 changes: 1 addition & 1 deletion CuteLogger/src/Logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,7 @@ void Logger::write(LogLevel logLevel, const char* file, int line, const char* fu
*/
void Logger::writeAssert(const char* file, int line, const char* function, const char* condition)
{
write(Logger::Fatal, file, line, function, nullptr, QString("ASSERT: \"%1\"").arg(condition));
write(Logger::Fatal, file, line, function, nullptr, QStringLiteral("ASSERT: \"%1\"").arg(condition));
}


Expand Down
2 changes: 1 addition & 1 deletion src/commands/timelinecommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1969,7 +1969,7 @@ void AlignClipsCommand::redo()
if (alignment.speed != 1.0) {
double warpspeed = Util::GetSpeedFromProducer(info->producer) * alignment.speed;
QString filename = Util::GetFilenameFromProducer(info->producer, false);
QString s = QString("%1:%2:%3").arg("timewarp").arg(warpspeed).arg(filename);
QString s = QStringLiteral("%1:%2:%3").arg("timewarp").arg(warpspeed).arg(filename);
item.clip = new Mlt::Producer(MLT.profile(), s.toUtf8().constData());
if (!item.clip || !item.clip->is_valid()) {
delete item.clip;
Expand Down
5 changes: 3 additions & 2 deletions src/commands/undohelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ void UndoHelper::debugPrintState(const QString &title)
LOG_DEBUG() << "timeline state:" << title << "{";
for (int i = 0; i < m_model.trackList().count(); ++i) {
int mltIndex = m_model.trackList()[i].mlt_index;
QString trackStr = QString(" track %1 (mlt-idx %2):").arg(i).arg(mltIndex);
QString trackStr = QStringLiteral(" track %1 (mlt-idx %2):").arg(i).arg(mltIndex);
QScopedPointer<Mlt::Producer> trackProducer(m_model.tractor()->track(mltIndex));
Mlt::Playlist playlist(*trackProducer);

Expand All @@ -324,7 +324,8 @@ void UndoHelper::debugPrintState(const QString &title)
if (info.producer->is_blank() && info.cut) {
uid = MLT.uuid(*info.cut);
}
trackStr += QString(" [ %5 %1 -> %2 (%3 frames) %4]").arg(info.frame_in).arg(info.frame_out).arg(
trackStr += QStringLiteral(" [ %5 %1 -> %2 (%3 frames) %4]").arg(info.frame_in).arg(
info.frame_out).arg(
info.frame_count).arg(info.cut->is_blank() ? "blank " : "clip").arg(uid.toString());
}
LOG_DEBUG() << qPrintable(trackStr);
Expand Down
2 changes: 1 addition & 1 deletion src/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ QDir Database::thumbnailsDir()
n = query.value(0).toInt();
}
query.exec(
QString("SELECT hash, accessed, image FROM thumbnails ORDER BY accessed DESC LIMIT %1").arg(
QStringLiteral("SELECT hash, accessed, image FROM thumbnails ORDER BY accessed DESC LIMIT %1").arg(
kMaxThumbnailCount));
for (int i = 0; query.next(); i++) {
QString fileName = toFileName(query.value(0).toString());
Expand Down
10 changes: 5 additions & 5 deletions src/dialogs/alignaudiodialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,13 @@ AlignAudioDialog::AlignAudioDialog(QString title, MultitrackModel *model,
glayout->addWidget(new QLabel(tr("Speed adjustment range")), row, 0, Qt::AlignRight);
m_speedCombo = new QComboBox();
m_speedCombo->setToolTip("Larger speed adjustment ranges take longer to process.");
m_speedCombo->addItem(tr("None") + QString(" (%L1%)").arg(0), QVariant(0));
m_speedCombo->addItem(tr("Narrow") + QString(" (%L1%)").arg((double)0.1, 0, 'g', 2),
m_speedCombo->addItem(tr("None") + QStringLiteral(" (%L1%)").arg(0), QVariant(0));
m_speedCombo->addItem(tr("Narrow") + QStringLiteral(" (%L1%)").arg((double)0.1, 0, 'g', 2),
QVariant(0.001));
m_speedCombo->addItem(tr("Normal") + QString(" (%L1%)").arg((double)0.5, 0, 'g', 2),
m_speedCombo->addItem(tr("Normal") + QStringLiteral(" (%L1%)").arg((double)0.5, 0, 'g', 2),
QVariant(0.005));
m_speedCombo->addItem(tr("Wide") + QString(" (%L1%)").arg(1), QVariant(0.01));
m_speedCombo->addItem(tr("Very wide") + QString(" (%L1%)").arg(5), QVariant(0.05));
m_speedCombo->addItem(tr("Wide") + QStringLiteral(" (%L1%)").arg(1), QVariant(0.01));
m_speedCombo->addItem(tr("Very wide") + QStringLiteral(" (%L1%)").arg(5), QVariant(0.05));
double defaultRange = Settings.audioReferenceSpeedRange();
for (int i = 0; i < m_speedCombo->count(); i++) {
if (m_speedCombo->itemData(i).toDouble() == defaultRange) {
Expand Down
2 changes: 1 addition & 1 deletion src/dialogs/customprofiledialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ QString CustomProfileDialog::profileName() const
// Replace characters that are not allowed in Windows file names
QString filename = ui->nameEdit->text();
static QRegularExpression re("[" + QRegularExpression::escape( "\\/:*?\"<>|" ) + "]");
filename = filename.replace(re, QString( "_" ));
filename = filename.replace(re, QStringLiteral( "_" ));
return filename;
}

Expand Down
2 changes: 1 addition & 1 deletion src/dialogs/filedatedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ FileDateDialog::FileDateDialog(QString title, Mlt::Producer *producer, QWidget *
setWindowTitle(tr("%1 File Date").arg(title));
int64_t milliseconds = producer->get_creation_time();
QDateTime creation_time;
if ( !milliseconds ) {
if (!milliseconds ) {
creation_time = QDateTime::currentDateTime();
} else {
// Set the date to the current producer date.
Expand Down
2 changes: 1 addition & 1 deletion src/dialogs/multifileexportdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ QString MultiFileExportDialog::appendField(QString text, QComboBox *combo, int c
}
case NAME_FIELD_INDEX: {
int digits = QString::number(m_playlist->count()).size();
field = QString("%1").arg(clipIndex + 1, digits, 10, QChar('0'));
field = QStringLiteral("%1").arg(clipIndex + 1, digits, 10, QChar('0'));
break;
}
case NAME_FIELD_DATE: {
Expand Down
7 changes: 4 additions & 3 deletions src/dialogs/saveimagedialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
static QString suffixFromFilter(const QString &filterText)
{
QString suffix = filterText.section("*", 1, 1).section(")", 0, 0).section(" ", 0, 0);
if ( !suffix.startsWith(".") ) {
if (!suffix.startsWith(".") ) {
suffix.clear();
}
return suffix;
Expand Down Expand Up @@ -60,7 +60,8 @@ SaveImageDialog::SaveImageDialog(QWidget *parent, const QString &caption, QImage
selectNameFilter(selectedNameFilter);

// Use the current player time as a suggested file name
QString nameSuggestion = QString("Shotcut_%1").arg(MLT.producer()->frame_time(mlt_time_clock));
QString nameSuggestion = QStringLiteral("Shotcut_%1").arg(MLT.producer()->frame_time(
mlt_time_clock));
nameSuggestion = nameSuggestion.replace(":", "_");
nameSuggestion = nameSuggestion.replace(".", "_");
nameSuggestion += suffix;
Expand Down Expand Up @@ -125,5 +126,5 @@ void SaveImageDialog::onFileSelected(const QString &file)
}
m_image.save(m_saveFile, Q_NULLPTR, (fi.suffix() == "webp") ? 80 : -1);
Settings.setSavePath(fi.path());
Settings.setExportFrameSuffix(QString(".") + fi.suffix());
Settings.setExportFrameSuffix(QStringLiteral(".") + fi.suffix());
}
2 changes: 1 addition & 1 deletion src/dialogs/subtitletrackdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ static void fillLanguages(QComboBox *combo)
}
for (auto it = iso639_2LanguageCodes.keyValueBegin(); it != iso639_2LanguageCodes.keyValueEnd();
++it) {
QString text = QString("%1 (%2)").arg(it->first).arg(it->second);
QString text = QStringLiteral("%1 (%2)").arg(it->first).arg(it->second);
combo->addItem(text, it->second);
}
}
Expand Down
9 changes: 3 additions & 6 deletions src/dialogs/transcribeaudiodialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ TranscribeAudioDialog::TranscribeAudioDialog(const QString &trackName, QWidget *
auto path = QFileDialog::getOpenFileName(this, tr("Find Whisper.cpp"), Settings.whisperExe(),
QString(),
nullptr, Util::getFileDialogOptions());
if (QFileInfo(path).isExecutable())
{
if (QFileInfo(path).isExecutable()) {
Settings.setWhisperExe(path);
updateWhisperStatus();
}
Expand All @@ -213,13 +212,11 @@ TranscribeAudioDialog::TranscribeAudioDialog(const QString &trackName, QWidget *
auto path = QFileDialog::getOpenFileName(this, tr("Find Whisper.cpp"), Settings.whisperModel(),
"*.bin",
nullptr, Util::getFileDialogOptions());
if (QFileInfo(path).exists())
{
if (QFileInfo(path).exists()) {
LOG_INFO() << "Model found" << path;
Settings.setWhisperModel(path);
updateWhisperStatus();
} else
{
} else {
LOG_INFO() << "Model not found" << path;
}
});
Expand Down
Loading

0 comments on commit 0564aba

Please sign in to comment.