Skip to content

Commit

Permalink
refactor: replace QString(tr()) with tr() to simplify code
Browse files Browse the repository at this point in the history
  • Loading branch information
Integral-Tech committed Nov 6, 2024
1 parent 7fa11cc commit 27fc4d8
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/docks/encodedock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2266,7 +2266,7 @@ void EncodeDock::on_videoBufferDurationChanged()
QString vb = ui->videoBitrateCombo->currentText();
vb.replace('k', "").replace('M', "000");
double duration = (double)ui->videoBufferSizeSpinner->value() * 8.0 / vb.toDouble();
QString label = QString(tr("KiB (%1s)")).arg(duration);
QString label = tr("KiB (%1s)").arg(duration);
ui->videoBufferSizeSuffixLabel->setText(label);
}

Expand Down
4 changes: 2 additions & 2 deletions src/models/resourcemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ QVariant ResourceModel::data(const QModelIndex &index, int role) const
QString path = Util::GetFilenameFromProducer(producer, true);
QFileInfo info(path);
double size = (double)info.size() / (double)(1024 * 1024);
result = QString(tr("%1MB")).arg(QLocale().toString(size, 'f', 2));
result = tr("%1MB").arg(QLocale().toString(size, 'f', 2));
break;
}
case COLUMN_VID_DESCRIPTION: {
Expand All @@ -309,7 +309,7 @@ QVariant ResourceModel::data(const QModelIndex &index, int role) const
QString key = QStringLiteral("meta.media.%1.codec.name").arg(index);
QString codec(producer->get(key.toLatin1().constData()));
double frame_rate = frame_rate_num / frame_rate_den;
result = QString(tr("%1 %2x%3 %4fps"))
result = tr("%1 %2x%3 %4fps")
.arg(codec)
.arg(width)
.arg(height)
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/blipproducerwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,5 @@ void BlipProducerWidget::on_preset_saveClicked()

QString BlipProducerWidget::detail() const
{
return QString(tr("Period: %1s")).arg(ui->periodSpinBox->value());
return tr("Period: %1s").arg(ui->periodSpinBox->value());
}
2 changes: 1 addition & 1 deletion src/widgets/countproducerwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,6 @@ void CountProducerWidget::on_preset_saveClicked()

QString CountProducerWidget::detail() const
{
return QString(tr("Count: %1 %2")).arg(ui->directionCombo->currentText()).arg(
return tr("Count: %1 %2").arg(ui->directionCombo->currentText()).arg(
ui->styleCombo->currentText());
}
4 changes: 2 additions & 2 deletions src/widgets/scopes/videohistogramscopewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ void VideoHistogramScopeWidget::mouseMoveEvent(QMouseEvent *event)
qreal ire0x = width() * IRE0 / 256;
qreal ireStep = (ire0x - ire100x) / 100.0;
int ire = (ire0x - event->pos().x()) / ireStep;
text = QString(tr("Value: %1\nIRE: %2")).arg(QString::number(value), QString::number(ire));
text = tr("Value: %1\nIRE: %2").arg(QString::number(value), QString::number(ire));
} else {
text = QString(tr("Value: %1")).arg(QString::number(value));
text = tr("Value: %1").arg(QString::number(value));
}

QToolTip::showText(event->globalPosition().toPoint(), text);
Expand Down
6 changes: 3 additions & 3 deletions src/widgets/scopes/videorgbparadescopewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,10 @@ void VideoRgbParadeScopeWidget::mouseMoveEvent(QMouseEvent *event)

if (frameWidth != 0) {
int pixel = frameWidth * channelX / channelWidth;
text = QString(tr("Channel: %1\nPixel: %2\nValue: %3")).arg(channelLabel).arg(QString::number(
pixel)).arg(QString::number(value));
text = tr("Channel: %1\nPixel: %2\nValue: %3").arg(channelLabel).arg(QString::number(
pixel)).arg(QString::number(value));
} else {
text = QString(tr("Channel: %1\nValue: %2")).arg(channelLabel).arg(QString::number(value));
text = tr("Channel: %1\nValue: %2").arg(channelLabel).arg(QString::number(value));
}
QToolTip::showText(event->globalPosition().toPoint(), text);
}
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/scopes/videorgbwaveformscopewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,9 @@ void VideoRgbWaveformScopeWidget::mouseMoveEvent(QMouseEvent *event)

if (frameWidth != 0) {
int pixel = frameWidth * event->pos().x() / width();
text = QString(tr("Pixel: %1\nValue: %2")).arg(QString::number(pixel)).arg(QString::number(value));
text = tr("Pixel: %1\nValue: %2").arg(QString::number(pixel)).arg(QString::number(value));
} else {
text = QString(tr("Value: %1")).arg(QString::number(value));
text = tr("Value: %1").arg(QString::number(value));
}
QToolTip::showText(event->globalPosition().toPoint(), text);
}
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/scopes/videovectorscopewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ void VideoVectorScopeWidget::mouseMoveEvent(QMouseEvent *event)
qreal realY = (qreal)event->pos().y() - ((qreal)height() - squareRect.height()) / 2;
qreal u = realX * 255.0 / squareRect.width();
qreal v = (squareRect.height() - realY) * 255.0 / squareRect.height();
QString text = QString(tr("U: %1\nV: %2")).arg(QString::number(qRound(u)),
QString::number(qRound(v)));
QString text = tr("U: %1\nV: %2").arg(QString::number(qRound(u)),
QString::number(qRound(v)));
QToolTip::showText(event->globalPosition().toPoint(), text);
}

Expand Down
4 changes: 2 additions & 2 deletions src/widgets/scopes/videowaveformscopewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ void VideoWaveformScopeWidget::mouseMoveEvent(QMouseEvent *event)

if (frameWidth != 0) {
int pixel = frameWidth * event->pos().x() / width();
text = QString(tr("Pixel: %1\nIRE: %2")).arg(QString::number(pixel), QString::number(ire));
text = tr("Pixel: %1\nIRE: %2").arg(QString::number(pixel), QString::number(ire));
} else {
text = QString(tr("IRE: %1")).arg(QString::number(ire));
text = tr("IRE: %1").arg(QString::number(ire));
}
QToolTip::showText(event->globalPosition().toPoint(), text);
}
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/scopes/videozoomwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void VideoZoomWidget::mouseMoveEvent(QMouseEvent *event)
/*
// Create a tool tip to display pixel information
PixelValues values = pixelToValues(currMousePixel);
QString text = QString(tr("Zoom: %1x\nPixel: %2,%3\nRGB: %4 %5 %6\nYUV: %7 %8 %9")).arg(
QString text = tr("Zoom: %1x\nPixel: %2,%3\nRGB: %4 %5 %6\nYUV: %7 %8 %9").arg(
QString::number(m_zoom)).arg(
QString::number(currMousePixel.x() + 1)).arg(
QString::number(currMousePixel.y() + 1)).arg(
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/toneproducerwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,6 @@ void ToneProducerWidget::on_preset_saveClicked()

QString ToneProducerWidget::detail() const
{
return QString(tr("Tone: %1Hz %2dB")).arg(ui->frequencySpinBox->value()).arg(
return tr("Tone: %1Hz %2dB").arg(ui->frequencySpinBox->value()).arg(
ui->levelSpinBox->value());
}

0 comments on commit 27fc4d8

Please sign in to comment.